nv.py 1.5 KB

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