-
Notifications
You must be signed in to change notification settings - Fork 197
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
Changes from all commits
835ada3
41b94eb
2fdfb26
4d0f36a
110dc8d
f66f193
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,10 @@ | |
from easybuild.tools.toolchain.constants import COMPILER_VARIABLES | ||
from easybuild.tools.toolchain.toolchain import Toolchain | ||
|
||
# default optimization 'level' (see COMPILER_SHARED_OPTION_MAP/COMPILER_OPT_FLAGS) | ||
DEFAULT_OPT_LEVEL = 'defaultopt' | ||
|
||
# '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' | ||
|
||
|
@@ -63,7 +65,7 @@ class Compiler(Toolchain): | |
'pic': (False, "Use PIC"), # also FFTW | ||
'noopt': (False, "Disable compiler optimizations"), | ||
'lowopt': (False, "Low compiler optimizations"), | ||
'defaultopt': (False, "Default compiler optimizations"), # not set, but default | ||
DEFAULT_OPT_LEVEL: (False, "Default compiler optimizations"), # not set, but default | ||
'opt': (False, "High compiler optimizations"), | ||
'optarch': (True, "Enable architecture optimizations"), | ||
'strict': (False, "Strict (highest) precision"), | ||
|
@@ -94,7 +96,7 @@ class Compiler(Toolchain): | |
'shared': 'shared', | ||
'noopt': 'O0', | ||
'lowopt': 'O1', | ||
'defaultopt': 'O2', | ||
DEFAULT_OPT_LEVEL: 'O2', | ||
'opt': 'O3', | ||
'32bit' : 'm32', | ||
'cstd': 'std=%(value)s', | ||
|
@@ -104,7 +106,7 @@ class Compiler(Toolchain): | |
COMPILER_GENERIC_OPTION = None | ||
|
||
COMPILER_FLAGS = ['debug', 'verbose', 'static', 'shared', 'openmp', 'pic', 'unroll'] # any compiler | ||
COMPILER_OPT_FLAGS = ['noopt', 'lowopt', 'defaultopt', 'opt'] # optimisation args, ordered ! | ||
COMPILER_OPT_FLAGS = ['noopt', 'lowopt', DEFAULT_OPT_LEVEL, 'opt'] # optimisation args, ordered ! | ||
COMPILER_PREC_FLAGS = ['strict', 'precise', 'defaultprec', 'loose', 'veryloose'] # precision flags, ordered ! | ||
|
||
COMPILER_CC = None | ||
|
@@ -231,9 +233,15 @@ 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 not in self.COMPILER_OPT_FLAGS: | ||
raise EasyBuildError("Unknown value for default optimisation: %s (possibilities are %s)" % | ||
(default_opt_level, self.COMPILER_OPT_FLAGS)) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
# 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_level)] | ||
|
||
optarchflags = [] | ||
if build_option('optarch') == OPTARCH_GENERIC: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about
and then also use
default_opt_level
below