Skip to content

Commit 8aa3513

Browse files
authored
[SYCL][CUDA] Windows and MSVC support for CUDA backend (#4345)
Patch adds windows support for CUDA backend. Adds general handling of Windows file paths Windows support is enabled with remangling of variables from PR #4207 as it fixes mismatch between windows 32-bit longs and default 64-bit long and handles wchar_size. Adds changes to account for MSVC's default to private classes. Fixes to unittests for windows. Signed-off-by: Steffen Larsen <[email protected]>
1 parent 631fd69 commit 8aa3513

File tree

16 files changed

+144
-73
lines changed

16 files changed

+144
-73
lines changed

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ CudaInstallationDetector::CudaInstallationDetector(
125125
SmallVector<Candidate, 4> Candidates;
126126

127127
// In decreasing order so we prefer newer versions to older versions.
128-
std::initializer_list<const char *> Versions = {"8.0", "7.5", "7.0"};
128+
std::initializer_list<const char *> Versions = {
129+
"11.4", "11.3", "11.2", "11.1", "10.2", "10.1", "10.0",
130+
"9.2", "9.1", "9.0", "8.0", "7.5", "7.0"};
129131
auto &FS = D.getVFS();
130132

131133
if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
@@ -187,18 +189,29 @@ CudaInstallationDetector::CudaInstallationDetector(
187189
if (CheckLibDevice && !FS.exists(LibDevicePath))
188190
continue;
189191

190-
// On Linux, we have both lib and lib64 directories, and we need to choose
191-
// based on our triple. On MacOS, we have only a lib directory.
192-
//
193-
// It's sufficient for our purposes to be flexible: If both lib and lib64
194-
// exist, we choose whichever one matches our triple. Otherwise, if only
195-
// lib exists, we use it.
196-
if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
197-
LibPath = InstallPath + "/lib64";
198-
else if (FS.exists(InstallPath + "/lib"))
199-
LibPath = InstallPath + "/lib";
200-
else
201-
continue;
192+
if (HostTriple.isOSWindows()) {
193+
if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib/x64"))
194+
LibPath = InstallPath + "/lib/x64";
195+
else if (FS.exists(InstallPath + "/lib/Win32"))
196+
LibPath = InstallPath + "/lib/Win32";
197+
else if (FS.exists(InstallPath + "/lib"))
198+
LibPath = InstallPath + "/lib";
199+
else
200+
continue;
201+
} else {
202+
// On Linux, we have both lib and lib64 directories, and we need to choose
203+
// based on our triple. On MacOS, we have only a lib directory.
204+
//
205+
// It's sufficient for our purposes to be flexible: If both lib and lib64
206+
// exist, we choose whichever one matches our triple. Otherwise, if only
207+
// lib exists, we use it.
208+
if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
209+
LibPath = InstallPath + "/lib64";
210+
else if (FS.exists(InstallPath + "/lib"))
211+
LibPath = InstallPath + "/lib";
212+
else
213+
continue;
214+
}
202215

203216
Version = CudaVersion::UNKNOWN;
204217
if (auto CudaHFile = FS.getBufferForFile(InstallPath + "/include/cuda.h"))
@@ -703,12 +716,19 @@ void CudaToolChain::addClangTargetOptions(
703716
llvm::sys::path::append(WithInstallPath, Twine("../../../share/clc"));
704717
LibraryPaths.emplace_back(WithInstallPath.c_str());
705718

719+
// Select remangled libclc variant. 64-bit longs default, 32-bit longs on
720+
// Windows
706721
std::string LibSpirvTargetName =
707722
"remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc";
723+
if (HostTC.getTriple().isOSWindows())
724+
LibSpirvTargetName =
725+
"remangled-l32-signed_char.libspirv-nvptx64--nvidiacl.bc";
726+
708727
for (StringRef LibraryPath : LibraryPaths) {
709728
SmallString<128> LibSpirvTargetFile(LibraryPath);
710729
llvm::sys::path::append(LibSpirvTargetFile, LibSpirvTargetName);
711-
if (llvm::sys::fs::exists(LibSpirvTargetFile)) {
730+
if (llvm::sys::fs::exists(LibSpirvTargetFile) ||
731+
DriverArgs.hasArg(options::OPT__HASH_HASH_HASH)) {
712732
LibSpirvFile = std::string(LibSpirvTargetFile.str());
713733
break;
714734
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda-sycldevice -nocudalib -target x86_64-unknown-windows-msvc %s 2> %t.win.out
2+
// RUN: FileCheck %s --check-prefixes=CHECK-WINDOWS --input-file %t.win.out
3+
// CHECK-WINDOWS: remangled-l32-signed_char.libspirv-nvptx64--nvidiacl.bc
4+
//
5+
// RUN: %clang -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda-sycldevice -nocudalib -target x86_64-unknown-linux-gnu %s 2> %t.lnx.out
6+
// RUN: FileCheck %s --check-prefixes=CHECK-LINUX --input-file %t.lnx.out
7+
// CHECK-LINUX: remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc

libclc/cmake/modules/HandleInLLVMTree.cmake

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
macro(configure_in_llvm_tree)
2-
set(LLVM_CLANG ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
3-
set(LLVM_AS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-as)
4-
set(LLVM_LINK ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-link)
5-
set(LLVM_OPT ${LLVM_RUNTIME_OUTPUT_INTDIR}/opt)
6-
set(LIBCLC_REMANGLER ${LLVM_RUNTIME_OUTPUT_INTDIR}/libclc-remangler)
2+
set(LLVM_CLANG ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX})
3+
set(LLVM_AS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-as${CMAKE_EXECUTABLE_SUFFIX})
4+
set(LLVM_LINK ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-link${CMAKE_EXECUTABLE_SUFFIX})
5+
set(LLVM_OPT ${LLVM_RUNTIME_OUTPUT_INTDIR}/opt${CMAKE_EXECUTABLE_SUFFIX})
6+
set(LIBCLC_REMANGLER ${LLVM_RUNTIME_OUTPUT_INTDIR}/libclc-remangler${CMAKE_EXECUTABLE_SUFFIX})
77

8-
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
9-
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang "" )
10-
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
11-
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-as)
12-
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-as "" )
13-
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-as)
14-
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-link)
15-
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-link "" )
16-
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-link)
17-
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/opt)
18-
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/opt "" )
19-
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/opt)
20-
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/libclc-remangler)
21-
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/libclc-remangler "" )
22-
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/libclc-remangler)
8+
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX})
9+
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX} "" )
10+
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX})
11+
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-as${CMAKE_EXECUTABLE_SUFFIX})
12+
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-as${CMAKE_EXECUTABLE_SUFFIX} "" )
13+
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-as${CMAKE_EXECUTABLE_SUFFIX})
14+
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-link${CMAKE_EXECUTABLE_SUFFIX})
15+
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-link${CMAKE_EXECUTABLE_SUFFIX} "" )
16+
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-link${CMAKE_EXECUTABLE_SUFFIX})
17+
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/opt${CMAKE_EXECUTABLE_SUFFIX})
18+
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/opt${CMAKE_EXECUTABLE_SUFFIX} "" )
19+
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/opt${CMAKE_EXECUTABLE_SUFFIX})
20+
if (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/libclc-remangler${CMAKE_EXECUTABLE_SUFFIX})
21+
file(WRITE ${LLVM_RUNTIME_OUTPUT_INTDIR}/libclc-remangler${CMAKE_EXECUTABLE_SUFFIX} "" )
22+
endif (NOT EXISTS ${LLVM_RUNTIME_OUTPUT_INTDIR}/libclc-remangler${CMAKE_EXECUTABLE_SUFFIX})
2323

