# Copyright (c) 2024 Justin Davis (davisjustin302@gmail.com)## MIT License# mypy: disable-error-code="import-untyped"from__future__importannotationsimportcontextlibwithcontextlib.suppress(Exception):try:importcuda.bindings.runtimeascudartexcept(ImportError,ModuleNotFoundError):fromcudaimportcudartfrom._cudaimportcuda_call
[docs]defcreate_stream()->cudart.cudaStream_t:""" Create a CUDA Stream. Returns ------- cudart.cudaStream_t The CUDA stream. """returncuda_call(cudart.cudaStreamCreate())
[docs]defdestroy_stream(stream:cudart.cudaStream_t)->None:""" Destroy a CUDA Stream. Parameters ---------- stream : cudart.cudaStream_t The CUDA stream to destroy. """cuda_call(cudart.cudaStreamDestroy(stream))
[docs]defstream_synchronize(stream:cudart.cudaStream_t)->None:""" Copy a numpy array to a device pointer with error checking. Parameters ---------- stream : cudart.cudaStream_t The stream to synchronize calls for. """cuda_call(cudart.cudaStreamSynchronize(stream))