@@ -179,9 +179,15 @@ struct dpctl_capi
179
179
: default_sycl_queue {}, default_usm_memory {}, default_usm_ndarray {},
180
180
as_usm_memory {}
181
181
{
182
- // Import Cython CAPI for dpctl
182
+ // Import Cython-generated C-API for dpctl
183
+ // This imports python modules and initializes
184
+ // static variables such as function pointers for C-API,
185
+ // e.g. SyclDevice_GetDeviceRef, etc.
186
+ // pointers to Python types, i.e. PySyclDeviceType, etc.
187
+ // and exported constants, i.e. USM_ARRAY_C_CONTIGUOUS, etc.
183
188
import_dpctl ();
184
189
190
+ // Python type objects for classes implemented by dpctl
185
191
this -> Py_SyclDeviceType_ = & Py_SyclDeviceType ;
186
192
this -> PySyclDeviceType_ = & PySyclDeviceType ;
187
193
this -> Py_SyclContextType_ = & Py_SyclContextType ;
@@ -212,12 +218,14 @@ struct dpctl_capi
212
218
this -> SyclQueue_GetQueueRef_ = SyclQueue_GetQueueRef ;
213
219
this -> SyclQueue_Make_ = SyclQueue_Make ;
214
220
221
+ // dpctl.memory API
215
222
this -> Memory_GetUsmPointer_ = Memory_GetUsmPointer ;
216
223
this -> Memory_GetContextRef_ = Memory_GetContextRef ;
217
224
this -> Memory_GetQueueRef_ = Memory_GetQueueRef ;
218
225
this -> Memory_GetNumBytes_ = Memory_GetNumBytes ;
219
226
this -> Memory_Make_ = Memory_Make ;
220
227
228
+ // dpctl.tensor.usm_ndarray API
221
229
this -> UsmNDArray_GetData_ = UsmNDArray_GetData ;
222
230
this -> UsmNDArray_GetNDim_ = UsmNDArray_GetNDim ;
223
231
this -> UsmNDArray_GetShape_ = UsmNDArray_GetShape ;
@@ -228,6 +236,7 @@ struct dpctl_capi
228
236
this -> UsmNDArray_GetQueueRef_ = UsmNDArray_GetQueueRef ;
229
237
this -> UsmNDArray_GetOffset_ = UsmNDArray_GetOffset ;
230
238
239
+ // constants
231
240
this -> USM_ARRAY_C_CONTIGUOUS_ = USM_ARRAY_C_CONTIGUOUS ;
232
241
this -> USM_ARRAY_F_CONTIGUOUS_ = USM_ARRAY_F_CONTIGUOUS ;
233
242
this -> USM_ARRAY_WRITABLE_ = USM_ARRAY_WRITABLE ;
@@ -247,6 +256,7 @@ struct dpctl_capi
247
256
this -> UAR_TYPE_SENTINEL_ = UAR_TYPE_SENTINEL ;
248
257
this -> UAR_HALF_ = UAR_HALF ;
249
258
259
+ // deduced disjoint types
250
260
this -> UAR_INT8_ = UAR_BYTE ;
251
261
this -> UAR_UINT8_ = UAR_UBYTE ;
252
262
this -> UAR_INT16_ = UAR_SHORT ;
@@ -266,6 +276,8 @@ struct dpctl_capi
266
276
unsigned long long, unsigned int > (
267
277
UAR_ULONG , UAR_ULONGLONG , UAR_UINT );
268
278
279
+ // create shared pointers to python objects used in type-casters
280
+ // for dpctl::memory::usm_memory and dpctl::tensor::usm_ndarray
269
281
sycl ::queue q_ {};
270
282
PySyclQueueObject * py_q_tmp =
271
283
SyclQueue_Make (reinterpret_cast < DPCTLSyclQueueRef > (& q_ ));
0 commit comments