@@ -1944,34 +1944,43 @@ def inject_gpu_property(ec):
19441944 # - drop dependency to build dependency
19451945 # - add 'gpu' Lmod property
19461946 # - add envvar with package version
1947- pkg_names = ( "CUDA" , "cuDNN" )
1947+ pkg_names = ( "CUDA" , "cuDNN" , "ROCm-LLVM" )
1948+ # skip dropping step for ROCm-LLVM as it is redistributable
1949+ drop_to_builddep = ( "CUDA" , "cuDNN" )
19481950 pkg_versions = { }
19491951 add_gpu_property = ''
19501952
1953+ # If none of the gpu packages are in the easyconfig, do not process further
1954+ dep_names = {dep [0 ] for dep in ec_dict ['dependencies' ]}
1955+ if not any (pkg in dep_names for pkg in pkg_names ):
1956+ return ec
1957+
1958+ # Check if pkg_name is in the dependencies, if so drop dependency to build
1959+ # dependency and set variable for later adding the 'gpu' Lmod property
1960+ # to '.remove' dependencies from ec_dict['dependencies'] we make a copy,
1961+ # iterate over the copy and can then savely use '.remove' on the original
19511962 for pkg_name in pkg_names :
1952- # Check if pkg_name is in the dependencies, if so drop dependency to build
1953- # dependency and set variable for later adding the 'gpu' Lmod property
1954- # to '.remove' dependencies from ec_dict['dependencies'] we make a copy,
1955- # iterate over the copy and can then savely use '.remove' on the original
1956- # ec_dict['dependencies'].
1957- deps = ec_dict ['dependencies' ][:]
1958- if (pkg_name in [dep [0 ] for dep in deps ]):
1963+ for dep in ec_dict ['dependencies' ][:]:
1964+ if dep [0 ] != pkg_name :
1965+ continue
1966+
19591967 add_gpu_property = 'add_property("arch","gpu")'
1960- for dep in deps :
1961- if pkg_name == dep [ 0 ]:
1962- # make pkg_name a build dependency only (rpathing saves us from link errors)
1963- ec .log .info ("Dropping dependency on %s to build dependency" % pkg_name )
1964- ec_dict ['dependencies' ].remove (dep )
1965- if dep not in ec_dict [ 'builddependencies' ]:
1966- ec_dict ['builddependencies' ]. append ( dep )
1967- # take note of version for creating the modluafooter
1968- pkg_versions [ pkg_name ] = dep [ 1 ]
1968+ pkg_versions [ pkg_name ] = dep [ 1 ]
1969+
1970+ if pkg_name in drop_to_builddep :
1971+ ec .log .info ("Dropping dependency on %s to build dependency" % pkg_name )
1972+ ec_dict ['dependencies' ].remove (dep )
1973+ # Avoid adding a duplicate
1974+ if dep not in ec_dict ['builddependencies' ]:
1975+ ec_dict [ 'builddependencies' ]. append ( dep )
1976+
19691977 if add_gpu_property :
19701978 ec .log .info ("Injecting gpu as Lmod arch property and envvars for dependencies with their version" )
19711979 modluafooter = 'modluafooter'
19721980 extra_mod_footer_lines = [add_gpu_property ]
19731981 for pkg_name , version in pkg_versions .items ():
1974- envvar = "EESSI%sVERSION" % pkg_name .upper ()
1982+ # follow the convention for replacing - with MIN
1983+ envvar = "EESSI%sVERSION" % pkg_name .upper ().replace ('-' , 'MIN' )
19751984 extra_mod_footer_lines .append ('setenv("%s","%s")' % (envvar , version ))
19761985 # take into account that modluafooter may already be set
19771986 if modluafooter in ec_dict :
0 commit comments