public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Linux c++ opmization--- linux runs at half the speed of windows?
@ 2007-03-08 12:30 Shane R
  2007-03-08 15:01 ` Andrew Haley
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Shane R @ 2007-03-08 12:30 UTC (permalink / raw)
  To: gcc-help

Hi,

I hope this is the appropriate forum. Please direct me to the correct one if 
it is not.

I am trying to optimize a c++ application that I ported from a windows 
system to Linux.
The app is a terminal based application that does some one time file io at 
the start then runs completely in memory. After the one time io the app runs 
successive timed epochs on the same data in Windows as Linux. The app is a 
program that runs some code for doing non-linear optmization (math stuff).

The reason why I am posting is that I timed the time it takes for the 
application to complete an epoch. It take twice as long in Linux as 
windows?!?!

My system is an Intel Centrino Duo with 2gigs of ram. The application is 
only using a fraction of available memory in windows and linux. The 
application is single-threaded in both.

I am using Visual Studio 2003 in Windows and when I type gcc -v I get:
Target: i486-linux-gnu
Configured with: ../src/configure -v 
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-mpfr --enable-checking=release 
i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)



I am currently using these g++ options:

CFLAGS = -o3 -O3 -march=pentium4 -ffast-math  -funroll-loops -Wall 
-Wno-return-type

But I have tried every permutation of the above options to virtually no 
effect

The average run time of an epoch in windows is about 3000 milliseconds while 
the average run time of an epoch in Linux is 6000!

I don't know if it matters but I am doing calls to the rand() function in 
both my windows and linux apps.

On another note does anyone have any experience with the Intel drop in 
replacement for GCC?

Thanks in advance for any help,

Shane

_________________________________________________________________
Match.com - Click Here To Find Singles In Your Area Today!  
http://match.engb.msn.com/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux c++ opmization--- linux runs at half the speed of windows?
  2007-03-08 12:30 Linux c++ opmization--- linux runs at half the speed of windows? Shane R
@ 2007-03-08 15:01 ` Andrew Haley
  2007-03-08 16:10 ` Atwood, Robert C
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Andrew Haley @ 2007-03-08 15:01 UTC (permalink / raw)
  To: Shane R; +Cc: gcc-help

Shane R writes:

 > I hope this is the appropriate forum. Please direct me to the correct one if 
 > it is not.
 > 
 > I am trying to optimize a c++ application that I ported from a windows 
 > system to Linux.

OK.

 > The app is a terminal based application that does some one time file io at 
 > the start then runs completely in memory. After the one time io the app runs 
 > successive timed epochs on the same data in Windows as Linux. The app is a 
 > program that runs some code for doing non-linear optmization (math stuff).
 > 
 > The reason why I am posting is that I timed the time it takes for the 
 > application to complete an epoch. It take twice as long in Linux as 
 > windows?!?!

That is fairly unusual.

 > My system is an Intel Centrino Duo with 2gigs of ram. The application is 
 > only using a fraction of available memory in windows and linux. The 
 > application is single-threaded in both.
 > 
 > I am using Visual Studio 2003 in Windows and when I type gcc -v I get:
 > Target: i486-linux-gnu
 > Configured with: ../src/configure -v 
 > --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
 > --enable-shared --with-system-zlib --libexecdir=/usr/lib 
 > --without-included-gettext --enable-threads=posix --enable-nls 
 > --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
 > --enable-libstdcxx-debug --enable-mpfr --enable-checking=release 
 > i486-linux-gnu
 > Thread model: posix
 > gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)
 > 
 > 
 > 
 > I am currently using these g++ options:
 > 
 > CFLAGS = -o3 -O3 -march=pentium4 -ffast-math  -funroll-loops -Wall 
 > -Wno-return-type
 > 
 > But I have tried every permutation of the above options to virtually no 
 > effect
 > 
 > The average run time of an epoch in windows is about 3000 milliseconds while 
 > the average run time of an epoch in Linux is 6000!
 > 
 > I don't know if it matters but I am doing calls to the rand() function in 
 > both my windows and linux apps.

It might matter, yes.

I suspect that the right approach is to do some profiling.  Make sure
oprofile is installed, then

sudo opcontrol --init
sudo opcontrol --start
<do your thing>
sudo opcontrol --stop
opreport -l 

Let us know how you get along.  You might be surprised where the time
goes.

Andrew.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Linux c++ opmization--- linux runs at half the speed of windows?
  2007-03-08 12:30 Linux c++ opmization--- linux runs at half the speed of windows? Shane R
  2007-03-08 15:01 ` Andrew Haley
@ 2007-03-08 16:10 ` Atwood, Robert C
  2007-03-08 17:10 ` Sven Eschenberg
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Atwood, Robert C @ 2007-03-08 16:10 UTC (permalink / raw)
  To: Shane R; +Cc: gcc-help

 
