@@ -481,7 +481,6 @@ cdef class _SyclRTManager:
481
481
'''
482
482
cdef dict _backend_ty_dict
483
483
cdef dict _device_ty_dict
484
- cdef SyclQueue current_queue
485
484
486
485
def __cinit__ (self ):
487
486
@@ -518,6 +517,16 @@ cdef class _SyclRTManager:
518
517
'''
519
518
DPPLPlatform_DumpInfo()
520
519
520
+ def print_available_backends (self ):
521
+ """ Prints the available backends.
522
+ """
523
+ print (self ._backend_ty_dict.keys())
524
+
525
+ def get_current_backend (self ):
526
+ """ Returns the backend for the current queue as `backend_type` enum
527
+ """
528
+ return self .get_current_queue().get_sycl_backend()
529
+
521
530
def get_current_device_type (self ):
522
531
''' Returns current device type as `device_type` enum
523
532
'''
@@ -613,9 +622,9 @@ def create_program_from_source (SyclQueue q, unicode source, unicode copts=""):
613
622
copts (unicode) : Optional compilation flags that will be used
614
623
when compiling the program.
615
624
616
- Returns:
617
- program (SyclProgram): A SyclProgram object wrapping the
618
- syc::program returned by the C API.
625
+ Returns:
626
+ program (SyclProgram): A SyclProgram object wrapping the
627
+ syc::program returned by the C API.
619
628
'''
620
629
621
630
cdef DPPLSyclProgramRef Pref
@@ -674,9 +683,14 @@ def device_context (str queue_str="opencl:gpu:0"):
674
683
# If set_context is unable to create a new context an exception is raised.
675
684
try :
676
685
attrs = queue_str.split(' :' )
677
- if len (attrs) != 3 :
686
+ nattrs = len (attrs)
687
+ if (nattrs < 2 or nattrs > 3 ):
678
688
raise ValueError (" Invalid device context string. Should be "
679
- " backend:device:device_number" )
689
+ " backend:device:device_number or "
690
+ " backend:device. In the later case the "
691
+ " device_number defaults to 0" )
692
+ if nattrs == 2 :
693
+ attrs.append(" 0" )
680
694
ctxt = None
681
695
ctxt = _mgr._set_as_current_queue(attrs[0 ], attrs[1 ], int (attrs[2 ]))
682
696
yield ctxt
0 commit comments