2424
# Assume all works well
2525
# We can't test the compilers as they haven't been built yet

libclc/utils/prepare-builtins.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ int main(int argc, char **argv) {
7575
if (NamedMDNode *OCLVersion = M->getNamedMetadata("opencl.ocl.version"))
7676
M->eraseNamedMetadata(OCLVersion);
7777

78+
// wchar_size flag can cause a mismatch between libclc libraries and
79+
// modules using them. Since wchar is not used by libclc we drop the flag
80+
if (M->getModuleFlag("wchar_size")) {
81+
SmallVector<Module::ModuleFlagEntry, 4> ModuleFlags;
82+
M->getModuleFlagsMetadata(ModuleFlags);
83+
M->getModuleFlagsMetadata()->clearOperands();
84+
for (const Module::ModuleFlagEntry ModuleFlag : ModuleFlags)
85+
if (ModuleFlag.Key->getString() != "wchar_size")
86+
M->addModuleFlag(ModuleFlag.Behavior, ModuleFlag.Key->getString(),
87+
ModuleFlag.Val);
88+
}
89+
7890
// Set linkage of every external definition to linkonce_odr.
7991
for (Module::iterator i = M->begin(), e = M->end(); i != e; ++i) {
8092
if (!i->isDeclaration() && i->getLinkage() == GlobalValue::ExternalLinkage)

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#pragma once
1515

1616
#include <CL/sycl/backend_types.hpp>
17-
#include <CL/sycl/detail/common.hpp>
1817
#include <CL/sycl/detail/export.hpp>
1918
#include <CL/sycl/detail/os_util.hpp>
2019
#include <CL/sycl/detail/pi.h>
2120

2221
#include <cassert>
2322
#include <cstdint>
23+
#include <memory>
2424
#include <sstream>
2525
#include <string>
2626
#include <vector>

sycl/plugins/cuda/CMakeLists.txt

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ find_package(CUDA 10.1 REQUIRED)
99
# Make imported library global to use it within the project.
1010
add_library(cudadrv SHARED IMPORTED GLOBAL)
1111

12-
set_target_properties(
13-
cudadrv PROPERTIES
14-
IMPORTED_LOCATION ${CUDA_CUDA_LIBRARY}
15-
INTERFACE_INCLUDE_DIRECTORIES ${CUDA_INCLUDE_DIRS}
16-
)
12+
if (WIN32)
13+
set_target_properties(
14+
cudadrv PROPERTIES
15+
IMPORTED_IMPLIB ${CUDA_CUDA_LIBRARY}
16+
INTERFACE_INCLUDE_DIRECTORIES ${CUDA_INCLUDE_DIRS}
17+
)
18+
else()
19+
set_target_properties(
20+
cudadrv PROPERTIES
21+
IMPORTED_LOCATION ${CUDA_CUDA_LIBRARY}
22+
INTERFACE_INCLUDE_DIRECTORIES ${CUDA_INCLUDE_DIRS}
23+
)
24+
endif()
1725

1826
add_library(pi_cuda SHARED
1927
"${sycl_inc_dir}/CL/sycl/detail/pi.h"
@@ -37,6 +45,24 @@ target_link_libraries(pi_cuda
3745
cudadrv
3846
)
3947

48+
if (MSVC)
49+
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
50+
# which are individually tagged for all pi* symbols in pi.h
51+
target_compile_definitions(pi_cuda PRIVATE __SYCL_BUILD_SYCL_DLL)
52+
else()
53+
# we set the visibility of all symbols 'hidden' by default.
54+
# In pi.h file, we set exported symbols with visibility==default individually
55+
target_compile_options(pi_cuda PUBLIC -fvisibility=hidden)
56+
57+
# This script file is used to allow exporting pi* symbols only.
58+
# All other symbols are regarded as local (hidden)
59+
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
60+
61+
# Filter symbols based on the scope defined in the script file,
62+
# and export pi* function symbols in the library.
63+
target_link_libraries(pi_cuda PRIVATE "-Wl,--version-script=${linker_script}")
64+
endif()
65+
4066
add_common_options(pi_cuda)
4167

4268
install(TARGETS pi_cuda

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,10 @@ pi_result cuda_piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms,
686686
static pi_uint32 numPlatforms = 1;
687687
static _pi_platform platformId;
688688

689-
if (num_entries == 0 and platforms != nullptr) {
689+
if (num_entries == 0 && platforms != nullptr) {
690690
return PI_INVALID_VALUE;
691691
}
692-
if (platforms == nullptr and num_platforms == nullptr) {
692+
if (platforms == nullptr && num_platforms == nullptr) {
693693
return PI_INVALID_VALUE;
694694
}
695695

@@ -4503,7 +4503,7 @@ pi_result cuda_piextUSMFree(pi_context context, void *ptr) {
45034503
CU_POINTER_ATTRIBUTE_MEMORY_TYPE};
45044504
result = PI_CHECK_ERROR(cuPointerGetAttributes(
45054505
2, attributes, attribute_values, (CUdeviceptr)ptr));
4506-
assert(type == CU_MEMORYTYPE_DEVICE or type == CU_MEMORYTYPE_HOST);
4506+
assert(type == CU_MEMORYTYPE_DEVICE || type == CU_MEMORYTYPE_HOST);
45074507
if (is_managed || type == CU_MEMORYTYPE_DEVICE) {
45084508
// Memory allocated with cuMemAlloc and cuMemAllocManaged must be freed
45094509
// with cuMemFree
@@ -4707,7 +4707,7 @@ pi_result cuda_piextUSMGetMemAllocInfo(pi_context context, const void *ptr,
47074707
}
47084708
result = PI_CHECK_ERROR(cuPointerGetAttribute(
47094709
&value, CU_POINTER_ATTRIBUTE_MEMORY_TYPE, (CUdeviceptr)ptr));
4710-
assert(value == CU_MEMORYTYPE_DEVICE or value == CU_MEMORYTYPE_HOST);
4710+
assert(value == CU_MEMORYTYPE_DEVICE || value == CU_MEMORYTYPE_HOST);
47114711
if (value == CU_MEMORYTYPE_DEVICE) {
47124712
// pointer to device memory
47134713
return getInfo(param_value_size, param_value, param_value_size_ret,
@@ -4719,7 +4719,11 @@ pi_result cuda_piextUSMGetMemAllocInfo(pi_context context, const void *ptr,
47194719
PI_MEM_TYPE_HOST);
47204720
}
47214721
// should never get here
4722+
#ifdef _MSC_VER
4723+
__assume(0);
4724+
#else
47224725
__builtin_unreachable();
4726+
#endif
47234727
return getInfo(param_value_size, param_value, param_value_size_ret,
47244728
PI_MEM_TYPE_UNKNOWN);
47254729
}

sycl/unittests/pi/TestGetPlugin.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
#include <algorithm>
99
#include <detail/plugin.hpp>
1010
#include <functional>
11+
#include <optional>
1112

1213
namespace pi {
13-
inline cl::sycl::detail::plugin *initializeAndGet(cl::sycl::backend backend) {
14+
inline std::optional<cl::sycl::detail::plugin>
15+
initializeAndGet(cl::sycl::backend backend) {
1416
auto plugins = cl::sycl::detail::pi::initialize();
1517
auto it = std::find_if(plugins.begin(), plugins.end(),
1618
[=](cl::sycl::detail::plugin p) -> bool {
@@ -20,9 +22,9 @@ inline cl::sycl::detail::plugin *initializeAndGet(cl::sycl::backend backend) {
2022
std::string msg = GetBackendString(backend);
2123
msg += " PI plugin not found!";
2224
std::cerr << "Warning: " << msg << " Tests using it will be skipped.\n";
23-
return nullptr;
25+
return std::nullopt;
2426
}
25-
return &*it;
27+
return std::optional<cl::sycl::detail::plugin>(*it);
2628
}
2729

2830
inline std::vector<cl::sycl::detail::plugin> initializeAndRemoveInvalid() {

sycl/unittests/pi/cuda/test_base_objects.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ using namespace cl::sycl;
2424

2525
class CudaBaseObjectsTest : public ::testing::Test {
2626
protected:
27-
detail::plugin *plugin = pi::initializeAndGet(backend::cuda);
27+
std::optional<detail::plugin> plugin = pi::initializeAndGet(backend::cuda);
2828

2929
void SetUp() override {
3030
// skip the tests if the CUDA backend is not available
31-
if (!plugin) {
31+
if (!plugin.has_value()) {
3232
GTEST_SKIP();
3333
}
3434
}

sycl/unittests/pi/cuda/test_commands.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using namespace cl::sycl;
2121
struct CudaCommandsTest : public ::testing::Test {
2222

2323
protected:
24-
detail::plugin *plugin = pi::initializeAndGet(backend::cuda);
24+
std::optional<detail::plugin> plugin = pi::initializeAndGet(backend::cuda);
2525

2626
pi_platform platform_;
2727
pi_device device_;
@@ -30,7 +30,7 @@ struct CudaCommandsTest : public ::testing::Test {
3030

3131
void SetUp() override {
3232
// skip the tests if the CUDA backend is not available
33-
if (!plugin) {
33+
if (!plugin.has_value()) {
3434
GTEST_SKIP();
3535
}
3636

@@ -65,7 +65,7 @@ struct CudaCommandsTest : public ::testing::Test {
6565
}
6666

6767
void TearDown() override {
68-
if (plugin) {
68+
if (plugin.has_value()) {
6969
plugin->call<detail::PiApiKind::piQueueRelease>(queue_);
7070
plugin->call<detail::PiApiKind::piContextRelease>(context_);
7171
}

sycl/unittests/pi/cuda/test_contexts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ using namespace cl::sycl;
2525
struct CudaContextsTest : public ::testing::Test {
2626

2727
protected:
28-
detail::plugin *plugin = pi::initializeAndGet(backend::cuda);
28+
std::optional<detail::plugin> plugin = pi::initializeAndGet(backend::cuda);
2929

3030
pi_platform platform_;
3131
pi_device device_;
3232

3333
void SetUp() override {
3434
// skip the tests if the CUDA backend is not available
35-
if (!plugin) {
35+
if (!plugin.has_value()) {
3636
GTEST_SKIP();
3737
}
3838

sycl/unittests/pi/cuda/test_device.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ using namespace cl::sycl;
2121
struct CudaDeviceTests : public ::testing::Test {
2222

2323
protected:
24-
detail::plugin *plugin = pi::initializeAndGet(backend::cuda);
24+
std::optional<detail::plugin> plugin = pi::initializeAndGet(backend::cuda);
2525

2626
pi_platform platform_;
2727
pi_device device_;
2828
pi_context context_;
2929

3030
void SetUp() override {
3131
// skip the tests if the CUDA backend is not available
32-
if (!plugin) {
32+
if (!plugin.has_value()) {
3333
GTEST_SKIP();
3434
}
3535

@@ -56,7 +56,7 @@ struct CudaDeviceTests : public ::testing::Test {
5656
}
5757

5858
void TearDown() override {
59-
if (plugin) {
59+
if (plugin.has_value()) {
6060
plugin->call<detail::PiApiKind::piDeviceRelease>(device_);
6161
plugin->call<detail::PiApiKind::piContextRelease>(context_);
6262
}

sycl/unittests/pi/cuda/test_kernels.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ using namespace cl::sycl;
2424
struct CudaKernelsTest : public ::testing::Test {
2525

2626
protected:
27-
detail::plugin *plugin = pi::initializeAndGet(backend::cuda);
27+
std::optional<detail::plugin> plugin = pi::initializeAndGet(backend::cuda);
2828
pi_platform platform_;
2929
pi_device device_;
3030
pi_context context_;
3131
pi_queue queue_;
3232

3333
void SetUp() override {
3434
// skip the tests if the CUDA backend is not available
35-
if (!plugin) {
35+
if (!plugin.has_value()) {
3636
GTEST_SKIP();
3737
}
3838

@@ -65,7 +65,7 @@ struct CudaKernelsTest : public ::testing::Test {
6565
}
6666

6767
void TearDown() override {
68-
if (plugin) {
68+
if (plugin.has_value()) {
6969
plugin->call<detail::PiApiKind::piDeviceRelease>(device_);
7070
plugin->call<detail::PiApiKind::piQueueRelease>(queue_);
7171
plugin->call<detail::PiApiKind::piContextRelease>(context_);

0 commit comments

Comments
 (0)