Win32 compilers questions

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

Win32 compilers questions

Postby Eduardo Waghabi » 08 Aug 2005, 16:52

My story:

I?ve been using CygWin?s gcc compiler. With ?O1 options I get the fastest code, -O2 is almost the same as no optimizations and ?O3 compile even slower code. So I was thinking if I should try to mess with each optimization flag to try to get the best result.

I?ve always been suspicious about the effects of cygwin1.dll on my engine?s speed. So I decided to give DJGPP a try and it actually compiled slower code. Before I try Microsoft C++, I thought I should ask here if I should bother at all.


My questions:

What is, in your opinion, the fastest Win32 compiler?
What is you experience with CygWin? Do you think its code is slow?
Do detailed study of the compiler?s optimization flag pays off, or one should stick with the standard optimization options?(e.g. the ?O1, 2 and 3 options of gcc)
Eduardo Waghabi
 
Posts: 13
Joined: 15 Jul 2005, 19:43
Location: Rio de Janeiro, Brazil

Re: Win32 compilers questions

Postby Roman Hartmann » 08 Aug 2005, 19:10

Hi,
I tried quite a few of the free available C/C++ compilers.

-Borland Freecomandline C/C++ compiler
-GNU GCC (Windows/Linux)
-Intel C/C++ (Windows/Linux)
-Microsoft Visual C++ Express Edition Beta 2
-Microsoft Visual C++ Studio Toolkit 2003 (or similar named)

In my personal experience the Microsoft compilers produce the fastest code (for my engine). The code produced by the Intel compiler was only in the range of GCC. But I have to add that I had only the evaluation version of the Intel compiler (although Intel states it would produce the same code than the professional version).
But depending on the data structure you are using in your chess engine the results might be different for you anyway. My engine seems to run faster on intel systems than on AMD processors for some reasons although it's the other way around for many other chess engines. So I guess you have to try it out if switching the compiler makes any difference for you. Switching from GCC to the Microsoft compiler resulted in about 30% faster code in my case (although that's only valid for perft results).

Roman
User avatar
Roman Hartmann
 
Posts: 155
Joined: 11 Oct 2004, 14:21

Re: Win32 compilers questions

Postby Gian-Carlo Pascutto » 08 Aug 2005, 19:41

It makes no sense to talk about the speed of code generated by "GCC" if you don't mention the used version.
Gian-Carlo Pascutto
 
Posts: 42
Joined: 04 Jul 2005, 13:24
Location: Belgium

Re: Win32 compilers questions

Postby Roman Hartmann » 08 Aug 2005, 19:54

Gian-Carlo Pascutto wrote:It makes no sense to talk about the speed of code generated by "GCC" if you don't mention the used version.


True.
I'm pretty sure I used MinGW gcc version 3.2.3. Intel Compiler was version 9. The Microsoft Compiler seems to be version 14.

Roman
User avatar
Roman Hartmann
 
Posts: 155
Joined: 11 Oct 2004, 14:21

Re: Win32 compilers questions

Postby Gian-Carlo Pascutto » 08 Aug 2005, 21:28

Latest GCC is 3.4, although for 32-bit x86 platforms GCC 3.3 seems to be better for most programs.
Gian-Carlo Pascutto
 
Posts: 42
Joined: 04 Jul 2005, 13:24
Location: Belgium

Re: Win32 compilers questions

Postby Tord Romstad » 08 Aug 2005, 21:38

Gian-Carlo Pascutto wrote:Latest GCC is 3.4

I am not sure what the latest GCC is, but it is not 3.4. The GCC installed on my machine is version 4.0.0. This is on a Mac, but I doubt that the most recent GCC for PowerPC is newer than the most recent GCC for x86. The opposite seems more likely.

Tord
User avatar
Tord Romstad
 
Posts: 639
Joined: 09 Oct 2004, 12:49
Location: Oslo, Norway

Re: Win32 compilers questions

Postby Gian-Carlo Pascutto » 08 Aug 2005, 22:25

You are right, but I would not use GCC 4.0.0 or 4.0.1 for anything yet.

Unless you play against me in a tournament, then you should certainly use it :-P
Gian-Carlo Pascutto
 
Posts: 42
Joined: 04 Jul 2005, 13:24
Location: Belgium

Re: Win32 compilers questions

Postby Tord Romstad » 08 Aug 2005, 22:56

Gian-Carlo Pascutto wrote:You are right, but I would not use GCC 4.0.0 or 4.0.1 for anything yet.

