[f2py] OpenMP - again

Pearu Peterson pearu.peterson at gmail.com
Sat Sep 4 13:30:53 EEST 2010


Hi!

On Sat, Sep 4, 2010 at 12:31 PM, Paul Anton Letnes
<paul.anton.letnes at gmail.com> wrote:
> Dear f2py fans.
>
> I finally got an OpenMP example up and running. It even gives a decent speedup (1.8-ish) on my 2-core laptop! The only disadvantage is that I have not managed to pass the "-fopenmp" flag to the final compile-and-link command, meaning that if I simply run "make" (Makefile included, of course) the resulting python module is not linked to libopenmp. I managed to fix this by manually copying the final build command and adding the "-fopenmp" flag by hand - see detailed instructions in the Makefile.
>
> Can anyone please tell me how I can "automagically" get the -fopenmp flag into the final build command? I believe that will make this example more complete. Also, feel free to suggest improvements to this example!

Isn't -fopenmp the flag for the compiler, not for the linker?
f2py has --opt, --f90flags, and --f77flags switches that can be used for
specifying extra options to fortran compiler. Note that when
using these switches then their default values defined
by numpy.distutils.fcompiler will be overwritten. So, always
remember specifying these default values in the switches
as some of them might be required. Redefining --opt might
be the safest way as then one would loose only optimization
flags.

HTH,
Pearu



More information about the f2py-users mailing list