RuntimeHandle

class RuntimeHandle

Public Functions

template<typename L, typename ...Args>
inline EventId submit(ResourceId target, L &&launcher, Args&&... args) const

Submit a single task to the runtime system.

Parameters:
  • index_space – The index space defining the task dimensions.

  • target – The target processor for the task.

  • launcher – The task launcher.

  • args – The arguments that are forwarded to the launcher.

Returns:

The event identifier for the submitted task.

template<typename D, typename L, typename ...Args>
inline EventId parallel_submit(D &&domain, L &&launcher, Args&&... args) const

Submit a set of tasks to the runtime systems.

Parameters:
  • dist – The domain describing how the work is split.

  • launcher – The task launcher.

  • args – The arguments that are forwarded to the launcher.

Returns:

The event identifier for the submitted task.

template<size_t N = DOMAIN_DIMS, typename L, typename ...Args>
inline EventId parallel_submit(Dim<N> domain_size, Dim<N> chunk_size, L &&launcher, Args&&... args) const

Submit a set of tasks to the runtime systems.

Parameters:
  • domain_size – The index space defining the domain dimensions.

  • partitioner – The partitioner describing how the work is split.

  • launcher – The task launcher.

  • args – The arguments that are forwarded to the launcher.

Returns:

The event identifier for the submitted task.

template<size_t N = 1, typename T>
inline Array<T, N> allocate(const T *data, Dim<N> shape, MemoryId memory_id) const

Allocates an array in memory with the given shape and memory affinity.

The pointer to the given buffer should contain shape[0] * shape[1] * shape[2]... elements.

Parameters:
  • data – Pointer to the array data.

  • shape – Shape of the array.

  • memory_id – Identifier of the memory region.

Returns:

The allocated Array object.

template<size_t N = 1, typename T>
inline Array<T, N> allocate(const T *data, Dim<N> shape) const

Allocates an array in memory with the given shape.

The pointer to the given buffer should contain shape[0] * shape[1] * shape[2]... elements.

In which memory the data will be allocated is determined by memory_affinity_for_address.

Parameters:
  • data – Pointer to the array data.

  • shape – Shape of the array.

Returns:

The allocated Array object.

template<typename T, size_t N = 1>
inline Array<T, N> allocate(View<T, N> v) const

Alias for allocate(v.data(), v.sizes())

template<typename T, typename ...Is>
inline Array<T, sizeof...(Is)> allocate(const T *data, const Is&... num_elements) const

Alias for allocate(data, Dim<N>{sizes...})

template<typename T>
inline Array<T> allocate(const std::vector<T> &v) const

Alias for allocate(v.data(), v.size())

template<typename T>
inline Array<T> allocate(std::initializer_list<T> v) const

Alias for allocate(v.begin(), v.size())

MemoryId memory_affinity_for_address(const void *address) const

Returns the memory affinity for a given address.

EventId join(EventList events) const

Returns a new event that triggers when all the given events have triggered.

template<typename ...Es>
inline EventId join(Es... events) const

Returns a new event that triggers when all the given events have triggered. Each argument must be convertible to an EventId.

bool is_done(EventId) const

Returns true if the event with the provided identifier has finished, or false otherwise.

void wait(EventId id) const

Block the current thread until the event with the provided identifier completes.

bool wait_until(EventId id, 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 returns false.

bool wait_for(EventId id, 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 returns false.

EventId 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.

RuntimeHandle constrain_to(std::vector<ResourceId> resources) const

Return a new RuntimeHandle that is constrained to the given set of resources. In other words, it only can submit work onto those resources.

RuntimeHandle constrain_to(DeviceId device) const

Return a new RuntimeHandle that is constrained to the given device. In other words, it only can submit work onto that device.

RuntimeHandle constrain_to(ResourceId resource) const

Return a new RuntimeHandle that is constrained to the given resource. In other words, it only can submit work onto that resource.

const SystemInfo &info() const

Returns information about the current system.

Runtime &worker() const

Returns the inner Worker.