Skip to content

Treeture

Martin Hartl edited this page Jan 8, 2018 · 1 revision

Treeture

The AllScale API provides the treeture class to reference the computation of a value.

Member functions

Treetures provide the following operations.

Member function Description
void wait() Wait for the referenced task to be completed
const T& get() Wait for the referenced task to be completed and return the result

There are additional functions to combine treetures:

Function Description
template<typename A, typename B, typename M>
auto combine(A&& a, B&& b, M&& m, bool parallel = true)
Creates a new treeture waiting for the result of the two given treetures a and b and computing a new result using the given combination function m. The boolean parallel determines if the execution of the treetures is done in parallel or sequential
template<typename A, typename B>
auto sequential(A&& a, B&& b)
Execution of the given treetures a and b is done sequentially
template<typename A, typename B>
auto parallel(A&& a, B&& b)
Execution of the given treetures a and b is done in parallel
static treeture done(const T& value) References a finished task that produces the given value.

Examples

auto t1 = done(42);
assert_eq(42, t1.get());

auto t2 = done(20);
auto t3 = done(22);

auto t4 = combine(std::move(t2), std::move(t3), [](const auto& v1, const auto& v2) {
    return v1 + v2; //add the results
}, true);

assert_eq(42, t4.get());
Clone this wiki locally