Skip to content

Commit a04da75

Browse files
authored
[SYCL][ROCm] Setup lit tests for ROCm plugin (#4163)
This patch wires up the lit tests for the ROCm plugin adding `check-sycl-rocm`. `check-sycl-rocm` includes `check-sycl-rocm-on-device` and `check-sycl-rocm-ptx` to run the compiler tests with the NVIDIA triple if using the NVIDIA platform for ROCm or `check-sycl-rocm-gcn` if using the AMD platform. This PR is marked as draft is it requires a bit more work to get `check-sycl-rocm` to work properly.
1 parent c3d1300 commit a04da75

33 files changed

+192
-3
lines changed

sycl/doc/GetStartedGuide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ skipped.
424424
If CUDA support has been built, it is tested only if there are CUDA devices
425425
available.
426426
427+
If testing with ROCm for AMD make sure to specify the GPU being used
428+
by adding `-Xsycl-target-backend=amdgcn-amd-amdhsa-sycldevice
429+
--offload-arch=<target>` to the CMake variable
430+
`SYCL_CLANG_EXTRA_FLAGS`.
431+
427432
#### Run DPC++ E2E test suite
428433
429434
Follow instructions from the link below to build and run tests:

sycl/test/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,34 @@ if(SYCL_BUILD_PI_CUDA)
7575
add_custom_target(check-sycl-cuda)
7676
add_dependencies(check-sycl-cuda check-sycl-ptx)
7777
add_dependencies(check-sycl check-sycl-cuda)
78+
endif()
79+
80+
if(SYCL_BUILD_PI_ROCM)
81+
add_custom_target(check-sycl-rocm)
82+
if("${SYCL_BUILD_PI_ROCM_PLATFORM}" STREQUAL "NVIDIA")
83+
add_lit_testsuite(check-sycl-rocm-ptx "Running device-agnostic SYCL regression tests for ROCm NVidia PTX"
84+
${CMAKE_CURRENT_BINARY_DIR}
85+
ARGS ${RT_TEST_ARGS}
86+
PARAMS "SYCL_TRIPLE=nvptx64-nvidia-cuda-sycldevice;SYCL_PLUGIN=rocm"
87+
DEPENDS ${SYCL_TEST_DEPS}
88+
EXCLUDE_FROM_CHECK_ALL
89+
)
90+
91+
add_dependencies(check-sycl-rocm check-sycl-rocm-ptx)
92+
elseif("${SYCL_BUILD_PI_ROCM_PLATFORM}" STREQUAL "AMD")
93+
add_lit_testsuite(check-sycl-rocm-gcn "Running device-agnostic SYCL regression tests for ROCm AMDGCN"
94+
${CMAKE_CURRENT_BINARY_DIR}
95+
ARGS ${RT_TEST_ARGS}
96+
PARAMS "SYCL_TRIPLE=amdgcn-amd-amdhsa-sycldevice;SYCL_PLUGIN=rocm"
97+
DEPENDS ${SYCL_TEST_DEPS}
98+
EXCLUDE_FROM_CHECK_ALL
99+
)
100+
101+
add_dependencies(check-sycl-rocm check-sycl-rocm-gcn)
102+
else()
103+
message(FATAL_ERROR "SYCL_BUILD_PI_ROCM_PLATFORM must be set to either 'AMD' or 'NVIDIA' (set to: '${SYCL_BUILD_PI_ROCM_PLATFORM}')")
104+
endif()
78105

106+
add_dependencies(check-sycl check-sycl-rocm)
79107
endif()
80108
add_subdirectory(on-device)

sycl/test/basic_tests/built-ins.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
// CUDA does not support printf.
55
// UNSUPPORTED: cuda
6+
//
7+
// Hits an assertion with AMD:
8+
// XFAIL: rocm_amd
9+
610
#include <CL/sycl.hpp>
711

812
#include <cassert>

sycl/test/esimd/odr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
// Cuda does not support intrinsics generated by the ESIMD compilation path:
1212
// UNSUPPORTED: cuda
1313
//
14+
// Linking issues with AMD:
15+
// XFAIL: rocm_amd
16+
1417
#include <CL/sycl.hpp>
1518
#include <iostream>
1619
#include <sycl/ext/intel/experimental/esimd.hpp>

sycl/test/extensions/group-algorithm.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -I . -o %t.out
22
// Group operations are not supported on host device. The test checks that
33
// compilation succeeded.
4+
//
5+
// Missing __spirv_GroupIAdd, __spirv_GroupAll, __spirv_GroupBroadcast,
6+
// __spirv_GroupAny, __spirv_GroupSMin on AMD:
7+
// XFAIL: rocm_amd
48

59
// TODO: enable compile+runtime checks for operations defined in SPIR-V 1.3.
610
// That requires either adding a switch to clang (-spirv-max-version=1.3) or

sycl/test/lit.cfg.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@
103103
if triple == 'nvptx64-nvidia-cuda-sycldevice':
104104
config.available_features.add('cuda')
105105

106+
if triple == 'amdgcn-amd-amdhsa-sycldevice':
107+
config.available_features.add('rocm_amd')
108+
# For AMD the specific GPU has to be specified with --offload-arch
109+
if not re.match('.*--offload-arch.*', config.sycl_clang_extra_flags):
110+
raise Exception("Error: missing --offload-arch flag when trying to " \
111+
"run lit tests for AMD GPU, please add " \
112+
"`-Xsycl-target-backend=amdgcn-amd-amdhsa-sycldevice --offload-arch=<target>` to " \
113+
"the CMake variable SYCL_CLANG_EXTRA_FLAGS")
114+
106115
# Set timeout for test = 10 mins
107116
try:
108117
import psutil

sycl/test/on-device/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,17 @@ if(SYCL_BUILD_PI_CUDA)
4040
add_dependencies(check-sycl-cuda check-sycl-cuda-on-device)
4141
endif()
4242
endif()
43+
44+
if(SYCL_BUILD_PI_ROCM)
45+
add_lit_testsuite(check-sycl-rocm-on-device "Running the SYCL regression tests for ROCm"
46+
${CMAKE_CURRENT_BINARY_DIR}
47+
ARGS ${RT_TEST_ARGS}
48+
PARAMS "SYCL_PLUGIN=rocm"
49+
DEPENDS ${SYCL_TEST_DEPS}
50+
EXCLUDE_FROM_CHECK_ALL
51+
)
52+
set_target_properties(check-sycl-rocm-on-device PROPERTIES FOLDER "SYCL ROCm device tests")
53+
if(TARGET check-sycl-rocm)
54+
add_dependencies(check-sycl-rocm check-sycl-rocm-on-device)
55+
endif()
56+
endif()

sycl/test/on-device/back_to_back_collectives.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out
55
// RUN: %ACC_RUN_PLACEHOLDER %t.out
6+
//
7+
// Missing __spirv_GroupIAdd on AMD:
8+
// XFAIL: rocm_amd
69

710
#include <CL/sycl.hpp>
811
#include <numeric>

sycl/test/on-device/basic_tests/aspects.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// RUN: %clangxx -fsycl %s -o %t.out
22
// RUN: env SYCL_DEVICE_FILTER=%sycl_be %t.out
3+
//
4+
// Hip is missing some of the parameters tested here so it fails with ROCm for
5+
// NVIDIA
6+
// XFAIL: rocm_nvidia
37

48
//==--------------- aspects.cpp - SYCL device test ------------------------==//
59
//

sycl/test/on-device/basic_tests/specialization_constants/host_apis.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// RUN: %t.out
33

44
// UNSUPPORTED: cuda
5+
// UNSUPPORTED: rocm_nvidia
6+
// UNSUPPORTED: rocm_amd
57

68
#include <sycl/sycl.hpp>
79

0 commit comments

Comments
 (0)