Skip to content

Commit

Permalink
Select correct devices when tests run with XOBJECTS_TEST_CONTEXTS
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlopaciuk committed Jun 24, 2024
1 parent 53d3a5f commit 87939d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions xobjects/context_cupy.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ def build_kernels(

return out_kernels

def __str__(self):
return f"{type(self).__name__}:{cupy.cuda.get_device_id()}"

def nparray_to_context_array(self, arr):
"""
Copies a numpy array to the device memory.
Expand Down
7 changes: 6 additions & 1 deletion xobjects/context_pyopencl.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def build_kernels(
fid.write(specialized_source)

prg = cl.Program(self.context, specialized_source).build(
options="-cl-std=CL2.0"
options="-cl-std=CL2.0",
)

out_kernels = {}
Expand All @@ -238,6 +238,11 @@ def build_kernels(

return out_kernels

def __str__(self):
platform_id = cl.get_platforms().index(self.platform)
device_id = self.platform.get_devices().index(self.device)
return f"{type(self).__name__}:{platform_id}.{device_id}"

def nparray_to_context_array(self, arr):
"""
Copies a numpy array to the device memory.
Expand Down

0 comments on commit 87939d5

Please sign in to comment.