I've been using GCC 4.0.0 exclusively for the last few months, and I have never seen any problems. The only difference I have noticed compared to GCC 3.3 is that my program runs 10-15% faster. You could argue that my program is just a simple little toy which is not likely to trigger any obscure bugs or problems in the compiler, but if I recall correctly most of Mac OS X 10.4 is also compiled with GCC 4.0. When it's good enough to compile a modern OS with, I would say it is mature and stable enough for most purposes.

Unless you play against me in a tournament, then you should certainly use it :-P

If I ever play against you in a tournament, the compiler won't matter at all. Glaurung wouldn't have the shadow of a chance -- Sjeng is in a completely different class.

Tord
User avatar
Tord Romstad
 
Posts: 639
Joined: 09 Oct 2004, 12:49
Location: Oslo, Norway

Re: Win32 compilers questions

Postby Gian-Carlo Pascutto » 08 Aug 2005, 23:32

Tord Romstad wrote:
Gian-Carlo Pascutto wrote:You are right, but I would not use GCC 4.0.0 or 4.0.1 for anything yet.

I've been using GCC 4.0.0 exclusively for the last few months, and I have never seen any problems. The only difference I have noticed compared to GCC 3.3 is that my program runs 10-15% faster. You could argue that my program is just a simple little toy which is not likely to trigger any obscure bugs or problems in the compiler, but if I recall correctly most of Mac OS X 10.4 is also compiled with GCC 4.0. When it's good enough to compile a modern OS with, I would say it is mature and stable enough for most purposes.


I have unfortunately seen some rather ugly failure cases with GCC 4. It could be the code as well, with the more aggressive optimizers unveiling very subtle bugs, but that doesn't change the fact that one had better check whether the program is still working correctly.

Then again, the Intel compiler still doesn't make it through the code without crashing :-P

Unless you play against me in a tournament, then you should certainly use it :-P

If I ever play against you in a tournament, the compiler won't matter at all. Glaurung wouldn't have the shadow of a chance -- Sjeng is in a completely different class.


[Event "WCCC 11th"]
[Site "Graz"]
[Date "2003.11.22"]
[Round "1"]
[White "Deep Junior"]
[Black "Ruy Lopez"]
[Result "0-1"]
[ECO "C96"]
[PlyCount "124"]

1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3
O-O 9. h3 Na5 10. Bc2 c5 11. d4 cxd4 12. cxd4 Bb7 13. Nbd2 exd4 14. Nxd4 Re8
15. b4 Nc6 16. Nxc6 Bxc6 17. Nf3 d5 18. e5 Ne4 19. a3 a5 20. Rb1 axb4 21. axb4
Qb6 22. Be3 Qc7 23. Qd4 Ra3 24. Ra1 Rea8 25. Rxa3 Rxa3 26. Qb2 Ra6 27. Rc1 h6
28. Qb3 Qb7 29. Nd4 Bd7 30. f3 Ng5 31. Qd3 Bxb4 32. h4 Ra3 33. Nb3 Ne6 34. Qh7+
Kf8 35. Nd4 Nxd4 36. Bxd4 Qc7 37. e6 Bxe6 38. Bxg7+ Ke7 39. Bxh6 Bc5+ 40. Kh1
Be3 41. Re1 Bxh6 42. Qxh6 Qg3 43. Qd2 Qxh4+ 44. Kg1 Ra2 45. Rc1 Qc4 46. Kh1 Kd7
47. f4 Bg4 48. f5 Be2 49. f6 Kd6 50. Kh2 Kc7 51. Kg3 Kb7 52. Qg5 Qc3+ 53. Kh2
Qc7+ 54. Kh1 Rxc2 55. Qxd5+ Kb6 56. Qd4+ Rc5 57. Re1 Bc4 58. Kg1 Bd5 59. Rc1
Qd6 60. Qe3 Bb7 61. Rf1 Qd5 62. Qf2 b4 0-1

"Oops!"
Gian-Carlo Pascutto
 
Posts: 42
Joined: 04 Jul 2005, 13:24
Location: Belgium

Re: Win32 compilers questions

Postby Bryan Hofmann » 09 Aug 2005, 02:32

Eduardo Waghabi wrote:My story:

I’ve been using CygWin’s gcc compiler. With –O1 options I get the fastest code, -O2 is almost the same as no optimizations and –O3 compile even slower code. So I was thinking if I should try to mess with each optimization flag to try to get the best result.

I’ve always been suspicious about the effects of cygwin1.dll on my engine’s speed. So I decided to give DJGPP a try and it actually compiled slower code. Before I try Microsoft C++, I thought I should ask here if I should bother at all.


