Discussion created by empty_knapsack on Jun 2, 2009
Latest reply on Mar 16, 2011 by hisense1
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);

 while (calCtxIsEventDone(p->ctx, e) == CAL_RESULT_PENDING);

 calResMap((CALvoid**)&oRes, &pitch, outputRes, 0);
 // get results

 calModuleUnload(ctx, module);
 return 1;

void main()

 for (i=0; i<n; i++) {

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?