cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

shantanu
Journeyman III

clCreateBuffer call and Virtual Memory Size of the process

clCreateBuffer call and Virtual Memory Size of the process

Thanks for reading the post.

I have experienced that my process virtual memory (VM) size increases in sync with the number of times i call clCreateBuffer ... and decreases once I delete the clMem buffers. In my understanding, I was hoping that the VM size of the process should not be affected by how many times I create GPU buffer ...

Attached is the partial sample code for illustration.

I am running the simple process on Mac platform, and for my case X amount of GPU buffer created results in X amount of increase in my process Virtual Memory size.  I understand this is not Mac forum, but please help me with the general question -
"In OpenCL, creating GPU device buffer using clCreateBuffer with CL_MEM_READ_WRITE can affect the VM Size of the process itself?" 

for (int i = 0; i < NUM_CL_MEM_OBJS_CREATED; i++) { cl_mem clMemBuffer = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(float) * NUM_DATA, NULL, &_err)); CL_CHECK(clEnqueueWriteBuffer(queue, clMemBuffer, CL_TRUE, 0, sizeof(float) * NUM_DATA, static_cast<void*>(&dataInput[0]), 0, NULL, NULL)); CL_CHECK(clFinish(queue)); totalBytesGPUMem += sizeof(float) * NUM_DATA; clMemVec = clMemBuffer; printf("Total GPU Buffer Allocated so far %ld bytes (%f MB) ||| Virtual Memory of Process %d MB\n", totalBytesGPUMem, totalBytesGPUMem / (1024.0 * 1024.0), GetProcessVirtualMemoryUsageInMB()); usleep(1000000); } printf("Now deleting GPU Memor allocated\n"); for (int i = 0; i < NUM_CL_MEM_OBJS_CREATED; i++) { CL_CHECK(clReleaseMemObject(clMemVec)); printf("Virtual Memory of Process %d MB\n", GetProcessVirtualMemoryUsageInMB()); }

0 Likes
10 Replies