@@ -94,74 +94,125 @@ struct TestDPCTLSyclUSMInterface : public ::testing::Test
94
94
95
95
TEST_F (TestDPCTLSyclUSMInterface, MallocShared)
96
96
{
97
- sycl::queue q;
98
- DPCTLSyclQueueRef Q = dpctl::syclinterface::wrap<sycl::queue>(&q);
99
- ASSERT_TRUE (Q);
97
+ DPCTLSyclDeviceSelectorRef DSRef = DPCTLDefaultSelector_Create ();
98
+ ASSERT_TRUE (DSRef);
99
+ DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector (DSRef);
100
+ DPCTLDeviceSelector_Delete (DSRef);
101
+ ASSERT_TRUE (DRef);
102
+ DPCTLSyclQueueRef QRef =
103
+ DPCTLQueue_CreateForDevice (DRef, NULL , DPCTL_DEFAULT_PROPERTY);
104
+ DPCTLDevice_Delete (DRef);
105
+ ASSERT_TRUE (QRef);
106
+
100
107
const size_t nbytes = SIZE;
101
- auto Ptr = DPCTLmalloc_shared (nbytes, Q );
108
+ auto Ptr = DPCTLmalloc_shared (nbytes, QRef );
102
109
EXPECT_TRUE (bool (Ptr));
103
- common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_SHARED);
104
- DPCTLfree_with_queue (Ptr, Q);
110
+ common_test_body (nbytes, Ptr, QRef, DPCTLSyclUSMType::DPCTL_USM_SHARED);
111
+ DPCTLfree_with_queue (Ptr, QRef);
112
+
113
+ DPCTLQueue_Delete (QRef);
105
114
}
106
115
107
116
TEST_F (TestDPCTLSyclUSMInterface, MallocDevice)
108
117
{
109
- sycl::queue q;
110
- DPCTLSyclQueueRef Q = dpctl::syclinterface::wrap<sycl::queue>(&q);
111
- ASSERT_TRUE (Q);
118
+ DPCTLSyclDeviceSelectorRef DSRef = DPCTLDefaultSelector_Create ();
119
+ ASSERT_TRUE (DSRef);
120
+ DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector (DSRef);
121
+ DPCTLDeviceSelector_Delete (DSRef);
122
+ ASSERT_TRUE (DRef);
123
+ DPCTLSyclQueueRef QRef =
124
+ DPCTLQueue_CreateForDevice (DRef, NULL , DPCTL_DEFAULT_PROPERTY);
125
+ DPCTLDevice_Delete (DRef);
126
+ ASSERT_TRUE (QRef);
127
+
112
128
const size_t nbytes = SIZE;
113
- auto Ptr = DPCTLmalloc_device (nbytes, Q );
129
+ auto Ptr = DPCTLmalloc_device (nbytes, QRef );
114
130
EXPECT_TRUE (bool (Ptr));
115
- common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_DEVICE);
116
- DPCTLfree_with_queue (Ptr, Q);
131
+ common_test_body (nbytes, Ptr, QRef, DPCTLSyclUSMType::DPCTL_USM_DEVICE);
132
+ DPCTLfree_with_queue (Ptr, QRef);
133
+
134
+ DPCTLQueue_Delete (QRef);
117
135
}
118
136
119
137
TEST_F (TestDPCTLSyclUSMInterface, MallocHost)
120
138
{
121
- sycl::queue q;
122
- DPCTLSyclQueueRef Q = dpctl::syclinterface::wrap<sycl::queue>(&q);
123
- ASSERT_TRUE (Q);
139
+ DPCTLSyclDeviceSelectorRef DSRef = DPCTLDefaultSelector_Create ();
140
+ ASSERT_TRUE (DSRef);
141
+ DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector (DSRef);
142
+ DPCTLDeviceSelector_Delete (DSRef);
143
+ ASSERT_TRUE (DRef);
144
+ DPCTLSyclQueueRef QRef =
145
+ DPCTLQueue_CreateForDevice (DRef, NULL , DPCTL_DEFAULT_PROPERTY);
146
+ DPCTLDevice_Delete (DRef);
147
+ ASSERT_TRUE (QRef);
148
+
124
149
const size_t nbytes = SIZE;
125
- auto Ptr = DPCTLmalloc_host (nbytes, Q );
150
+ auto Ptr = DPCTLmalloc_host (nbytes, QRef );
126
151
EXPECT_TRUE (bool (Ptr));
127
- common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_HOST);
128
- DPCTLfree_with_queue (Ptr, Q);
152
+ common_test_body (nbytes, Ptr, QRef, DPCTLSyclUSMType::DPCTL_USM_HOST);
153
+ DPCTLfree_with_queue (Ptr, QRef);
154
+ DPCTLQueue_Delete (QRef);
129
155
}
130
156
131
157
TEST_F (TestDPCTLSyclUSMInterface, AlignedAllocShared)
132
158
{
133
- sycl::queue q;
134
- DPCTLSyclQueueRef Q = dpctl::syclinterface::wrap<sycl::queue>(&q);
135
- ASSERT_TRUE (Q);
159
+ DPCTLSyclDeviceSelectorRef DSRef = DPCTLDefaultSelector_Create ();
160
+ ASSERT_TRUE (DSRef);
161
+ DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector (DSRef);
162
+ DPCTLDeviceSelector_Delete (DSRef);
163
+ ASSERT_TRUE (DRef);
164
+ DPCTLSyclQueueRef QRef =
165
+ DPCTLQueue_CreateForDevice (DRef, NULL , DPCTL_DEFAULT_PROPERTY);
166
+ DPCTLDevice_Delete (DRef);
167
+ ASSERT_TRUE (QRef);
168
+
136
169
const size_t nbytes = SIZE;
137
- auto Ptr = DPCTLaligned_alloc_shared (64 , nbytes, Q );
170
+ auto Ptr = DPCTLaligned_alloc_shared (64 , nbytes, QRef );
138
171
EXPECT_TRUE (bool (Ptr));
139
- common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_SHARED);
140
- DPCTLfree_with_queue (Ptr, Q);
172
+ common_test_body (nbytes, Ptr, QRef, DPCTLSyclUSMType::DPCTL_USM_SHARED);
173
+ DPCTLfree_with_queue (Ptr, QRef);
174
+ DPCTLQueue_Delete (QRef);
141
175
}
142
176
143
177
TEST_F (TestDPCTLSyclUSMInterface, AlignedAllocDevice)
144
178
{
145
- sycl::queue q;
146
- DPCTLSyclQueueRef Q = dpctl::syclinterface::wrap<sycl::queue>(&q);
147
- ASSERT_TRUE (Q);
179
+ DPCTLSyclDeviceSelectorRef DSRef = DPCTLDefaultSelector_Create ();
180
+ ASSERT_TRUE (DSRef);
181
+ DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector (DSRef);
182
+ DPCTLDeviceSelector_Delete (DSRef);
183
+ ASSERT_TRUE (DRef);
184
+ DPCTLSyclQueueRef QRef =
185
+ DPCTLQueue_CreateForDevice (DRef, NULL , DPCTL_DEFAULT_PROPERTY);
186
+ DPCTLDevice_Delete (DRef);
187
+ ASSERT_TRUE (QRef);
188
+
148
189
const size_t nbytes = SIZE;
149
- auto Ptr = DPCTLaligned_alloc_device (64 , nbytes, Q );
190
+ auto Ptr = DPCTLaligned_alloc_device (64 , nbytes, QRef );
150
191
EXPECT_TRUE (bool (Ptr));
151
- common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_DEVICE);
152
- DPCTLfree_with_queue (Ptr, Q);
192
+ common_test_body (nbytes, Ptr, QRef, DPCTLSyclUSMType::DPCTL_USM_DEVICE);
193
+ DPCTLfree_with_queue (Ptr, QRef);
194
+ DPCTLQueue_Delete (QRef);
153
195
}
154
196
155
197
TEST_F (TestDPCTLSyclUSMInterface, AlignedAllocHost)
156
198
{
157
- sycl::queue q;
158
- DPCTLSyclQueueRef Q = dpctl::syclinterface::wrap<sycl::queue>(&q);
159
- ASSERT_TRUE (Q);
199
+ DPCTLSyclDeviceSelectorRef DSRef = DPCTLDefaultSelector_Create ();
200
+ ASSERT_TRUE (DSRef);
201
+ DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector (DSRef);
202
+ DPCTLDeviceSelector_Delete (DSRef);
203
+ ASSERT_TRUE (DRef);
204
+ DPCTLSyclQueueRef QRef =
205
+ DPCTLQueue_CreateForDevice (DRef, NULL , DPCTL_DEFAULT_PROPERTY);
206
+ DPCTLDevice_Delete (DRef);
207
+ ASSERT_TRUE (QRef);
208
+
160
209
const size_t nbytes = SIZE;
161
- auto Ptr = DPCTLaligned_alloc_host (64 , nbytes, Q );
210
+ auto Ptr = DPCTLaligned_alloc_host (64 , nbytes, QRef );
162
211
EXPECT_TRUE (bool (Ptr));
163
- common_test_body (nbytes, Ptr, Q, DPCTLSyclUSMType::DPCTL_USM_HOST);
164
- DPCTLfree_with_queue (Ptr, Q);
212
+ common_test_body (nbytes, Ptr, QRef, DPCTLSyclUSMType::DPCTL_USM_HOST);
213
+ DPCTLfree_with_queue (Ptr, QRef);
214
+
215
+ DPCTLQueue_Delete (QRef);
165
216
}
166
217
167
218
struct TestDPCTLSyclUSMNullArgs : public ::testing::Test
0 commit comments