File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -207,10 +207,11 @@ cdef class SyclContext(_SyclContext):
207
207
devices.append(SyclDevice._create(DRef))
208
208
DPCTLDeviceVector_Delete(DVRef)
209
209
return devices
210
-
210
+
211
+ @property
211
212
def device_count (self ):
212
213
"""
213
- Returns the number of sycl devices associated with SyclContext instance.
214
+ The number of sycl devices associated with SyclContext instance.
214
215
"""
215
216
cdef size_t num_devs = DPCTLContext_DeviceCount(self .get_context_ref())
216
217
if num_devs:
@@ -224,7 +225,7 @@ cdef class SyclContext(_SyclContext):
224
225
return " SyclContext"
225
226
226
227
def __repr__ (self ):
227
- cdef size_t n = self .device_count()
228
+ cdef size_t n = self .device_count
228
229
if n == 1 :
229
230
return (" <dpctl." + self .__name__ + " at {}>" .format(hex (id (self ))))
230
231
else :
Original file line number Diff line number Diff line change 14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
17
- """ Defines unit test cases for the SyclQueue class.
17
+ """ Defines unit test cases for the SyclContxt class.
18
18
"""
19
19
20
20
import dpctl
21
21
import pytest
22
22
23
+
23
24
list_of_standard_selectors = [
24
25
dpctl .select_accelerator_device ,
25
26
dpctl .select_cpu_device ,
@@ -358,3 +359,24 @@ def test_context_equals():
358
359
except dpctl .SyclQueueCreationError :
359
360
pytest .skip ()
360
361
assert ctx0 .equals (ctx1 )
362
+
363
+
364
+ def test_context_can_be_used_in_queue (valid_filter ):
365
+ try :
366
+ ctx = dpctl .SyclContext (valid_filter )
367
+ except ValueError :
368
+ pytest .skip ()
369
+ devs = ctx .get_devices ()
370
+ assert len (devs ) == ctx .device_count
371
+ for d in devs :
372
+ q = dpctl .SyclQueue (ctx , d )
373
+
374
+
375
+ @pytest .mark .xfail (reason = "DPC++ bug in device equality" )
376
+ def test_context_can_be_used_in_queue2 (valid_filter ):
377
+ d = dpctl .SyclDevice (valid_filter )
378
+ if d .default_selector_score < 0 :
379
+ # skip test for devices rejected by default selector
380
+ pytest .skip ()
381
+ ctx = dpctl .SyclContext (d )
382
+ q = dpctl .SyclQueue (ctx , d )
You can’t perform that action at this time.
0 commit comments