Highly Efficient FFT for Exascale: HeFFTe v2.4
|
Helper class to chain a series of compute calls with sycl::event. More...
#include <heffte_backend_oneapi.h>
Public Member Functions | |
event_chainer () | |
Constructor. | |
const std::vector< sycl::event > & | get_events () const |
Getter for the vector of events. | |
void | keep (sycl::event newEvent) |
Replace any stored event with the newEvent . | |
void | wait () |
Wait on the vector of events and then empty it. | |
Helper class to chain a series of compute calls with sycl::event.
Event dependencies can only be transferred to MKL in a std::vector, even when there is only one. This class maintains a vector of events for the purpose, so we minimize the amount of memory allocation needed. The vector is private so that the invariant of 0 or 1 elements is maintained.
Getting the first work started as fast as possible is important in latency-sensitive cases. We don't want the SYCL runtime to have to add a dependency for a null or previously-expired event. So we want the vector of events in this class to be empty at that time. So before an event is kept the vector is empty, and after waiting it is emptied. This creates more work resizing the vector in each call to keep(), but that work is just pointer comparison and arithmetic, and often overlaps with the submitted computation.
A typical use case looks like
event_chainer chainer; // ... foreach (auto& args : list_of_args) { sycl::event e = submit_work_with_dependencies(args, chainer.get_events()); chainer.keep(e); } // ... chainer.wait();
|
inline |
Replace any stored event with the newEvent
.
This assumes that the old event is no longer needed, because it was either waited upon or used as a dependency for another operation.