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