Skip to content

Commit

Permalink
Merge pull request #1 from boegel/optarch_cmdline
Browse files Browse the repository at this point in the history
fix minor remarks w.r.t. style & code organization
  • Loading branch information
georg-rath committed Jul 3, 2014
2 parents bc1881c + b4d7a0b commit 4ede63e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ def override_options(self):
'skip-test-cases': ("Skip running test cases", None, 'store_true', False, 't'),
'umask': ("umask to use (e.g. '022'); non-user write permissions on install directories are removed",
None, 'store', None),
'optarch': ("Set architecture optimization, overriding native architecture optimizations", None, 'store', None),
})
'optarch': ("Set architecture optimization, overriding native architecture optimizations",
None, 'store', None),
})

self.log.debug("override_options: descr %s opts %s" % (descr, opts))
self.add_group_parser(opts, descr)
Expand Down
12 changes: 7 additions & 5 deletions easybuild/tools/toolchain/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,13 @@ def _get_optimal_architecture(self):
if self.arch is None:
self.arch = systemtools.get_cpu_vendor()

if self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION is not None and self.arch in self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION:
if build_option('optarch') is not None:
optarch = build_option('optarch')
else:
optarch = self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[self.arch]
optarch = None
if build_option('optarch') is not None:
optarch = build_option('optarch')
elif self.arch in (self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION or []):
optarch = self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[self.arch]

if optarch is not None:
self.log.info("_get_optimal_architecture: using %s as optarch for %s." % (optarch, self.arch))
self.options.options_map['optarch'] = optarch

Expand Down
9 changes: 4 additions & 5 deletions test/framework/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,16 @@ def test_override_optarch(self):
"""Test whether overriding the optarch flag works."""
tc_class, _ = search_toolchain("goalf")
flag_vars = ['CFLAGS', 'CXXFLAGS', 'FFLAGS', 'F90FLAGS']
build_options = { }
for optarch_var in [ 'march=lovelylovelysandybridge', None ]:
build_options.update({'optarch': optarch_var})
for optarch_var in ['march=lovelylovelysandybridge', None]:
build_options = {'optarch': optarch_var}
init_config(build_options=build_options)
for enable in [True, False]:
tc = tc_class(version="1.1.0-no-OFED")
tc.set_options({'optarch': enable})
tc.prepare()
flag = None
if optarch_var is not None:
flag = '-march=lovelylovelysandybridge'
flag = '-%s' % optarch_var
else:
flag = '-march=native'

Expand All @@ -314,7 +313,7 @@ def test_override_optarch(self):
if enable:
self.assertTrue(flag in flags, "optarch: True means %s in %s" % (flag, flags))
else:
self.assertTrue(flag not in flags, "optarch: False means no %s in %s" % (flag, flags))
self.assertFalse(flag in flags, "optarch: False means no %s in %s" % (flag, flags))

def test_misc_flags_unique_fortran(self):
"""Test whether unique Fortran compiler flags are set correctly."""
Expand Down

0 comments on commit 4ede63e

Please sign in to comment.