Skip to content

Commit cd27728

Browse files
Used 1-line context manage syntax to avoid coverage drop
1 parent 23b8884 commit cd27728

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

dpctl/_sycl_event.pyx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ cdef class _SyclEvent:
9898

9999
def __dealloc__(self):
100100
if (self._event_ref):
101-
with nogil:
102-
DPCTLEvent_Wait(self._event_ref)
101+
with nogil: DPCTLEvent_Wait(self._event_ref)
103102
DPCTLEvent_Delete(self._event_ref)
104103
self._event_ref = NULL
105104
self.args = None
@@ -225,8 +224,7 @@ cdef class SyclEvent(_SyclEvent):
225224

226225
@staticmethod
227226
cdef void _wait(SyclEvent event):
228-
with nogil:
229-
DPCTLEvent_WaitAndThrow(event._event_ref)
227+
with nogil: DPCTLEvent_WaitAndThrow(event._event_ref)
230228

231229
@staticmethod
232230
def wait_for(event):
@@ -372,5 +370,4 @@ cdef class SyclEvent(_SyclEvent):
372370

373371
cpdef void wait(self):
374372
"Synchronously wait for completion of this event."
375-
with nogil:
376-
DPCTLEvent_Wait(self._event_ref)
373+
with nogil: DPCTLEvent_Wait(self._event_ref)

dpctl/_sycl_queue.pyx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,7 @@ cdef class SyclQueue(_SyclQueue):
824824
return SyclEvent._create(Eref, args)
825825

826826
cpdef void wait(self):
827-
with nogil:
828-
DPCTLQueue_Wait(self._queue_ref)
827+
with nogil: DPCTLQueue_Wait(self._queue_ref)
829828

830829
cpdef memcpy(self, dest, src, size_t count):
831830
cdef void *c_dest
@@ -847,8 +846,7 @@ cdef class SyclQueue(_SyclQueue):
847846
raise RuntimeError(
848847
"SyclQueue.memcpy operation encountered an error"
849848
)
850-
with nogil:
851-
DPCTLEvent_Wait(ERef)
849+
with nogil: DPCTLEvent_Wait(ERef)
852850
DPCTLEvent_Delete(ERef)
853851

854852
cpdef prefetch(self, mem, size_t count=0):
@@ -868,8 +866,7 @@ cdef class SyclQueue(_SyclQueue):
868866
raise RuntimeError(
869867
"SyclQueue.prefetch encountered an error"
870868
)
871-
with nogil:
872-
DPCTLEvent_Wait(ERef)
869+
with nogil: DPCTLEvent_Wait(ERef)
873870
DPCTLEvent_Delete(ERef)
874871

875872
cpdef mem_advise(self, mem, size_t count, int advice):
@@ -889,8 +886,7 @@ cdef class SyclQueue(_SyclQueue):
889886
raise RuntimeError(
890887
"SyclQueue.mem_advise operation encountered an error"
891888
)
892-
with nogil:
893-
DPCTLEvent_Wait(ERef)
889+
with nogil: DPCTLEvent_Wait(ERef)
894890
DPCTLEvent_Delete(ERef)
895891

896892
@property

dpctl/memory/_memory.pyx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,15 @@ cdef void copy_via_host(void *dest_ptr, SyclQueue dest_queue,
9494
src_ptr,
9595
nbytes
9696
)
97-
with nogil:
98-
DPCTLEvent_Wait(E1Ref)
97+
with nogil: DPCTLEvent_Wait(E1Ref)
9998

10099
E2Ref = DPCTLQueue_Memcpy(
101100
dest_queue.get_queue_ref(),
102101
dest_ptr,
103102
<void *>&host_buf[0],
104103
nbytes
105104
)
106-
with nogil:
107-
DPCTLEvent_Wait(E2Ref)
105+
with nogil: DPCTLEvent_Wait(E2Ref)
108106
DPCTLEvent_Delete(E1Ref)
109107
DPCTLEvent_Delete(E2Ref)
110108

@@ -400,8 +398,7 @@ cdef class _Memory:
400398
<void *>self.memory_ptr, # source
401399
<size_t>self.nbytes
402400
)
403-
with nogil:
404-
DPCTLEvent_Wait(ERef)
401+
with nogil: DPCTLEvent_Wait(ERef)
405402
DPCTLEvent_Delete(ERef)
406403

407404
return obj
@@ -426,8 +423,7 @@ cdef class _Memory:
426423
<void *>&host_buf[0], # source
427424
<size_t>buf_len
428425
)
429-
with nogil:
430-
DPCTLEvent_Wait(ERef)
426+
with nogil: DPCTLEvent_Wait(ERef)
431427
DPCTLEvent_Delete(ERef)
432428

433429
cpdef copy_from_device(self, object sycl_usm_ary):
@@ -469,8 +465,7 @@ cdef class _Memory:
469465
<void *>src_buf.p,
470466
<size_t>src_buf.nbytes
471467
)
472-
with nogil:
473-
DPCTLEvent_Wait(ERef)
468+
with nogil: DPCTLEvent_Wait(ERef)
474469
DPCTLEvent_Delete(ERef)
475470
else:
476471
copy_via_host(

0 commit comments

Comments
 (0)