Template Function shad::rt::asyncExecuteAtWithRet(Handle&, const Locality&, FunT&&, const std::shared_ptr<uint8_t>&, const uint32_t, ResT *)

Function Documentation

template <typename FunT, typename ResT>
void shad::rt::asyncExecuteAtWithRet(Handle &handle, const Locality &loc, FunT &&func, const std::shared_ptr<uint8_t> &argsBuffer, const uint32_t bufferSize, ResT *result)

Execute a function on a selected locality asynchronously and return a result.

Typical Usage:

struct Args {
  int a;
  char b;
};

void task(Handle & handle, const uint8_t *src, const uint32_t size,
          Args * res) {
  // Do something
}

Args args { 2, 'a' };
/* Args doesn't need a dynamic allocated buffer but
 * more complicated data structure might need it */
std::vector<std::unique_ptr<Args> outBuffers(numLocalities());
std::unique_ptr<uint8_t[]> ptr(new uint8_t[sizeof(Args)]);
memcpy(ptr.get(), &args, sizeof(Args));

Handle handle;
for (auto & locality : allLocalities()) {
  uint32_t localityID = static_cast<uint32_t>(locality);
  asyncExecuteAtWithRet(
    handle, locality, task, ptr.get(), sizeof(Args),
    &outBuffers[localityID]);
}
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, ResT *);
    
  • ResT: The type of the result value. The type can be a structure or a class but with the restriction that must be memcopy-able.
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.
  • result: The location where to store the result.