@@ -17,56 +17,141 @@ local eessi_os_type = "linux"
17
17
setenv (" EESSI_VERSION" , eessi_version )
18
18
setenv (" EESSI_CVMFS_REPO" , eessi_repo )
19
19
setenv (" EESSI_OS_TYPE" , eessi_os_type )
20
+ function eessiDebug (text )
21
+ if (mode () == " load" and os.getenv (" EESSI_DEBUG_INIT" )) then
22
+ LmodMessage (text )
23
+ end
24
+ end
20
25
function archdetect_cpu ()
21
26
local script = pathJoin (eessi_prefix , ' init' , ' lmod_eessi_archdetect_wrapper.sh' )
22
- if not os.getenv (" EESSI_ARCHDETECT_OPTIONS" ) then
27
+ -- make sure that we grab the value for architecture before the module unsets the environment variable (in unload mode)
28
+ local archdetect_options = os.getenv (" EESSI_ARCHDETECT_OPTIONS" ) or (os.getenv (" EESSI_ARCHDETECT_OPTIONS_OVERRIDE" ) or " " )
29
+ if not os.getenv (" EESSI_ARCHDETECT_OPTIONS_OVERRIDE" ) then
23
30
if convertToCanonical (LmodVersion ()) < convertToCanonical (" 8.6" ) then
24
- LmodError (" Loading this modulefile requires using Lmod version >= 8.6, but you can export EESSI_ARCHDETECT_OPTIONS to the available cpu architecture in the form of: x86_64/intel/haswell:x86_64/generic or aarch64/neoverse_v1:aarch64/generic" )
31
+ LmodError (" Loading this modulefile requires using Lmod version >= 8.6, but you can export EESSI_ARCHDETECT_OPTIONS_OVERRIDE to the available cpu architecture in the form of: x86_64/intel/haswell:x86_64/generic or aarch64/neoverse_v1:aarch64/generic" )
25
32
end
26
33
source_sh (" bash" , script )
27
34
end
28
- local archdetect_options = os.getenv (" EESSI_ARCHDETECT_OPTIONS" ) or " "
29
- for archdetect_filter_cpu in string.gmatch (archdetect_options , " ([^" .. " :" .. " ]+)" ) do
30
- if isDir (pathJoin (eessi_prefix , " software" , eessi_os_type , archdetect_filter_cpu , " software" )) then
31
- -- use x86_64/amd/zen3 for now when AMD Genoa (Zen4) CPU is detected,
32
- -- since optimized software installations for Zen4 are a work-in-progress,
33
- -- see https://gitlab.com/eessi/support/-/issues/37
34
- if archdetect_filter_cpu == " x86_64/amd/zen4" then
35
- archdetect_filter_cpu = " x86_64/amd/zen3"
36
- if mode () == " load" then
37
- LmodMessage (" Sticking to " .. archdetect_filter_cpu .. " for now, since optimized installations for AMD Genoa (Zen4) are a work in progress." )
35
+ -- EESSI_ARCHDETECT_OPTIONS is set by the script (_if_ it was called)
36
+ archdetect_options = os.getenv (" EESSI_ARCHDETECT_OPTIONS" ) or archdetect_options
37
+ if archdetect_options then
38
+ eessiDebug (" Got archdetect CPU options: " .. archdetect_options )
39
+ -- archdetect_options is a colon-separated list of CPU architectures that are compatible with
40
+ -- the host CPU and ordered from most specific to least specific, e.g.,
41
+ -- x86_64/intel/skylake_avx512:x86_64/intel/haswell:x86_64/generic
42
+ -- We loop over the list, and return the highest matching arch for which a directory exists for this EESSI version
43
+ for archdetect_filter_cpu in string.gmatch (archdetect_options , " ([^" .. " :" .. " ]+)" ) do
44
+ if isDir (pathJoin (eessi_prefix , " software" , eessi_os_type , archdetect_filter_cpu , " software" )) then
45
+ -- use x86_64/amd/zen3 for now when AMD Genoa (Zen4) CPU is detected,
46
+ -- since optimized software installations for Zen4 are a work-in-progress,
47
+ -- see https://gitlab.com/eessi/support/-/issues/37
48
+ if (archdetect_filter_cpu == " x86_64/amd/zen4" and not os.getenv (" EESSI_SOFTWARE_SUBDIR_OVERRIDE" ) == " x86_64/amd/zen4" ) then
49
+ archdetect_filter_cpu = " x86_64/amd/zen3"
50
+ if mode () == " load" then
51
+ LmodMessage (" Sticking to " .. archdetect_filter_cpu .. " for now, since optimized installations for AMD Genoa (Zen4) are a work in progress." )
52
+ end
38
53
end
54
+ eessiDebug (" Selected archdetect CPU: " .. archdetect_filter_cpu )
55
+ return archdetect_filter_cpu
39
56
end
40
- return archdetect_filter_cpu
41
57
end
58
+ LmodError (" Software directory check for the detected architecture failed" )
59
+ else
60
+ -- Still need to return something
61
+ return nil
42
62
end
43
- LmodError (" Software directory check for the detected architecture failed" )
44
63
end
64
+ function archdetect_accel ()
65
+ local script = pathJoin (eessi_prefix , ' init' , ' lmod_eessi_archdetect_wrapper_accel.sh' )
66
+ -- for unload mode, we need to grab the value before it is unset
67
+ local archdetect_accel = os.getenv (" EESSI_ACCEL_SUBDIR" ) or (os.getenv (" EESSI_ACCELERATOR_TARGET_OVERRIDE" ) or " " )
68
+ if not os.getenv (" EESSI_ACCELERATOR_TARGET_OVERRIDE " ) then
69
+ if convertToCanonical (LmodVersion ()) < convertToCanonical (" 8.6" ) then
70
+ LmodError (" Loading this modulefile requires using Lmod version >= 8.6, but you can export EESSI_ACCELERATOR_TARGET_OVERRIDE to the available accelerator architecture in the form of: accel/nvidia/cc80" )
71
+ end
72
+ source_sh (" bash" , script )
73
+ end
74
+ archdetect_accel = os.getenv (" EESSI_ACCEL_SUBDIR" ) or archdetect_accel
75
+ eessiDebug (" Got archdetect accel option: " .. archdetect_accel )
76
+ return archdetect_accel
77
+ end
78
+ -- archdetect finds the best compatible architecture, e.g., x86_64/amd/zen3
45
79
local archdetect = archdetect_cpu ()
80
+ -- archdetect_accel() attempts to identify an accelerator, e.g., accel/nvidia/cc80
81
+ local archdetect_accel = archdetect_accel ()
82
+ -- eessi_cpu_family is derived from the archdetect match, e.g., x86_64
46
83
local eessi_cpu_family = archdetect :match (" ([^/]+)" )
47
84
local eessi_software_subdir = archdetect
85
+ -- eessi_eprefix is the base location of the compat layer, e.g., /cvmfs/software.eessi.io/versions/2023.06/compat/linux/x86_64
48
86
local eessi_eprefix = pathJoin (eessi_prefix , " compat" , eessi_os_type , eessi_cpu_family )
87
+ -- eessi_software_path is the location of the software installations, e.g.,
88
+ -- /cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/amd/zen3
49
89
local eessi_software_path = pathJoin (eessi_prefix , " software" , eessi_os_type , eessi_software_subdir )
50
- local eessi_module_path = pathJoin (eessi_software_path , " modules" , " all" )
90
+ local eessi_modules_subdir = pathJoin (" modules" , " all" )
91
+ -- eessi_module_path is the location of the _CPU_ module files, e.g.,
92
+ -- /cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/amd/zen3/modules/all
93
+ local eessi_module_path = pathJoin (eessi_software_path , eessi_modules_subdir )
51
94
local eessi_site_software_path = string.gsub (eessi_software_path , " versions" , " host_injections" )
52
- local eessi_site_module_path = pathJoin (eessi_site_software_path , " modules" , " all" )
95
+ -- Site module path is the same as the EESSI one, but with `versions` changed to `host_injections`, e.g.,
96
+ -- /cvmfs/software.eessi.io/host_injections/2023.06/software/linux/x86_64/amd/zen3/modules/all
97
+ local eessi_site_module_path = pathJoin (eessi_site_software_path , eessi_modules_subdir )
53
98
setenv (" EPREFIX" , eessi_eprefix )
99
+ eessiDebug (" Setting EPREFIX to " .. eessi_eprefix )
54
100
setenv (" EESSI_CPU_FAMILY" , eessi_cpu_family )
101
+ eessiDebug (" Setting EESSI_CPU_FAMILY to " .. eessi_cpu_family )
55
102
setenv (" EESSI_SITE_SOFTWARE_PATH" , eessi_site_software_path )
103
+ eessiDebug (" Setting EESSI_SITE_SOFTWARE_PATH to " .. eessi_site_software_path )
56
104
setenv (" EESSI_SITE_MODULEPATH" , eessi_site_module_path )
105
+ eessiDebug (" Setting EESSI_SITE_MODULEPATH to " .. eessi_site_module_path )
57
106
setenv (" EESSI_SOFTWARE_SUBDIR" , eessi_software_subdir )
107
+ eessiDebug (" Setting EESSI_SOFTWARE_SUBDIR to " .. eessi_software_subdir )
58
108
setenv (" EESSI_PREFIX" , eessi_prefix )
109
+ eessiDebug (" Setting EESSI_PREFIX to " .. eessi_prefix )
59
110
setenv (" EESSI_EPREFIX" , eessi_eprefix )
111
+ eessiDebug (" Setting EPREFIX to " .. eessi_eprefix )
60
112
prepend_path (" PATH" , pathJoin (eessi_eprefix , " bin" ))
61
- prepend_path (" PATH" , pathJoin (eessi_eprefix , " usr/bin" ))
113
+ eessiDebug (" Adding " .. pathJoin (eessi_eprefix , " bin" ) .. " to PATH" )
114
+ prepend_path (" PATH" , pathJoin (eessi_eprefix , " usr" , " bin" ))
115
+ eessiDebug (" Adding " .. pathJoin (eessi_eprefix , " usr" , " bin" ) .. " to PATH" )
62
116
setenv (" EESSI_SOFTWARE_PATH" , eessi_software_path )
117
+ eessiDebug (" Setting EESSI_SOFTWARE_PATH to " .. eessi_software_path )
63
118
setenv (" EESSI_MODULEPATH" , eessi_module_path )
119
+ eessiDebug (" Setting EESSI_MODULEPATH to " .. eessi_module_path )
120
+ -- We ship our spider cache, so this location does not need to be spider-ed
64
121
if ( mode () ~= " spider" ) then
65
122
prepend_path (" MODULEPATH" , eessi_module_path )
123
+ eessiDebug (" Adding " .. eessi_module_path .. " to MODULEPATH" )
66
124
end
67
- prepend_path (" LMOD_RC" , pathJoin (eessi_software_path , " /.lmod/lmodrc.lua" ))
125
+ prepend_path (" LMOD_RC" , pathJoin (eessi_software_path , " .lmod" , " lmodrc.lua" ))
126
+ eessiDebug (" Adding " .. pathJoin (eessi_software_path , " .lmod" , " lmodrc.lua" ) .. " to LMOD_RC" )
127
+ -- Use pushenv for LMOD_PACKAGE_PATH as this may be set locally by the site
128
+ pushenv (" LMOD_PACKAGE_PATH" , pathJoin (eessi_software_path , " .lmod" ))
129
+ eessiDebug (" Setting LMOD_PACKAGE_PATH to " .. pathJoin (eessi_software_path , " .lmod" ))
130
+
131
+ -- the accelerator may have an empty value and we need to give some flexibility
132
+ -- * construct the path we expect to find
133
+ -- * then check it exists
134
+ -- * then update the modulepath
135
+ if not (archdetect_accel == nil or archdetect_accel == ' ' ) then
136
+ -- The CPU subdirectory of the accelerator installations is _usually_ the same as host CPU, but this can be overridden
137
+ eessi_accel_software_subdir = os.getenv (" EESSI_ACCEL_SOFTWARE_SUBDIR_OVERRIDE" ) or eessi_software_subdir
138
+ -- CPU location of the accelerator installations, e.g.,
139
+ -- /cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/amd/zen3
140
+ eessi_accel_software_path = pathJoin (eessi_prefix , " software" , eessi_os_type , eessi_accel_software_subdir )
141
+ -- location of the accelerator modules, e.g.,
142
+ -- /cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/amd/zen3/accel/nvidia/cc80/modules/all
143
+ eessi_module_path_accel = pathJoin (eessi_accel_software_path , archdetect_accel , eessi_modules_subdir )
144
+ eessiDebug (" Checking if " .. eessi_module_path_accel .. " exists" )
145
+ if isDir (eessi_module_path_accel ) then
146
+ setenv (" EESSI_MODULEPATH_ACCEL" , eessi_module_path_accel )
147
+ prepend_path (" MODULEPATH" , eessi_module_path_accel )
148
+ eessiDebug (" Using acclerator modules at: " .. eessi_module_path_accel )
149
+ end
150
+ end
151
+
152
+ -- prepend the site module path last so it has priority
68
153
prepend_path (" MODULEPATH" , eessi_site_module_path )
69
- setenv ( " LMOD_PACKAGE_PATH " , pathJoin ( eessi_software_path , " .lmod " ) )
154
+ eessiDebug ( " Adding " .. eessi_site_module_path .. " to MODULEPATH " )
70
155
if mode () == " load" then
71
156
LmodMessage (" EESSI/" .. eessi_version .. " loaded successfully" )
72
157
end
0 commit comments