I have a CUDA-based code and I want to incorporate OpenACC into some parts of the code. But, the function that I am trying to parallelize by OpenACC code sometimes is governed by CUDA calls and sometimes not.
My question is that how can I query OpenACC library to see whether device is busy or not. Is there any API calls for that?
Note: I am not completely familiar with CUDA, so I just use pseudo-code.
Sometimes the target function seq_function
is called on the host when device is busy with computation like below. But, sometimes it is called when device is not busy.
cudaMemAlloc(...);
cudaLaunchAsync(...);
...
//This is the function I am trying to parallelize with OpenACC
seq_function(...);
...
cudaWait(...);
cudaDealloc(...);
So, I want to make my target function flexible:
- if device is busy or a CUDA-based computation is running => use host.
- if device is not busy => use GPU through OpenACC-enabled code.
Is there a way to find whether the device is busy or not?