nv.py 1.5 KB

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