-
-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Support for the NVIDIA HPC SDK fortran compiler #17341
Description
PGI Compilers & Tools are now packaged in the NVIDIA HPC SDK (https://www.pgroup.com/index.htm).
This implies a few changes for the detection of the fortran compiler.
Our particular use case uses f2py to wrap fortran code.
nvfortran is the executable for compiling fortran code, pgfortran is still available as an alias for nvfortran.
The compiler detection process parses the output of the --version flag.
Here are the outputs of the --version flag for pgfortran 20.04 (previous packaging), pgfortran 20.07 (new packaing alias) and nvfortran 20.07 (new packagin):
$ pgfortran --version
pgfortran 20.4-0 linuxpower target on Linuxpower
PGI Compilers and Tools
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.$ pgfortran --version
pgfortran (aka nvfortran) 20.7-0 linuxpower target on Linuxpower
PGI Compilers and Tools
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.$ nvfortran --version
nvfortran 20.7-0 linuxpower target on Linuxpower
NVIDIA Compilers and Tools
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.Notice :
- the
(aka nvfortran)part (2nd output) breaks the version detection if the pgfortran executable is used. - nvfortran (3rd output) is not matched during version detection if the nvfortran executable is used.
Reproducing code example:
! file: helloworld.f90
module m_hello_world
contains
subroutine sayhello()
implicit none
print *, 'Hello, World!'
end subroutine sayhello
end module m_hello_worldCompiled with:
In this exemple the nvfortran executable is used
$ F77=nvfortran F90=nvfortran CC=gcc CPATH= f2py --verbose -c --fcompiler=pg helloworld.f90 -m helloworldError message:
This is the error message with the nvfortran executable.
customize PGroupFCompiler
find_executable('nvfortran')
Found executable ***/nvhpc/20.07/Linux_ppc64le/20.7/compilers/bin/nvfortran
Traceback (most recent call last):
File "***/python_venv/reproducer_venv/bin/f2py", line 11, in <module>
load_entry_point('numpy==1.19.2', 'console_scripts', 'f2py')()
File "***/python_venv/reproducer_venv/lib/python3.7/site-packages/numpy-1.19.2-py3.7-linux-ppc64le.egg/numpy/f2py/f2py2e.py", line 692, in main
run_compile()
File "***/python_venv/reproducer_venv/lib/python3.7/site-packages/numpy-1.19.2-py3.7-linux-ppc64le.egg/numpy/f2py/f2py2e.py", line 659, in run_compile
setup(ext_modules=[ext])
File "***/python_venv/reproducer_venv/lib/python3.7/site-packages/numpy-1.19.2-py3.7-linux-ppc64le.egg/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "***/anaconda3/2019.03/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "***/anaconda3/2019.03/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "***/anaconda3/2019.03/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "***/python_venv/reproducer_venv/lib/python3.7/site-packages/numpy-1.19.2-py3.7-linux-ppc64le.egg/numpy/distutils/command/build.py", line 40, in run
old_build.run(self)
File "***/anaconda3/2019.03/lib/python3.7/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "***/anaconda3/2019.03/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "***/anaconda3/2019.03/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "***/python_venv/reproducer_venv/lib/python3.7/site-packages/numpy-1.19.2-py3.7-linux-ppc64le.egg/numpy/distutils/command/build_ext.py", line 238, in run
if fcompiler and fcompiler.get_version():
File "***/python_venv/reproducer_venv/lib/python3.7/site-packages/numpy-1.19.2-py3.7-linux-ppc64le.egg/numpy/distutils/fcompiler/__init__.py", line 428, in get_version
raise CompilerNotFound()
numpy.distutils.fcompiler.CompilerNotFound
With the pgfortran executable the Traceback is identical.
Workarround
This modification allows to match "nvfortran" in the output of the --version flag.
diff --git a/numpy/distutils/fcompiler/pg.py b/numpy/distutils/fcompiler/pg.py
index 72442c4fe..306f7ef34 100644
--- a/numpy/distutils/fcompiler/pg.py
+++ b/numpy/distutils/fcompiler/pg.py
@@ -12,7 +12,7 @@ class PGroupFCompiler(FCompiler):
compiler_type = 'pg'
description = 'Portland Group Fortran Compiler'
- version_pattern = r'\s*pg(f77|f90|hpf|fortran) (?P<version>[\d.-]+).*'
+ version_pattern = r'\s*(pg|nv)(f77|f90|hpf|fortran) (?P<version>[\d.-]+).*'
if platform == 'darwin':
executables = {Handling the (aka nvfortran) part for the pgfortran executable seems trickier.
Numpy/Python version information:
$ python --version
Python 3.7.3$ pip show numpy
Name: numpy
Version: 1.19.2
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: ***/python_venv/reproducer_venv/lib/python3.7/site-packages/numpy-1.19.2-py3.7-linux-ppc64le.egg
Requires:
Required-by: f90wrap