My questions:

What is, in your opinion, the fastest Win32 compiler?
What is you experience with CygWin? Do you think its code is slow?
Do detailed study of the compiler’s optimization flag pays off, or one should stick with the standard optimization options?(e.g. the –O1, 2 and 3 options of gcc)


It depends on the platform you want to compile for, since you mention that you are using CYGWin I will assume you are looking for a Windows based compiler. The fastest I have tested is the MS Visual C++ 2005 Beta 2. This will as far as I know is available via MSDN subscriptions. The next would be MS Visual C++ 2005 Express, this can be had for free but will expire when the 2005 is released. If you look for free and fast then you best choice is MS Visual C++ 2003 .NET (command line only). You can download it at http://msdn.microsoft.com/visualc/vctoolkit2003/ . After you have installed it you will need to download the Core SDK http://www.microsoft.com/msdownload/pla ... sdkupdate/ .

If you are interested in Linux compiles then the Intel Compiler would be your best choice and is free for non commercial use.

Bryan
Bryan Hofmann
 
Posts: 98
Joined: 02 Oct 2004, 20:26
Location: USA

Re: Win32 compilers questions

Postby Jim Ablett » 09 Aug 2005, 18:36

You can get a Windows binaries of GCC 4.0 here >

http://www.byobingo.com/gcc_mingw.htm

Jim.
___________________________
http://jimablett.net63.net/
Jim Ablett
 
Posts: 721
Joined: 27 Sep 2004, 10:39
Location: Essex, England

Re: Win32 compilers questions

Postby Joachim Rang » 09 Aug 2005, 19:09

Bryan Hofmann wrote:It depends on the platform you want to compile for, since you mention that you are using CYGWin I will assume you are looking for a Windows based compiler. The fastest I have tested is the MS Visual C++ 2005 Beta 2. This will as far as I know is available via MSDN subscriptions. The next would be MS Visual C++ 2005 Express, this can be had for free but will expire when the 2005 is released. If you look for free and fast then you best choice is MS Visual C++ 2003 .NET (command line only). You can download it at http://msdn.microsoft.com/visualc/vctoolkit2003/ . After you have installed it you will need to download the Core SDK http://www.microsoft.com/msdownload/pla ... sdkupdate/ .

Bryan


I have downloaded and installed both. I have build .obj-Files wiht vctoolkit. Now how do I build exes? If I start SDK and type nmake it says file not found...

regards Joachim
Joachim Rang
 
Posts: 69
Joined: 26 Sep 2004, 22:00

Re: Win32 compilers questions

Postby Pradu » 09 Aug 2005, 20:14

You could use CodeBlocks--it supports many compilers including the Microsoft 2003 Toolkit.
User avatar
Pradu
 
Posts: 343
Joined: 12 Jan 2005, 19:17
Location: Chandler, Arizona, USA

Re: Win32 compilers questions

Postby Bryan Hofmann » 09 Aug 2005, 23:27

Joachim Rang wrote:
Bryan Hofmann wrote:It depends on the platform you want to compile for, since you mention that you are using CYGWin I will assume you are looking for a Windows based compiler. The fastest I have tested is the MS Visual C++ 2005 Beta 2. This will as far as I know is available via MSDN subscriptions. The next would be MS Visual C++ 2005 Express, this can be had for free but will expire when the 2005 is released. If you look for free and fast then you best choice is MS Visual C++ 2003 .NET (command line only). You can download it at http://msdn.microsoft.com/visualc/vctoolkit2003/ . After you have installed it you will need to download the Core SDK http://www.microsoft.com/msdownload/pla ... sdkupdate/ .

Bryan


I have downloaded and installed both. I have build .obj-Files wiht vctoolkit. Now how do I build exes? If I start SDK and type nmake it says file not found...

regards Joachim


From the MS Visual C command prompt in the fruit source directory;

cl /O2 /GL *.cpp

I don't use make files nor do I use GUI's ,command line only.
Bryan Hofmann
 
Posts: 98
Joined: 02 Oct 2004, 20:26
Location: USA

Re: Win32 compilers questions

Postby Joachim Rang » 10 Aug 2005, 11:53

Bryan Hofmann wrote:
From the MS Visual C command prompt in the fruit source directory;

cl /O2 /GL *.cpp

I don't use make files nor do I use GUI's ,command line only.



thanks but if I try to compile Fruit there is an error: windows.h Cannot open Include file not found. I guess some variables are not set correct on my machine.

