@@ -24,7 +24,14 @@ using namespace cl::sycl;
2424
2525class CudaBaseObjectsTest : public ::testing::Test {
2626protected:
27- detail::plugin plugin = pi::initializeAndGet(backend::cuda);
27+ detail::plugin *plugin = pi::initializeAndGet(backend::cuda);
28+
29+ void SetUp () override {
30+ // skip the tests if the CUDA backend is not available
31+ if (!plugin) {
32+ GTEST_SKIP ();
33+ }
34+ }
2835
2936 CudaBaseObjectsTest () = default;
3037
@@ -35,28 +42,28 @@ TEST_F(CudaBaseObjectsTest, piContextCreate) {
3542 pi_uint32 numPlatforms = 0 ;
3643 pi_platform platform = nullptr ;
3744 pi_device device;
38- ASSERT_EQ (plugin. getBackend (), backend::cuda);
45+ ASSERT_EQ (plugin-> getBackend (), backend::cuda);
3946
40- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
47+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
4148 0 , nullptr , &numPlatforms)),
4249 PI_SUCCESS)
4350 << " piPlatformsGet failed.\n " ;
4451
45- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
52+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
4653 numPlatforms, &platform, nullptr )),
4754 PI_SUCCESS)
4855 << " piPlatformsGet failed.\n " ;
4956
5057 ASSERT_GE (numPlatforms, 1u );
5158 ASSERT_NE (platform, nullptr );
5259
53- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piDevicesGet>(
60+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piDevicesGet>(
5461 platform, PI_DEVICE_TYPE_GPU, 1 , &device, nullptr )),
5562 PI_SUCCESS)
5663 << " piDevicesGet failed.\n " ;
5764
5865 pi_context ctxt = nullptr ;
59- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextCreate>(
66+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextCreate>(
6067 nullptr , 1 , &device, nullptr , nullptr , &ctxt)),
6168 PI_SUCCESS)
6269 << " piContextCreate failed.\n " ;
@@ -79,24 +86,24 @@ TEST_F(CudaBaseObjectsTest, piContextCreatePrimaryTrue) {
7986 pi_platform platform;
8087 pi_device device;
8188
82- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
89+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
8390 0 , nullptr , &numPlatforms)),
8491 PI_SUCCESS)
8592 << " piPlatformsGet failed.\n " ;
8693
87- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
94+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
8895 numPlatforms, &platform, nullptr )),
8996 PI_SUCCESS)
9097 << " piPlatformsGet failed.\n " ;
9198
92- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piDevicesGet>(
99+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piDevicesGet>(
93100 platform, PI_DEVICE_TYPE_GPU, 1 , &device, nullptr )),
94101 PI_SUCCESS);
95102 pi_context_properties properties[] = {
96103 __SYCL_PI_CONTEXT_PROPERTIES_CUDA_PRIMARY, PI_TRUE, 0 };
97104
98105 pi_context ctxt;
99- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextCreate>(
106+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextCreate>(
100107 properties, 1 , &device, nullptr , nullptr , &ctxt)),
101108 PI_SUCCESS);
102109 EXPECT_NE (ctxt, nullptr );
@@ -115,7 +122,7 @@ TEST_F(CudaBaseObjectsTest, piContextCreatePrimaryTrue) {
115122 cuErr = cuCtxGetCurrent (¤t);
116123 ASSERT_EQ (cuErr, CUDA_SUCCESS);
117124 ASSERT_EQ (current, cudaContext);
118- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
125+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
119126 PI_SUCCESS);
120127}
121128
@@ -124,24 +131,24 @@ TEST_F(CudaBaseObjectsTest, piContextCreatePrimaryFalse) {
124131 pi_platform platform;
125132 pi_device device;
126133
127- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
134+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
128135 0 , nullptr , &numPlatforms)),
129136 PI_SUCCESS)
130137 << " piPlatformsGet failed.\n " ;
131138
132- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
139+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
133140 numPlatforms, &platform, nullptr )),
134141 PI_SUCCESS)
135142 << " piPlatformsGet failed.\n " ;
136143
137- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piDevicesGet>(
144+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piDevicesGet>(
138145 platform, PI_DEVICE_TYPE_GPU, 1 , &device, nullptr )),
139146 PI_SUCCESS);
140147 pi_context_properties properties[] = {
141148 __SYCL_PI_CONTEXT_PROPERTIES_CUDA_PRIMARY, PI_FALSE, 0 };
142149
143150 pi_context ctxt;
144- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextCreate>(
151+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextCreate>(
145152 properties, 1 , &device, nullptr , nullptr , &ctxt)),
146153 PI_SUCCESS);
147154 EXPECT_NE (ctxt, nullptr );
@@ -160,7 +167,7 @@ TEST_F(CudaBaseObjectsTest, piContextCreatePrimaryFalse) {
160167 cuErr = cuCtxGetCurrent (¤t);
161168 ASSERT_EQ (cuErr, CUDA_SUCCESS);
162169 ASSERT_EQ (current, cudaContext);
163- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
170+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
164171 PI_SUCCESS);
165172}
166173
@@ -169,22 +176,22 @@ TEST_F(CudaBaseObjectsTest, piContextCreateChildThread) {
169176 pi_platform platform;
170177 pi_device device;
171178
172- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
179+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
173180 0 , nullptr , &numPlatforms)),
174181 PI_SUCCESS)
175182 << " piPlatformsGet failed.\n " ;
176183
177- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
184+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
178185 numPlatforms, &platform, nullptr )),
179186 PI_SUCCESS)
180187 << " piPlatformsGet failed.\n " ;
181188
182- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piDevicesGet>(
189+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piDevicesGet>(
183190 platform, PI_DEVICE_TYPE_GPU, 1 , &device, nullptr )),
184191 PI_SUCCESS);
185192
186193 pi_context ctxt;
187- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextCreate>(
194+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextCreate>(
188195 nullptr , 1 , &device, nullptr , nullptr , &ctxt)),
189196 PI_SUCCESS);
190197 EXPECT_NE (ctxt, nullptr );
@@ -215,6 +222,6 @@ TEST_F(CudaBaseObjectsTest, piContextCreateChildThread) {
215222
216223 callContextFromOtherThread.join ();
217224
218- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
225+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
219226 PI_SUCCESS);
220227}
0 commit comments