File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -265,3 +265,35 @@ def test_cpython_api_SyclDevice_Make():
265265
266266 d2 = make_d_fn (d .addressof_ref ())
267267 assert d == d2
268+
269+
270+ def test_get_device_id_method ():
271+ """
272+ Test that the get_device_id method reconstructs the same device.
273+ """
274+ devices = dpctl .get_devices ()
275+ for d in devices :
276+ dev_id = d .get_device_id ()
277+ d_r = dpctl .SyclDevice (str (dev_id ))
278+ assert dev_id == devices .index (d )
279+ assert d == d_r
280+ assert hash (d ) == hash (d_r )
281+
282+
283+ def test_sub_devices_disallow_device_id ():
284+ try :
285+ dev = dpctl .SyclDevice ()
286+ except dpctl .SyclDeviceCreationError :
287+ pytest .skip ("No default device available" )
288+ try :
289+ sdevs = dev .create_sub_devices (partition = "next_partitionable" )
290+ except dpctl .SyclSubDeviceCreationError :
291+ sdevs = None
292+ try :
293+ if sdevs is None :
294+ sdevs = dev .create_sub_devices (partition = [1 , 1 ])
295+ except dpctl .SyclSubDeviceCreationError :
296+ pytest .skip ("Default device can not be partitioned" )
297+ assert isinstance (sdevs , list ) and len (sdevs ) > 0
298+ with pytest .raises (TypeError ):
299+ sdevs [0 ].get_device_id ()
You can’t perform that action at this time.
0 commit comments