|
| 1 | +## |
| 2 | +# Copyright 2015 Bart Oldeman |
| 3 | +# |
| 4 | +# This file is triple-licensed under GPLv2 (see below), MIT, and |
| 5 | +# BSD three-clause licenses. |
| 6 | +# |
| 7 | +# This file is part of EasyBuild, |
| 8 | +# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), |
| 9 | +# with support of Ghent University (http://ugent.be/hpc), |
| 10 | +# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en), |
| 11 | +# the Hercules foundation (http://www.herculesstichting.be/in_English) |
| 12 | +# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). |
| 13 | +# |
| 14 | +# http://github.com/hpcugent/easybuild |
| 15 | +# |
| 16 | +# EasyBuild is free software: you can redistribute it and/or modify |
| 17 | +# it under the terms of the GNU General Public License as published by |
| 18 | +# the Free Software Foundation v2. |
| 19 | +# |
| 20 | +# EasyBuild is distributed in the hope that it will be useful, |
| 21 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | +# GNU General Public License for more details. |
| 24 | +# |
| 25 | +# You should have received a copy of the GNU General Public License |
| 26 | +# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. |
| 27 | +## |
| 28 | +""" |
| 29 | +Support for PGI compilers (pgcc, pgc++, pgfortran) as toolchain compilers. |
| 30 | +
|
| 31 | +@author: Bart Oldeman (McGill University, Calcul Quebec, Compute Canada) |
| 32 | +""" |
| 33 | + |
| 34 | +from distutils.version import LooseVersion |
| 35 | + |
| 36 | +import easybuild.tools.systemtools as systemtools |
| 37 | +from easybuild.tools.build_log import EasyBuildError |
| 38 | +from easybuild.tools.toolchain.compiler import Compiler |
| 39 | + |
| 40 | + |
| 41 | +TC_CONSTANT_PGI = "PGI" |
| 42 | + |
| 43 | + |
| 44 | +class Pgi(Compiler): |
| 45 | + """PGI compiler class |
| 46 | + """ |
| 47 | + |
| 48 | + COMPILER_MODULE_NAME = ['PGI'] |
| 49 | + |
| 50 | + COMPILER_FAMILY = TC_CONSTANT_PGI |
| 51 | + |
| 52 | + # References: |
| 53 | + # http://www.pgroup.com/doc/pgiref.pdf |
| 54 | + # http://www.pgroup.com/products/freepgi/freepgi_ref/ch02.html#Mflushz |
| 55 | + # http://www.pgroup.com/products/freepgi/freepgi_ref/ch02.html#Mfprelaxed |
| 56 | + # http://www.pgroup.com/products/freepgi/freepgi_ref/ch02.html#Mfpapprox |
| 57 | + COMPILER_UNIQUE_OPTION_MAP = { |
| 58 | + 'i8': 'i8', |
| 59 | + 'r8': 'r8', |
| 60 | + 'optarch': '', # PGI by default generates code for the arch it is running on! |
| 61 | + 'openmp': 'mp', |
| 62 | + 'strict': ['Mnoflushz','Kieee'], |
| 63 | + 'precise': ['Mnoflushz'], |
| 64 | + 'defaultprec': ['Mflushz'], |
| 65 | + 'loose': ['Mfprelaxed'], |
| 66 | + 'veryloose': ['Mfprelaxed=div,order,intrinsic,recip,sqrt,rsqrt', 'Mfpapprox'], |
| 67 | + } |
| 68 | + |
| 69 | + # used when 'optarch' toolchain option is enabled (and --optarch is not specified) |
| 70 | + COMPILER_OPTIMAL_ARCHITECTURE_OPTION = { |
| 71 | + systemtools.AMD : '', |
| 72 | + systemtools.INTEL : '', |
| 73 | + } |
| 74 | + # used with --optarch=GENERIC |
| 75 | + COMPILER_GENERIC_OPTION = { |
| 76 | + systemtools.AMD : 'tp=x64', |
| 77 | + systemtools.INTEL : 'tp=x64', |
| 78 | + } |
| 79 | + |
| 80 | + COMPILER_CC = 'pgcc' |
| 81 | + COMPILER_CXX = 'pgc++' |
| 82 | + |
| 83 | + COMPILER_F77 = 'pgf77' |
| 84 | + COMPILER_F90 = 'pgfortran' |
| 85 | + COMPILER_FC = 'pgfortran' |
| 86 | + |
| 87 | + LINKER_TOGGLE_STATIC_DYNAMIC = { |
| 88 | + 'static': '-Bstatic', |
| 89 | + 'dynamic':'-Bdynamic', |
| 90 | + } |
| 91 | + |
| 92 | + def _set_compiler_flags(self): |
| 93 | + """Set -tp=x64 if optarch is set to False.""" |
| 94 | + if not self.options.get('optarch', False): |
| 95 | + self.variables.nextend('OPTFLAGS', ['tp=x64']) |
| 96 | + super(Pgi, self)._set_compiler_flags() |
0 commit comments