-
Notifications
You must be signed in to change notification settings - Fork 202
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
reset keep toolchain component class 'constants' every time #1294
Changes from 8 commits
02e85d9
f532b8d
2cee2ad
5c94dd1
8d1cdf4
391cc62
0671a43
d4c5fc6
77cf7f6
cf16ee2
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
@author: Stijn De Weirdt (Ghent University) | ||
@author: Kenneth Hoste (Ghent University) | ||
""" | ||
|
||
import copy | ||
from distutils.version import LooseVersion | ||
|
||
from easybuild.toolchains.compiler.inteliccifort import TC_CONSTANT_INTELCOMP | ||
|
@@ -69,11 +69,16 @@ class IntelMKL(LinAlg): | |
SCALAPACK_MODULE_NAME = ['imkl'] | ||
SCALAPACK_LIB = ["mkl_scalapack%(lp64_sc)s"] | ||
SCALAPACK_LIB_MT = ["mkl_scalapack%(lp64_sc)s"] | ||
SCALAPACK_LIB_MAP = {"lp64_sc":"_lp64"} | ||
SCALAPACK_LIB_MAP = {'lp64_sc': '_lp64'} | ||
SCALAPACK_REQUIRES = ['LIBBLACS', 'LIBBLAS'] | ||
SCALAPACK_LIB_GROUP = True | ||
SCALAPACK_LIB_STATIC = True | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Toolchain constructor.""" | ||
self.add_class_constants_to_restore(['BLAS_LIB_MAP', 'SCALAPACK_LIB', 'SCALAPACK_LIB_MT', 'SCALAPACK_LIB_MAP']) | ||
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. support this via the init kwargs. this just looks too weird. def __init__(self, *args, **kwargs):
csts = kwargs.setdefault('class_constants', [])
csts.extend(['BLAS_LIB_MAP', 'SCALAPACK_LIB', 'SCALAPACK_LIB_MT', 'SCALAPACK_LIB_MAP'])
super(IntelMKL, self).__init__(*args, **kwargs) |
||
super(IntelMKL, self).__init__(*args, **kwargs) | ||
|
||
def _set_blas_variables(self): | ||
"""Fix the map a bit""" | ||
interfacemap = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
@author: Stijn De Weirdt (Ghent University) | ||
@author: Kenneth Hoste (Ghent University) | ||
""" | ||
|
||
import copy | ||
import os | ||
from vsc.utils import fancylogger | ||
|
||
|
@@ -58,6 +58,10 @@ class Toolchain(object): | |
VERSION = None | ||
TOOLCHAIN_FAMILY = None | ||
|
||
# list of class 'constants' that should be restored for every new instance of this class | ||
CLASS_CONSTANTS_TO_RESTORE = None | ||
CLASS_CONSTANT_COPIES = {} | ||
|
||
# class method | ||
def _is_toolchain_for(cls, name): | ||
"""see if this class can provide support for toolchain named name""" | ||
|
@@ -95,6 +99,10 @@ def __init__(self, name=None, version=None, mns=None): | |
|
||
self.vars = None | ||
|
||
self.add_class_constants_to_restore([]) # make sure self.CLASS_CONSTANTS_TO_RESTORE is initialised | ||
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. this is a bit odd, no? why is the default not 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. Defining a class constant as a value of a mutable type is a problem, especially if you update it (see I need to make sure a new list gets created for every toolchain class ( That doesn't happen if you set it to 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. This was the reason the previous test by Jenkins failed btw (see last commit). 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. ofcourse. |
||
self._copy_class_constants() | ||
self._restore_class_constants() | ||
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. make a new method
because this looks so strange otherwise |
||
|
||
self.modules_tool = modules_tool() | ||
self.mns = mns | ||
self.mod_full_name = None | ||
|
@@ -108,6 +116,13 @@ def __init__(self, name=None, version=None, mns=None): | |
self.mod_short_name = self.mns.det_short_module_name(tc_dict) | ||
self.init_modpaths = self.mns.det_init_modulepaths(tc_dict) | ||
|
||
def add_class_constants_to_restore(self, names): | ||
"""Add given constants to list of class constants to restore with each new instance.""" | ||
if self.CLASS_CONSTANTS_TO_RESTORE is None: | ||
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. i don't understand the benefit of None. initial 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. no, it can't, that's what I had initially... we update 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. ok |
||
self.CLASS_CONSTANTS_TO_RESTORE = names[:] | ||
else: | ||
self.CLASS_CONSTANTS_TO_RESTORE.extend(names) | ||
|
||
def base_init(self): | ||
if not hasattr(self, 'log'): | ||
self.log = fancylogger.getLogger(self.__class__.__name__, fname=False) | ||
|
@@ -122,6 +137,32 @@ def base_init(self): | |
if hasattr(self, 'LINKER_TOGGLE_STATIC_DYNAMIC'): | ||
self.variables.LINKER_TOGGLE_STATIC_DYNAMIC = self.LINKER_TOGGLE_STATIC_DYNAMIC | ||
|
||
def _copy_class_constants(self): | ||
"""Copy class constants that needs to be restored again when a new instance is created.""" | ||
# this only needs to be done the first time (for this class, taking inheritance into account is key) | ||
key = self.__class__ | ||
if key not in self.CLASS_CONSTANT_COPIES: | ||
self.CLASS_CONSTANT_COPIES[key] = {} | ||
for cst in self.CLASS_CONSTANTS_TO_RESTORE: | ||
if hasattr(self, cst): | ||
self.CLASS_CONSTANT_COPIES[key][cst] = copy.deepcopy(getattr(self, cst)) | ||
else: | ||
raise EasyBuildError("Class constant '%s' to be restored does not exist in %s", cst, self) | ||
|
||
self.log.debug("Copied class constants: %s", self.CLASS_CONSTANT_COPIES[key]) | ||
|
||
def _restore_class_constants(self): | ||
"""Restored class constants that need to be restored when a new instance is created.""" | ||
key = self.__class__ | ||
for cst in self.CLASS_CONSTANT_COPIES[key]: | ||
newval = copy.deepcopy(self.CLASS_CONSTANT_COPIES[key][cst]) | ||
if hasattr(self, cst): | ||
self.log.debug("Restoring class constant '%s' to %s (was: %s)", cst, newval, getattr(self, cst)) | ||
else: | ||
self.log.debug("Restoring (currently undefined) class constant '%s' to %s", cst, newval) | ||
|
||
setattr(self, cst, newval) | ||
|
||
def get_variable(self, name, typ=str): | ||
"""Get value for specified variable. | ||
typ: indicates what type of return value is expected""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#%Module | ||
|
||
set root /tmp/icc/11.1.073 | ||
|
||
setenv EBROOTICC "$root" | ||
setenv EBVERSIONICC "11.1.073" | ||
setenv EBDEVELICC "$root/easybuild/icc-11.1.073-easybuild-devel" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#%Module | ||
|
||
proc ModulesHelp { } { | ||
puts stderr { Intel Cluster Toolkit Compiler Edition provides Intel C/C++ and Fortran compilers, Intel MPI & Intel MKL. - Homepage: http://software.intel.com/en-us/intel-cluster-toolkit-compiler/ | ||
} | ||
} | ||
|
||
module-whatis {Intel Cluster Toolkit Compiler Edition provides Intel C/C++ and Fortran compilers, Intel MPI & Intel MKL. - Homepage: http://software.intel.com/en-us/intel-cluster-toolkit-compiler/} | ||
|
||
set root /tmp/ictce/3.2.2.u3 | ||
|
||
conflict ictce | ||
|
||
if { ![is-loaded icc/11.1.073] } { | ||
module load icc/11.1.073 | ||
} | ||
|
||
if { ![is-loaded ifort/11.1.073] } { | ||
module load ifort/11.1.073 | ||
} | ||
|
||
if { ![is-loaded impi/4.0.0.028] } { | ||
module load impi/4.0.0.028 | ||
} | ||
|
||
if { ![is-loaded imkl/10.2.6.038] } { | ||
module load imkl/10.2.6.038 | ||
} | ||
|
||
|
||
setenv EBROOTICTCE "$root" | ||
setenv EBVERSIONICTCE "3.2.2.u3" | ||
setenv EBDEVELICTCE "$root/easybuild/ictce-3.2.2.u3-easybuild-devel" | ||
|
||
|
||
# built with EasyBuild version 1.9.0dev |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#%Module | ||
|
||
set root /tmp/ifort/11.1.073 | ||
|
||
setenv EBROOTIFORT "$root" | ||
setenv EBVERSIONIFORT "11.1.073" | ||
setenv EBDEVELIFORT "$root/easybuild/ifort-11.1.073-easybuild-devel" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#%Module | ||
|
||
set root /var/folders/8s/_frgh9sj6m744mxt5w5lyztr0000gn/T/eb-SGdeX9/tmptwWn9I | ||
|
||
setenv EBROOTIMKL "$root" | ||
setenv EBVERSIONIMKL "10.2.6.038" | ||
setenv EBDEVELIMKL "$root/easybuild/imkl-10.2.6.038-easybuild-devel" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#%Module | ||
|
||
set root /tmp/impi/4.0.0.028 | ||
|
||
setenv EBROOTIMPI "$root" | ||
setenv EBVERSIONIMPI "4.0.0.028" | ||
setenv EBDEVELIMPI "$root/easybuild/impi-4.0.0.028-easybuild-devel" |
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.
not needed?
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.
will remove, thx