GCC Compiling

Discussion of chess software programming and technical issues.

Moderator: Ras

Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: GCC Compiling

Post by Edsel Apostol »

Thanks Bob,

You answered the questions I was about to post.

I'm just wondering though which is more efficient, your '-fprofile-arcs" or Jim's "-fprofile-generate" method?

I also have one question that has not been answered before. Is it possible that a 64 bit program could be compiled in a 32 bit OS without running it? Forgive my ignorance as I have no experience yet with compiling in 64 bit programs.
User avatar
Jim Ablett
Posts: 2367
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: GCC Compiling

Post by Jim Ablett »

Is it possible that a 64 bit program could be compiled in a 32 bit OS without running it?
Hi Edsel,

I can answer that question because I did it for the first 64-bit sloppy compile.

On the mingw64 page you will find a version which runs on 32 bit processor/ 32 bit environment.
You can successfully compile 64 bit version, but downside side you won't be able to test it or run it in 32 bit os,
so you would have to send to somebody else whose got 64 bit os to test it.

Jim.
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: GCC Compiling

Post by Edsel Apostol »

Thanks once again Jim!

My tester has a 64 bit OS so that's not a problem.
Aleks Peshkov
Posts: 958
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia
Full name: Aleks Peshkov

Re: GCC Compiling

Post by Aleks Peshkov »

Jim Ablett wrote:Just using msvc in instead of gcc could give you an extra 30% maybe more.
It depends, my program is 30% faster in GCC, because I can order GCC to inline code much more aggressively.

Another example: I cannot make Visual C++ good use of x86 assembler bit test (bt, btc, bts, btr) instructions both in intrinsics and in inline assembler forms.
User avatar
Jim Ablett
Posts: 2367
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: GCC Compiling

Post by Jim Ablett »

Aleks Peshkov wrote:
Jim Ablett wrote:Just using msvc in instead of gcc could give you an extra 30% maybe more.
It depends, my program is 30% faster in GCC, because I can order GCC to inline code much more aggressively.

Another example: I cannot make Visual C++ good use of x86 assembler bit test (bt, btc, bts, btr) instructions both in intrinsics and in inline assembler forms.
Hi Aleks,

Your program may be an exception rather than a rule here. My straight gcc chess engine compiles (no hand tuning) are almost without exception at least 30% slower than my equivalent Intel/mscv compiles. I can only think of one engine I've compiled , Phalanx where the speed was the same.

Jim.
Aleks Peshkov
Posts: 958
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia
Full name: Aleks Peshkov

Re: GCC Compiling

Post by Aleks Peshkov »

I use -Wdisabled-optimization -Winline for GCC and it helps much to control the shape of builded code.
wgarvin
Posts: 838
Joined: Thu Jul 05, 2007 5:03 pm
Location: British Columbia, Canada

Re: GCC Compiling

Post by wgarvin »

Aleks Peshkov wrote:
Jim Ablett wrote:Just using msvc in instead of gcc could give you an extra 30% maybe more.
It depends, my program is 30% faster in GCC, because I can order GCC to inline code much more aggressively.

Another example: I cannot make Visual C++ good use of x86 assembler bit test (bt, btc, bts, btr) instructions both in intrinsics and in inline assembler forms.
By the way, you can force MSVC to inline code with a compiler-specific extension:

Code: Select all

#define FORCE_INLINE __forceinline
FORCE_INLINE void Foo() { }
Here is a similar incantation which should work for GCC:

Code: Select all

#define FORCE_INLINE __inline__ __attribute__((always_inline))
FORCE_INLINE void Foo() { }
I usually put these macros in the same header as my base types and other simple platform- or compiler-specific declarations.

...Unfortunately, I don't know of a convenient way to force either compiler NOT to inline code, other than to put the function definition in another .cpp file which the compiler doesn't get to see before it sees the call site. So that's what I do when I need that behaviour, even though its a bit inconvenient.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: GCC Compiling

Post by bob »

Edsel Apostol wrote:Thanks Bob,

You answered the questions I was about to post.

I'm just wondering though which is more efficient, your '-fprofile-arcs" or Jim's "-fprofile-generate" method?

I also have one question that has not been answered before. Is it possible that a 64 bit program could be compiled in a 32 bit OS without running it? Forgive my ignorance as I have no experience yet with compiling in 64 bit programs.
I am not sure what profile-generate does that is different from the option I gave... but I will try to investigate it to find out...