Add support for IBM threaded compilers: xl*_r (#2894)

* Add support for IBM threaded compilers, xl*_r

Added new compiler class, xl_r; added default flags to the compilers.yaml file.

* Add cppflags to the set of default flags to be added to the compilers stanza in compiler.yaml.

These flags are optional. Only defined flags will be listed in the compilers.yaml file.

* Fix scripting warnings revealed by flake8.

Updated __init__.py and xl_r.py to conform with flake8 rules.

* Add justification to the definition of the XL default compiler flags.
This commit is contained in:
serbanmaerean 2017-01-25 18:26:17 -05:00 committed by Todd Gamblin
parent fc866ae0fe
commit 5e2a96574b
8 changed files with 158 additions and 9 deletions

8
lib/spack/env/cc vendored
View file

@ -98,25 +98,25 @@ case "$command" in
cpp)
mode=cpp
;;
cc|c89|c99|gcc|clang|icc|pgcc|xlc)
cc|c89|c99|gcc|clang|icc|pgcc|xlc|xlc_r)
command="$SPACK_CC"
language="C"
comp="CC"
lang_flags=C
;;
c++|CC|g++|clang++|icpc|pgc++|xlc++)
c++|CC|g++|clang++|icpc|pgc++|xlc++|xlc++_r)
command="$SPACK_CXX"
language="C++"
comp="CXX"
lang_flags=CXX
;;
ftn|f90|fc|f95|gfortran|ifort|pgfortran|xlf90|nagfor)
ftn|f90|fc|f95|gfortran|ifort|pgfortran|xlf90|xlf90_r|nagfor)
command="$SPACK_FC"
language="Fortran 90"
comp="FC"
lang_flags=F
;;
f77|gfortran|ifort|pgfortran|xlf|nagfor|ftn)
f77|gfortran|ifort|pgfortran|xlf|xlf_r|nagfor|ftn)
command="$SPACK_F77"
language="Fortran 77"
comp="F77"

1
lib/spack/env/xl_r/xlc++_r vendored Symbolic link
View file

@ -0,0 +1 @@
../cc

1
lib/spack/env/xl_r/xlc_r vendored Symbolic link
View file

@ -0,0 +1 @@
../cc

1
lib/spack/env/xl_r/xlf90_r vendored Symbolic link
View file

@ -0,0 +1 @@
../cc

1
lib/spack/env/xl_r/xlf_r vendored Symbolic link
View file

@ -0,0 +1 @@
../cc

View file

@ -40,6 +40,7 @@
_imported_compilers_module = 'spack.compilers'
_path_instance_vars = ['cc', 'cxx', 'f77', 'fc']
_flags_instance_vars = ['cflags', 'cppflags', 'cxxflags', 'fflags']
_other_instance_vars = ['modules', 'operating_system', 'environment',
'extra_rpaths']
_cache_config_file = []
@ -60,6 +61,9 @@ def _to_dict(compiler):
d['paths'] = dict((attr, getattr(compiler, attr, None))
for attr in _path_instance_vars)
d['flags'] = dict((fname, fvals) for fname, fvals in compiler.flags)
d['flags'].update(dict((attr, getattr(compiler, attr, None))
for attr in _flags_instance_vars
if hasattr(compiler, attr)))
d['operating_system'] = str(compiler.operating_system)
d['target'] = str(compiler.target)
d['modules'] = compiler.modules if compiler.modules else []

View file

