Skip to content

guard 'module unload' statements in modules for Cray* toolchains#2286

Merged
ocaisa merged 1 commit intoeasybuilders:developfrom
boegel:craytoolchain_guard_module_unload
Dec 18, 2020
Merged

guard 'module unload' statements in modules for Cray* toolchains#2286
ocaisa merged 1 commit intoeasybuilders:developfrom
boegel:craytoolchain_guard_module_unload

Conversation

@boegel
Copy link
Copy Markdown
Member

@boegel boegel commented Dec 16, 2020

Some module tools trigger an error when unloading modules for which the corresponding module file does not exist, so it's better to guard the module unload statements.

This results in the following change in the generated module file (using CrayCCE-20.08.eb):

$ diff -u modules/all/CrayCCE/20.08.old modules/all/CrayCCE/20.08
--- modules/all/CrayCCE/20.08.old	2020-12-16 22:11:08.332746000 +0100
+++ modules/all/CrayCCE/20.08	2020-12-16 22:11:21.817132000 +0100
@@ -24,9 +24,18 @@

 conflict CrayCCE

-module unload PrgEnv-gnu
-module unload PrgEnv-intel
-module unload PrgEnv-pgi
+if { [ is-loaded PrgEnv-gnu ] } {
+    module unload PrgEnv-gnu
+}
+
+if { [ is-loaded PrgEnv-intel ] } {
+    module unload PrgEnv-intel
+}
+
+if { [ is-loaded PrgEnv-pgi ] } {
+    module unload PrgEnv-pgi
+}
+

 if { ![ is-loaded PrgEnv-cray ] } {
     module load PrgEnv-cray

fixes #2283

@boegel
Copy link
Copy Markdown
Member Author

boegel commented Dec 16, 2020

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS CrayCCE-20.08.eb

Build succeeded for 1 out of 1 (1 easyconfigs in total)
daint102 - Linux UNKNOWN UNKNOWN, x86_64, Intel(R) Xeon(R) CPU E5-2650 v3 @ 2.30GHz, Python 2.7.17
See https://gist.github.com/6b94b420fd1fd84b0c123b8983dcd845 for a full test report.

@boegel
Copy link
Copy Markdown
Member Author

boegel commented Dec 16, 2020

@gppezzi @victorusu @lucamar @vkarak Any thoughts on this?

@vkarak
Copy link
Copy Markdown

vkarak commented Dec 17, 2020

@boegel lgtm. It makes sense, since I've seen this behaviour as well.

Copy link
Copy Markdown
Member

@ocaisa ocaisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ocaisa ocaisa merged commit f4ca2c0 into easybuilders:develop Dec 18, 2020
@lucamar
Copy link
Copy Markdown

lucamar commented Dec 18, 2020

Thanks for the comment @boegel: I think that we used on some system the CSCS custom script craytoolchain.py to cope with a bug in Modules 4.0 and 4.1, where unloading an non existing modulefile generates an "Unable to locate modulefile" error.
Starting with version 4.2, unloading a module only looks at loaded module list and does not trigger a modulefile search: so starting version 4.2 the same behavior than Modules compatibility version 3.2 is obtained (section unload in https://modules.readthedocs.io/en/latest/diff_v3_v4.html).

The difference was the use of the array AVAIL_PRGENVS instead of KNOWN_PRGENVS to iterate prgenv:

AVAIL_PRGENVS=[]
for prgenv in [prgenv for prgenv in KNOWN_PRGENVS]:
    try:
        subprocess.check_call("module unload %s &> /dev/null" % prgenv, shell=True)
        AVAIL_PRGENVS.append(prgenv)
    except subprocess.CalledProcessError:
        continue

@boegel boegel deleted the craytoolchain_guard_module_unload branch December 18, 2020 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants