@@ -24,7 +24,14 @@ using namespace cl::sycl;
24
24
25
25
class CudaBaseObjectsTest : public ::testing::Test {
26
26
protected:
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
+ }
28
35
29
36
CudaBaseObjectsTest () = default;
30
37
@@ -35,28 +42,28 @@ TEST_F(CudaBaseObjectsTest, piContextCreate) {
35
42
pi_uint32 numPlatforms = 0 ;
36
43
pi_platform platform = nullptr ;
37
44
pi_device device;
38
- ASSERT_EQ (plugin. getBackend (), backend::cuda);
45
+ ASSERT_EQ (plugin-> getBackend (), backend::cuda);
39
46
40
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
47
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
41
48
0 , nullptr , &numPlatforms)),
42
49
PI_SUCCESS)
43
50
<< " piPlatformsGet failed.\n " ;
44
51
45
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
52
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
46
53
numPlatforms, &platform, nullptr )),
47
54
PI_SUCCESS)
48
55
<< " piPlatformsGet failed.\n " ;
49
56
50
57
ASSERT_GE (numPlatforms, 1u );
51
58
ASSERT_NE (platform, nullptr );
52
59
53
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piDevicesGet>(
60
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piDevicesGet>(
54
61
platform, PI_DEVICE_TYPE_GPU, 1 , &device, nullptr )),
55
62
PI_SUCCESS)
56
63
<< " piDevicesGet failed.\n " ;
57
64
58
65
pi_context ctxt = nullptr ;
59
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextCreate>(
66
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextCreate>(
60
67
nullptr , 1 , &device, nullptr , nullptr , &ctxt)),
61
68
PI_SUCCESS)
62
69
<< " piContextCreate failed.\n " ;
@@ -79,24 +86,24 @@ TEST_F(CudaBaseObjectsTest, piContextCreatePrimaryTrue) {
79
86
pi_platform platform;
80
87
pi_device device;
81
88
82
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
89
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
83
90
0 , nullptr , &numPlatforms)),
84
91
PI_SUCCESS)
85
92
<< " piPlatformsGet failed.\n " ;
86
93
87
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
94
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
88
95
numPlatforms, &platform, nullptr )),
89
96
PI_SUCCESS)
90
97
<< " piPlatformsGet failed.\n " ;
91
98
92
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piDevicesGet>(
99
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piDevicesGet>(
93
100
platform, PI_DEVICE_TYPE_GPU, 1 , &device, nullptr )),
94
101
PI_SUCCESS);
95
102
pi_context_properties properties[] = {
96
103
__SYCL_PI_CONTEXT_PROPERTIES_CUDA_PRIMARY, PI_TRUE, 0 };
97
104
98
105
pi_context ctxt;
99
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextCreate>(
106
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextCreate>(
100
107
properties, 1 , &device, nullptr , nullptr , &ctxt)),
101
108
PI_SUCCESS);
102
109
EXPECT_NE (ctxt, nullptr );
@@ -115,7 +122,7 @@ TEST_F(CudaBaseObjectsTest, piContextCreatePrimaryTrue) {
115
122
cuErr = cuCtxGetCurrent (¤t);
116
123
ASSERT_EQ (cuErr, CUDA_SUCCESS);
117
124
ASSERT_EQ (current, cudaContext);
118
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
125
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
119
126
PI_SUCCESS);
120
127
}
121
128
@@ -124,24 +131,24 @@ TEST_F(CudaBaseObjectsTest, piContextCreatePrimaryFalse) {
124
131
pi_platform platform;
125
132
pi_device device;
126
133
127
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
134
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
128
135
0 , nullptr , &numPlatforms)),
129
136
PI_SUCCESS)
130
137
<< " piPlatformsGet failed.\n " ;
131
138
132
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
139
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
133
140
numPlatforms, &platform, nullptr )),
134
141
PI_SUCCESS)
135
142
<< " piPlatformsGet failed.\n " ;
136
143
137
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piDevicesGet>(
144
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piDevicesGet>(
138
145
platform, PI_DEVICE_TYPE_GPU, 1 , &device, nullptr )),
139
146
PI_SUCCESS);
140
147
pi_context_properties properties[] = {
141
148
__SYCL_PI_CONTEXT_PROPERTIES_CUDA_PRIMARY, PI_FALSE, 0 };
142
149
143
150
pi_context ctxt;
144
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextCreate>(
151
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextCreate>(
145
152
properties, 1 , &device, nullptr , nullptr , &ctxt)),
146
153
PI_SUCCESS);
147
154
EXPECT_NE (ctxt, nullptr );
@@ -160,7 +167,7 @@ TEST_F(CudaBaseObjectsTest, piContextCreatePrimaryFalse) {
160
167
cuErr = cuCtxGetCurrent (¤t);
161
168
ASSERT_EQ (cuErr, CUDA_SUCCESS);
162
169
ASSERT_EQ (current, cudaContext);
163
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
170
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
164
171
PI_SUCCESS);
165
172
}
166
173
@@ -169,22 +176,22 @@ TEST_F(CudaBaseObjectsTest, piContextCreateChildThread) {
169
176
pi_platform platform;
170
177
pi_device device;
171
178
172
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
179
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
173
180
0 , nullptr , &numPlatforms)),
174
181
PI_SUCCESS)
175
182
<< " piPlatformsGet failed.\n " ;
176
183
177
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piPlatformsGet>(
184
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piPlatformsGet>(
178
185
numPlatforms, &platform, nullptr )),
179
186
PI_SUCCESS)
180
187
<< " piPlatformsGet failed.\n " ;
181
188
182
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piDevicesGet>(
189
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piDevicesGet>(
183
190
platform, PI_DEVICE_TYPE_GPU, 1 , &device, nullptr )),
184
191
PI_SUCCESS);
185
192
186
193
pi_context ctxt;
187
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextCreate>(
194
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextCreate>(
188
195
nullptr , 1 , &device, nullptr , nullptr , &ctxt)),
189
196
PI_SUCCESS);
190
197
EXPECT_NE (ctxt, nullptr );
@@ -215,6 +222,6 @@ TEST_F(CudaBaseObjectsTest, piContextCreateChildThread) {
215
222
216
223
callContextFromOtherThread.join ();
217
224
218
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
225
+ ASSERT_EQ ((plugin-> call_nocheck <detail::PiApiKind::piContextRelease>(ctxt)),
219
226
PI_SUCCESS);
220
227
}
0 commit comments