From a71e7d73498214c61c312bcb21d8e3bd8b313b29 Mon Sep 17 00:00:00 2001 From: Daniel Vanzo Date: Fri, 18 Sep 2020 10:31:23 +0200 Subject: [PATCH 1/4] ENH: Add support for the NVIDIA HPC SDK fortran compiler --- numpy/distutils/fcompiler/__init__.py | 2 +- numpy/distutils/fcompiler/nv.py | 48 +++++++++++++++++++++++++++ numpy/tests/test_public_api.py | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 numpy/distutils/fcompiler/nv.py diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index 1c3069363f84..31c992d8fb1d 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -745,7 +745,7 @@ def wrap_unlinkable_objects(self, objects, output_dir, extra_dll_dir): ('win32', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang')), ('cygwin.*', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95')), - ('linux.*', ('gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', + ('linux.*', ('gnu95', 'intel', 'lahey', 'pg', 'nv', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor')), ('darwin.*', ('gnu95', 'nag', 'absoft', 'ibm', 'intel', 'gnu', 'g95', 'pg')), ('sunos.*', ('sun', 'gnu', 'gnu95', 'g95')), diff --git a/numpy/distutils/fcompiler/nv.py b/numpy/distutils/fcompiler/nv.py new file mode 100644 index 000000000000..60d117c80166 --- /dev/null +++ b/numpy/distutils/fcompiler/nv.py @@ -0,0 +1,48 @@ +# https://developer.nvidia.com/hpc-sdk +import sys + +from numpy.distutils.fcompiler import FCompiler + +compilers = ['NVHPCFCompiler'] + +class NVHPCFCompiler(FCompiler): + + compiler_type = 'nv' + description = 'NVIDIA HPC SDK' + version_pattern = r'\s*(nvfortran|(pg(f77|f90|fortran)) \(aka nvfortran\)) (?P[\d.-]+).*' + + executables = { + 'version_cmd': ["", "-V"], + 'compiler_f77': ["nvfortran"], + 'compiler_fix': ["nvfortran", "-Mfixed"], + 'compiler_f90': ["nvfortran"], + 'linker_so': [""], + 'archiver': ["ar", "-cr"], + 'ranlib': ["ranlib"] + } + pic_flags = ['-fpic'] + + module_dir_switch = '-module ' + module_include_switch = '-I' + + def get_flags(self): + opt = ['-Minform=inform', '-Mnosecond_underscore'] + return self.pic_flags + opt + + def get_flags_opt(self): + return ['-fast'] + + def get_flags_debug(self): + return ['-g'] + + def get_flags_linker_so(self): + return ["-shared", '-fpic'] + + def runtime_library_dir_option(self, dir): + return '-R%s' % dir + +if __name__ == '__main__': + from distutils import log + log.set_verbosity(2) + from numpy.distutils import customized_fcompiler + print(customized_fcompiler(compiler='nv').get_version()) diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index fb7ec5d83eb4..716feef9f8c6 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -246,6 +246,7 @@ def test_NPY_NO_EXPORT(): "distutils.fcompiler.none", "distutils.fcompiler.pathf95", "distutils.fcompiler.pg", + "distutils.fcompiler.nv", "distutils.fcompiler.sun", "distutils.fcompiler.vast", "distutils.from_template", From b484cd405407b3a47549b3ebaa2b3659da386a78 Mon Sep 17 00:00:00 2001 From: Daniel Vanzo Date: Tue, 22 Sep 2020 15:08:21 +0200 Subject: [PATCH 2/4] ENH: Add comments about Nvidia HPC SDK and PGI --- numpy/distutils/fcompiler/nv.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/numpy/distutils/fcompiler/nv.py b/numpy/distutils/fcompiler/nv.py index 60d117c80166..4cf30f5ef100 100644 --- a/numpy/distutils/fcompiler/nv.py +++ b/numpy/distutils/fcompiler/nv.py @@ -5,6 +5,10 @@ compilers = ['NVHPCFCompiler'] +""" +Since august 2020 the NVIDIA HPC SDK includes the compilers formely known as The Portland Group compilers. +https://www.pgroup.com/index.htm +""" class NVHPCFCompiler(FCompiler): compiler_type = 'nv' From e694d1728dbfa1a23ab838e252403a160496ff02 Mon Sep 17 00:00:00 2001 From: danbeibei <57632244+danbeibei@users.noreply.github.com> Date: Fri, 2 Oct 2020 15:57:18 +0200 Subject: [PATCH 3/4] Update numpy/distutils/fcompiler/nv.py Co-authored-by: Eric Wieser --- numpy/distutils/fcompiler/nv.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/numpy/distutils/fcompiler/nv.py b/numpy/distutils/fcompiler/nv.py index 4cf30f5ef100..c5f203ee8ddb 100644 --- a/numpy/distutils/fcompiler/nv.py +++ b/numpy/distutils/fcompiler/nv.py @@ -1,15 +1,18 @@ -# https://developer.nvidia.com/hpc-sdk import sys from numpy.distutils.fcompiler import FCompiler compilers = ['NVHPCFCompiler'] -""" -Since august 2020 the NVIDIA HPC SDK includes the compilers formely known as The Portland Group compilers. -https://www.pgroup.com/index.htm -""" class NVHPCFCompiler(FCompiler): + """ NVIDIA High Performance Computing (HPC) SDK Fortran Compiler + + https://developer.nvidia.com/hpc-sdk + + Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers, + https://www.pgroup.com/index.htm. + See also `numpy.distutils.fcompiler.pg`. + """ compiler_type = 'nv' description = 'NVIDIA HPC SDK' From 378e9cec632610b06b6aaaa2ade16767ecf616b3 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 9 Oct 2020 10:37:46 -0600 Subject: [PATCH 4/4] BUG: Fix indentation. --- numpy/distutils/fcompiler/nv.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/numpy/distutils/fcompiler/nv.py b/numpy/distutils/fcompiler/nv.py index c5f203ee8ddb..8e9f1683558a 100644 --- a/numpy/distutils/fcompiler/nv.py +++ b/numpy/distutils/fcompiler/nv.py @@ -5,14 +5,14 @@ compilers = ['NVHPCFCompiler'] class NVHPCFCompiler(FCompiler): - """ NVIDIA High Performance Computing (HPC) SDK Fortran Compiler + """ NVIDIA High Performance Computing (HPC) SDK Fortran Compiler - https://developer.nvidia.com/hpc-sdk + https://developer.nvidia.com/hpc-sdk - Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers, - https://www.pgroup.com/index.htm. - See also `numpy.distutils.fcompiler.pg`. - """ + Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers, + https://www.pgroup.com/index.htm. + See also `numpy.distutils.fcompiler.pg`. + """ compiler_type = 'nv' description = 'NVIDIA HPC SDK'