Template Function shad::rt::asyncExecuteAtWithRetBuff(Handle&, const Locality&, FunT&&, const InArgsT&, uint8_t *, uint32_t *)¶
- Defined in File runtime.h
Function Documentation¶
-
template <typename FunT, typename InArgsT>
voidshad::rt
::
asyncExecuteAtWithRetBuff
(Handle &handle, 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(Handle & handle, const Args & args, const uint8_t *dst, uint32_t * outsize) { memcpy(&args, dst, sizeof(Args)); *outsize = sizeof(Args); } Args args { 2, 'a' }; std::vector<std::unique_ptr<uint8_t[]>> outBuffers(numLocalities()); std::vector<uint32_t> outSizes(numLocalities(), 0); for (auto & vecPtr : outBuffers) { std::unique_ptr<uint8_t[]> outbuff(new uint8_t[sizeof(Args)]); vecPtr = std::move(outbuff); } Handle handle; for (auto & locality : allLocalities()) { uint32_t localityID = static_cast<uint32_t>(locality); if (localityID % 2) // every call will overwrite outbuff asyncExecuteAtWithRetBuff( handle, locality, task, args, outBuffers[localityID].get(), &outSizes[localityID]); } waitForCompletion(handle);
- Template Parameters
FunT
: The type of the function to be executed. The function prototype must be:void(Handle &, 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
handle
: An Handle for the associated task-group.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