gpuopenaccpgi

OPENACC function equivalent to CUDA's cudaError_t cudaMemGetInfo


I would like to know the size of the available memory at certain point of the program at runtime. I was wondering if OpenACC has any functions equivalent to CUDA's cudaMemGetInfo().


Solution

  • The OpenACC standard doesn't have this but PGI does have an OpenACC extension API call you can use. "acc_get_free_memory" will return the amount of free memory on the device while "acc_get_memory" will return the amount of total memory. Include "accel.h" which is where PGI has the prototypes for it's OpenACC extensions. Both return an unsigned long.

    While I haven't tried myself, you might be able to call "cudaMemGetInfo" directly as well.