Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions easybuild/toolchains/compiler/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class Clang(Compiler):
'defaultprec': [],
'loose': ['ffast-math', 'fno-unsafe-math-optimizations'],
'veryloose': ['ffast-math'],
'vectorize': 'fvectorize',
'novectorize': 'fno-vectorize',
}

# used when 'optarch' toolchain option is enabled (and --optarch is not specified)
Expand Down
13 changes: 8 additions & 5 deletions easybuild/toolchains/compiler/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import easybuild.tools.systemtools as systemtools
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.modules import get_software_root, get_software_version
from easybuild.tools.toolchain.compiler import Compiler
from easybuild.tools.toolchain.compiler import Compiler, DEFAULT_OPT_LEVEL


TC_CONSTANT_GCC = "GCC"
Expand All @@ -61,10 +61,13 @@ class Gcc(Compiler):
'lto': 'flto',
'ieee': ['mieee-fp', 'fno-trapping-math'],
'strict': ['mieee-fp', 'mno-recip'],
'precise':['mno-recip'],
'defaultprec':[],
'loose': ['mrecip', 'mno-ieee-fp'],
'veryloose': ['mrecip=all', 'mno-ieee-fp'],
'precise': ['mno-recip'],
'defaultprec': ['fno-math-errno'],
'loose': ['fno-math-errno', 'mrecip', 'mno-ieee-fp'],
'veryloose': ['fno-math-errno', 'mrecip=all', 'mno-ieee-fp'],
'vectorize': 'ftree-vectorize',
'novectorize': 'fno-tree-vectorize',
DEFAULT_OPT_LEVEL: ['O2', 'ftree-vectorize'],
}

# used when 'optarch' toolchain option is enabled (and --optarch is not specified)
Expand Down
5 changes: 4 additions & 1 deletion easybuild/toolchains/compiler/ibmxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from distutils.version import LooseVersion

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


TC_CONSTANT_IBMCOMP = "IBMXL"
Expand All @@ -35,6 +35,9 @@ class IBMXL(Compiler):
'defaultprec': ['', '', ''],
'loose': [''],
'veryloose': [''],
'vectorize': 'qsimd=auto',
'novectorize': 'qsimd=noauto',
DEFAULT_OPT_LEVEL: ['O2', 'qsimd=auto'],
'ibm-static': 'qstaticlink=xllibs',
'pic': 'qpic',
'shared': 'qmkshrobj',
Expand Down
2 changes: 2 additions & 0 deletions easybuild/toolchains/compiler/inteliccifort.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class IntelIccIfort(Compiler):
'defaultprec': ['ftz', 'fp-speculation=safe', 'fp-model source'],
'loose': ['fp-model fast=1'],
'veryloose': ['fp-model fast=2'],
'vectorize': 'vec',
'novectorize': 'no-vec',
'intel-static': 'static-intel',
'no-icc': 'no-icc',
'error-unknown-option': 'we10006', # error at warning #10006: ignoring unknown option
Expand Down
2 changes: 2 additions & 0 deletions easybuild/toolchains/compiler/pgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Pgi(Compiler):
'defaultprec': ['Mflushz'],
'loose': ['Mfprelaxed'],
'veryloose': ['Mfprelaxed=div,order,intrinsic,recip,sqrt,rsqrt', 'Mfpapprox'],
'vectorize': 'Mvect',
'novectorize': 'Mnovect',
}

# used when 'optarch' toolchain option is enabled (and --optarch is not specified)
Expand Down
22 changes: 20 additions & 2 deletions easybuild/tools/toolchain/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class Compiler(Toolchain):
'static': (False, "Build static library"),
'32bit': (False, "Compile 32bit target"), # LA, FFTW
'openmp': (False, "Enable OpenMP"),
'vectorize': (None, "Enable compiler auto-vectorization, default except for noopt and lowopt"),
'novectorize': (None, "Disable compiler auto-vectorization, default for noopt and lowopt"), # not set, only used to map
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartoldeman Why do we need both? Can't we detect True or False (vs None) for vectorize instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is in the mappings in gcc.py etc. I cannot map 'vectorize' to '-ftree-vectorize' for True and to '-fno-tree-vectorize' for False, unless those mappings get redesigned of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I could use ['fno-tree-vectorize','ftree-vectorize'] with a bit of code to select first or second. It's just inconsistent with the current use. Maybe use a dict to distinguish:
{False: 'fno-tree-vectorize', True: 'ftree-vectorize'}