> On another note does anyone have any experience with the 
> Intel drop in 
> replacement for GCC?
> 
> Thanks in advance for any help,
> 
> Shane

Yes but not very good experience, perhaps mediocre. I had very annoying
problems with a bug in the intel optimizer .. It seemed like my code was
way faster, until I noticed that it was not giving the correct results,
and observed that the optimizer was reducing precision when it should
not. There was also some case where it kept optimizing a=b; b=c; into
effectively  a=b=c; not the same thing at all!

 THe recommended workaround was to reduce the optimization level , at
which point it was no longer faster and I had lost my own time faffing
about with it.   Since then that bug was supposedly fixed in later
release, but they lost my confidence and convinced me further that free
software is the way to go, not only for political, but also practical
reasons.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux c++ opmization--- linux runs at half the speed of windows?
  2007-03-08 12:30 Linux c++ opmization--- linux runs at half the speed of windows? Shane R
  2007-03-08 15:01 ` Andrew Haley
  2007-03-08 16:10 ` Atwood, Robert C
@ 2007-03-08 17:10 ` Sven Eschenberg
  2007-03-12 22:06 ` Lawrence Crowl
  2007-03-12 23:49 ` John Carter
  4 siblings, 0 replies; 8+ messages in thread
From: Sven Eschenberg @ 2007-03-08 17:10 UTC (permalink / raw)
  To: Shane R; +Cc: gcc-help

Hi Shane,

I am wondering if you are using large memory support in linux (since you 
got 2GB)? I am asking, because on my system I experienced the following 
strange behavior:

Compiling a whole package, which is fairly big the compile time varies 
strongly between the setup of using  large memory support and when not 
using it. As soon as I use large memory support the compile times grows 
by a factor between 2 and 3, I never did a profiling, what exactly 
causes the slow down, it just seems obvious that the large memory 
support causes a massive slowdown (certainly on memory access). I wonder 
if you are basically having the same problem. Maybe, after collecting 
some profiling data, you might come to the conclusion that memory access 
takes a lot of time, maybe you could check against a kernel without 
large memory support.

I might be completely wrong, but it came across my mind, since you got 2 
GB of RAM and might have large memory support enabled.

Regards

-Sven


Shane R wrote:
> Hi,
>
> I hope this is the appropriate forum. Please direct me to the correct 
> one if it is not.
>
> I am trying to optimize a c++ application that I ported from a windows 
> system to Linux.
> The app is a terminal based application that does some one time file 
> io at the start then runs completely in memory. After the one time io 
> the app runs successive timed epochs on the same data in Windows as 
> Linux. The app is a program that runs some code for doing non-linear 
> optmization (math stuff).
>
> The reason why I am posting is that I timed the time it takes for the 
> application to complete an epoch. It take twice as long in Linux as 
> windows?!?!
>
> My system is an Intel Centrino Duo with 2gigs of ram. The application 
> is only using a fraction of available memory in windows and linux. The 
> application is single-threaded in both.
>
> I am using Visual Studio 2003 in Windows and when I type gcc -v I get:
> Target: i486-linux-gnu
> Configured with: ../src/configure -v 
> --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
> --enable-shared --with-system-zlib --libexecdir=/usr/lib 
> --without-included-gettext --enable-threads=posix --enable-nls 
> --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
> --enable-libstdcxx-debug --enable-mpfr --enable-checking=release 
> i486-linux-gnu
> Thread model: posix
> gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux c++ opmization--- linux runs at half the speed of windows?
  2007-03-08 12:30 Linux c++ opmization--- linux runs at half the speed of windows? Shane R
                   ` (2 preceding siblings ...)
  2007-03-08 17:10 ` Sven Eschenberg
@ 2007-03-12 22:06 ` Lawrence Crowl
  2007-03-12 23:13   ` Artūras Moskvinas
  2007-03-13  8:57   ` Galloth
  2007-03-12 23:49 ` John Carter
  4 siblings, 2 replies; 8+ messages in thread
From: Lawrence Crowl @ 2007-03-12 22:06 UTC (permalink / raw)
  To: Shane R; +Cc: gcc-help

Is your windows compiler doing automatic parallelization by chance?
Twice as fast on a dual core processor is a bit too coincidental.  :-)

On 3/8/07, Shane R <crazguy22@hotmail.com> wrote:
> Hi,
>
> I hope this is the appropriate forum. Please direct me to the correct one if
> it is not.
>
> I am trying to optimize a c++ application that I ported from a windows
> system to Linux.
> The app is a terminal based application that does some one time file io at
> the start then runs completely in memory. After the one time io the app runs
> successive timed epochs on the same data in Windows as Linux. The app is a
> program that runs some code for doing non-linear optmization (math stuff).
>
> The reason why I am posting is that I timed the time it takes for the
> application to complete an epoch. It take twice as long in Linux as
> windows?!?!
>
> My system is an Intel Centrino Duo with 2gigs of ram. The application is
> only using a fraction of available memory in windows and linux. The
> application is single-threaded in both.
>
> I am using Visual Studio 2003 in Windows and when I type gcc -v I get:
> Target: i486-linux-gnu
> Configured with: ../src/configure -v
> --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
> --enable-shared --with-system-zlib --libexecdir=/usr/lib
> --without-included-gettext --enable-threads=posix --enable-nls
> --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
> --enable-libstdcxx-debug --enable-mpfr --enable-checking=release
> i486-linux-gnu
> Thread model: posix
> gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)
>
>
>
> I am currently using these g++ options:
>
> CFLAGS = -o3 -O3 -march=pentium4 -ffast-math  -funroll-loops -Wall
> -Wno-return-type
>
> But I have tried every permutation of the above options to virtually no
> effect
>
> The average run time of an epoch in windows is about 3000 milliseconds while
> the average run time of an epoch in Linux is 6000!
>
> I don't know if it matters but I am doing calls to the rand() function in
> both my windows and linux apps.
>
> On another note does anyone have any experience with the Intel drop in
> replacement for GCC?
>
> Thanks in advance for any help,
>
> Shane
>
> _________________________________________________________________
> Match.com - Click Here To Find Singles In Your Area Today!
> http://match.engb.msn.com/
>
>


-- 
Lawrence Crowl

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux c++ opmization--- linux runs at half the speed of windows?
  2007-03-12 22:06 ` Lawrence Crowl
