-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: f2py in numpy 2.0.1 cannot compile code with explicit openmp procedure calls [Intel compilers] #27163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I went back to python 3.11.6 and after modifying |
OTOH, shouldn't this just be done by editing the |
I know there's still not a lot of clarity on the way the scope of F2PY has changed with the shift to meson, F2PY is meant to focus purely on generating the wrappers, the build system is meant to be customized with the |
This should be working by default since #26703 in any case, could you also share the generated |
Where can I find this |
This was true before as well though, passing |
Indeed, for
If you look at the original error, it's the C compiler invocation that is failing. |
OTOH, does adding `c_args: ['-qopenmp']` fix this? Might be worth having a way to pass `c_args` from the command line.
However, for OpenMP in particular it might be best to just pass `--dep openmp` which should solve this (or make it an upstream error [1] since it'll add `dependency('openmp')`...
[1] https://mesonbuild.com/Dependencies.html#openmp
…On 8/20/24 5:56 PM, Sourish Basu ***@***.***> wrote:
CFLAGS='-qopenmp' FC=ifx CC=icx CXX=icpx f2py -c
mwe_f2py.pyf --f77flags='-qopenmp' --f90flags='-qopenmp'
-liomp5 mwe_f2py.F90
Where can I find this |meson.build| that is being generated? I
don't see it in the folder where my |F90| and |pyf| files are.
One of the joys of the meson system, I have discovered, is that
it very helpfully deletes all intermediate files.
This was true before as well though, passing |--build-dir whatever|
is required to keep all the generated files (including the
|whatever/meson.build| file).
Indeed, for |f2py| that was always the case :-) My complaint was a
carryover from trying to use |meson| instead of |distutils| for
compiling (other) python modules. Anyway, here's what is inside
|meson.build|:
|project('mwe_f2py', ['c', 'fortran'], version : '0.1', meson_version:
'>= 1.1.0', default_options : [ 'warning_level=1', 'buildtype=release'
]) fc = meson.get_compiler('fortran') py =
import('python').find_installation('''/work2/noaa/co2/sbasu/packages/python/3.12.4/bin/python''', pure: false) py_dep = py.dependency() incdir_numpy = run_command(py, ['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'], check : true ).stdout().strip() incdir_f2py = run_command(py, ['-c', 'import os; os.chdir(".."); import numpy.f2py; print(numpy.f2py.get_include())'], check : true ).stdout().strip() inc_np = include_directories(incdir_numpy) np_dep = declare_dependency(include_directories: inc_np) incdir_f2py = incdir_numpy / '..' / '..' / 'f2py' / 'src' inc_f2py = include_directories(incdir_f2py) fortranobject_c = incdir_f2py / 'fortranobject.c' inc_np = include_directories(incdir_numpy, incdir_f2py) # gh-25000 quadmath_dep = fc.find_library('quadmath', required: false) iomp5 = declare_dependency(link_args : ['-liomp5']) py.extension_module('mwe_f2py', [ '''mwe_f2py.F90''', '''mwe_f2pymodule.c''', '''mwe_f2py-f2pywrappers2.f90''', fortranobject_c ], include_directories: [ inc_np, ], dependencies : [ py_dep, quadmath_dep, iomp5, ], fortran_args: ['-qopenmp'], install : true) |
If you look at the original error, it's the C compiler invocation that
is failing.
—
Reply to this email directly, view it on GitHub
<#27163 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBCUT2NR66VDODNTIR6KDTZSN7ODAVCNFSM6AAAAABMJA3G2SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJZGQZDQNBQHA>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Since
You mean like this?
This did not work, it still barfed with the error
|
Ah sorry, so you can always go into the
Hmm, odd. The flags seemed to be passed, but evidently f2py -c mwe.pyf mwe.f90 --dep openmp
python -c "import mwe_f2py" Does However as a work around, adding |
Maybe try the meson-specific
|
Uh oh!
There was an error while loading. Please reload this page.
Describe the issue:
I have compiled python 3.12.4 and numpy 2.0.1 with intel oneapi 2024.1 compilers on a compute cluster for multiple people to use. I have some f2py code that explicitly uses openmp library calls such as
omp_set_num_threads
. With previous versions of python, including 3.11.6, I could compile this withwhich would produce a perfectly working python module
mwe_f2py.cpython-311-x86_64-linux-gnu.so
. However, since everything has moved to the new-fangled meson now, this is no longer possible on python 3.12.4. So instead if I doit raises the error
undefined reference to 'omp_set_num_threads'
. This should not happen because I am supplying-qopenmp
as a compiler option.Reproduce the code example:
Put the following in
mwe_f2py.F90
and the following in
mwe_f2py.pyf
,Error message:
Python and NumPy Versions:
2.0.1
3.12.4 (main, Jul 29 2024, 10:14:44) [Clang 18.0.0 (icx 2024.1.0.20240308)]
Runtime Environment:
[{'numpy_version': '2.0.1',
'python': '3.12.4 (main, Jul 29 2024, 10:14:44) [Clang 18.0.0 (icx '
'2024.1.0.20240308)]',
'uname': uname_result(system='Linux', node='hercules-login-3.hpc.msstate.edu', release='5.14.0-162.23.1.el9_1.x86_64', version='#1 SMP PREEMPT_DYNAMIC Tue Apr 11 19:09:37 UTC 2023', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL'],
'not_found': ['AVX512_KNL']}},
{'filepath': '/apps/spack-managed/gcc-11.3.1/intel-oneapi-compilers-2024.1.0-76aou5yu2oqfcz72vq7lp77bp3rqcoht/compiler/2024.1/lib/libiomp5.so',
'internal_api': 'openmp',
'num_threads': 160,
'prefix': 'libiomp',
'user_api': 'openmp',
'version': None}]
Context for the issue:
No response
The text was updated successfully, but these errors were encountered: