Why only first call to calCtxIsEventDone() non-blocking?
I've code very similar to example in CAL documentation:
int Run(...)
{
CALmodule module = 0;
calModuleLoad(&module, ctx, image);
CALfunc func = 0;
CALname inName, outName, constName;
calModuleGetEntry(&func, ctx, module, "main");
calModuleGetName(&inName, ctx, module, "i0");
calModuleGetName(&outName, ctx, module, "o0");
calModuleGetName(&constName, ctx, module, "cb0");
calCtxSetMem(ctx, inName, inputMem);
calCtxSetMem(ctx, outName, outputMem);
calCtxSetMem(ctx, constName, constMem);
CALdomain domain = {0, 0, dimx, dimy};
CALevent e = 0;
if (calCtxRunProgram(&e, p->ctx, func, &domain) != CAL_RESULT_OK) {
return 0;
}
int result = calCtxIsEventDone(p->ctx, e);
Do_CPU_Calculations();
while (calCtxIsEventDone(p->ctx, e) == CAL_RESULT_PENDING);
calResMap((CALvoid**)&oRes, &pitch, outputRes, 0);
// get results
calResUnmap(outputRes);
calModuleUnload(ctx, module);
return 1;
}
void main()
{
Init();
for (i=0; i<n; i++) {
PrepareData();
Run();
}
...
}
Problem is that only first call to calCtxIsEvenDone non-blocking, i.e.
it returns CAL_RESULT_PENDING, so it's possible to do cpu calculations
parallel to kernel execution. All other calls to calCtxIsEventDone ends
as stall until kernel fully executed and result returned always CAL_RESULT_OK, so no parallel CPU calculations possible.
Is it CAL bug or something else?