Cray clean environment (#7582)

* Create unload_module method

Extract code from load_module into unload_module.

* Unload modules to create a clean env on Cray

removes cray-libsci, cray-mpich and darshan to prevent any silent
linking with those packages.
This commit is contained in:
Mario Melara 2018-03-23 14:53:52 -07:00 committed by becker33
parent 666e8e3a9b
commit 385622953d
2 changed files with 19 additions and 3 deletions

View File

@ -31,7 +31,7 @@
from spack.operating_systems.cray_frontend import CrayFrontend from spack.operating_systems.cray_frontend import CrayFrontend
from spack.operating_systems.cnl import Cnl from spack.operating_systems.cnl import Cnl
from llnl.util.filesystem import join_path from llnl.util.filesystem import join_path
from spack.util.module_cmd import get_module_cmd from spack.util.module_cmd import get_module_cmd, unload_module
def _get_modules_in_modulecmd_output(output): def _get_modules_in_modulecmd_output(output):
@ -103,11 +103,19 @@ def setup_platform_environment(cls, pkg, env):
""" Change the linker to default dynamic to be more """ Change the linker to default dynamic to be more
similar to linux/standard linker behavior similar to linux/standard linker behavior
""" """
# Unload these modules to prevent any silent linking or unnecessary
# I/O profiling in the case of darshan.
modules_to_unload = ["cray-mpich", "darshan", "cray-libsci"]
for module in modules_to_unload:
unload_module(module)
env.set('CRAYPE_LINK_TYPE', 'dynamic') env.set('CRAYPE_LINK_TYPE', 'dynamic')
cray_wrapper_names = join_path(build_env_path, 'cray') cray_wrapper_names = join_path(build_env_path, 'cray')
if os.path.isdir(cray_wrapper_names): if os.path.isdir(cray_wrapper_names):
env.prepend_path('PATH', cray_wrapper_names) env.prepend_path('PATH', cray_wrapper_names)
env.prepend_path('SPACK_ENV_PATH', cray_wrapper_names) env.prepend_path('SPACK_ENV_PATH', cray_wrapper_names)
# Makes spack installed pkg-config work on Crays # Makes spack installed pkg-config work on Crays
env.append_path("PKG_CONFIG_PATH", "/usr/lib64/pkgconfig") env.append_path("PKG_CONFIG_PATH", "/usr/lib64/pkgconfig")
env.append_path("PKG_CONFIG_PATH", "/usr/local/lib64/pkgconfig") env.append_path("PKG_CONFIG_PATH", "/usr/local/lib64/pkgconfig")

View File

@ -115,6 +115,14 @@ def get_module_cmd_from_bash(bashopts=''):
return module_cmd return module_cmd
def unload_module(mod):
"""Takes a module name and unloads the module from the environment. It does
not check whether conflicts arise from the unloaded module"""
modulecmd = get_module_cmd()
exec(compile(modulecmd('unload', mod, output=str, error=str), '<string>',
'exec'))
def load_module(mod): def load_module(mod):
"""Takes a module name and removes modules until it is possible to """Takes a module name and removes modules until it is possible to
load that module. It then loads the provided module. Depends on the load that module. It then loads the provided module. Depends on the
@ -130,8 +138,8 @@ def load_module(mod):
text = modulecmd('show', mod, output=str, error=str).split() text = modulecmd('show', mod, output=str, error=str).split()
for i, word in enumerate(text): for i, word in enumerate(text):
if word == 'conflict': if word == 'conflict':
exec(compile(modulecmd('unload', text[i + 1], output=str, unload_module(text[i + 1])
error=str), '<string>', 'exec'))
# Load the module now that there are no conflicts # Load the module now that there are no conflicts
# Some module systems use stdout and some use stderr # Some module systems use stdout and some use stderr
load = modulecmd('load', mod, output=str, error='/dev/null') load = modulecmd('load', mod, output=str, error='/dev/null')