|
| 1 | +## |
| 2 | +# Copyright 2014-2021 Ghent University |
| 3 | +# |
| 4 | +# This file is part of EasyBuild, |
| 5 | +# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), |
| 6 | +# with support of Ghent University (http://ugent.be/hpc), |
| 7 | +# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), |
| 8 | +# Flemish Research Foundation (FWO) (http://www.fwo.be/en) |
| 9 | +# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). |
| 10 | +# |
| 11 | +# https://github.com/easybuilders/easybuild |
| 12 | +# |
| 13 | +# EasyBuild is free software: you can redistribute it and/or modify |
| 14 | +# it under the terms of the GNU General Public License as published by |
| 15 | +# the Free Software Foundation v2. |
| 16 | +# |
| 17 | +# EasyBuild is distributed in the hope that it will be useful, |
| 18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | +# GNU General Public License for more details. |
| 21 | +# |
| 22 | +# You should have received a copy of the GNU General Public License |
| 23 | +# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. |
| 24 | +## |
| 25 | +""" |
| 26 | +Support for the Fujitsu compiler drivers (aka fcc, frt). |
| 27 | +
|
| 28 | +The basic concept is the same as for the Cray Programming Environment. |
| 29 | +
|
| 30 | +:author: Miguel Dias Costa (National University of Singapore) |
| 31 | +""" |
| 32 | +import os |
| 33 | + |
| 34 | +import easybuild.tools.environment as env |
| 35 | +import easybuild.tools.systemtools as systemtools |
| 36 | +from easybuild.tools.toolchain.compiler import Compiler, DEFAULT_OPT_LEVEL |
| 37 | + |
| 38 | +TC_CONSTANT_FUJITSU = 'Fujitsu' |
| 39 | +TC_CONSTANT_MODULE_NAME = 'lang' |
| 40 | +TC_CONSTANT_MODULE_VAR = 'FJSVXTCLANGA' |
| 41 | + |
| 42 | + |
| 43 | +class FujitsuCompiler(Compiler): |
| 44 | + """Generic support for using Fujitsu compiler drivers.""" |
| 45 | + TOOLCHAIN_FAMILY = TC_CONSTANT_FUJITSU |
| 46 | + |
| 47 | + COMPILER_MODULE_NAME = [TC_CONSTANT_MODULE_NAME] |
| 48 | + COMPILER_FAMILY = TC_CONSTANT_FUJITSU |
| 49 | + |
| 50 | + # make sure fcc is always called in clang compatibility mode |
| 51 | + COMPILER_CC = 'fcc -Nclang' |
| 52 | + COMPILER_CXX = 'FCC -Nclang' |
| 53 | + |
| 54 | + COMPILER_F77 = 'frt' |
| 55 | + COMPILER_F90 = 'frt' |
| 56 | + COMPILER_FC = 'frt' |
| 57 | + |
| 58 | + COMPILER_UNIQUE_OPTION_MAP = { |
| 59 | + DEFAULT_OPT_LEVEL: 'O2', |
| 60 | + 'lowopt': 'O1', |
| 61 | + 'noopt': 'O0', |
| 62 | + 'opt': 'Kfast', # -O3 -Keval,fast_matmul,fp_contract,fp_relaxed,fz,ilfunc,mfunc,omitfp,simd_packed_promotion |
| 63 | + 'optarch': '', # Fujitsu compiler by default generates code for the arch it is running on |
| 64 | + 'openmp': 'Kopenmp', |
| 65 | + 'unroll': 'funroll-loops', |
| 66 | + # apparently the -Kfp_precision flag doesn't work in clang mode, will need to look into these later |
| 67 | + # also at strict vs precise and loose vs veryloose |
| 68 | + 'strict': ['Knoeval,nofast_matmul,nofp_contract,nofp_relaxed,noilfunc'], # ['Kfp_precision'], |
| 69 | + 'precise': ['Knoeval,nofast_matmul,nofp_contract,nofp_relaxed,noilfunc'], # ['Kfp_precision'], |
| 70 | + 'defaultprec': [], |
| 71 | + 'loose': ['Kfp_relaxed'], |
| 72 | + 'veryloose': ['Kfp_relaxed'], |
| 73 | + # apparently the -K[NO]SVE flags don't work in clang mode |
| 74 | + # SVE is enabled by default, -Knosimd seems to disable it |
| 75 | + 'vectorize': {False: 'Knosimd', True: ''}, |
| 76 | + } |
| 77 | + |
| 78 | + # used when 'optarch' toolchain option is enabled (and --optarch is not specified) |
| 79 | + COMPILER_OPTIMAL_ARCHITECTURE_OPTION = { |
| 80 | + # -march=archi[+features]. At least on Fugaku, these are set by default (-march=armv8.3-a+sve and -mcpu=a64fx) |
| 81 | + (systemtools.AARCH64, systemtools.ARM): '', |
| 82 | + } |
| 83 | + |
| 84 | + # used with --optarch=GENERIC |
| 85 | + COMPILER_GENERIC_OPTION = { |
| 86 | + (systemtools.AARCH64, systemtools.ARM): '-mcpu=generic -mtune=generic', |
| 87 | + } |
| 88 | + |
| 89 | + def prepare(self, *args, **kwargs): |
| 90 | + super(FujitsuCompiler, self).prepare(*args, **kwargs) |
| 91 | + |
| 92 | + # make sure the fujitsu module libraries are found (and added to rpath by wrapper) |
| 93 | + libdir = os.path.join(os.getenv(TC_CONSTANT_MODULE_VAR), 'lib64') |
| 94 | + self.log.debug("Adding %s to $LIBRARY_PATH" % libdir) |
| 95 | + env.setvar('LIBRARY_PATH', os.pathsep.join([os.getenv('LIBRARY_PATH'), libdir])) |
| 96 | + |
| 97 | + def _set_compiler_vars(self): |
| 98 | + super(FujitsuCompiler, self)._set_compiler_vars() |
| 99 | + |
| 100 | + # enable clang compatibility mode |
| 101 | + # moved to compiler constants to make sure it is always used |
| 102 | + # self.variables.nappend('CFLAGS', ['Nclang']) |
| 103 | + # self.variables.nappend('CXXFLAGS', ['Nclang']) |
0 commit comments