@@ -88,8 +88,8 @@ cdef class SyclContext(_SyclContext):
88
88
cdef int _init_from_one_device(self , SyclDevice device, int props):
89
89
cdef DPCTLSyclDeviceRef DRef = device.get_device_ref()
90
90
cdef DPCTLSyclContextRef CRef = NULL
91
- cdef error_handler_callback * eh_callback = \
92
- < error_handler_callback * > & default_async_error_handler
91
+ cdef error_handler_callback * eh_callback = (
92
+ < error_handler_callback * > & default_async_error_handler)
93
93
# look up cached contexts for root devices first
94
94
CRef = DPCTLDeviceMgr_GetCachedContext(DRef)
95
95
if (CRef is NULL ):
@@ -103,11 +103,11 @@ cdef class SyclContext(_SyclContext):
103
103
cdef int _init_from_devices(self , object devices, int props):
104
104
cdef int num_devices = len (devices)
105
105
cdef int i = 0
106
- cdef int j
106
+ cdef int j = 0
107
107
cdef size_t num_bytes
108
108
cdef DPCTLDeviceVectorRef DVRef = NULL
109
- cdef error_handler_callback * eh_callback = \
110
- < error_handler_callback * > & default_async_error_handler
109
+ cdef error_handler_callback * eh_callback = (
110
+ < error_handler_callback * > & default_async_error_handler)
111
111
cdef DPCTLSyclContextRef CRef = NULL
112
112
cdef DPCTLSyclDeviceRef * elems
113
113
@@ -120,17 +120,14 @@ cdef class SyclContext(_SyclContext):
120
120
if not isinstance (dev, SyclDevice):
121
121
elems[i] = NULL
122
122
else :
123
- elems[i] = DPCTLDevice_Copy(( < SyclDevice> dev).get_device_ref() )
123
+ elems[i] = ( < SyclDevice> dev).get_device_ref()
124
124
if (elems[i] is NULL ):
125
- for j in range (0 , i):
126
- DPCTLDevice_Delete(elems[j])
127
125
PyMem_Free(elems)
128
126
return - 4
129
127
i = i + 1
128
+ # CreateFromArray will make copies of devices referenced by elems
130
129
DVRef = DPCTLDeviceVector_CreateFromArray(num_devices, elems)
131
130
if (DVRef is NULL ):
132
- for j in range (num_devices):
133
- DPCTLDevice_Delete(elems[j])
134
131
PyMem_Free(elems)
135
132
return - 5
136
133
PyMem_Free(elems)
0 commit comments