Skip to content

Commit a04da75

Browse files
authored
[SYCL][ROCm] Setup lit tests for ROCm plugin (intel#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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
3+
//
4+
// Hits an assert in the Lower Work Group Scope Code pass on AMD:
5+
// XFAIL: rocm_amd
36

47
// This test checks all possible scenarios of running single_task, parallel_for
58
// and parallel_for_work_group to verify that this code compiles and runs

sycl/test/on-device/basic_tests/specialization_constants/non_native/aot_w_kernel_handler_wo_spec_consts.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
3+
//
4+
// Hits an assert in the Lower Work Group Scope Code pass on AMD:
5+
// XFAIL: rocm_amd
36

47
// This test checks correctness of compiling and running of application with
58
// kernel lambdas containing kernel_handler arguments and w/o usage of

sycl/test/on-device/basic_tests/specialization_constants/non_native/gpu.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// REQUIRES: ocloc, gpu, TEMPORARY_DISABLED
22
// UNSUPPORTED: cuda
33
// CUDA is not compatible with SPIR.
4+
//
5+
// UNSUPPORTED: rocm_nvidia
6+
// UNSUPPORTED: rocm_amd
7+
// ROCm is not compatible with SPIR.
48

59
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend=spir64_gen-unknown-unknown-sycldevice "-device *" %S/Inputs/common.cpp -o %t.out
610
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/on-device/extensions/intel-ext-device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//
55
// REQUIRES: gpu
66
// UNSUPPORTED: cuda
7+
// UNSUPPORTED: rocm_nvidia
8+
// UNSUPPORTED: rocm_amd
79

810
//==--------- intel-ext-device.cpp - SYCL device test ------------==//
911
//

sycl/test/on-device/group_algorithms_sycl2020/all_of.cpp

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

69
#include "support.h"
710
#include <CL/sycl.hpp>

sycl/test/on-device/group_algorithms_sycl2020/any_of.cpp

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

69
#include "support.h"
710
#include <CL/sycl.hpp>

sycl/test/on-device/group_algorithms_sycl2020/exclusive_scan.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
5+
//
6+
// Missing __spirv_GroupIAdd, __spirv_GroupBroadcast, __spirv_GroupSMin and
7+
// __spirv_GroupSMax on AMD:
8+
// XFAIL: rocm_amd
59

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

sycl/test/on-device/group_algorithms_sycl2020/group_broadcast.cpp

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

69
#include "support.h"
710
#include <CL/sycl.hpp>

sycl/test/on-device/group_algorithms_sycl2020/inclusive_scan.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
5+
//
6+
// Missing __spirv_GroupIAdd, __spirv_GroupBroadcast, __spirv_GroupSMin and
7+
// __spirv_GroupSMax on AMD:
8+
// XFAIL: rocm_amd
59

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

sycl/test/on-device/group_algorithms_sycl2020/none_of.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
5+
//
6+
// Missing __spirv_GroupAll and __spirv_GroupAny on AMD:
7+
// XFAIL: rocm_amd
58

69
#include "support.h"
710
#include <CL/sycl.hpp>

sycl/test/on-device/group_algorithms_sycl2020/permute_select.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
55
//
6+
// Missing __spirv_SubgroupId, __spirv_SubgroupMaxSize, __spirv_SubgroupShuffle* on AMD:
7+
// XFAIL: rocm_amd
8+
//
69
//==------------ permute_select.cpp -*- C++ -*-----------------------------===//
710
//
811
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

sycl/test/on-device/group_algorithms_sycl2020/reduce.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
5+
//
6+
// Missinsg __spirv_GroupIAdd, __spirv_GroupSMin and __spirv_GroupSMax on AMD:
7+
// XFAIL: rocm_amd
58

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

sycl/test/on-device/group_algorithms_sycl2020/shift_left_right.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
55
//
6+
// Missing __spirv_SubgroupId, __spirv_SubgroupMaxSize, __spirv_SubgroupShuffle* on AMD:
7+
// XFAIL: rocm_amd
8+
//
69
//==------------ shift_left_right.cpp -*- C++ -*----------------------------==//
710
//
811
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

sycl/test/on-device/lit.cfg.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@
105105
def getDeviceCount(device_type):
106106
is_cuda = False;
107107
is_level_zero = False;
108+
is_rocm_amd = False;
109+
is_rocm_nvidia = False;
108110
process = subprocess.Popen([get_device_count_by_type_path, device_type, backend],
109111
stdout=subprocess.PIPE)
110112
(output, err) = process.communicate()
@@ -130,11 +132,15 @@ def getDeviceCount(device_type):
130132
is_cuda = True;
131133
if re.match(r".*level zero", result[1]):
132134
is_level_zero = True;
135+
if re.match(r".*rocm-amd", result[1]):
136+
is_rocm_amd = True;
137+
if re.match(r".*rocm-nvidia", result[1]):
138+
is_rocm_nvidia = True;
133139

134140
if err:
135141
lit_config.warning("getDeviceCount {TYPE} {BACKEND} stderr:{ERR}".format(
136142
TYPE=device_type, BACKEND=backend, ERR=err))
137-
return [value,is_cuda,is_level_zero]
143+
return [value,is_cuda,is_level_zero,is_rocm_amd,is_rocm_nvidia]
138144

139145
# check if compiler supports CL command line options
140146
cl_options=False
@@ -220,7 +226,9 @@ def getDeviceCount(device_type):
220226

221227
cuda = False
222228
level_zero = False
223-
[gpu_count, cuda, level_zero] = getDeviceCount("gpu")
229+
rocm_amd = False
230+
rocm_nvidia = False
231+
[gpu_count, cuda, level_zero, rocm_amd, rocm_nvidia] = getDeviceCount("gpu")
224232

225233
if gpu_count > 0:
226234
found_at_least_one_device = True
@@ -232,6 +240,16 @@ def getDeviceCount(device_type):
232240
config.available_features.add('cuda')
233241
elif level_zero:
234242
config.available_features.add('level_zero')
243+
elif rocm_amd:
244+
config.available_features.add('rocm_amd')
245+
# For AMD the specific GPU has to be specified with --offload-arch
246+
if not re.match('.*--offload-arch.*', config.sycl_clang_extra_flags):
247+
raise Exception("Error: missing --offload-arch flag when trying to " \
248+
"run lit tests for AMD GPU, please add " \
249+
"`-Xsycl-target-backend=amdgcn-amd-amdhsa-sycldevice --offload-arch=<target>` to " \
250+
"the CMake variable SYCL_CLANG_EXTRA_FLAGS")
251+
elif rocm_nvidia:
252+
config.available_features.add('rocm_nvidia')
235253

236254
if platform.system() == "Linux":
237255
gpu_run_on_linux_substitute = "env SYCL_DEVICE_FILTER={SYCL_PLUGIN}:gpu,host ".format(SYCL_PLUGIN=backend)
@@ -261,8 +279,10 @@ def getDeviceCount(device_type):
261279
if not cuda and not level_zero and found_at_least_one_device:
262280
config.available_features.add('opencl')
263281

264-
if cuda:
282+
if cuda or rocm_nvidia:
265283
config.substitutions.append( ('%sycl_triple', "nvptx64-nvidia-cuda-sycldevice" ) )
284+
elif rocm_amd:
285+
config.substitutions.append( ('%sycl_triple', "amdgcn-amd-amdhsa-sycldevice" ) )
266286
else:
267287
config.substitutions.append( ('%sycl_triple', "spir64-unknown-unknown-sycldevice" ) )
268288

sycl/test/on-device/span/span.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
5+
//
6+
// Fails to release USM pointer on ROCm for NVIDIA
7+
// XFAIL: rocm_nvidia
58

69
#include <numeric>
710
#include <sycl/sycl.hpp>

sycl/test/on-device/srgb/srgba-read.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
// XFAIL: level_zero
66
// UNSUPPORTED: cuda
7+
// UNSUPPORTED: rocm_nvidia
8+
// UNSUPPORTED: rocm_amd
79

810
#include <CL/sycl.hpp>
911

sycl/unittests/SYCL2020/KernelBundle.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ TEST(KernelBundle, GetKernelBundleFromKernel) {
7070
return;
7171
}
7272

73+
if (Plt.get_backend() == sycl::backend::rocm) {
74+
std::cout << "Test is not supported on ROCm platform, skipping\n";
75+
return;
76+
}
77+
7378
sycl::unittest::PiMock Mock{Plt};
7479
setupDefaultMockAPIs(Mock);
7580

sycl/unittests/SYCL2020/SpecConstDefaultValues.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ TEST(SpecConstDefaultValues, DefaultValuesAreSet) {
8282
return;
8383
}
8484

85+
if (Plt.get_backend() == sycl::backend::rocm) {
86+
std::cerr << "Test is not supported on ROCm platform, skipping\n";
87+
return;
88+
}
89+
8590
sycl::unittest::PiMock Mock{Plt};
8691
setupDefaultMockAPIs(Mock);
8792

@@ -116,6 +121,11 @@ TEST(SpecConstDefaultValues, DefaultValuesAreOverriden) {
116121
return;
117122
}
118123

124+
if (Plt.get_backend() == sycl::backend::rocm) {
125+
std::cerr << "Test is not supported on ROCm platform, skipping\n";
126+
return;
127+
}
128+
119129
sycl::unittest::PiMock Mock{Plt};
120130
setupDefaultMockAPIs(Mock);
121131

0 commit comments

Comments
 (0)