@ 2007-03-12 23:13   ` Artūras Moskvinas
  2007-03-13  8:57   ` Galloth
  1 sibling, 0 replies; 8+ messages in thread
From: Artūras Moskvinas @ 2007-03-12 23:13 UTC (permalink / raw)
  To: Lawrence Crowl; +Cc: Shane R, gcc-help

Hi,

You should try profiling, it should help you to find the place were
program is taking longest (gprof). Maybe you use some floating point
operations??? Commercial compilers often like to use non IEEE compliant
floating operations, try -ffast-math...

> Is your windows compiler doing automatic parallelization by chance?
> Twice as fast on a dual core processor is a bit too coincidental.  :-)
> 
> On 3/8/07, Shane R <crazguy22@hotmail.com> wrote:
>> Hi,
>>
>> I hope this is the appropriate forum. Please direct me to the correct
>> one if
>> it is not.
>>
>> I am trying to optimize a c++ application that I ported from a windows
>> system to Linux.
>> The app is a terminal based application that does some one time file
>> io at
>> the start then runs completely in memory. After the one time io the
>> app runs
>> successive timed epochs on the same data in Windows as Linux. The app
>> is a
>> program that runs some code for doing non-linear optmization (math
>> stuff).
>>
>> The reason why I am posting is that I timed the time it takes for the
>> application to complete an epoch. It take twice as long in Linux as
>> windows?!?!
>>
>> My system is an Intel Centrino Duo with 2gigs of ram. The application is
>> only using a fraction of available memory in windows and linux. The
>> application is single-threaded in both.
>>
>> I am using Visual Studio 2003 in Windows and when I type gcc -v I get:
>> Target: i486-linux-gnu
>> Configured with: ../src/configure -v
>> --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
>> --enable-shared --with-system-zlib --libexecdir=/usr/lib
>> --without-included-gettext --enable-threads=posix --enable-nls
>> --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
>> --enable-libstdcxx-debug --enable-mpfr --enable-checking=release
>> i486-linux-gnu
>> Thread model: posix
>> gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)
>>
>>
>>
>> I am currently using these g++ options:
>>
>> CFLAGS = -o3 -O3 -march=pentium4 -ffast-math  -funroll-loops -Wall
>> -Wno-return-type
>>
>> But I have tried every permutation of the above options to virtually no
>> effect
>>
>> The average run time of an epoch in windows is about 3000 milliseconds
>> while
>> the average run time of an epoch in Linux is 6000!
>>
>> I don't know if it matters but I am doing calls to the rand() function in
>> both my windows and linux apps.
>>
>> On another note does anyone have any experience with the Intel drop in
>> replacement for GCC?
>>
>> Thanks in advance for any help,
>>
>> Shane
>>
>> _________________________________________________________________
>> Match.com - Click Here To Find Singles In Your Area Today!
>> http://match.engb.msn.com/
>>
>>
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux c++ opmization--- linux runs at half the speed of   windows?
  2007-03-08 12:30 Linux c++ opmization--- linux runs at half the speed of windows? Shane R
                   ` (3 preceding siblings ...)
  2007-03-12 22:06 ` Lawrence Crowl
