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

Workaround for LMOD only allowing a single hook to be registered, which made our first hook unused #490

Merged
15 changes: 11 additions & 4 deletions create_lmodrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
return content
end

local function cuda_enabled_load_hook(t)
local function eessi_cuda_enabled_load_hook(t)
local frameStk = require("FrameStk"):singleton()
local mt = frameStk:mt()
local simpleName = string.match(t.modFullName, "(.-)/")
Expand Down Expand Up @@ -94,7 +94,7 @@
end
end

local function openmpi_load_hook(t)
local function eessi_openmpi_load_hook(t)
-- disable smcuda BTL when loading OpenMPI module for aarch64/neoverse_v1,
-- to work around hang/crash due to bug in OpenMPI;
-- see https://gitlab.com/eessi/support/-/issues/41
Expand All @@ -114,8 +114,15 @@
end
end

hook.register("load", cuda_enabled_load_hook)
hook.register("load", openmpi_load_hook)
-- Combine both functions into a single one, as we can only register one function as load hook in lmod
-- Also: make it non-local, so it can be imported and extended by other lmodrc files if needed
function eessi_load_hook(t)
eessi_cuda_enabled_load_hook(t)
eessi_openmpi_load_hook(t)
end


hook.register("load", eessi_load_hook)
"""

def error(msg):
Expand Down
14 changes: 10 additions & 4 deletions init/eessi_environment_variables
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ if [ -d $EESSI_PREFIX ]; then
false
fi

export LMOD_RC="$EESSI_SOFTWARE_PATH/.lmod/lmodrc.lua"
if [ -f $LMOD_RC ]; then
show_msg "Found Lmod configuration file at $LMOD_RC"
export LMOD_CONFIG_DIR="$EESSI_SOFTWARE_PATH/.lmod"
if [ -f $LMOD_CONFIG_DIR/lmodrc.lua ]; then
show_msg "Found Lmod configuration file at $LMOD_CONFIG_DIR/lmodrc.lua"
else
error "Lmod configuration file not found at $LMOD_RC"
error "Lmod configuration file not found at $LMOD_CONFIG_DIR/lmodrc.lua"
fi
# Allow for site-specific lmod configuration
host_lmod_rc="${EESSI_PREFIX/versions/host_injections}"/.lmod/lmodrc.lua
casparvl marked this conversation as resolved.
Show resolved Hide resolved
if [ -f $host_lmod_rc ]; then
show_msg "Found site Lmod configuration file at $LMOD_RC"
export LMOD_RC="$host_lmod_rc"
ocaisa marked this conversation as resolved.
Show resolved Hide resolved
fi

else
Expand Down