Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to define the default compiler optimsation level #1565

Merged
merged 6 commits into from
Jan 23, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions easybuild/tools/config.py
Expand Up @@ -90,6 +90,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
BUILD_OPTIONS_CMDLINE = {
None: [
'aggregate_regtest',
'default_opt_level',
'download_timeout',
'dump_test_report',
'easyblock',
Expand Down
3 changes: 3 additions & 0 deletions easybuild/tools/options.py
Expand Up @@ -73,6 +73,7 @@
from easybuild.tools.ordereddict import OrderedDict
from easybuild.tools.run import run_cmd
from easybuild.tools.package.utilities import avail_package_naming_schemes
from easybuild.tools.toolchain.compiler import Compiler
from easybuild.tools.toolchain.utilities import search_toolchain
from easybuild.tools.repository.repository import avail_repositories
from easybuild.tools.version import this_is_easybuild
Expand Down Expand Up @@ -213,6 +214,8 @@ def override_options(self):
'cleanup-builddir': ("Cleanup build dir after successful installation.", None, 'store_true', True),
'cleanup-tmpdir': ("Cleanup tmp dir after successful run.", None, 'store_true', True),
'color': ("Allow color output", None, 'store_true', True),
'default-opt-level': ("Specify default optimisation level", 'choice', 'store', 'defaultopt',
Compiler.COMPILER_OPT_FLAGS),
'deprecated': ("Run pretending to be (future) version, to test removal of deprecated code.",
None, 'store', None),
'download-timeout': ("Timeout for initiating downloads (in seconds)", float, 'store', None),
Expand Down
12 changes: 10 additions & 2 deletions easybuild/tools/toolchain/compiler.py
Expand Up @@ -35,7 +35,7 @@
from easybuild.tools.toolchain.toolchain import Toolchain


# 'GENERIC' can beused to enable generic compilation instead of optimized compilation (which is the default)
# 'GENERIC' can be used to enable generic compilation instead of optimized compilation (which is the default)
# by doing eb --optarch=GENERIC
OPTARCH_GENERIC = 'GENERIC'

Expand Down Expand Up @@ -231,9 +231,17 @@ def _set_compiler_flags(self):
fflags = [self.options.option(x) for x in self.COMPILER_F_FLAGS + self.COMPILER_F_UNIQUE_FLAGS \
if self.options.get(x, False)]

# Allow a user-defined default optimisation
default_opt_level = build_option('default_opt_level')
if default_opt_level in self.COMPILER_OPT_FLAGS:
default_opt = default_opt_level
else:
raise EasyBuildError("Unknown value for default optimisation: %s (possibilities are %s)" %
(default_opt_level, self.COMPILER_OPT_FLAGS))
Copy link
Member

Choose a reason for hiding this comment

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

how about

default_opt_level = build_option('default_opt_level')
if default_opt_level not in self.COMPILER_OPT_FLAGS:
    raise ...

and then also use default_opt_level below


Copy link
Member Author

Choose a reason for hiding this comment

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

Invalid option already picked up by the option parser...could remove the if/else?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, leave it there, it's pretty cheap, and we may change things later such that default_opt_level comes from somewhere else

# 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('defaultopt')]
[self.options.option(default_opt)]

optarchflags = []
if build_option('optarch') == OPTARCH_GENERIC:
Expand Down