@ 2007-03-12 23:49 ` John Carter
  4 siblings, 0 replies; 8+ messages in thread
From: John Carter @ 2007-03-12 23:49 UTC (permalink / raw)
  To: Shane R; +Cc: gcc-help


On Thu, 8 Mar 2007, Shane R wrote:

> I am trying to optimize a c++ application that I ported from a windows system 
> to Linux.

1. Do you use gcc under windows as well? If so which version on windows and which on Linux? gcc is not the best optimizer in the world....

2. Run...
   vmstat 5
for a half a page whilst your app is running and post that.

3. Watch "top", is your CPU running at 100%? Is it very near 100% in
user mode? Is your particular app running at very near 100% in user mode?


4. Run your app under "strace" and see what it's doing.

5. -O3 and -funroll-loops does not necessarily improve things if it
destroys the cache utility.

6. -O2 -fomit-frame-pointer -march=WHATEVERAPPROPRIATE may do better.

7. My general experience is Linux Apps run significantly faster than windows.

8. Fire up gkrellm. Hmm you say you have a centrino duo, does that
mean it has dual cores? Does gkrellm show you have two CPU's running?
ie. Do you have the right kernel for your Dual core?

> The app is a terminal based application that does some one time file io at 
> the start then runs completely in memory.

Does it read/write lots to any file / device eg. terminal?




John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter@tait.co.nz
New Zealand

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linux c++ opmization--- linux runs at half the speed of windows?
  2007-03-12 22:06 ` Lawrence Crowl
  2007-03-12 23:13   ` Artūras Moskvinas
@ 2007-03-13  8:57   ` Galloth
  1 sibling, 0 replies; 8+ messages in thread
From: Galloth @ 2007-03-13  8:57 UTC (permalink / raw)
  To: Lawrence Crowl; +Cc: gcc-help

hi,
is it possible, that Your windows compiler is able to optimize for
Core or Core2 processors? Pentium4 is not Dual Core. Intel rebuild the
whole processor.

Jan K

2007/3/12, Lawrence Crowl <crowl@google.com>:
> Is your windows compiler doing automatic parallelization by chance?
> Twice as fast on a dual core processor is a bit too coincidental.  :-)
>
> On 3/8/07, Shane R <crazguy22@hotmail.com> wrote:
> > Hi,
> >
> > I hope this is the appropriate forum. Please direct me to the correct one if
> > it is not.
> >
> > I am trying to optimize a c++ application that I ported from a windows
> > system to Linux.
> > The app is a terminal based application that does some one time file io at
> > the start then runs completely in memory. After the one time io the app runs
> > successive timed epochs on the same data in Windows as Linux. The app is a
> > program that runs some code for doing non-linear optmization (math stuff).
> >
> > The reason why I am posting is that I timed the time it takes for the
> > application to complete an epoch. It take twice as long in Linux as
> > windows?!?!
> >
> > My system is an Intel Centrino Duo with 2gigs of ram. The application is
> > only using a fraction of available memory in windows and linux. The
> > application is single-threaded in both.
> >
> > I am using Visual Studio 2003 in Windows and when I type gcc -v I get:
> > Target: i486-linux-gnu
> > Configured with: ../src/configure -v
> > --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
> > --enable-shared --with-system-zlib --libexecdir=/usr/lib
> > --without-included-gettext --enable-threads=posix --enable-nls
> > --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
> > --enable-libstdcxx-debug --enable-mpfr --enable-checking=release
> > i486-linux-gnu
> > Thread model: posix
> > gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)
> >
> >
> >
> > I am currently using these g++ options:
> >
> > CFLAGS = -o3 -O3 -march=pentium4 -ffast-math  -funroll-loops -Wall
> > -Wno-return-type
> >
> > But I have tried every permutation of the above options to virtually no
> > effect
> >
> > The average run time of an epoch in windows is about 3000 milliseconds while
> > the average run time of an epoch in Linux is 6000!
> >
> > I don't know if it matters but I am doing calls to the rand() function in
> > both my windows and linux apps.
> >
> > On another note does anyone have any experience with the Intel drop in
> > replacement for GCC?
> >
> > Thanks in advance for any help,
> >
> > Shane
> >
> > _________________________________________________________________
> > Match.com - Click Here To Find Singles In Your Area Today!
> > http://match.engb.msn.com/
> >
> >
>
>
> --
> Lawrence Crowl
>


-- 
Jan Kastil
galloth@jabbim.cz

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-03-13  7:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-08 12:30 Linux c++ opmization--- linux runs at half the speed of windows? Shane R
2007-03-08 15:01 ` Andrew Haley
2007-03-08 16:10 ` Atwood, Robert C
2007-03-08 17:10 ` Sven Eschenberg
2007-03-12 22:06 ` Lawrence Crowl
2007-03-12 23:13   ` Artūras Moskvinas
2007-03-13  8:57   ` Galloth
2007-03-12 23:49 ` John Carter

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).