Template Function shad::rt::asyncForEachAt(Handle&, const Locality&, FunT&&, const std::shared_ptr<uint8_t>&, const uint32_t, const size_t)

Function Documentation

template <typename FunT>
void shad::rt::asyncForEachAt(Handle &handle, const Locality &loc, FunT &&func, const std::shared_ptr<uint8_t> &argsBuffer, const uint32_t bufferSize, const size_t numIters)

Execute a parallel loop at a specific locality asynchronously.

Typical Usage:

std::shared_ptr<uint8_t> buffer(new uint8_t[2]{ 5, 5 },
                                std::default_delete<uint8_t[]>());

Handle handle;
shad::rt::asyncForEachAt(locality,
    handle,
    [](Handle & handle, const uint8_t * input, const uint32_t size,
       size_t itrNum) {
      // Do something.
    },
    buffer, 2,
    iterations);
/* do something else */
shad::rt::waitForCompletion(handle);

Template Parameters
  • FunT: The type of the function to be executed. The function prototype must be:
    void(Handle &, const uint8_t *, const uint32_t, size_t itrNum);
    
    where the itrNum is the n-th iteration of the loop.
Parameters
  • handle: An Handle for the associated task-group.
  • loc: The Locality where the function must be executed.
  • func: The function to execute.
  • argsBuffer: A buffer of bytes to be passed to the function.
  • bufferSize: The size of the buffer argsBuffer passed.
  • numIters: The total number of iteration of the loop.