Template Function shad::rt::executeOnAll(FunT&&, const std::shared_ptr<uint8_t>&, const uint32_t)

Function Documentation

template <typename FunT>
void shad::rt::executeOnAll(FunT &&func, const std::shared_ptr<uint8_t> &argsBuffer, const uint32_t bufferSize)

Execute a function on all localities synchronously.

Typical Usage:

struct Args {
  int a;
  char b;
};

void task(const uint8_t *, const uint32_t) {  /* do something */ }

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

executeOnAll(task, ptr.get(), sizeof(Args));

Template Parameters
  • FunT: The type of the function to be executed. The function prototype must be:
    void(const uint8_t *, const uint32_t);
    
Parameters
  • func: The function to execute.
  • argsBuffer: A buffer of bytes to be passed to the function.
  • bufferSize: The size of the buffer argsBuffer passed.