Skip to content

add toolchain definition for Fujitsu ARM toolchain #3677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 25, 2021
103 changes: 103 additions & 0 deletions easybuild/toolchains/compiler/fujitsu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
##
# Copyright 2014-2021 Ghent University
#
# 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),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# 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 the Fujitsu compiler drivers (aka fcc, frt).

The basic concept is the same as for the Cray Programming Environment.

:author: Miguel Dias Costa (National University of Singapore)
"""
import os

import easybuild.tools.environment as env
import easybuild.tools.systemtools as systemtools
from easybuild.tools.toolchain.compiler import Compiler, DEFAULT_OPT_LEVEL

TC_CONSTANT_FUJITSU = 'Fujitsu'
TC_CONSTANT_MODULE_NAME = 'lang'
TC_CONSTANT_MODULE_VAR = 'FJSVXTCLANGA'


class FujitsuCompiler(Compiler):
"""Generic support for using Fujitsu compiler drivers."""
TOOLCHAIN_FAMILY = TC_CONSTANT_FUJITSU

COMPILER_MODULE_NAME = [TC_CONSTANT_MODULE_NAME]
COMPILER_FAMILY = TC_CONSTANT_FUJITSU

# make sure fcc is always called in clang compatibility mode
COMPILER_CC = 'fcc -Nclang'
COMPILER_CXX = 'FCC -Nclang'

COMPILER_F77 = 'frt'
COMPILER_F90 = 'frt'
COMPILER_FC = 'frt'

COMPILER_UNIQUE_OPTION_MAP = {
DEFAULT_OPT_LEVEL: 'O2',
'lowopt': 'O1',
'noopt': 'O0',
'opt': 'Kfast', # -O3 -Keval,fast_matmul,fp_contract,fp_relaxed,fz,ilfunc,mfunc,omitfp,simd_packed_promotion
'optarch': '', # Fujitsu compiler by default generates code for the arch it is running on
'openmp': 'Kopenmp',
'unroll': 'funroll-loops',
# apparently the -Kfp_precision flag doesn't work in clang mode, will need to look into these later
# also at strict vs precise and loose vs veryloose
'strict': ['Knoeval,nofast_matmul,nofp_contract,nofp_relaxed,noilfunc'], # ['Kfp_precision'],
'precise': ['Knoeval,nofast_matmul,nofp_contract,nofp_relaxed,noilfunc'], # ['Kfp_precision'],
'defaultprec': [],
'loose': ['Kfp_relaxed'],
'veryloose': ['Kfp_relaxed'],
# apparently the -K[NO]SVE flags don't work in clang mode
# SVE is enabled by default, -Knosimd seems to disable it
'vectorize': {False: 'Knosimd', True: ''},
}

# used when 'optarch' toolchain option is enabled (and --optarch is not specified)
COMPILER_OPTIMAL_ARCHITECTURE_OPTION = {
# -march=archi[+features]. At least on Fugaku, these are set by default (-march=armv8.3-a+sve and -mcpu=a64fx)
(systemtools.AARCH64, systemtools.ARM): '',
}

# used with --optarch=GENERIC
COMPILER_GENERIC_OPTION = {
(systemtools.AARCH64, systemtools.ARM): '-mcpu=generic -mtune=generic',
}

def prepare(self, *args, **kwargs):
super(FujitsuCompiler, self).prepare(*args, **kwargs)

# make sure the fujitsu module libraries are found (and added to rpath by wrapper)
libdir = os.path.join(os.getenv(TC_CONSTANT_MODULE_VAR), 'lib64')
self.log.debug("Adding %s to $LIBRARY_PATH" % libdir)
env.setvar('LIBRARY_PATH', os.pathsep.join([os.getenv('LIBRARY_PATH'), libdir]))

def _set_compiler_vars(self):
super(FujitsuCompiler, self)._set_compiler_vars()

# enable clang compatibility mode
# moved to compiler constants to make sure it is always used
# self.variables.nappend('CFLAGS', ['Nclang'])
# self.variables.nappend('CXXFLAGS', ['Nclang'])
78 changes: 78 additions & 0 deletions easybuild/toolchains/fcc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
##
# Copyright 2012-2021 Ghent University
#
# 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),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# 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 Fujitsu Compiler toolchain.

:author: Miguel Dias Costa (National University of Singapore)
"""
from easybuild.toolchains.compiler.fujitsu import FujitsuCompiler
from easybuild.tools.toolchain.toolchain import SYSTEM_TOOLCHAIN_NAME


class FCC(FujitsuCompiler):
"""Compiler toolchain with Fujitsu Compiler."""
NAME = 'FCC'
SUBTOOLCHAIN = SYSTEM_TOOLCHAIN_NAME
OPTIONAL = False

