f2py compile with the -qopenmp ifort flag even in the serial mode
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
I have a Fortran 90 code, with OpenMP implemented for some parts. Now to compile the Fortran code using f2py with OpenMP support I have to pass the f90 compiler flags. Now the code should compile with OpenMP support only if I provide the OpenMP relevant flag, unless it must be compiled as a normal serial code. This works as expected for gfortran but for ifort it doesn't. Lets explain this,
if I run,
(gfortran serial mode)
f2py -c adt.f90 -m adt_module
*Gives output (last few lines)*
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
(gfortran parallel mode)
f2py -c adt.f90 -m adt_module --f90flags='-fopenmp' -lgomp
*output*
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -fopenmp -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fopenmp -fPIC -O3 -funroll-loops
As you can clearly see there is no -fopenmp flag during the compilation in serial mode, as expected as I haven't pass the required flag
Now for ifort
(ifort parallel mode)
f2py -c adt.f90 -m adt_module --fcompiler=intelem --f90flags='-qopenmp' -liomp5
*Output*
Fortran f77 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -fPIC -fp-model strict -O1 -qopenmp
Fortran f90 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FR -qopenmp -fPIC -fp-model strict -O1 -qopenmp
Fortran fix compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -qopenmp -fPIC -fp-model strict -O1 -qopenmp
(ifort serial mode)
f2py -c adt.f90 -m adt_module --fcompiler=intelem
*Output*
Fortran f77 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -fPIC -fp-model strict -O1 -qopenmp
Fortran f90 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FR -fPIC -fp-model strict -O1 -qopenmp
Fortran fix compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -fPIC -fp-model strict -O1 -qopenmp
Now, here's the problem, see here compiling is done with -qopenmp flag for serial mode but I haven't passed it in command line.
Python/Numpy version:
import sys, numpy; print(numpy.version, sys.version)
('1.15.4', '2.7.5 (default, Oct 30 2018, 23:45:53) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]')
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the serial and parallel f2py commands with the intelem compiler and inspect the f2py compiler configuration that supplies the ifort flags. Done means serial compilation no longer includes -qopenmp, while explicitly passing --f90flags='-qopenmp' still enables it for parallel builds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100