Possibility of de-activating openacc region

Dear all,
I have the situation where a specific routine contains openACC statements and is therefore meant to run on the gpu. However, the very same routine is also to be used on the host.

I can of course solve this issue by using a flag of some sort in the subroutine to use the acc version or not depending on the subroutine call, but that seems cumbersome.

Is there some acc statement to somehow de-activate a region? That would be a great help for this problem. Or are there alternatives to the solution outlined above (duplication essentially)?

Thanks,
Danny.

Hi Danny,

To selectively enable/disable an OpenACC construct at runtime you’d use the “if” clause.

Something like:

void func(int * arr, int usegpu) {

#pragma acc parallel loop if(usegpu) 
for ....  {
  // do something
}

}

-Mat

Exactly what I need !

Thx,
Danny.