# override in order to add an exception for the Fujitsu lang/tcsds module
def _add_dependency_variables(self, names=None, cpp=None, ld=None):
""" Add LDFLAGS and CPPFLAGS to the self.variables based on the dependencies
names should be a list of strings containing the name of the dependency
"""
cpp_paths = ['include']
ld_paths = ['lib']
if not self.options.get('32bit', None):
ld_paths.insert(0, 'lib64')

if cpp is not None:
for p in cpp:
if p not in cpp_paths:
cpp_paths.append(p)
if ld is not None:
for p in ld:
if p not in ld_paths:
ld_paths.append(p)

if not names:
deps = self.dependencies
else:
deps = [{'name': name} for name in names if name is not None]

# collect software install prefixes for dependencies
roots = []
for dep in deps:
if dep.get('external_module', False):
# for software names provided via external modules, install prefix may be unknown
names = dep['external_module_metadata'].get('name', [])
roots.extend([root for root in self.get_software_root(names) if root is not None])
else:
roots.extend(self.get_software_root(dep['name']))

for root in roots:
# skip Fujitsu's 'lang/tcsds' module, including the top level include breaks vectorization in clang mode
if 'tcsds' not in root:
self.variables.append_subdirs("CPPFLAGS", root, subdirs=cpp_paths)
self.variables.append_subdirs("LDFLAGS", root, subdirs=ld_paths)
38 changes: 38 additions & 0 deletions easybuild/toolchains/ffmpi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
##
# Copyright 2012-2021 Ghent University
#
# 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),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# 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 ffmpi compiler toolchain (includes Fujitsu Compiler and MPI).

:author: Miguel Dias Costa (National University of Singapore)
"""
from easybuild.toolchains.fcc import FCC
from easybuild.toolchains.mpi.fujitsumpi import FujitsuMPI


class Ffmpi(FCC, FujitsuMPI):
"""Compiler toolchain with Fujitsu Compiler and MPI."""
NAME = 'ffmpi'
SUBTOOLCHAIN = FCC.NAME
COMPILER_MODULE_NAME = [FCC.NAME]
15 changes: 9 additions & 6 deletions easybuild/toolchains/fft/fftw.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ class Fftw(Fft):
"""FFTW FFT library"""

FFT_MODULE_NAME = ['FFTW']
FFTW_API_VERSION = ''

def _set_fftw_variables(self):

suffix = ''
version = self.get_software_version(self.FFT_MODULE_NAME)[0]
if LooseVersion(version) < LooseVersion('2') or LooseVersion(version) >= LooseVersion('4'):
raise EasyBuildError("_set_fft_variables: FFTW unsupported version %s (major should be 2 or 3)", version)
elif LooseVersion(version) > LooseVersion('2'):
suffix = '3'
suffix = self.FFTW_API_VERSION
if not suffix:
version = self.get_software_version(self.FFT_MODULE_NAME)[0]
if LooseVersion(version) < LooseVersion('2') or LooseVersion(version) >= LooseVersion('4'):
raise EasyBuildError("_set_fft_variables: FFTW unsupported version %s (major should be 2 or 3)",
version)
elif LooseVersion(version) > LooseVersion('2'):
suffix = '3'

# order matters!
fftw_libs = ["fftw%s" % suffix]
Expand Down
37 changes: 37 additions & 0 deletions easybuild/toolchains/fft/fujitsufftw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##
# Copyright 2012-2021 Ghent University
#
# 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),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# 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 Fujitsu FFTW as toolchain FFT library.

:author: Miguel Dias Costa (National University of Singapore)
"""
from easybuild.toolchains.fft.fftw import Fftw


class FujitsuFFTW(Fftw):
"""Fujitsu FFTW FFT library"""

FFT_MODULE_NAME = ['FFTW3-sve']
FFTW_API_VERSION = '3'
39 changes: 39 additions & 0 deletions easybuild/toolchains/fujitsu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
##
# Copyright 2014-2021 Ghent University
#
# 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),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# 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/>.
##
"""
Fujitsu toolchain: Fujitsu compilers and MPI + Fujitsu SSL2 and Fujitsu FFTW

:author: Miguel Dias Costa (National University of Singapore)
"""
from easybuild.toolchains.ffmpi import Ffmpi
from easybuild.toolchains.fft.fujitsufftw import FujitsuFFTW
from easybuild.toolchains.linalg.fujitsussl import FujitsuSSL


class Fujitsu(Ffmpi, FujitsuFFTW, FujitsuSSL):
"""Compiler toolchain for Fujitsu."""
NAME = 'Fujitsu'
SUBTOOLCHAIN = Ffmpi.NAME
COMPILER_MODULE_NAME = []
Loading