I'm using f2py to offload performance critical sections of my python code to fortran. I have two fortran compilers, gfortran and ifort. Since the code I run will be on intel processors, ifort is usually faster. But for the most critical part of my code, I observe the opposite, with gfortran being faster by 40%! After inspecting the actual command line ifort is being called with, I noticed that f2py appends -fp-model strict to the command line no matter what I specify in the FFLAGS environment variable. I suspect that this is the cause of the ifort slowness.
Is there a way to make f2py stop enforcing this floating point model? I've tried both adding -fp-model fast to FFLAGS and f2py's --f90flags argument, but while they appear on the final command line, they do so before the strict flag, and are therefore overridden. While I appreciate support for NaNs etc., it is not worth a 40% slowdown.
Here is my f2py command line:
FFLAGS="-openmp -Ofast -fPIC" f2py --fcompiler=intelem -c -m pmat_core_32 pmat_core_32.f90 -liomp5
and here are the flags that are actually passed to ifort, according to the f2py output:
-FI -openmp -Ofast -fPIC -xhost -openmp -fp-model strict
				
                        
The flags
-xhost -openmp -fp-model strictcome fromin the file
site-packages/numpy/distutils/fcompiler/intel.pyfor the classes that invoke ifort.You have two options to modify the behavior of these flags:
f2pywith the--nooptflag to suppress these flagsf2pywith the--opt='blah'to override these flagsYou can get the flags you desire with: