Skip to content

Commit

Permalink
Add accelerator detection to Lmod version of EESSI initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
ocaisa committed Oct 11, 2024
1 parent 80ce564 commit 887bc8a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
2 changes: 2 additions & 0 deletions init/lmod_eessi_archdetect_wrapper_accel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This can be leveraged by the source_sh() feature of Lmod
export EESSI_ACCEL_SUBDIR=$($(dirname $(readlink -f $BASH_SOURCE))/eessi_archdetect.sh accelpath)
35 changes: 32 additions & 3 deletions init/modules/EESSI/2023.06.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,27 @@ function archdetect_cpu()
end
LmodError("Software directory check for the detected architecture failed")
end
function archdetect_accel()
local script = pathJoin(eessi_prefix, 'init', 'lmod_eessi_archdetect_wrapper_accel.sh')
if not os.getenv("EESSI_ACCEL_SUBDIR") then
if convertToCanonical(LmodVersion()) < convertToCanonical("8.6") then
LmodError("Loading this modulefile requires using Lmod version >= 8.6, but you can export EESSI_ACCEL_SUBDIR to the available accelerator architecture in the form of: accel/nvidia/cc80")
end
source_sh("bash", script)
end
local archdetect_accel = os.getenv("EESSI_ACCEL_SUBDIR") or ""
return archdetect_accel
end
local archdetect = archdetect_cpu()
local archdetect_accel = archdetect_accel()
local eessi_cpu_family = archdetect:match("([^/]+)")
local eessi_software_subdir = archdetect
local eessi_eprefix = pathJoin(eessi_prefix, "compat", eessi_os_type, eessi_cpu_family)
local eessi_software_path = pathJoin(eessi_prefix, "software", eessi_os_type, eessi_software_subdir)
local eessi_module_path = pathJoin(eessi_software_path, "modules", "all")
local eessi_modules_subdir = pathJoin("modules", "all")
local eessi_module_path = pathJoin(eessi_software_path, eessi_modules_subdir)
local eessi_site_software_path = string.gsub(eessi_software_path, "versions", "host_injections")
local eessi_site_module_path = pathJoin(eessi_site_software_path, "modules", "all")
local eessi_site_module_path = pathJoin(eessi_site_software_path, eessi_modules_subdir)
setenv("EPREFIX", eessi_eprefix)
setenv("EESSI_CPU_FAMILY", eessi_cpu_family)
setenv("EESSI_SITE_SOFTWARE_PATH", eessi_site_software_path)
Expand All @@ -65,8 +78,24 @@ if ( mode() ~= "spider" ) then
prepend_path("MODULEPATH", eessi_module_path)
end
prepend_path("LMOD_RC", pathJoin(eessi_software_path, "/.lmod/lmodrc.lua"))
prepend_path("MODULEPATH", eessi_site_module_path)
setenv("LMOD_PACKAGE_PATH", pathJoin(eessi_software_path, ".lmod"))

-- the accelerator may have an empty value and we need to give some flexibility
-- * construct the path we expect to find
-- * then check it exists
-- * then update the modulepath
if not (archdetect_accel == nil or archdetect_accel == '') then
eessi_accel_software_subdir = os.getenv("EESSI_ACCEL_SOFTWARE_SUBDIR_OVERRIDE") or eessi_software_subdir
eessi_accel_software_path = pathJoin(eessi_prefix, "software", eessi_os_type, eessi_accel_software_subdir)
eessi_module_path_accel = pathJoin(eessi_accel_software_path, eessi_accel_software_subdir, eessi_modules_subdir)
if isDir(eessi_modulepath_accel) then
setenv("EESSI_MODULEPATH_ACCEL", eessi_module_path_accel)
prepend_path("MODULEPATH", eessi_module_path_accel)
end
end

-- prepend the site module path last so it has priority
prepend_path("MODULEPATH", eessi_site_module_path)
if mode() == "load" then
LmodMessage("EESSI/" .. eessi_version .. " loaded successfully")
end

0 comments on commit 887bc8a

Please sign in to comment.