shantanu

clCreateBuffer call and Virtual Memory Size of the process

Discussion created by shantanu on Oct 12, 2011
Latest reply on Oct 14, 2011 by LeeHowes
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[i] = 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[i])); printf("Virtual Memory of Process %d MB\n", GetProcessVirtualMemoryUsageInMB()); }

Outcomes