|
11 | 11 | import easybuild.tools.environment as env |
12 | 12 | from easybuild.easyblocks.generic.configuremake import obtain_config_guess |
13 | 13 | from easybuild.framework.easyconfig.constants import EASYCONFIG_CONSTANTS |
14 | | -from easybuild.framework.easyconfig.easyconfig import get_toolchain_hierarchy |
| 14 | +from easybuild.framework.easyconfig.easyconfig import ( |
| 15 | + get_toolchain_hierarchy, |
| 16 | + process_easyconfig, |
| 17 | + robot_find_easyconfig, |
| 18 | +) |
15 | 19 | from easybuild.tools import config |
16 | 20 | from easybuild.tools.build_log import EasyBuildError, print_msg, print_warning |
17 | 21 | from easybuild.tools.config import build_option, install_path, update_build_option |
@@ -1934,45 +1938,69 @@ def replace_binary_non_distributable_files_with_symlinks(log, install_dir, pkg_n |
1934 | 1938 | symlink(host_inj_path, full_path) |
1935 | 1939 |
|
1936 | 1940 |
|
| 1941 | +def find_rocm_llvm_dependency(ec): |
| 1942 | + """ |
| 1943 | + Return the ROCm-LLVM dependency for this easyconfig, or None. ROCm-LLVM can |
| 1944 | + be a direct dependency, a direct toolchain component (rocm-compilers as the |
| 1945 | + toolchain), or one level deeper inside the rocm-compilers bundle when the |
| 1946 | + toolchain is rompi/rfbf/rfoss. |
| 1947 | + """ |
| 1948 | + for dep in ec.asdict()['dependencies']: |
| 1949 | + if dep['name'] == 'ROCm-LLVM': |
| 1950 | + return dep |
| 1951 | + |
| 1952 | + if is_system_toolchain(ec.toolchain.name): |
| 1953 | + return None |
| 1954 | + |
| 1955 | + tcdeps = ec.toolchain.tcdeps or [] |
| 1956 | + for dep in tcdeps: |
| 1957 | + if dep['name'] == 'ROCm-LLVM': |
| 1958 | + return dep |
| 1959 | + for dep in tcdeps: |
| 1960 | + if dep['name'] == 'rocm-compilers': |
| 1961 | + rocm_compilers_ec = robot_find_easyconfig(dep['name'], dep['version'] + dep['versionsuffix']) |
| 1962 | + if rocm_compilers_ec: |
| 1963 | + rocm_compilers_deps = process_easyconfig(rocm_compilers_ec)[0]['ec'].dependencies(runtime_only=True) |
| 1964 | + for subdep in rocm_compilers_deps: |
| 1965 | + if subdep['name'] == 'ROCm-LLVM': |
| 1966 | + return subdep |
| 1967 | + |
| 1968 | + return None |
| 1969 | + |
| 1970 | + |
1937 | 1971 | def inject_gpu_property(ec): |
1938 | 1972 | """ |
1939 | 1973 | Add 'gpu' property and EESSI<PACKAGE>VERSION envvars via modluafooter |
1940 | 1974 | easyconfig parameter, and drop dependencies to build dependencies |
1941 | 1975 | """ |
1942 | 1976 | ec_dict = ec.asdict() |
1943 | | - # Check if CUDA, cuDNN, you-name-it is in the dependencies, if so |
1944 | | - # - drop dependency to build dependency |
1945 | | - # - add 'gpu' Lmod property |
1946 | | - # - add envvar with package version |
1947 | | - pkg_names = ( "CUDA", "cuDNN", "ROCm-LLVM" ) |
1948 | | - # skip dropping step for ROCm-LLVM as it is redistributable |
1949 | | - drop_to_builddep = ( "CUDA", "cuDNN" ) |
1950 | 1977 | pkg_versions = { } |
1951 | 1978 | add_gpu_property = '' |
1952 | 1979 |
|
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 |
| 1980 | + # Check if pkg_name is related to CUDA, if so drop dependency to build |
1959 | 1981 | # dependency and set variable for later adding the 'gpu' Lmod property |
1960 | 1982 | # to '.remove' dependencies from ec_dict['dependencies'] we make a copy, |
1961 | 1983 | # iterate over the copy and can then savely use '.remove' on the original |
1962 | | - for pkg_name in pkg_names: |
| 1984 | + # ec_dict['dependencies']. |
| 1985 | + for pkg_name in ('CUDA', 'cuDNN'): |
1963 | 1986 | for dep in ec_dict['dependencies'][:]: |
1964 | 1987 | if dep[0] != pkg_name: |
1965 | 1988 | continue |
1966 | 1989 |
|
1967 | 1990 | add_gpu_property = 'add_property("arch","gpu")' |
1968 | 1991 | pkg_versions[pkg_name] = dep[1] |
1969 | 1992 |
|
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) |
| 1993 | + ec.log.info("Dropping dependency on %s to build dependency" % pkg_name) |
| 1994 | + ec_dict['dependencies'].remove(dep) |
| 1995 | + if dep not in ec_dict['builddependencies']: |
| 1996 | + ec_dict['builddependencies'].append(dep) |
| 1997 | + |
| 1998 | + # ROCm-LLVM is handled separately: it is redistributable (kept as a runtime dep) |
| 1999 | + # and may be pulled in via a ROCm toolchain rather than as a direct dependency. |
| 2000 | + rocm_llvm_dep = find_rocm_llvm_dependency(ec) |
| 2001 | + if rocm_llvm_dep is not None: |
| 2002 | + add_gpu_property = 'add_property("arch","gpu")' |
| 2003 | + pkg_versions['ROCm-LLVM'] = rocm_llvm_dep['version'] + (rocm_llvm_dep['versionsuffix'] or '') |
1976 | 2004 |
|
1977 | 2005 | if add_gpu_property: |
1978 | 2006 | ec.log.info("Injecting gpu as Lmod arch property and envvars for dependencies with their version") |
|
0 commit comments