@@ -303,7 +303,7 @@ cdef class SyclQueue:
303
303
"""
304
304
305
305
@staticmethod
306
- cdef SyclQueue _create (DPCTLSyclQueueRef qref):
306
+ cdef SyclQueue _create(DPCTLSyclQueueRef qref):
307
307
if qref is NULL :
308
308
raise SyclQueueCreationError(" Queue creation failed." )
309
309
cdef SyclQueue ret = SyclQueue.__new__ (SyclQueue)
@@ -605,7 +605,7 @@ cdef class _SyclRTManager:
605
605
cdef dict _backend_enum_ty_dict
606
606
cdef dict _device_enum_ty_dict
607
607
608
- def __cinit__ (self ):
608
+ def __cinit__ (self ):
609
609
610
610
self ._backend_str_ty_dict = {
611
611
" opencl" : _backend_type._OPENCL,
@@ -627,7 +627,7 @@ cdef class _SyclRTManager:
627
627
device_type.gpu : _device_type._GPU,
628
628
}
629
629
630
- def _set_as_current_queue (self , backend_ty , device_ty , device_id ):
630
+ def _set_as_current_queue (self , backend_ty , device_ty , device_id ):
631
631
cdef DPCTLSyclQueueRef queue_ref
632
632
633
633
try :
@@ -642,45 +642,47 @@ cdef class _SyclRTManager:
642
642
raise UnsupportedBackendError(" Backend can only be opencl or "
643
643
" level-0" )
644
644
645
- def _remove_current_queue (self ):
645
+ def _remove_current_queue (self ):
646
646
DPCTLQueueMgr_PopQueue()
647
647
648
- def dump (self ):
648
+ def dump (self ):
649
649
""" Prints information about the Runtime object.
650
650
"""
651
651
DPCTLPlatform_DumpInfo()
652
652
653
- def print_available_backends (self ):
654
- """ Prints the available backends.
653
+ def print_available_backends (self ):
654
+ """ Prints the available SYCL backends.
655
655
"""
656
656
print (self ._backend_str_ty_dict.keys())
657
657
658
- cpdef get_current_backend (self ):
659
- """ Returns the backend for the current queue as `backend_type` enum
658
+ cpdef get_current_backend(self ):
659
+ """ Returns the backend for the current queue as a `backend_type` enum
660
660
"""
661
661
return self .get_current_queue().get_sycl_backend()
662
662
663
- cpdef get_current_device_type (self ):
664
- """ Returns current device type as `device_type` enum
663
+ cpdef get_current_device_type(self ):
664
+ """ Returns current device type as a `device_type` enum
665
665
"""
666
666
return self .get_current_queue().get_sycl_device().get_device_type()
667
667
668
- cpdef SyclQueue get_current_queue (self ):
669
- """ Returns the activated SYCL queue as a PyCapsule.
668
+ cpdef SyclQueue get_current_queue(self ):
669
+ """ Returns the currently activate SYCL queue as a new SyclQueue object.
670
+ If there are no active queues then a SyclQueueCreationError exception is
671
+ raised.
670
672
"""
671
673
return SyclQueue._create(DPCTLQueueMgr_GetCurrentQueue())
672
674
673
- def get_num_activated_queues (self ):
674
- """ Return the number of currently activated queues for this thread.
675
+ def get_num_activated_queues (self ):
676
+ """ Returns the number of currently activated queues for this thread.
675
677
"""
676
678
return DPCTLQueueMgr_GetNumActivatedQueues()
677
679
678
- def get_num_platforms (self ):
680
+ def get_num_platforms (self ):
679
681
""" Returns the number of available non-host SYCL platforms.
680
682
"""
681
683
return DPCTLPlatform_GetNumNonHostPlatforms()
682
684
683
- def get_num_queues (self , backend_ty , device_ty ):
685
+ def get_num_queues (self , backend_ty , device_ty ):
684
686
cdef size_t num = 0
685
687
try :
686
688
beTy = self ._backend_enum_ty_dict[backend_ty]
@@ -699,7 +701,7 @@ cdef class _SyclRTManager:
699
701
700
702
return num
701
703
702
- def has_gpu_queues (self , backend_ty = backend_type.opencl):
704
+ def has_gpu_queues (self , backend_ty = backend_type.opencl):
703
705
cdef size_t num = 0
704
706
try :
705
707
beTy = self ._backend_enum_ty_dict[backend_ty]
@@ -714,7 +716,7 @@ cdef class _SyclRTManager:
714
716
else :
715
717
return False
716
718
717
- def has_cpu_queues (self , backend_ty = backend_type.opencl):
719
+ def has_cpu_queues (self , backend_ty = backend_type.opencl):
718
720
cdef size_t num = 0
719
721
try :
720
722
beTy = self ._backend_enum_ty_dict[backend_ty]
@@ -729,21 +731,21 @@ cdef class _SyclRTManager:
729
731
else :
730
732
return False
731
733
732
- def has_sycl_platforms (self ):
734
+ def has_sycl_platforms (self ):
733
735
cdef size_t num_platforms = DPCTLPlatform_GetNumNonHostPlatforms()
734
736
if num_platforms:
735
737
return True
736
738
else :
737
739
return False
738
740
739
- def is_in_device_context (self ):
741
+ def is_in_device_context (self ):
740
742
cdef size_t num = DPCTLQueueMgr_GetNumActivatedQueues()
741
743
if num:
742
744
return True
743
745
else :
744
746
return False
745
747
746
- def set_default_queue (self , backend_ty , device_ty , device_id ):
748
+ def set_default_queue (self , backend_ty , device_ty , device_id ):
747
749
cdef DPCTLSyclQueueRef ret
748
750
try :
749
751
if isinstance (backend_ty, str ):
@@ -785,8 +787,17 @@ set_default_queue = _mgr.set_default_queue
785
787
is_in_device_context = _mgr.is_in_device_context
786
788
787
789
cpdef SyclQueue get_current_queue():
788
- """
789
- Obtain current Sycl Queue from Data Parallel Control package.
790
+ """ Returns the currently activate SYCL queue as a new SyclQueue object.
791
+
792
+ Returns:
793
+ SyclQueue: If there is a currently active SYCL queue that queue
794
+ is returned wrapped in a SyclQueue object. The SyclQueue object
795
+ owns a copy of the currently active SYCL queue as an opaque
796
+ `DPCTLSyclQueueRef` pointer. The pointer is freed when the SyclQueue
797
+ is garbage collected.
798
+
799
+ Raises:
800
+ SyclQueueCreationError: If no currently active SYCL queue found.
790
801
"""
791
802
return _mgr.get_current_queue()
792
803
@@ -805,7 +816,7 @@ cpdef get_current_backend():
805
816
from contextlib import contextmanager
806
817
807
818
@contextmanager
808
- def device_context (str queue_str = " opencl:gpu:0" ):
819
+ def device_context (str queue_str = " opencl:gpu:0" ):
809
820
"""
810
821
The SYCL queue defined by the "backend:device type:device id" tuple is
811
822
set as the currently active queue, *i.e.*, a subsequent call to
0 commit comments