[CUDA] Recycle CUDA events (#2604)

* Make CudaEvent a CudaHandle

* Add caching for CudaEvent

* Make sure cuda events are destroyed at last

* Fix headers

* SharedEvent => AtomicEvent

* RawCudaEvent => CudaEventHandle, CudaEventWrapper => CopyableCudaEvent

* Remove unneeded asserts
This commit is contained in:
Cheng
2025-09-23 10:42:03 +09:00
committed by GitHub
parent 711a645807
commit ae438d05fa
6 changed files with 159 additions and 110 deletions

View File

@@ -15,8 +15,9 @@ bool is_available() {
}
void new_stream(Stream s) {
// Force initalization of cuda, so cuda runtime get destroyed at last.
cudaFree(nullptr);
// Force initalization of CUDA by creating an event, so the CUDA runtime and
// our CUDA event pool get destroyed last.
cu::CudaEvent(cudaEventDefault);
// Ensure the static stream objects get created.
cu::get_command_encoder(s);
}