'packed-linker-options': (False, "Pack the linker options as comma separated list"), # ScaLAPACK mainly
'rpath': (True, "Use RPATH wrappers when --rpath is enabled in EasyBuild configuration"),
}
Expand Down Expand Up @@ -246,7 +248,23 @@ def _set_compiler_flags(self):

# 1st one is the one to use. add default at the end so len is at least 1
optflags = [self.options.option(x) for x in self.COMPILER_OPT_FLAGS if self.options.get(x, False)] + \
[self.options.option(default_opt_level)]
[self.options.option(default_opt_level)][:1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartoldeman To be correct, this should be this I think...

optflags = ([...] + [...])[:1]


# only apply if the vectorize toolchainopt is explicitly set
# otherwise the individual compiler toolchain file should make sure that
# vectorization is disabled for noopt and lowopt, and enabled otherwise.
if self.options.get('vectorize') is not None:
novectorize = self.options.option('novectorize')
vectorize = self.options.option('vectorize')
if self.options['vectorize']:
vectflags = vectorize
else:
vectflags = novectorize
# avoid double use of such flags
if isinstance(optflags[0], list):
optflags[0] = [setting for setting in optflags[0]
if setting not in (novectorize, vectorize)]
optflags.append(vectflags)

optarchflags = []
if build_option('optarch') == OPTARCH_GENERIC:
Expand All @@ -259,7 +277,7 @@ def _set_compiler_flags(self):
precflags = [self.options.option(x) for x in self.COMPILER_PREC_FLAGS if self.options.get(x, False)] + \
[self.options.option('defaultprec')]

self.variables.nextend('OPTFLAGS', optflags[:1] + optarchflags)
self.variables.nextend('OPTFLAGS', optflags + optarchflags)
self.variables.nextend('PRECFLAGS', precflags[:1])

# precflags last
Expand Down
2 changes: 1 addition & 1 deletion test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2961,7 +2961,7 @@ def test_dump_env_config(self):
"module load hwloc/1.6.2-GCC-4.7.2", # loading of dependency module
# defining build env
"export FC='gfortran'",
"export CFLAGS='-O2 -march=native'",
"export CFLAGS='-O2 -ftree-vectorize -march=native -fno-math-errno'",
]
for pattern in patterns:
regex = re.compile("^%s$" % pattern, re.M)
Expand Down
28 changes: 15 additions & 13 deletions test/framework/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def test_misc_flags_shared(self):
# we need to make sure we check for flags, not letter (e.g. 'v' vs '-v')
flag = '-%s' % tc.COMPILER_SHARED_OPTION_MAP[opt]
for var in flag_vars:
flags = tc.get_variable(var)
flags = tc.get_variable(var).split()
if enable:
self.assertTrue(flag in flags, "%s: True means %s in %s" % (opt, flag, flags))
else:
Expand All @@ -290,7 +290,7 @@ def test_misc_flags_unique(self):
flag_vars = ['CFLAGS', 'CXXFLAGS', 'FCFLAGS', 'FFLAGS', 'F90FLAGS']