@ -29,17 +29,16 @@
class Xl(Compiler):
# Subclasses use possible names of C compiler
cc_names = ['xlc', 'xlc_r']
cc_names = ['xlc']
# Subclasses use possible names of C++ compiler
cxx_names = ['xlC', 'xlC_r', 'xlc++', 'xlc++_r']
cxx_names = ['xlC', 'xlc++']
# Subclasses use possible names of Fortran 77 compiler
f77_names = ['xlf', 'xlf_r']
f77_names = ['xlf']
# Subclasses use possible names of Fortran 90 compiler
fc_names = ['xlf90', 'xlf90_r', 'xlf95', 'xlf95_r',
'xlf2003', 'xlf2003_r', 'xlf2008', 'xlf2008_r']
fc_names = ['xlf90', 'xlf95', 'xlf2003', 'xlf2008']
# Named wrapper links within spack.build_env_path
link_paths = {'cc': 'xl/xlc',
@ -62,6 +61,20 @@ def cxx11_flag(self):
def pic_flag(self):
return "-qpic"
@property
def fflags(self):
# The -qzerosize flag is effective only for the Fortran 77
# compilers and allows the use of zero size objects.
# For Fortran 90 and beyond, it is set by default and has not impact.
# Its use has no negative side effects.
# The -qstrict flag allows the Fortran 90+ compilers to parse the
# source files using fixed form rule. As a result, if -qfixed is in
# effect, free form files (that are not also fixed form files) will
# fail to compile regardless of the compiler invocation command.
# Use the -qfree flag in the packages' configuration file to undo the
# -qfixed flag, as the last one wins.
return "-qzerosize -qfixed"
@classmethod
def default_version(cls, comp):
"""The '-qversion' is the standard option fo XL compilers.

View file

@ -0,0 +1,128 @@
##############################################################################
# Copyright (c) 2016, International Business Machines Corporation
#
# This file is part of Spack.
# Created by Serban Maerean, serban@us.ibm.com based on a similar file,
# spack/lib/spack/spack/compilers/xl.py, produced by Todd Gamblin,
# tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/llnl/spack
# Please also see the LICENSE file for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, February 1999.
#
# This program 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 terms and
# conditions of the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack.compiler import *
import llnl.util.tty as tty
from spack.version import ver
class XlR(Compiler):
# Subclasses use possible names of C compiler
cc_names = ['xlc_r']
# Subclasses use possible names of C++ compiler
cxx_names = ['xlC_r', 'xlc++_r']
# Subclasses use possible names of Fortran 77 compiler
f77_names = ['xlf_r']
# Subclasses use possible names of Fortran 90 compiler
fc_names = ['xlf90_r', 'xlf95_r', 'xlf2003_r', 'xlf2008_r']
# Named wrapper links within spack.build_env_path
link_paths = {'cc': 'xl_r/xlc_r',
'cxx': 'xl_r/xlc++_r',
'f77': 'xl_r/xlf_r',
'fc': 'xl_r/xlf90_r'}
@property
def openmp_flag(self):
return "-qsmp=omp"
@property
def cxx11_flag(self):
if self.version < ver('13.1'):
tty.die("Only xlC 13.1 and above have some c++11 support.")
else:
return "-qlanglvl=extended0x"
@property
def pic_flag(self):
return("-qpic")
@property
def fflags(self):
# The -qzerosize flag is effective only for the Fortran 77
# compilers and allows the use of zero size objects.
# For Fortran 90 and beyond, it is set by default and has not impact.
# Its use has no negative side effects.
# The -qstrict flag allows the Fortran 90+ compilers to parse the
# source files using fixed form rule. As a result, if -qfixed is in
# effect, free form files (that are not also fixed form files) will
# fail to compile regardless of the compiler invocation command.
# Use the -qfree flag in the packages' configuration file to undo the
# -qfixed flag, as the last one wins.
return "-qzerosize -qfixed"
@classmethod
def default_version(self, comp):
"""The '-qversion' is the standard option fo XL compilers.
Output looks like this::
IBM XL C/C++ for Linux, V11.1 (5724-X14)
Version: 11.01.0000.0000
or::
IBM XL Fortran for Linux, V13.1 (5724-X16)
Version: 13.01.0000.0000
or::
IBM XL C/C++ for AIX, V11.1 (5724-X13)
Version: 11.01.0000.0009
or::
IBM XL C/C++ Advanced Edition for Blue Gene/P, V9.0
Version: 09.00.0000.0017
"""
return get_compiler_version(
comp, '-qversion', r'([0-9]?[0-9]\.[0-9])')
@classmethod
def fc_version(cls, fc):
"""The fortran and C/C++ versions of the XL compiler are always
two units apart. By this we mean that the fortran release that
goes with XL C/C++ 11.1 is 13.1. Having such a difference in
version number is confusing spack quite a lot. Most notably
if you keep the versions as is the default xl compiler will
only have fortran and no C/C++. So we associate the Fortran
compiler with the version associated to the C/C++ compiler.
One last stumble. Version numbers over 10 have at least a .1
those under 10 a .0. There is no xlf 9.x or under currently
available. BG/P and BG/L can such a compiler mix and possibly
older version of AIX and linux on power.
"""
fver = get_compiler_version(fc, '-qversion', r'([0-9]?[0-9]\.[0-9])')
cver = float(fver) - 2
if cver < 10:
cver = cver - 0.1
return str(cver)
@classmethod
def f77_version(cls, f77):
return cls.fc_version(f77)