Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d72c58

Browse files
authored
Merge pull request #17522 from charris/backport-17344
ENH: Support for the NVIDIA HPC SDK nvfortran compiler
2 parents 629bcf4 + 378e9ce commit 7d72c58

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

numpy/distutils/fcompiler/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ def wrap_unlinkable_objects(self, objects, output_dir, extra_dll_dir):
745745
('win32', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95',
746746
'intelvem', 'intelem', 'flang')),
747747
('cygwin.*', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95')),
748-
('linux.*', ('gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq',
748+
('linux.*', ('gnu95', 'intel', 'lahey', 'pg', 'nv', 'absoft', 'nag', 'vast', 'compaq',
749749
'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor')),
750750
('darwin.*', ('gnu95', 'nag', 'absoft', 'ibm', 'intel', 'gnu', 'g95', 'pg')),
751751
('sunos.*', ('sun', 'gnu', 'gnu95', 'g95')),

numpy/distutils/fcompiler/nv.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import sys
2+
3+
from numpy.distutils.fcompiler import FCompiler
4+
5+
compilers = ['NVHPCFCompiler']
6+
7+
class NVHPCFCompiler(FCompiler):
8+
""" NVIDIA High Performance Computing (HPC) SDK Fortran Compiler
9+
10+
https://developer.nvidia.com/hpc-sdk
11+
12+
Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers,
13+
https://www.pgroup.com/index.htm.
14+
See also `numpy.distutils.fcompiler.pg`.
15+
"""
16+
17+
compiler_type = 'nv'
18+
description = 'NVIDIA HPC SDK'
19+
version_pattern = r'\s*(nvfortran|(pg(f77|f90|fortran)) \(aka nvfortran\)) (?P<version>[\d.-]+).*'
20+
21+
executables = {
22+
'version_cmd': ["<F90>", "-V"],
23+
'compiler_f77': ["nvfortran"],
24+
'compiler_fix': ["nvfortran", "-Mfixed"],
25+
'compiler_f90': ["nvfortran"],
26+
'linker_so': ["<F90>"],
27+
'archiver': ["ar", "-cr"],
28+
'ranlib': ["ranlib"]
29+
}
30+
pic_flags = ['-fpic']
31+
32+
module_dir_switch = '-module '
33+
module_include_switch = '-I'
34+
35+
def get_flags(self):
36+
opt = ['-Minform=inform', '-Mnosecond_underscore']
37+
return self.pic_flags + opt
38+
39+
def get_flags_opt(self):
40+
return ['-fast']
41+
42+
def get_flags_debug(self):
43+
return ['-g']
44+
45+
def get_flags_linker_so(self):
46+
return ["-shared", '-fpic']
47+
48+
def runtime_library_dir_option(self, dir):
49+
return '-R%s' % dir
50+
51+
if __name__ == '__main__':
52+
from distutils import log
53+
log.set_verbosity(2)
54+
from numpy.distutils import customized_fcompiler
55+
print(customized_fcompiler(compiler='nv').get_version())

numpy/tests/test_public_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ def test_NPY_NO_EXPORT():
246246
"distutils.fcompiler.none",
247247
"distutils.fcompiler.pathf95",
248248
"distutils.fcompiler.pg",
249+
"distutils.fcompiler.nv",
249250
"distutils.fcompiler.sun",
250251
"distutils.fcompiler.vast",
251252
"distutils.from_template",

0 commit comments

Comments
 (0)