# setting option should result in corresponding flag to be set (unique options)
for opt in ['unroll', 'optarch', 'openmp']:
for opt in ['unroll', 'optarch', 'openmp', 'vectorize']:
for enable in [True, False]:
tc = self.get_toolchain("goalf", version="1.1.0-no-OFED")
tc.set_options({opt: enable})
Expand Down Expand Up @@ -387,7 +387,7 @@ def test_compiler_dependent_optarch(self):
"""Test whether specifying optarch on a per compiler basis works."""
flag_vars = ['CFLAGS', 'CXXFLAGS', 'FCFLAGS', 'FFLAGS', 'F90FLAGS']
intel_options = [('intelflag', 'intelflag'), ('GENERIC', 'xSSE2'), ('', '')]
gcc_options = [('gccflag', 'gccflag'), ('-ftree-vectorize', '-ftree-vectorize'), ('', '')]
gcc_options = [('gccflag', 'gccflag'), ('march=nocona', 'march=nocona'), ('', '')]
gcccore_options = [('gcccoreflag', 'gcccoreflag'), ('GENERIC', 'march=x86-64 -mtune=generic'), ('', '')]
toolchains = [('iccifort', '2011.13.367'), ('GCC', '4.7.2'), ('GCCcore', '6.2.0'), ('PGI', '16.7-GCC-5.4.0-2.26')]
enabled = [True, False]
Expand Down Expand Up @@ -476,20 +476,20 @@ def test_precision_flags(self):

flag_vars = ['CFLAGS', 'CXXFLAGS', 'FCFLAGS', 'FFLAGS', 'F90FLAGS']

# check default precision: no specific flag for GCC
# check default precision: -fno-math-errno flag for GCC
tc = self.get_toolchain("goalf", version="1.1.0-no-OFED")
tc.set_options({})
tc.prepare()
for var in flag_vars:
self.assertEqual(os.getenv(var), "-O2 -march=native")
self.assertEqual(os.getenv(var), "-O2 -ftree-vectorize -march=native -fno-math-errno")

# check other precision flags
prec_flags = {
'ieee': "-mieee-fp -fno-trapping-math",
'ieee': "-fno-math-errno -mieee-fp -fno-trapping-math",
'strict': "-mieee-fp -mno-recip",
'precise': "-mno-recip",
'loose': "-mrecip -mno-ieee-fp",
'veryloose': "-mrecip=all -mno-ieee-fp",
'loose': "-fno-math-errno -mrecip -mno-ieee-fp",
'veryloose': "-fno-math-errno -mrecip=all -mno-ieee-fp",
}
for prec in prec_flags:
for enable in [True, False]:
Expand All @@ -498,9 +498,9 @@ def test_precision_flags(self):
tc.prepare()
for var in flag_vars:
if enable:
self.assertEqual(os.getenv(var), "-O2 -march=native %s" % prec_flags[prec])
self.assertEqual(os.getenv(var), "-O2 -ftree-vectorize -march=native %s" % prec_flags[prec])
else:
self.assertEqual(os.getenv(var), "-O2 -march=native")
self.assertEqual(os.getenv(var), "-O2 -ftree-vectorize -march=native -fno-math-errno")
self.modtool.purge()

def test_cgoolf_toolchain(self):
Expand Down Expand Up @@ -579,8 +579,10 @@ def test_goolfc(self):
tc.set_options(opts)
tc.prepare()

archflags = tc.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[(tc.arch, tc.cpu_family)]
optflags = "-O2 -ftree-vectorize -%s -fno-math-errno -fopenmp" % archflags
nvcc_flags = r' '.join([
r'-Xcompiler="-O2 -%s -fopenmp"' % tc.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[(tc.arch, tc.cpu_family)],
r'-Xcompiler="%s"' % optflags,
# the use of -lcudart in -Xlinker is a bit silly but hard to avoid
r'-Xlinker=".* -lm -lrt -lcudart -lpthread"',
r' '.join(["-gencode %s" % x for x in opts['cuda_gencode']]),
Expand Down Expand Up @@ -903,9 +905,9 @@ def test_independence(self):

tc_cflags = {
'CrayCCE': "-O2 -homp -craype-verbose",
'CrayGNU': "-O2 -fopenmp -craype-verbose",
'CrayGNU': "-O2 -fno-math-errno -fopenmp -craype-verbose",
'CrayIntel': "-O2 -ftz -fp-speculation=safe -fp-model source -fopenmp -craype-verbose",
'GCC': "-O2 -test -fopenmp",
'GCC': "-O2 -ftree-vectorize -test -fno-math-errno -fopenmp",
'iccifort': "-O2 -test -ftz -fp-speculation=safe -fp-model source -fopenmp",
}

Expand Down