On Saturday 18 October 2003 19:34, Kevan Hashemi wrote:
Most things take two or three times as long with GPC. I expect code running
Are you enabling any optimizations while compiling? gpc is based around gcc backend and in general produces fairly good code. However to enjoy this you *have* to ask compiler to do so. Leaving out debug info helps as well.
Basically you can use all the standard gcc optimization switches (man/info gcc, look into gcc invocation). In particular the minimal set of switches might look like: -O2 -march=??? [-fomit-frame-pointer] you might try -Os instead of O2, or -O3
-O2 enables bunch of "safe" optimizations, and may be used in almost any situation.
-O3 additionally enables some loop unrolling, which generally makes code larger and sometimes faster, but sometimes slower.
-Os optimizes for size (instead of speed), which might improve cashe hits, which in turn sometimes provides massive speedups..
-fomit-frame-pointer - frees one register, which is more usefull on x86 architecture, however makes debugging impossible.
Few more options to look into (not as safe) -ffast-math (disables some checks and features, in particular "nan" is no longer defined, which have beaten few (mostly scientific) programs on my memory, although surprisingly not that many..
-expensive-optimizations - somewhat safer, although may (additionally) increase your compilation time and it is hard to squeeze anything on top of -O2 anyway..
-mfpmath=sse - may be a life saver on pentium3/4 or athlon (or brake things) but probably not that usefull outside x86.
Plus alignment stuff like -fforce-addr or -falign-functions=4/8 might add you few percent here and there..
Kind of a disclaimer: I am writing this off the memory, so I might have misspelled some of the flags (oh, and some of them have been renamed during transition from gcc-2.95.x to gcc-3.x), but they should be pretty close. Look into man/info pages for more detailed description and exact spelling..
George