regards Joachim
Joachim Rang
 
Posts: 69
Joined: 26 Sep 2004, 22:00

Re: Win32 compilers questions

Postby Alessandro Scotti » 10 Aug 2005, 12:33

Joachim Rang wrote:if I try to compile Fruit there is an error: windows.h Cannot open Include file not found. I guess some variables are not set correct on my machine.


There is a batch file named vcvars32.bat that you must execute first, it will set all the required environment variables.
User avatar
Alessandro Scotti
 
Posts: 306
Joined: 20 Nov 2004, 00:10
Location: Rome, Italy

Re: Win32 compilers questions

Postby Joachim Rang » 10 Aug 2005, 13:11

Alessandro Scotti wrote:
Joachim Rang wrote:if I try to compile Fruit there is an error: windows.h Cannot open Include file not found. I guess some variables are not set correct on my machine.


There is a batch file named vcvars32.bat that you must execute first, it will set all the required environment variables.


I know and I executed this. Unfortunately it didn't work. But now after manually copying the lib and include folder from sdk to visual toolkit it works. I think not the standard procedure but who cares. ;-)

Thanks all who helped me with this.

regards Joachim

:D :D :D
Joachim Rang
 
Posts: 69
Joined: 26 Sep 2004, 22:00

Re: Win32 compilers questions

Postby Alessandro Scotti » 10 Aug 2005, 13:41

Joachim Rang wrote:I know and I executed this. Unfortunately it didn't work. But now after manually copying the lib and include folder from sdk to visual toolkit it works. I think not the standard procedure but who cares. ;-)


Ops, I didn't notice you had the SDK separated from the compiler! Copying is definitely ok if it solves the problem! :-) Anyway, my vcvars32.bat only sets three variables: PATH, INCLUDE and LIB. Probably you can get the same result by adding the SDK path to INCLUDE and LIB... just guessing though.
User avatar
Alessandro Scotti
 
Posts: 306
Joined: 20 Nov 2004, 00:10
Location: Rome, Italy

Re: Win32 compilers questions

Postby Sven Schüle » 10 Aug 2005, 15:20

Alessandro Scotti wrote:
Joachim Rang wrote:I know and I executed this. Unfortunately it didn't work. But now after manually copying the lib and include folder from sdk to visual toolkit it works. I think not the standard procedure but who cares. ;-)


Ops, I didn't notice you had the SDK separated from the compiler! Copying is definitely ok if it solves the problem! :-) Anyway, my vcvars32.bat only sets three variables: PATH, INCLUDE and LIB. Probably you can get the same result by adding the SDK path to INCLUDE and LIB... just guessing though.

Hi,

can someone please tell me which SDK exactly can/should be used with the MSVC++ Toolkit 2003 compiler? Perhaps with a download link? I have already tried searching on the Microsoft pages but I only found a "MS ... Server 2003" SDK and I wasn't sure if this was the right one.

Sven
User avatar
Sven Schüle
 
Posts: 240
Joined: 26 Sep 2004, 20:19
Location: Berlin, Germany

Re: Win32 compilers questions

Postby Eduardo Waghabi » 11 Aug 2005, 22:22

Bryan thanks a lot for the MSVC++ 2003 tip. I?ve downloaded it and my first tests showed /O2 and /GL flags got me a 20% performance gain against gcc 3.4.4 compilation (CygWin) using ?O1.

This on an Intel Pentium 4. I?ll test it later in my AMD at home.

Has anyone here ever used Intel VTune Performance Analyzer? It?s a nifty tool to spot bottlenecks. You can download a free trial at www.intel.com/software/products/vtune/d ... e_eval.htm

P.S. Sven, the 2003 Server SP1 SDK is indeed the correct one (link above, see Bryan post). I?ve downloaded the huge iso image because the web install and the separate .cab files didn?t work for me (I dunno why).
P.S.2 Yes to make MSVC work with the SDK in your ?Visual C++ Toolkit 2003 Command Prompt? just include the SDK path in the vcvars32.bat file:
Code: Select all
Set PATH=C:\Program Files\Microsoft Platform SDK\bin;C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;%PATH%;
Set INCLUDE=C:\Program Files\Microsoft Platform SDK\include;C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
Set LIB=C:\Program Files\Microsoft Platform SDK\lib;C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib;%LIB%


Abra?os,
Eduardo Waghabi
 
Posts: 13
Joined: 15 Jul 2005, 19:43
Location: Rio de Janeiro, Brazil

Next

Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 51 guests