From 385622953dc3ddf733ff577f0ef00044c55bf72c Mon Sep 17 00:00:00 2001 From: Mario Melara Date: Fri, 23 Mar 2018 14:53:52 -0700 Subject: 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. --- lib/spack/spack/platforms/cray.py | 10 +++++++++- lib/spack/spack/util/module_cmd.py | 12 ++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py index e6e9685f74..dee98c0629 100644 --- a/lib/spack/spack/platforms/cray.py +++ b/lib/spack/spack/platforms/cray.py @@ -31,7 +31,7 @@ from spack.architecture import Platform, Target, NoPlatformError from spack.operating_systems.cray_frontend import CrayFrontend from spack.operating_systems.cnl import Cnl 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): @@ -103,11 +103,19 @@ class Cray(Platform): """ Change the linker to default dynamic to be more 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') cray_wrapper_names = join_path(build_env_path, 'cray') + if os.path.isdir(cray_wrapper_names): env.prepend_path('PATH', cray_wrapper_names) env.prepend_path('SPACK_ENV_PATH', cray_wrapper_names) + # Makes spack installed pkg-config work on Crays env.append_path("PKG_CONFIG_PATH", "/usr/lib64/pkgconfig") env.append_path("PKG_CONFIG_PATH", "/usr/local/lib64/pkgconfig") diff --git a/lib/spack/spack/util/module_cmd.py b/lib/spack/spack/util/module_cmd.py index e5dc0f84a6..1419ec4455 100644 --- a/lib/spack/spack/util/module_cmd.py +++ b/lib/spack/spack/util/module_cmd.py @@ -115,6 +115,14 @@ def get_module_cmd_from_bash(bashopts=''): 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), '', + 'exec')) + + def load_module(mod): """Takes a module name and removes modules until it is possible to 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() for i, word in enumerate(text): if word == 'conflict': - exec(compile(modulecmd('unload', text[i + 1], output=str, - error=str), '', 'exec')) + unload_module(text[i + 1]) + # Load the module now that there are no conflicts # Some module systems use stdout and some use stderr load = modulecmd('load', mod, output=str, error='/dev/null') -- cgit v1.2.3-60-g2f50