Created
February 7, 2016 07:38
-
-
Save InnovArul/d1eb6f2c865bd2c1d89a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define MALLOC_LIMIT 1024*1024*1024 //1 GB | |
//eliminate calling cudaDeviceSetLimit multiple times | |
bool IsMallocSet = false; | |
/** | |
* API to set the malloc limit of GPU | |
*/ | |
static void setMallocLimit() { | |
// cudaDeviceSetLimit can be called only once to set the malloc limit | |
// this if loop is to prevent multiple calls of cudaDeviceSetLimit | |
if(!IsMallocSet) | |
{ | |
cudaError_t cuda_status = cudaDeviceSetLimit(cudaLimitMallocHeapSize, MALLOC_LIMIT); | |
if (cudaSuccess != cuda_status) { | |
printf("Error: cudaDeviceSetLimit fails, %s \n", | |
cudaGetErrorString(cuda_status)); | |
return; | |
} | |
IsMallocSet = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment