Skip to content

Commit f61a136

Browse files
authored
[SYCL][OpenCL] Ban AMD OpenCL platform (#5825) (#6878)
Compiling kernels for it is not supported, device info sometimes throws, and there is the HIP backend for those wanting to use an AMD GPU. ```console $ sycl-ls # before [opencl:gpu:0] Intel(R) OpenCL HD Graphics, Intel(R) UHD Graphics 770 [0x4680] 3.0 [22.35.24055] [opencl:gpu:1] AMD Accelerated Parallel Processing, gfx1032 2.0 [3452.0 (HSA1.1,LC)] [ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) UHD Graphics 770 [0x4680] 1.3 [1.3.24055] [ext_oneapi_cuda:gpu:0] NVIDIA CUDA BACKEND, NVIDIA GeForce RTX 3060 0.0 [CUDA 11.7] [ext_oneapi_hip:gpu:0] AMD HIP BACKEND, gfx1032 0.0 [HIP 50221.15] $ sycl-ls # after [opencl:gpu:0] Intel(R) OpenCL HD Graphics, Intel(R) UHD Graphics 770 [0x4680] 3.0 [22.35.24055] [ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) UHD Graphics 770 [0x4680] 1.3 [1.3.24055] [ext_oneapi_cuda:gpu:0] NVIDIA CUDA BACKEND, NVIDIA GeForce RTX 3060 0.0 [CUDA 11.7] [ext_oneapi_hip:gpu:0] AMD HIP BACKEND, gfx1032 0.0 [HIP 50221.15] ``` Closes #5825
1 parent 2002dc0 commit f61a136

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

sycl/source/detail/platform_impl.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,28 @@ static bool IsBannedPlatform(platform Platform) {
7575
// To avoid problems on default users and deployment of DPC++ on platforms
7676
// where CUDA is available, the OpenCL support is disabled.
7777
//
78-
auto IsNVIDIAOpenCL = [](platform Platform) {
78+
// There is also no support for the AMD HSA backend for OpenCL consumption,
79+
// as well as reported problems with device queries, so AMD OpenCL support
80+
// is disabled as well.
81+
//
82+
auto IsMatchingOpenCL = [](platform Platform, const std::string_view name) {
7983
if (getSyclObjImpl(Platform)->is_host())
8084
return false;
8185

82-
const bool HasCUDA = Platform.get_info<info::platform::name>().find(
83-
"NVIDIA CUDA") != std::string::npos;
86+
const bool HasNameMatch = Platform.get_info<info::platform::name>().find(
87+
name) != std::string::npos;
8488
const auto Backend =
8589
detail::getSyclObjImpl(Platform)->getPlugin().getBackend();
86-
const bool IsCUDAOCL = (HasCUDA && Backend == backend::opencl);
87-
if (detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_ALL) && IsCUDAOCL) {
88-
std::cout << "SYCL_PI_TRACE[all]: "
89-
<< "NVIDIA CUDA OpenCL platform found but is not compatible."
90-
<< std::endl;
90+
const bool IsMatchingOCL = (HasNameMatch && Backend == backend::opencl);
91+
if (detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_ALL) &&
92+
IsMatchingOCL) {
93+
std::cout << "SYCL_PI_TRACE[all]: " << name
94+
<< " OpenCL platform found but is not compatible." << std::endl;
9195
}
92-
return IsCUDAOCL;
96+
return IsMatchingOCL;
9397
};
94-
return IsNVIDIAOpenCL(Platform);
98+
return IsMatchingOpenCL(Platform, "NVIDIA CUDA") ||
99+
IsMatchingOpenCL(Platform, "AMD Accelerated Parallel Processing");
95100
}
96101

97102
// This routine has the side effect of registering each platform's last device

0 commit comments

Comments
 (0)