mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
[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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user