Skip to content

Commit 40df59e

Browse files
committed
Remove dlpack assertions and address other review comments
1 parent 70f0da6 commit 40df59e

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

cuda_core/examples/memory_ops.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
ProgramOptions,
1515
launch,
1616
)
17-
from cuda.core.experimental._dlpack import DLDeviceType
1817

1918
# Kernel for memory operations
2019
code = """
@@ -36,6 +35,8 @@
3635
dev = Device()
3736
dev.set_current()
3837
stream = dev.create_stream()
38+
# tell CuPy to use our stream as the current stream:
39+
cp.cuda.ExternalStream(int(stream.handle)).use()
3940

4041
# Compile kernel
4142
arch = "".join(f"{i}" for i in dev.compute_capability)
@@ -106,23 +107,12 @@
106107
# Verify the copy operation
107108
assert cp.allclose(new_device_array, pinned_array), "Pinned to device copy failed"
108109

109-
# Demonstrate DLPack integration
110-
print("\nDLPack device information:")
111-
print(f"Device buffer DLPack device: {device_buffer.__dlpack_device__()}")
112-
print(f"Pinned buffer DLPack device: {pinned_buffer.__dlpack_device__()}")
113-
114-
# Assert DLPack device types
115-
device_dlpack = device_buffer.__dlpack_device__()
116-
pinned_dlpack = pinned_buffer.__dlpack_device__()
117-
118-
assert device_dlpack[0] == DLDeviceType.kDLCUDA, "Device buffer should have CUDA device type"
119-
assert pinned_dlpack[0] == DLDeviceType.kDLCUDAHost, "Pinned buffer should have CUDA host device type"
120-
121110
# Clean up
122111
device_buffer.close(stream)
123112
pinned_buffer.close(stream)
124113
new_device_buffer.close(stream)
125114
stream.close()
115+
cp.cuda.Stream.null.use() # reset CuPy's current stream to the null stream
126116

127117
# Verify buffers are properly closed
128118
assert device_buffer.handle == 0, "Device buffer should be closed"

0 commit comments

Comments
 (0)