RuntimeHandle
-
class RuntimeHandle
Public Functions
Submit a task to the runtime system.
- Parameters:
task – The Task definition.
reqs – The task requirements.
- Returns:
The event identifier of the submitted task.
-
template<typename Launcher, typename ...Args>
inline EventId submit(Launcher launcher, Args&&... args) const Submit a task to the runtime system using a task launcher.
- Parameters:
launcher – The launcher that will submit the task.
args – The arguments that are forwarded to the launcher.
- Returns:
The event identifier of the submitted task.
-
template<typename Launcher>
inline DeviceId find_device(const Launcher &launcher) const Find the device identifier that would be used by the provided task launcher.
-
MemoryId memory_affinity_for_address(const void *address) const
Returns the memory identifier that has the best affinity for the given memory address.
-
template<typename T, size_t N>
inline Array<T, N> allocate_array(const T *data_ptr, std::array<index_t, N> sizes) const Create a new array where the data is provided by memory stored on the host. The dimensions of the new array will be
sizes
. The provided buffer must contain exactlysizes[0] * sizes[1] * ...
elements.- Parameters:
data_ptr – The provided data elements.
sizes – The dimensions of the new array.
- Returns:
The new array.
-
template<typename T, typename ...Sizes, size_t N = sizeof...(Sizes)>
inline Array<T, N> allocate(const T *data_ptr, Sizes... sizes) const Create a new array where the data is provided by memory stored on the host. The dimensions of the new array will be
{sizes[0], sizes[1], ...}
. The provided buffer must contain exactlysizes[0] * sizes[1] * ...
elements.- Parameters:
data_ptr – The provided data elements.
sizes – The dimensions of the new array.
- Returns:
The new array.
-
template<typename T>
inline Array<T> allocate(const std::vector<T> &vector) const This is an alias for
allocate(vector.data(), vector.size())
-
template<typename T, size_t N>
inline Array<T> allocate(view<T, N> input) const This is an alias for
allocate(input.data(), input.sizes())
-
template<typename T>
inline Array<T> allocate(std::initializer_list<T> list) const This is an alias for
allocate(list.data(), list.size())
-
EventId join(EventList events) const
Takes a list of events and returns a new event that gets triggered once all the provided events have completed.
-
template<typename ...Es>
inline EventId join(Es... events) const Takes a list of events and returns a new event that gets triggered once all the provided events have completed.
- Parameters:
events – The events. Each argument should be convertible to an EventId.
-
bool is_done(EventId id) const
Returns
true
if the event with the provided id has finished, otherwise returnsfalse
.
-
void wait(EventId id) const
Block the current thread until the event with the provided id completes.
-
bool wait_until(EventId id, typename std::chrono::system_clock::time_point deadline) const
Block the current thread until the event with the provided id completes. Blocks until either the event completes or the deadline is exceeded, whatever comes first.
- Returns:
true
if the event with the provided id has finished, otherwise returnsfalse
.
-
bool wait_for(EventId id, typename std::chrono::system_clock::duration duration) const
Block the current thread until the event with the provided id completes. Blocks until either the event completes or the duration is exceeded, whatever comes first.
- Returns:
true
if the event with the provided id has finished, otherwise returnsfalse
.
-
EventId submit_barrier() const
Submit a barrier the runtime system. The barrier completes once all the tasks submitted to the runtime system so far have finished.
- Returns:
The identifier of the barrier.
-
void synchronize() const
Blocks until all the tasks submitted to the runtime system have finished and the system has become idle.
-
inline std::shared_ptr<Runtime> inner() const
Returns the inner
RuntimeImpl
.- Returns:
The
RuntimeImpl
.