Skip to content

Commit 1a8bb53

Browse files
authored
[SYCL][HIP] Simplify ROCm path CMake variables (#6406)
Use a single CMake variable for the root of the ROCm installation rather than three for the hip include directory, the hip library and the hsa include directories. And add a clear CMake error when the ROCm installation doesn't exist. This was discussed a little while back in #6145 and should make working with non-standard ROCm installation easier and clearer.
1 parent 53ec7e2 commit 1a8bb53

File tree

2 files changed

+21
-26
lines changed

2 files changed

+21
-26
lines changed

sycl/doc/GetStartedGuide.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ Enabling this flag requires an installation of
231231
ROCm on the system, for instruction on how to install this refer to
232232
[AMD ROCm Installation Guide for Linux](https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html).
233233

234+
The DPC++ build assumes that ROCm is installed in `/opt/rocm`, if it
235+
is installed somewhere else, the directory must be provided through
236+
the CMake variable `SYCL_BUILD_PI_HIP_ROCM_DIR` which can be passed
237+
using the `--cmake-opt` option of `configure.py` as follows:
238+
239+
```
240+
python $DPCPP_HOME/llvm/buildbot/configure.py --hip \
241+
--cmake-opt=-DSYCL_BUILD_PI_HIP_ROCM_DIR=/usr/local/rocm
242+
```
243+
234244
Currently, this has only been tried on Linux, with ROCm 4.2.0 or 4.3.0 and
235245
using the MI50 (gfx906) and MI100 (gfx908) devices.
236246

@@ -240,26 +250,6 @@ produce a standard ELF shared code object which can be loaded and executed on an
240250
The LLD project is enabled by default when configuring for HIP. For more details
241251
on building LLD refer to [LLD Build Guide](https://lld.llvm.org/).
242252

243-
The following CMake variables can be updated to change where CMake is looking
244-
for the HIP installation:
245-
246-
* `SYCL_BUILD_PI_HIP_INCLUDE_DIR`: Path to HIP include directory (default
247-
`/opt/rocm/hip/include`).
248-
* `SYCL_BUILD_PI_HIP_HSA_INCLUDE_DIR`: Path to HSA include directory (default
249-
`/opt/rocm/hsa/include`).
250-
* `SYCL_BUILD_PI_HIP_AMD_LIBRARY`: Path to HIP runtime library (default
251-
`/opt/rocm/hip/lib/libamdhip64.so`).
252-
253-
These variables can be passed to `configure.py` using `--cmake-opt`, for example
254-
with a ROCm installation in `/usr/local`:
255-
256-
```
257-
python $DPCPP_HOME/llvm/buildbot/configure.py --hip \
258-
--cmake-opt=-DSYCL_BUILD_PI_HIP_INCLUDE_DIR=/usr/local/rocm/hip/include \
259-
--cmake-opt=-DSYCL_BUILD_PI_HIP_HSA_INCLUDE_DIR=/usr/local/rocm/hsa/include \
260-
--cmake-opt=-DSYCL_BUILD_PI_HIP_AMD_LIBRARY=/usr/local/rocm/hip/lib/libamdhip64.so
261-
```
262-
263253
### Build DPC++ toolchain with support for HIP NVIDIA
264254

265255
There is experimental support for DPC++ for HIP on Nvidia devices. Note as this

sycl/plugins/hip/CMakeLists.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ set(SYCL_BUILD_PI_HIP_PLATFORM "AMD" CACHE STRING "PI HIP platform, AMD or NVIDI
44

55
message(STATUS "Including the PI API HIP backend for ${SYCL_BUILD_PI_HIP_PLATFORM}.")
66

7-
# Set default HIP include dirs
8-
set(SYCL_BUILD_PI_HIP_INCLUDE_DIR "/opt/rocm/hip/include" CACHE STRING "HIP include dir")
9-
set(SYCL_BUILD_PI_HIP_HSA_INCLUDE_DIR "/opt/rocm/hsa/include" CACHE STRING "HSA include dir")
10-
set(HIP_HEADERS "${SYCL_BUILD_PI_HIP_INCLUDE_DIR};${SYCL_BUILD_PI_HIP_HSA_INCLUDE_DIR}")
7+
# Set default ROCm installation directory
8+
set(SYCL_BUILD_PI_HIP_ROCM_DIR "/opt/rocm" CACHE STRING "ROCm installation dir")
9+
10+
if(NOT EXISTS "${SYCL_BUILD_PI_HIP_ROCM_DIR}")
11+
message(FATAL_ERROR "Couldn't find ROCm installation in '${SYCL_BUILD_PI_HIP_ROCM_DIR}',"
12+
" please set SYCL_BUILD_PI_HIP_ROCM_DIR to the path of the ROCm installation.")
13+
endif()
14+
15+
# Set HIP include dirs
16+
set(HIP_HEADERS "${SYCL_BUILD_PI_HIP_ROCM_DIR}/hip/include;${SYCL_BUILD_PI_HIP_ROCM_DIR}/hsa/include")
1117

1218
# Create pi_hip library
1319
add_sycl_plugin(hip
@@ -23,12 +29,11 @@ set_target_properties(pi_hip PROPERTIES LINKER_LANGUAGE CXX)
2329

2430
if("${SYCL_BUILD_PI_HIP_PLATFORM}" STREQUAL "AMD")
2531
# Import HIP runtime library
26-
set(SYCL_BUILD_PI_HIP_AMD_LIBRARY "/opt/rocm/hip/lib/libamdhip64.so" CACHE STRING "HIP AMD runtime library")
2732
add_library(rocmdrv SHARED IMPORTED GLOBAL)
2833

2934
set_target_properties(
3035
rocmdrv PROPERTIES
31-
IMPORTED_LOCATION ${SYCL_BUILD_PI_HIP_AMD_LIBRARY}
36+
IMPORTED_LOCATION "${SYCL_BUILD_PI_HIP_ROCM_DIR}/hip/lib/libamdhip64.so"
3237
INTERFACE_INCLUDE_DIRECTORIES "${HIP_HEADERS}"
3338
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${HIP_HEADERS}"
3439
)

0 commit comments

Comments
 (0)