Template Function shad::rt::executeAtWithRetBuff(const Locality&, FunT&&, const InArgsT&, uint8_t *, uint32_t *)

Function Documentation

template <typename FunT, typename InArgsT>
void shad::rt::executeAtWithRetBuff(const Locality &loc, FunT &&func, const InArgsT &args, uint8_t *resultBuffer, uint32_t *resultSize)

Execute a function on a selected locality synchronously and return a buffer.

Typical Usage:

struct Args {
  int a;
  char b;
};

void task(const Args & args,
          const uint8_t *dst, uint32_t * outsize) {
  memcpy(&args, dst, sizeof(Args));
  *outsize = sizeof(Args);
}

Args args { 2, 'a' };
std::unique_ptr<uint8_t[]> outbuff(new uint8_t[sizeof(Args)]);
uint32_t size(0);
for (auto & locality : allLocalities)
  if (static_cast<uint32_t>(locality) % 2)
    // every call will overwrite outbuff
    executeAtWithRetBuffer(locality, task, args, outbuff.get(), &size);

Template Parameters
  • FunT: The type of the function to be executed. The function prototype must be:
    void(const InArgsT &, const uint8_t *, uint32_t *);
    
  • InArgsT: The type of the argument accepted by the function. The type can be a structure or a class but with the restriction that must be memcopy-able.
Parameters
  • loc: The Locality where the function must be executed.
  • func: The function to execute.
  • args: The arguments to be passed to the function.
  • resultBuffer: The buffer where to store the results.
  • resultSize: The location where the runtime will store the number of bytes written in the result buffer