Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-09

Speed difference between intel/ppc on intel Mac

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tom Verhoeff

I have an Intel-based MacBook Pro. Until recently, I still used a PowerPC version of FPC. PowerPC code on this machine runs through (invisible) emulation.

However, I upgraded now to FPC 2.2.2 for Intel on mac. And to my surprise one of my time-consuming apps is twice slower, instead of faster. The PowerPC version took 95 minutes, the Intel version takes 195 minutes. This is on exactly the same machine, some OS.

It could be a compiler options issue. But I tried to compile the Intel version for fastest code (no checking, etc.).

Is there a way to see what options fpc actually uses (i.e. to find out which options are in effect, e.g. useful when both configuration file and command line options are being used)?

The app does not use floating point operations.

Anyone else have the same experience?

Any suggestions?

Thanks,

Tom

E-MAIL: T.Verhoeff @ TUE.NL | Dept. of Math. & Comp. Science PHONE: +31 40 247 41 25 | Technische Universiteit Eindhoven FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven http://www.win.tue.nl/~wstomv/ | The Netherlands

Reply by email

Jonas Maebe
to Tom Verhoeff
Tom Verhoeff wrote 12 lines
I have an Intel-based MacBook Pro. Until recently, I still used a PowerPC version of FPC. PowerPC code on this machine runs through (invisible) emulation. However, I upgraded now to FPC 2.2.2 for Intel on mac. And to my surprise one of my time-consuming apps is twice slower, instead of faster. The PowerPC version took 95 minutes, the Intel version takes 195 minutes. This is on exactly the same machine, some OS. It could be a compiler options issue. But I tried to compile the Intel version for fastest code (no checking, etc.).

Even if you'd compile an Intel version without any optimisations, it will normally be faster than the most optimised PPC version. One thing that may be happening here is however that because your program runs for such a long time, the dynamic optimiser in the PPC emulator is able to optimise the code so well that it actually becomes faster than the best that a static compiler could ever do. This sort of program, especially if its computation kernel is not too large, is an ideal candidate for run time optimisation.

Another possibility is that the computation kernel is fairly small and that the register allocator of the emulator does a better job with register allocation than FPC's register allocator (how many values you can keep in registers in inner loops can make quite big differences in execution speed).

Is there a way to see what options fpc actually uses (i.e. to find out which options are in effect, e.g. useful when both configuration file and command line options are being used)?

You can use -vd to have the compiler print out all compiler options it interprets (both from configuration files and from the command line). In general, to get the best code for an Intel Core family processor, use something like

-O3ppentium4 -Cppentium4 -Cfsse2

i doubt it'll speed up your program by a factor of 2 in any case though.

Jonas

Reply by email

Micha Nelissen
to Jonas Maebe
Jonas Maebe wrote 8 lines
You can use -vd to have the compiler print out all compiler options it interprets (both from configuration files and from the command line). In general, to get the best code for an Intel Core family processor, use something like -O3ppentium4 -Cppentium4 -Cfsse2 i doubt it'll speed up your program by a factor of 2 in any case though.

Hmm there are weak spots in FPC. E.g. fannkuch in the shootout:

http://shootout.alioth.debian.org/u32/benchmark.php?test=fannkuch&lang=fpascal&id=5

FPC is 2.1 times slower than gcc here. Maybe this program is like it?

It's still quite unlikely that an assembly emulator would optimize it run so much better than the original compiler could.

Micha

Reply by email

Jonas Maebe
to Micha Nelissen
Micha Nelissen wrote 14 lines
Jonas Maebe wrote: > You can use -vd to have the compiler print out all compiler options > it interprets (both from configuration files and from the command > line). In general, to get the best code for an Intel Core family > processor, use something like > -O3ppentium4 -Cppentium4 -Cfsse2 > i doubt it'll speed up your program by a factor of 2 in any case > though. Hmm there are weak spots in FPC. E.g. fannkuch in the shootout: http://shootout.alioth.debian.org/u32/benchmark.php?test=fannkuch&lang=fpascal&id=5 FPC is 2.1 times slower than gcc here. Maybe this program is like it?

The program of Tom is compiled by FCP/PPC and emulated on an Intel machine vs compiled by FPC/Intel and run natively on the same Intel machine, with the former being 2 times faster than the latter. Programs written for advocacy purposes by different people in different languages and compiled by completely different compilers but for the same target architecture don't really seem to be very relevant to me in this case.

Jonas

Reply by email