* Some Problems about gcc 4.8.2 on cygwin
@ 2014-03-14 13:12 rexdf Rexdf
2014-03-14 14:12 ` Marco Atzeri
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: rexdf Rexdf @ 2014-03-14 13:12 UTC (permalink / raw)
To: cygwin
1.the following code:
#include <unistd.h>
#include <curses.h>
int main() {
initscr();
move(0, 0);
addstr("hello, world\n");
refresh();
sleep(5);
endwin();
return 0;
}
The following is my shell command:
$ pkg-config --libs --cflags ncurses
-I/usr/include/ncurses -lncurses
$ gcc $(pkg-config --libs --cflags ncurses) curses_test.c -o curses_test
/tmp/cc74H73T.o:curses_test.c:(.text+0xf): undefined reference to `initscr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x14): undefined reference to
`ncwrap_stdscr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x2c): undefined reference to `wmove'
/tmp/cc74H73T.o:curses_test.c:(.text+0x31): undefined reference to
`ncwrap_stdscr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x49): undefined reference to `waddnstr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x4e): undefined reference to
`ncwrap_stdscr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x56): undefined reference to `wrefresh'
/tmp/cc74H73T.o:curses_test.c:(.text+0x67): undefined reference to `endwin'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
/tmp/cc74H73T.o: bad reloc address 0x20 in section `.eh_frame'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
final link failed: Invalid operation
collect2: error: ld returned 1 exit status
$ gcc curses_test.c $(pkg-config --libs --cflags ncurses) -o curses_test
$ ./curses_test.exe
Do I have to put the source file before `-I/usr/include/ncurses
-lncurses`? And why?
2.It's about OpenMP
openmp_1.cpp
#include <iostream>
#include <time.h>
void test()
{
int a = 0;
for (int i=0;i<100000000;i++)
a++;
}
int main()
{
clock_t t1 = clock();
for (int i=0;i<8;i++)
test();
clock_t t2 = clock();
std::cout<<"time: "<<t2-t1<<std::endl;
}
openmp_2.cpp
#include <iostream>
#include <time.h>
void test()
{
int a = 0;
for (int i=0;i<100000000;i++)
a++;
}
int main()
{
clock_t t1 = clock();
#pragma omp parallel for
for (int i=0;i<8;i++)
test();
clock_t t2 = clock();
std::cout<<"time: "<<t2-t1<<std::endl;
}
On cygwin
g++ openmp_1.cpp -o openmp_1.exe
g++ openmp_2.cpp -o opemnp_2.exe -fopenmp
time 1937
time 2297
On MingW-g++ 4.8.1
g++ openmp_1.cpp -o openmp_1.exe
g++ openmp_2.cpp -o opemnp_2.exe -fopenmp
time 1975
time 492
On Visual Studio 2013
Openmp_2.cpp Project
C/C++ --> Language --> Open MP Support yes(/openmp)
time 1849
time 321
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Some Problems about gcc 4.8.2 on cygwin
2014-03-14 13:12 Some Problems about gcc 4.8.2 on cygwin rexdf Rexdf
@ 2014-03-14 14:12 ` Marco Atzeri
2014-03-14 14:14 ` Tim Prince
2014-03-14 14:24 ` rexdf Rexdf
2 siblings, 0 replies; 5+ messages in thread
From: Marco Atzeri @ 2014-03-14 14:12 UTC (permalink / raw)
To: cygwin
On 14/03/2014 13:42, rexdf Rexdf wrote:
> 1.the following code:
>
> #include <unistd.h>
> #include <curses.h>
> int main() {
> initscr();
> move(0, 0);
> addstr("hello, world\n");
> refresh();
> sleep(5);
> endwin();
> return 0;
> }
>
> The following is my shell command:
>
> $ pkg-config --libs --cflags ncurses
> -I/usr/include/ncurses -lncurses
>
> $ gcc $(pkg-config --libs --cflags ncurses) curses_test.c -o curses_test
try this way
gcc curses_test.c -o curses_test $(pkg-config --libs --cflags ncurses)
> 2.It's about OpenMP
> openmp_1.cpp
> #include <iostream>
> #include <time.h>
> void test()
> {
> int a = 0;
> for (int i=0;i<100000000;i++)
> a++;
> }
> int main()
> {
> clock_t t1 = clock();
> for (int i=0;i<8;i++)
> test();
> clock_t t2 = clock();
> std::cout<<"time: "<<t2-t1<<std::endl;
> }
>
> openmp_2.cpp
> #include <iostream>
> #include <time.h>
> void test()
> {
> int a = 0;
> for (int i=0;i<100000000;i++)
> a++;
> }
> int main()
> {
> clock_t t1 = clock();
> #pragma omp parallel for
> for (int i=0;i<8;i++)
> test();
> clock_t t2 = clock();
> std::cout<<"time: "<<t2-t1<<std::endl;
> }
>
> On cygwin
> g++ openmp_1.cpp -o openmp_1.exe
> g++ openmp_2.cpp -o opemnp_2.exe -fopenmp
> time 1937
> time 2297
>
> On MingW-g++ 4.8.1
> g++ openmp_1.cpp -o openmp_1.exe
> g++ openmp_2.cpp -o opemnp_2.exe -fopenmp
> time 1975
> time 492
>
> On Visual Studio 2013
> Openmp_2.cpp Project
> C/C++ --> Language --> Open MP Support yes(/openmp)
> time 1849
> time 321
and the question is ?
Marco
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Some Problems about gcc 4.8.2 on cygwin
2014-03-14 13:12 Some Problems about gcc 4.8.2 on cygwin rexdf Rexdf
2014-03-14 14:12 ` Marco Atzeri
@ 2014-03-14 14:14 ` Tim Prince
2014-03-14 14:24 ` rexdf Rexdf
2 siblings, 0 replies; 5+ messages in thread
From: Tim Prince @ 2014-03-14 14:14 UTC (permalink / raw)
To: cygwin
On 3/14/2014 8:42 AM, rexdf Rexdf wrote: 2.It's about OpenMP
<elided stuff which doesn't quote legibly>
Is there a cygwin related question here? Questions on OpenMP and
clock() might be tolerated on gcc-help.
Advice on how to make meaningful benchmarks is definitely off topic.
With cygwin g++ 4.9 at -O or -O3 on win8.1 I get
time: 0
as evidently the compiler can shortcut your test loop (is that what you
wished?).
For the -O0 -fopenmp build,
time: 2484 (1 thread)
time: 2547 (2 threads)
time: 2828 (3 t)
time: 3187 (4 t)
Much as would be expected, as you are asking for the total time spent
among all threads (usual interpretation of clock()).
The bash time command shows real time decreasing with number of threads
(close to total clock time divided by number of threads). OpenMP
provides the function omp_get_wtime() for performance measurement
(possibly a wrapper for gettimeofday()).
The cygwin library evidently doesn't treat clock() as equivalent to
omp_get_wtime(). Speculation on how you could find a non-cygwin library
which treats them as equivalent is probably off topic here.
Anyway, I think your problem is not with the cygwin gcc, unless you are
looking for the more aggressive optimization of version 4.9.
--
Tim Prince
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Some Problems about gcc 4.8.2 on cygwin
2014-03-14 13:12 Some Problems about gcc 4.8.2 on cygwin rexdf Rexdf
2014-03-14 14:12 ` Marco Atzeri
2014-03-14 14:14 ` Tim Prince
@ 2014-03-14 14:24 ` rexdf Rexdf
2014-03-14 14:30 ` Marco Atzeri
2 siblings, 1 reply; 5+ messages in thread
From: rexdf Rexdf @ 2014-03-14 14:24 UTC (permalink / raw)
To: cygwin
If you use -O3 or -O2, then the loop is optimed to nothing. Because
the a++ never is used.
My question is :
1. On archlinux gcc 4.8.2, `gcc curses_test.c $(pkg-config --libs
--cflags ncurses) -o curses_test` and `gcc $(pkg-config --libs
--cflags ncurses) curses_test.c -o curses_test` works.
On cygwin it doesn't work, why?
2. what is wrong in openmp on cygwin? How can I fix it?
2014-03-14 20:42 GMT+08:00 rexdf Rexdf <weiyong.mao@gmail.com>:
> 1.the following code:
>
> #include <unistd.h>
> #include <curses.h>
> int main() {
> initscr();
> move(0, 0);
> addstr("hello, world\n");
> refresh();
> sleep(5);
> endwin();
> return 0;
> }
>
> The following is my shell command:
>
> $ pkg-config --libs --cflags ncurses
> -I/usr/include/ncurses -lncurses
>
> $ gcc $(pkg-config --libs --cflags ncurses) curses_test.c -o curses_test
> /tmp/cc74H73T.o:curses_test.c:(.text+0xf): undefined reference to `initscr'
> /tmp/cc74H73T.o:curses_test.c:(.text+0x14): undefined reference to
> `ncwrap_stdscr'
> /tmp/cc74H73T.o:curses_test.c:(.text+0x2c): undefined reference to `wmove'
> /tmp/cc74H73T.o:curses_test.c:(.text+0x31): undefined reference to
> `ncwrap_stdscr'
> /tmp/cc74H73T.o:curses_test.c:(.text+0x49): undefined reference to `waddnstr'
> /tmp/cc74H73T.o:curses_test.c:(.text+0x4e): undefined reference to
> `ncwrap_stdscr'
> /tmp/cc74H73T.o:curses_test.c:(.text+0x56): undefined reference to `wrefresh'
> /tmp/cc74H73T.o:curses_test.c:(.text+0x67): undefined reference to `endwin'
> /usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
> /tmp/cc74H73T.o: bad reloc address 0x20 in section `.eh_frame'
> /usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
> final link failed: Invalid operation
> collect2: error: ld returned 1 exit status
>
> $ gcc curses_test.c $(pkg-config --libs --cflags ncurses) -o curses_test
>
> $ ./curses_test.exe
>
>
> Do I have to put the source file before `-I/usr/include/ncurses
> -lncurses`? And why?
>
>
> 2.It's about OpenMP
> openmp_1.cpp
> #include <iostream>
> #include <time.h>
> void test()
> {
> int a = 0;
> for (int i=0;i<100000000;i++)
> a++;
> }
> int main()
> {
> clock_t t1 = clock();
> for (int i=0;i<8;i++)
> test();
> clock_t t2 = clock();
> std::cout<<"time: "<<t2-t1<<std::endl;
> }
>
> openmp_2.cpp
> #include <iostream>
> #include <time.h>
> void test()
> {
> int a = 0;
> for (int i=0;i<100000000;i++)
> a++;
> }
> int main()
> {
> clock_t t1 = clock();
> #pragma omp parallel for
> for (int i=0;i<8;i++)
> test();
> clock_t t2 = clock();
> std::cout<<"time: "<<t2-t1<<std::endl;
> }
>
> On cygwin
> g++ openmp_1.cpp -o openmp_1.exe
> g++ openmp_2.cpp -o opemnp_2.exe -fopenmp
> time 1937
> time 2297
>
> On MingW-g++ 4.8.1
> g++ openmp_1.cpp -o openmp_1.exe
> g++ openmp_2.cpp -o opemnp_2.exe -fopenmp
> time 1975
> time 492
>
> On Visual Studio 2013
> Openmp_2.cpp Project
> C/C++ --> Language --> Open MP Support yes(/openmp)
> time 1849
> time 321
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Some Problems about gcc 4.8.2 on cygwin
2014-03-14 14:24 ` rexdf Rexdf
@ 2014-03-14 14:30 ` Marco Atzeri
0 siblings, 0 replies; 5+ messages in thread
From: Marco Atzeri @ 2014-03-14 14:30 UTC (permalink / raw)
To: cygwin
On 14/03/2014 15:00, rexdf Rexdf wrote:
please read
http://en.wikipedia.org/wiki/Posting_style
in this mailing list we use "Bottom-posting" and "Trimming"
> My question is :
> 1. On archlinux gcc 4.8.2, `gcc curses_test.c $(pkg-config --libs
> --cflags ncurses) -o curses_test` and `gcc $(pkg-config --libs
> --cflags ncurses) curses_test.c -o curses_test` works.
> On cygwin it doesn't work, why?
>
because Windows works differently and the order matters.
> 2. what is wrong in openmp on cygwin? How can I fix it?
I doubt something is wrong, likely you have wrong expectation
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-03-14 14:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-14 13:12 Some Problems about gcc 4.8.2 on cygwin rexdf Rexdf
2014-03-14 14:12 ` Marco Atzeri
2014-03-14 14:14 ` Tim Prince
2014-03-14 14:24 ` rexdf Rexdf
2014-03-14 14:30 ` Marco Atzeri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).