Skip to content

Commit 4a752a9

Browse files
authored
Merge pull request #3677 from migueldiascosta/fujitsu
add toolchain definition for Fujitsu ARM toolchain
2 parents e0bb957 + 63cea59 commit 4a752a9

File tree

8 files changed

+487
-6
lines changed

8 files changed

+487
-6
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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'])

easybuild/toolchains/fcc.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
##
2+
# Copyright 2012-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+
EasyBuild support for Fujitsu Compiler toolchain.
27+
28+
:author: Miguel Dias Costa (National University of Singapore)
29+
"""
30+
from easybuild.toolchains.compiler.fujitsu import FujitsuCompiler
31+
from easybuild.tools.toolchain.toolchain import SYSTEM_TOOLCHAIN_NAME
32+
33+
34+
class FCC(FujitsuCompiler):
35+
"""Compiler toolchain with Fujitsu Compiler."""
36+
NAME = 'FCC'
37+
SUBTOOLCHAIN = SYSTEM_TOOLCHAIN_NAME
38+
OPTIONAL = False
39+
40+
# override in order to add an exception for the Fujitsu lang/tcsds module
41+
def _add_dependency_variables(self, names=None, cpp=None, ld=None):
42+
""" Add LDFLAGS and CPPFLAGS to the self.variables based on the dependencies
43+
names should be a list of strings containing the name of the dependency
44+
"""
45+
cpp_paths = ['include']
46+
ld_paths = ['lib']
47+
if not self.options.get('32bit', None):
48+
ld_paths.insert(0, 'lib64')
49+
50+
if cpp is not None:
51+
for p in cpp:
52+
if p not in cpp_paths:
53+
cpp_paths.append(p)
54+
if ld is not None:
55+
for p in ld:
56+
if p not in ld_paths:
57+
ld_paths.append(p)
58+
59+
if not names:
60+
deps = self.dependencies
61+
else:
62+
deps = [{'name': name} for name in names if name is not None]
63+
64+
# collect software install prefixes for dependencies
65+
roots = []
66+
for dep in deps:
67+
if dep.get('external_module', False):
68+
# for software names provided via external modules, install prefix may be unknown
69+
names = dep['external_module_metadata'].get('name', [])
70+
roots.extend([root for root in self.get_software_root(names) if root is not None])
71+
else:
72+
roots.extend(self.get_software_root(dep['name']))
73+
74+
for root in roots:
75+
# skip Fujitsu's 'lang/tcsds' module, including the top level include breaks vectorization in clang mode
76+
if 'tcsds' not in root:
77+
self.variables.append_subdirs("CPPFLAGS", root, subdirs=cpp_paths)
78+
self.variables.append_subdirs("LDFLAGS", root, subdirs=ld_paths)

easybuild/toolchains/ffmpi.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
##
2+
# Copyright 2012-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+
EasyBuild support for ffmpi compiler toolchain (includes Fujitsu Compiler and MPI).
27+
28+
:author: Miguel Dias Costa (National University of Singapore)
29+
"""
30+
from easybuild.toolchains.fcc import FCC
31+
from easybuild.toolchains.mpi.fujitsumpi import FujitsuMPI
32+
33+
34+
class Ffmpi(FCC, FujitsuMPI):
35+
"""Compiler toolchain with Fujitsu Compiler and MPI."""
36+
NAME = 'ffmpi'
37+
SUBTOOLCHAIN = FCC.NAME
38+
COMPILER_MODULE_NAME = [FCC.NAME]

easybuild/toolchains/fft/fftw.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ class Fftw(Fft):
3939
"""FFTW FFT library"""
4040

4141
FFT_MODULE_NAME = ['FFTW']
42+
FFTW_API_VERSION = ''
4243

4344
def _set_fftw_variables(self):
4445

45-
suffix = ''
46-
version = self.get_software_version(self.FFT_MODULE_NAME)[0]
47-
if LooseVersion(version) < LooseVersion('2') or LooseVersion(version) >= LooseVersion('4'):
48-
raise EasyBuildError("_set_fft_variables: FFTW unsupported version %s (major should be 2 or 3)", version)
49-
elif LooseVersion(version) > LooseVersion('2'):
50-
suffix = '3'
46+
suffix = self.FFTW_API_VERSION
47+
if not suffix:
48+
version = self.get_software_version(self.FFT_MODULE_NAME)[0]
49+
if LooseVersion(version) < LooseVersion('2') or LooseVersion(version) >= LooseVersion('4'):
50+
raise EasyBuildError("_set_fft_variables: FFTW unsupported version %s (major should be 2 or 3)",
51+
version)
52+
elif LooseVersion(version) > LooseVersion('2'):
53+
suffix = '3'
5154

5255
# order matters!
5356
fftw_libs = ["fftw%s" % suffix]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
##
2+
# Copyright 2012-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 Fujitsu FFTW as toolchain FFT library.
27+
28+
:author: Miguel Dias Costa (National University of Singapore)
29+
"""
30+
from easybuild.toolchains.fft.fftw import Fftw
31+
32+
33+
class FujitsuFFTW(Fftw):
34+
"""Fujitsu FFTW FFT library"""
35+
36+
FFT_MODULE_NAME = ['FFTW3-sve']
37+
FFTW_API_VERSION = '3'

easybuild/toolchains/fujitsu.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
Fujitsu toolchain: Fujitsu compilers and MPI + Fujitsu SSL2 and Fujitsu FFTW
27+
28+
:author: Miguel Dias Costa (National University of Singapore)
29+
"""
30+
from easybuild.toolchains.ffmpi import Ffmpi
31+
from easybuild.toolchains.fft.fujitsufftw import FujitsuFFTW
32+
from easybuild.toolchains.linalg.fujitsussl import FujitsuSSL
33+
34+
35+
class Fujitsu(Ffmpi, FujitsuFFTW, FujitsuSSL):
36+
"""Compiler toolchain for Fujitsu."""
37+
NAME = 'Fujitsu'
38+
SUBTOOLCHAIN = Ffmpi.NAME
39+
COMPILER_MODULE_NAME = []

0 commit comments

Comments
 (0)