|
Hi
I wonder if there is any obvious thing I should be doing here? Simple benchmarks show that the same program compiled with MS VC 2003 or MS VC 2010 are about twice as fast as the program compiled with GCC. I find this strange as GCC clearly produces better quality code. I have compared the assembler output from both compilers. Even when compiled with -O3 the run is slower with GCC. What am I missing ? Regards Jeremy ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
|
> What am I missing ?
Telling us more details what the code does? --tml ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
|
In reply to this post by Jeremy Hall
OK,
Its a console text editor that supports a scripting language. The editor is about 11,250 lines of C and is self contained on Windows (doesn't use any extra libraries). Its been heavily optimized over many years. The "benchmark" is a (complex) regression test script reports the elapsed time at the end. It does a great deal of work including a lot of arithmetic and memory access, but very little disk access. I realise its too big an example for specific suggestions. I'll try and create a small example with simple compiler options for both compilers. I was really wondering if anyone else had seen this and if so what were their conclusions? FYI, the timings I had were (Windows XP SP3, on 1.6GHz Athlon XP, 1GB) : MinGW GCC 4.5.2 -Os 173 seconds MinGW GCC 4.5.2 -O3 105 seconds MS Visual C++ 2010 -O1s 89 seconds MS Visual C++ 2010 -O2t 87 seconds The same script on a 32 bit Linux box (GCC) runs a little faster (143 secs -Os), but still not as fast as VC++. The Linux 64 bit version on a 4GHz Core i7 executes in 20 seconds :-) The VS 2010 compile looks like this: D:\ge>cl -DFILE_TABS=4 -DSCREEN_TABS=2 /O1isyb2 /J /fp:fast /GFrS- /Qfast_transcendentals /arch:SSE /Zp4 /W2 g.c /Feg.exe /FAs Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 The MinGW GCC (4.5.2) options are:- gcc -pipe -std=c99 -funsigned-char -DFILE_TABS=4 -DSCREEN_TABS=2 g.c -Os -Wall -Wextra -Wno-char-subscripts -ffast-math -mfpmath=387 -mpc80 -mhard-float -s -fno-ident -fshort-enums -fwhole-program -minline-all-stringops -fmerge-all-constants -fomit-frame-pointer -fno-non-call-exceptions -fno-asynchronous-unwind-tables -fno-exceptions -fno-unwind-tables -fira-loop-pressure -fstrict-aliasing -fstrict-overflow -march=athlon-xp -mtune=athlon-xp -o g Regards Jeremy ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
|
Jeremy Hall wrote:
> > The same script on a 32 bit Linux box (GCC) runs a little faster (143 > secs -Os), but still not as fast as VC++. > The Linux 64 bit version on a 4GHz Core i7 executes in 20 seconds :-) > Everything runs faster on Linux so if your goal is fastest speed of execution your choice would be to use the OS that runs faster. As for Windows OS, I do not know the reasons for the differences. -- Earnie -- http://www.for-my-kids.com ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
|
In reply to this post by Jeremy Hall
Jeremy Hall writes:
> gcc [...] -mfpmath=387 -mpc80 [...] I'm not sure if MinGW actually supports the -mpc80 option, but Visual C++ doesn't support 80-bit floating point arithmetic. It puts the processor in 64-bit rounding mode by default and long doubles are only 64-bits. If you're using long doubles then that could explain some of the performace differnce. You're also using 387 math with GCC and it looks like VC++ is using faster SSE math. Anyways, 105 seconds versus 87 seconds seems like a reasonable difference in performance between the two compilers. Ross Ridge ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
|
In reply to this post by Jeremy Hall
Thanks Ross,
I only use doubles, not long doubles. I thought -mpc80 caused 80bit intermediate arithmetic to be used with the 387; which is the default for Linux GCC anyway, I tried removing SSE from the VC build and it did slow down the VC run a little, but only a few percent. Interesting! Really, I was surprised GCC didn't produce faster code given the effort that lots of very clever people put into the optimizer, and you can see, in general, the assembler produced is much more sophisticated. MS hardly seem to develop VC, it doesn't even support C99 after 11 years, Still, now I have started using MinGW, its so nice to be using the same compiler on all platforms, have decent warnings, have C99 support etc. ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
|
Hi Jeremy,
On Sun, 23 Jan 2011, Jeremy Hall wrote: >> MinGW GCC 4.5.2 -Os 173 seconds >> MinGW GCC 4.5.2 -O3 105 seconds >> MS Visual C++ 2010 -O1s 89 seconds >> MS Visual C++ 2010 -O2t 87 seconds It's well known that GCC's -Os produces *much* slower code in return for reducing executable size, so if you want to compare the highest performances of GCC and VC then I would ignore -Os completely. > Really, I was surprised GCC didn't produce faster code given the effort > that lots of very clever people put into the optimizer, and you can see, > in general, the assembler produced is much more sophisticated. It may be because it's an intermediate language compiler that supports several source languages other than C++, and several target architectures other than i386. This may reduce the number of optimisations that it can apply. It is also mainly developed by volunteers, whereas: > MS hardly seem to develop VC, it doesn't even support C99 after 11 years, Windows and most of its software (MS Office, IE, etc) have always been compiled with VC or its ancestors, and being a commercial product, Windows always had to be fast. They could make their programmers write bizarre contortions to get through the compiler, but if that compiler produced awful code then Windows would suffer in the marketplace. So they had a business incentive to spend a lot of money on making the compiler produce really fast code (maybe a long time ago), but they never really had an incentive to add language features. It would still be very interesting if you could reduce the problem to a test case and compare the assembler code generated by the two compilers. If GCC can be improved then all x86 Linuxes and FreeBSD would benefit as well, and many people would thank you :) Cheers, Chris. -- _____ __ _ \ __/ / ,__(_)_ | Chris Wilson <[hidden email]> Cambs UK | / (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Ruby/Perl/SQL Developer | \__/_/_/_//_/___/ | We are GNU : free your mind & your software | ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
|
On Sun, 23 Jan 2011 11:32:07 +0000 (GMT)
Chris Wilson <[hidden email]> wrote: > So they had a business incentive to spend a lot of money on making > the compiler produce really fast code (maybe a long time ago), but > they never really had an incentive to add language features. I think Microsoft haven't implemented C99 because most customers build C code using the C++ compiler since it's seen as a "better C", so there's very little demand now for anything other than C++0x. http://connect.microsoft.com/VisualStudio/feedback/details/531634/support-iso-c99-standard has a response from Microsoft. -- Bruce Cran ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
|
In reply to this post by Jeremy Hall
2011/1/23 Jeremy Hall <[hidden email]>:
> I only use doubles, not long doubles. I thought -mpc80 caused 80bit > intermediate arithmetic to be used with the > 387; which is the default for Linux GCC anyway, Try -march=pentium4 -mfpmath=sse -mieee-fp -mmmx -msse -msse2 -fexcess-precision=standard to get compareble sse math within gcc (-fexcess-precision=standard only sinced 4.5) See http://blog.andreas.org/display?id=9 > I tried removing SSE from the VC build and it did slow down the VC run > a little, but only a few percent. > Interesting! > > Really, I was surprised GCC didn't produce faster code given the > effort that lots of very clever people > put into the optimizer, and you can see, in general, the assembler > produced is much more sophisticated. > MS hardly seem to develop VC, it doesn't even support C99 after 11 years, > > Still, now I have started using MinGW, its so nice to be using the > same compiler on all platforms, have decent warnings, have C99 support > etc. > > ------------------------------------------------------------------------------ > Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! > Finally, a world-class log management solution at an even better price-free! > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > February 28th, so secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsight-sfd2d > _______________________________________________ > MinGW-users mailing list > [hidden email] > > This list observes the Etiquette found at > http://www.mingw.org/Mailing_Lists. > We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. > > _______________________________________________ > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingw-users > Also: mailto:[hidden email]?subject=unsubscribe > -- Reini Urban http://phpwiki.org/ http://murbreak.at/ ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:[hidden email]?subject=unsubscribe |
| Free forum by Nabble | Edit this page |
