forked from spack/spack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hipsycl: add compile options for ROCm (spack#45497)
Co-authored-by: cloirec <[email protected]>
- Loading branch information
Showing
1 changed file
with
37 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,15 @@ | |
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
||
import json | ||
import os | ||
from os import path | ||
|
||
from llnl.util import filesystem | ||
|
||
from spack.package import * | ||
|
||
|
||
class Hipsycl(CMakePackage): | ||
class Hipsycl(CMakePackage, ROCmPackage): | ||
"""hipSYCL is an implementation of the SYCL standard programming model | ||
over NVIDIA CUDA/AMD HIP""" | ||
|
||
|
@@ -26,6 +27,7 @@ class Hipsycl(CMakePackage): | |
license("BSD-2-Clause") | ||
|
||
version("stable", branch="stable", submodules=True) | ||
version("24.02.0", commit="974adc33ea5a35dd8b5be68c7a744b37482b8b64", submodules=True) | ||
version("23.10.0", commit="3952b468c9da89edad9dff953cdcab0a3c3bf78c", submodules=True) | ||
version("0.9.4", commit="99d9e24d462b35e815e0e59c1b611936c70464ae", submodules=True) | ||
version("0.9.4", commit="99d9e24d462b35e815e0e59c1b611936c70464ae", submodules=True) | ||
|
@@ -35,9 +37,8 @@ class Hipsycl(CMakePackage): | |
version("0.8.0", commit="2daf8407e49dd32ebd1c266e8e944e390d28b22a", submodules=True) | ||
version("develop", branch="develop", submodules=True) | ||
|
||
depends_on("cxx", type="build") # generated | ||
|
||
variant("cuda", default=False, description="Enable CUDA backend for SYCL kernels") | ||
variant("rocm", default=False, description="Enable ROCM backend for SYCL kernels") | ||
|
||
depends_on("[email protected]:", type="build") | ||
depends_on("boost +filesystem", when="@:0.8") | ||
|
@@ -78,8 +79,7 @@ def cmake_args(self): | |
spec = self.spec | ||
args = [ | ||
"-DWITH_CPU_BACKEND:Bool=TRUE", | ||
# TODO: no ROCm stuff available in spack yet | ||
"-DWITH_ROCM_BACKEND:Bool=FALSE", | ||
"-DWITH_ROCM_BACKEND:Bool={0}".format("TRUE" if "+rocm" in spec else "FALSE"), | ||
"-DWITH_CUDA_BACKEND:Bool={0}".format("TRUE" if "+cuda" in spec else "FALSE"), | ||
# prevent hipSYCL's cmake to look for other LLVM installations | ||
# if the specified one isn't compatible | ||
|
@@ -120,6 +120,11 @@ def cmake_args(self): | |
# explicit CUDA toolkit | ||
if "+cuda" in spec: | ||
args.append("-DCUDA_TOOLKIT_ROOT_DIR:String={0}".format(spec["cuda"].prefix)) | ||
if "+rocm" in spec: | ||
args.append("-DWITH_ACCELERATED_CPU:STRING=OFF") | ||
args.append("-DROCM_PATH:STRING={0}".format(os.environ.get("ROCM_PATH"))) | ||
if self.spec.satisfies("@24.02.0:"): | ||
args.append("-DWITH_SSCP_COMPILER=OFF") | ||
return args | ||
|
||
@run_after("install") | ||
|
@@ -158,31 +163,32 @@ def adjust_core_config(config): | |
# the libc++.so and libc++abi.so dyn linked to the sycl | ||
# ptx backend | ||
rpaths = set() | ||
so_paths = filesystem.find_libraries( | ||
"libc++", self.spec["llvm"].prefix, shared=True, recursive=True | ||
) | ||
if len(so_paths) != 1: | ||
raise InstallError( | ||
"concretized llvm dependency must provide a " | ||
"unique directory containing libc++.so, " | ||
"found: {0}".format(so_paths) | ||
) | ||
rpaths.add(path.dirname(so_paths[0])) | ||
so_paths = filesystem.find_libraries( | ||
"libc++abi", self.spec["llvm"].prefix, shared=True, recursive=True | ||
) | ||
if len(so_paths) != 1: | ||
raise InstallError( | ||
"concretized llvm dependency must provide a " | ||
"unique directory containing libc++abi, " | ||
"found: {0}".format(so_paths) | ||
if "~rocm" in spec: | ||
so_paths = filesystem.find_libraries( | ||
"libc++", self.spec["llvm"].prefix, shared=True, recursive=True | ||
) | ||
rpaths.add(path.dirname(so_paths[0])) | ||
|
||
def adjust_cuda_config(config): | ||
config["default-cuda-link-line"] += " " + " ".join( | ||
"-rpath {0}".format(p) for p in rpaths | ||
if len(so_paths) != 1: | ||
raise InstallError( | ||
"concretized llvm dependency must provide a " | ||
"unique directory containing libc++.so, " | ||
"found: {0}".format(so_paths) | ||
) | ||
rpaths.add(path.dirname(so_paths[0])) | ||
so_paths = filesystem.find_libraries( | ||
"libc++abi", self.spec["llvm"].prefix, shared=True, recursive=True | ||
) | ||
return config | ||
|
||
edit_config(configfiles["cuda"], adjust_cuda_config) | ||
if len(so_paths) != 1: | ||
raise InstallError( | ||
"concretized llvm dependency must provide a " | ||
"unique directory containing libc++abi, " | ||
"found: {0}".format(so_paths) | ||
) | ||
rpaths.add(path.dirname(so_paths[0])) | ||
|
||
def adjust_cuda_config(config): | ||
config["default-cuda-link-line"] += " " + " ".join( | ||
"-rpath {0}".format(p) for p in rpaths | ||
) | ||
return config | ||
|
||
edit_config(configfiles["cuda"], adjust_cuda_config) |