diff --git a/Custom_Toolchains/compiler/nvhpc.py b/Custom_Toolchains/compiler/nvhpc.py new file mode 100644 index 0000000000000000000000000000000000000000..194939816d32b8676b46de648e7a8e6591ee355c --- /dev/null +++ b/Custom_Toolchains/compiler/nvhpc.py @@ -0,0 +1,111 @@ +## +# Copyright 2015 Bart Oldeman +# +# This file is triple-licensed under GPLv2 (see below), MIT, and +# BSD three-clause licenses. +# +# This file is part of EasyBuild, +# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), +# with support of Ghent University (http://ugent.be/hpc), +# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), +# the Hercules foundation (http://www.herculesstichting.be/in_English) +# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). +# +# https://github.com/easybuilders/easybuild +# +# EasyBuild is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation v2. +# +# EasyBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. +## +""" +Support for NVIDIA HPC SDK ('NVHPC') compilers (nvc, nvc++, nvfortran) as toolchain compilers. NVHPC is the successor of the PGI compilers, on which this file is based upon. + +:author: Bart Oldeman (McGill University, Calcul Quebec, Compute Canada) +:author: Damian Alvarez (Forschungszentrum Juelich GmbH) +:author: Andreas Herten (Forschungszentrum Juelich GmbH) +""" + +from distutils.version import LooseVersion + +import easybuild.tools.systemtools as systemtools +from easybuild.tools.build_log import EasyBuildError +from easybuild.tools.toolchain.compiler import Compiler + + +TC_CONSTANT_NVHPC = "NVHPC" + + +class Nvhpc(Compiler): + """NVHPC compiler class + """ + + COMPILER_MODULE_NAME = ['NVHPC'] + + COMPILER_FAMILY = TC_CONSTANT_NVHPC + + # References: + # https://docs.nvidia.com/hpc-sdk/compilers/hpc-compilers-user-guide/index.html + # nvc --help + # And previously, for PGI: + # http://www.pgroup.com/doc/pgiref.pdf + # http://www.pgroup.com/products/freepgi/freepgi_ref/ch02.html#Mflushz + # http://www.pgroup.com/products/freepgi/freepgi_ref/ch02.html#Mfprelaxed + # http://www.pgroup.com/products/freepgi/freepgi_ref/ch02.html#Mfpapprox + COMPILER_UNIQUE_OPTION_MAP = { + 'i8': 'i8', + 'r8': 'r8', + 'optarch': '', # PGI by default generates code for the arch it is running on! + 'openmp': 'mp', + 'ieee': 'Kieee', + 'strict': ['Mnoflushz','Kieee'], + 'precise': ['Mnoflushz'], + 'defaultprec': ['Mflushz'], + 'loose': ['Mfprelaxed'], + 'veryloose': ['Mfprelaxed=div,order,intrinsic,recip,sqrt,rsqrt', 'Mfpapprox'], + 'vectorize': {False: 'Mnovect', True: 'Mvect'}, + } + + # used when 'optarch' toolchain option is enabled (and --optarch is not specified) + COMPILER_OPTIMAL_ARCHITECTURE_OPTION = { + (systemtools.X86_64, systemtools.AMD): 'tp=host', + (systemtools.X86_64, systemtools.INTEL): 'tp=host', + } + # used with --optarch=GENERIC + COMPILER_GENERIC_OPTION = { + (systemtools.X86_64, systemtools.AMD): 'tp=px', + (systemtools.X86_64, systemtools.INTEL): 'tp=px', + } + + COMPILER_CC = 'nvc' + # C++ compiler command is version-dependent, see below + COMPILER_CXX = 'nvc++' + + # COMPILER_F77 = 'pgf77' + # COMPILER_F90 = 'pgf90' + COMPILER_FC = 'nvfortran' + + LINKER_TOGGLE_STATIC_DYNAMIC = { + 'static': '-Bstatic', + 'dynamic':'-Bdynamic', + } + + def _set_compiler_flags(self): + """Set -tp=x64 if optarch is set to False.""" + if not self.options.get('optarch', False): + self.variables.nextend('OPTFLAGS', ['tp=x64']) + super(Nvhpc, self)._set_compiler_flags() + + def _set_compiler_vars(self): + """Set the compiler variables""" + nvhpc_version = self.get_software_version(self.COMPILER_MODULE_NAME)[0] + + super(Nvhpc, self)._set_compiler_vars() + diff --git a/Custom_Toolchains/nvhpc.py b/Custom_Toolchains/nvhpc.py new file mode 100644 index 0000000000000000000000000000000000000000..cc6c8e2a29dec97ab4c93d617998f98034e336b9 --- /dev/null +++ b/Custom_Toolchains/nvhpc.py @@ -0,0 +1,46 @@ +## +# Copyright 2015 Bart Oldeman +# +# This file is triple-licensed under GPLv2 (see below), MIT, and +# BSD three-clause licenses. +# +# This file is part of EasyBuild, +# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), +# with support of Ghent University (http://ugent.be/hpc), +# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), +# the Hercules foundation (http://www.herculesstichting.be/in_English) +# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). +# +# https://github.com/easybuilders/easybuild +# +# EasyBuild is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation v2. +# +# EasyBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. +## +""" +EasyBuild support for PGI compiler toolchain. + +:author: Bart Oldeman (McGill University, Calcul Quebec, Compute Canada) +""" + +from easybuild.toolchains.compiler.nvhpc import Nvhpc +from easybuild.toolchains.gcccore import GCCcore +from easybuild.tools.toolchain.toolchain import SYSTEM_TOOLCHAIN_NAME + + +class NvhpcToolchain(Nvhpc): + """Simple toolchain with just the NVIDIA HPC SDK compilers.""" + NAME = 'NVHPC' + # use GCCcore as subtoolchain rather than GCC, since two 'real' compiler-only toolchains don't mix well, + # in particular in a hierarchical module naming scheme + SUBTOOLCHAIN = [GCCcore.NAME, SYSTEM_TOOLCHAIN_NAME] + OPTIONAL = False +