HPX - High Performance ParalleX

PrevUpHomeNext

Extensions for Task Blocks

In HPX we implemented some extensions for task_block beyond the actual standards porposal N4411. The main addition is that a task_block can be invoked with a execution policy as its first argument, very similar to the parallel algorithms.

template <typename Func>
int traverse(node& n, Func && compute)
{
    int left = 0, right = 0;
    define_task_block(
        par,                        // specify an execution policy
        [&](task_block<>& tr) {
            if (n.left)
                tr.run([&] { left = traverse(*n.left, compute); });
            if (n.right)
                tr.run([&] { right = traverse(*n.right, compute); });
        });

    return compute(n) + left + right;
}

This also causes the hpx::parallel::task_block object to be a template in our implementation. The template argment is the type of the execution policy used to create the task block. The template argment defaults to hpx::parallel::parallel_execution_policy.

HPX still supports calling hpx::parallel::define_task_block without an explicit execution policy. In this case the task block will run using the hpx::parallel::parallel_execution_policy.

HPX also adds the ability to access the execution policy which was used to create a given task_block.


PrevUpHomeNext