Skip to content

Commit

Permalink
add toolchain definition for fujitsu toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
migueldiascosta committed May 16, 2021
1 parent 89ff20d commit e8e0153
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 6 deletions.
80 changes: 80 additions & 0 deletions easybuild/toolchains/compiler/fujitsu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
##
# 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 the same as for the Cray Programming Environment.
:author: Miguel Dias Costa (National University of Singapore)
"""
import easybuild.tools.systemtools as systemtools
from easybuild.tools.toolchain.compiler import Compiler, DEFAULT_OPT_LEVEL

TC_CONSTANT_FUJITSU = 'Fujitsu'


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

# compiler module name is lang (with version e.g. tcsds-1.2.31)
COMPILER_MODULE_NAME = ['lang']
COMPILER_FAMILY = TC_CONSTANT_FUJITSU

COMPILER_CC = 'fcc'
COMPILER_CXX = 'FCC'
COMPILER_F77 = 'frt'
COMPILER_F90 = 'frt'
COMPILER_FC = 'frt'

COMPILER_UNIQUE_OPTION_MAP = {
DEFAULT_OPT_LEVEL: 'Kfast',
'optarch': '', # Fujitsu compiler by default generates code for the arch it is running on
'openmp': 'Kopenmp',
'unroll': 'funroll-loops',
'strict': ['Kfp_precision'],
'precise': ['Kfp_precision'],
'defaultprec': [],
'loose': ['Kfp_relaxed'],
'veryloose': ['Kfp_relaxed'],
'vectorize': {False: 'KNOSVE', True: 'KSVE'},
}

# 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 _set_compiler_vars(self):
super(FujitsuCompiler, self)._set_compiler_vars()

self.variables.nappend('CFLAGS', ['Nclang'])
self.variables.nappend('CXXFLAGS', ['Nclang'])
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 fompi compiler toolchain (includes Fujitsu Compiler and MPI).
:author: Miguel Dias Costa (National University of Singapore)
"""
from easybuild.toolchains.compiler.fujitsu import FujitsuCompiler
from easybuild.toolchains.linalg.fujitsussl import FujitsuSSL
from easybuild.toolchains.mpi.fujitsumpi import FujitsuMPI


class ffmpi(FujitsuCompiler, FujitsuMPI, FujitsuSSL):
"""Compiler toolchain with Fujitsu Compiler and MPI."""
NAME = 'ffmpi'
SUBTOOLCHAIN = FujitsuCompiler.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'
40 changes: 40 additions & 0 deletions easybuild/toolchains/fujitsu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
##
# 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.compiler.fujitsu import FujitsuCompiler
from easybuild.toolchains.linalg.fujitsussl import FujitsuSSL
from easybuild.toolchains.ffmpi import ffmpi
from easybuild.toolchains.fft.fujitsufftw import FujitsuFFTW
from easybuild.toolchains.mpi.fujitsumpi import FujitsuMPI


class Fujitsu(FujitsuCompiler, FujitsuMPI, FujitsuSSL, FujitsuFFTW):
"""Compiler toolchain for Fujitsu."""
NAME = 'Fujitsu'
SUBTOOLCHAIN = ffmpi.NAME
115 changes: 115 additions & 0 deletions easybuild/toolchains/linalg/fujitsussl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
##
# 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 Fujitsu's SSL library, which provides BLAS/LAPACK support.
:author: Miguel Dias Costa (National University of Singapore)
"""
import os


from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.toolchain.constants import COMPILER_FLAGS
from easybuild.tools.toolchain.linalg import LinAlg


FUJITSU_SSL_MODULE_NAME = None
TC_CONSTANT_FUJITSU_SSL = 'FujitsuSSL'


class FujitsuSSL(LinAlg):
"""Support for Fujitsu's SSL library, which provides BLAS/LAPACK support."""
# BLAS/LAPACK support
# via lang/tcsds module
BLAS_MODULE_NAME = ['lang']

# no need to specify libraries, compiler driver takes care of linking the right libraries
BLAS_LIB = ['']
BLAS_LIB_MT = ['']
BLAS_FAMILY = TC_CONSTANT_FUJITSU_SSL

LAPACK_MODULE_NAME = None
LAPACK_IS_BLAS = True
LAPACK_FAMILY = TC_CONSTANT_FUJITSU_SSL

BLACS_MODULE_NAME = None

SCALAPACK_MODULE_NAME = BLAS_MODULE_NAME
SCALAPACK_LIB = ['']
SCALAPACK_LIB_MT = ['']
SCALAPACK_FAMILY = TC_CONSTANT_FUJITSU_SSL

def _get_software_root(self, name):
"""Get install prefix for specified software name; special treatment for Fujitsu modules."""
if name == 'lang':
# Fujitsu-provided module
env_var = 'FJSVXTCLANGA'
root = os.getenv(env_var, None)
if root is None:
raise EasyBuildError("Failed to determine install prefix for %s via $%s", name, env_var)
else:
self.log.debug("Obtained install prefix for %s via $%s: %s", name, env_var, root)
else:
root = super(FujitsuSSL, self)._get_software_root(name)

return root

def _set_blas_variables(self):
"""Setting FujitsuSSL specific BLAS related variables"""
super(FujitsuSSL, self)._set_blas_variables()
if self.options.get('openmp', None):
for flags_var, _ in COMPILER_FLAGS:
self.variables.nappend(flags_var, ['SSL2BLAMP'])
else:
for flags_var, _ in COMPILER_FLAGS:
self.variables.nappend(flags_var, ['SSL2'])

def _set_scalapack_variables(self):
"""Setting FujitsuSSL specific SCALAPACK related variables"""
super(FujitsuSSL, self)._set_scalapack_variables()
for flags_var, _ in COMPILER_FLAGS:
self.variables.nappend(flags_var, ['SCALAPACK'])

def definition(self):
"""
Filter BLAS module from toolchain definition.
The SSL2 module is loaded indirectly (and versionless) via the lang module,
and thus is not a direct toolchain component.
"""
tc_def = super(FujitsuSSL, self).definition()
tc_def['BLAS'] = []
tc_def['LAPACK'] = []
tc_def['SCALAPACK'] = []
return tc_def

def set_variables(self):
"""Set the variables"""
self._set_blas_variables()
self._set_lapack_variables()
self._set_scalapack_variables()

self.log.devel('set_variables: LinAlg variables %s', self.variables)

super(FujitsuSSL, self).set_variables()
Loading

0 comments on commit e8e0153

Please sign in to comment.