I would like to use offload, but the length of the result is not until the offload has finished. I was wondering about the correct method of doing this. Here is my idea. Will this work? Is there a more elegant way?
Georg
const char *pBufOut=NULL;
std::size_t lOutBufLen;
// compute result on MIC, alloc buffer, but return only length.
#pragma offload target(mic) out(lOutBufLen) nocopy(pBufOut: length(0) alloc_if(0) free_if(0))
{
// compute length of result
...
pBufOut=malloc(computedSize);
// copy contents of result to buffer
...
lOutBufLen=computedSize;
}
// create suitable buffer on host side
pBufOut=malloc(lOutBufLen);
// copy result to host side, deallocate memory on MIC, do nothing else...
#pragma offload target(mic) out(pBufOut: length(lOutBufLen) alloc_if(0) free_if(0))
{;}


