Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:hpcugent/easybuild-framework int…
Browse files Browse the repository at this point in the history
…o gcc_tree_vectorize
  • Loading branch information
bartoldeman committed Feb 1, 2018
2 parents 9c8098c + 44577b6 commit 347e78e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
31 changes: 16 additions & 15 deletions easybuild/tools/toolchain/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,28 +280,29 @@ def _set_optimal_architecture(self, default_optarch=None):
:param default_optarch: default value to use for optarch, rather than using default value based on architecture
(--optarch and --optarch=GENERIC still override this value)
"""
use_generic = False
optarch = build_option('optarch')
# --optarch is specified with flags to use
if optarch is not None and isinstance(optarch, dict):
# optarch has been validated as complex string with multiple compilers and converted to a dictionary
# first try module names, then the family in optarch
current_compiler_names = (getattr(self, 'COMPILER_MODULE_NAME', []) +
[getattr(self, 'COMPILER_FAMILY', None)])
for current_compiler in current_compiler_names:
if current_compiler in optarch:
optarch = optarch[current_compiler]
break
# still a dict: no option for this compiler
if isinstance(optarch, dict):
optarch = None
self.log.info("_set_optimal_architecture: no optarch found for compiler %s. Ignoring option.",
current_compiler)

use_generic = False
if optarch is not None:
# optarch has been parsed as a simple string
if isinstance(optarch, basestring):
if optarch == OPTARCH_GENERIC:
use_generic = True

# optarch has been validated as complex string with multiple compilers and converted to a dictionary
elif isinstance(optarch, dict):
current_compiler = getattr(self, 'COMPILER_FAMILY', None)
if current_compiler in optarch:
if optarch[current_compiler] == OPTARCH_GENERIC:
use_generic = True
else:
optarch = optarch[current_compiler]
# no option for this compiler
else:
optarch = None
self.log.info("_set_optimal_architecture: no optarch found for compiler %s. Ignoring option.",
current_compiler)
else:
raise EasyBuildError("optarch is neither an string or a dict %s. This should never happen", optarch)

Expand Down
14 changes: 10 additions & 4 deletions test/framework/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,18 @@ 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'), ('GENERIC', 'march=x86-64 -mtune=generic'), ('', '')]
toolchains = [('iccifort', '2011.13.367'), ('GCC', '4.7.2'), ('PGI', '16.7-GCC-5.4.0-2.26')]
gcc_options = [('gccflag', 'gccflag'), ('-ftree-vectorize', '-ftree-vectorize'), ('', '')]
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]

test_cases = product(intel_options, gcc_options, toolchains, enabled)
test_cases = product(intel_options, gcc_options, gcccore_options, toolchains, enabled)

for (intel_flags, intel_flags_exp), (gcc_flags, gcc_flags_exp), (toolchain, toolchain_ver), enable in test_cases:
for (intel_flags, intel_flags_exp), (gcc_flags, gcc_flags_exp), (gcccore_flags, gcccore_flags_exp), (toolchain, toolchain_ver), enable in test_cases:
optarch_var = {}
optarch_var['Intel'] = intel_flags
optarch_var['GCC'] = gcc_flags
optarch_var['GCCcore'] = gcccore_flags
build_options = {'optarch': optarch_var}
init_config(build_options=build_options)
tc = self.get_toolchain(toolchain, version=toolchain_ver)
Expand All @@ -407,6 +409,8 @@ def test_compiler_dependent_optarch(self):
flags = intel_flags_exp
elif toolchain == 'GCC':
flags = gcc_flags_exp
elif toolchain == 'GCCcore':
flags = gcccore_flags_exp
else: # PGI as an example of compiler not set
# default optarch flag, should be the same as the one in
# tc.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[(tc.arch,tc.cpu_family)]
Expand All @@ -423,6 +427,8 @@ def test_compiler_dependent_optarch(self):
intel_options[1][1],
gcc_options[0][1],
gcc_options[1][1],
gcccore_options[0][1],
gcccore_options[1][1],
'xHost', # default optimal for Intel
'march=native', # default optimal for GCC
]
Expand Down

0 comments on commit 347e78e

Please sign in to comment.