Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import base64
import ctypes
import struct
import threading

import numpy as np

Expand All @@ -58,14 +59,16 @@
# and be reused throughout the process. May revisit for stream pool if
# asynchronous write on CUDA shared memory region is requested
_dlpack_stream = {}
_dlpack_stream_lock = threading.Lock()


# Helper function to retrieve internally managed CUDA stream
def _get_or_create_global_cuda_stream(device_id):
global _dlpack_stream
if device_id not in _dlpack_stream:
_dlpack_stream[device_id] = CudaStream(device_id)
return _dlpack_stream[device_id]._stream
with _dlpack_stream_lock:
if device_id not in _dlpack_stream:
_dlpack_stream[device_id] = CudaStream(device_id)
return _dlpack_stream[device_id]._stream


def _support_uva(shm_device_id, ext_device_id):
Expand Down