Skip to content

Commit

Permalink
Temporary to simplify event creation
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Hemstad <[email protected]>
  • Loading branch information
wence- and jrhemstad authored Nov 8, 2023
1 parent 0d32e92 commit 76324e6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,14 @@ class stream_ordered_memory_resource : public crtp<PoolResource>, public device_
// main: it is undefined behaviour to call into the CUDA
// runtime below main.
thread_local std::vector<cudaEvent_t> events_tls(rmm::get_num_cuda_devices());
auto event = [device_id = this->device_id_]() {
if (events_tls[device_id.value()]) { return events_tls[device_id.value()]; }
RMM_ASSERT_CUDA_SUCCESS(
cudaEventCreateWithFlags(&events_tls[device_id.value()], cudaEventDisableTiming));
return events_tls[device_id.value()];
auto event = [device_id = this->device_id_]() {
auto& e = events_tls[device_id.value()];
if (!e) {
// These events are deliberately not destructed and therefore live until
// program exit.
RMM_ASSERT_CUDA_SUCCESS(cudaEventCreateWithFlags(&e, cudaEventDisableTiming));
}
return e;
}();
return stream_event_pair{stream.value(), event};
}
Expand Down

0 comments on commit 76324e6

Please sign in to comment.