Skip to content

Commit 87939d5

Browse files
Select correct devices when tests run with XOBJECTS_TEST_CONTEXTS
1 parent 53d3a5f commit 87939d5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

xobjects/context_cupy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ def build_kernels(
473473

474474
return out_kernels
475475

476+
def __str__(self):
477+
return f"{type(self).__name__}:{cupy.cuda.get_device_id()}"
478+
476479
def nparray_to_context_array(self, arr):
477480
"""
478481
Copies a numpy array to the device memory.

xobjects/context_pyopencl.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def build_kernels(
219219
fid.write(specialized_source)
220220

221221
prg = cl.Program(self.context, specialized_source).build(
222-
options="-cl-std=CL2.0"
222+
options="-cl-std=CL2.0",
223223
)
224224

225225
out_kernels = {}
@@ -238,6 +238,11 @@ def build_kernels(
238238

239239
return out_kernels
240240

241+
def __str__(self):
242+
platform_id = cl.get_platforms().index(self.platform)
243+
device_id = self.platform.get_devices().index(self.device)
244+
return f"{type(self).__name__}:{platform_id}.{device_id}"
245+
241246
def nparray_to_context_array(self, arr):
242247
"""
243248
Copies a numpy array to the device memory.

0 commit comments

Comments
 (0)