mgNobody
mgNobody

Reputation: 778

OpenACC - How to find if device is busy doing some CUDA operations?

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:

Is there a way to find whether the device is busy or not?

Upvotes: 1

Views: 676

Answers (1)

Mat Colgrove
Mat Colgrove

Reputation: 5646

I don't know of a way to programmatically get the device utilization. You can get the memory usage via cudaMemGetInfo which you might be able to use to extrapolate if something is running on the GPU or not.

Upvotes: 1

Related Questions