views:

61

answers:

2

I would like to know how much free memory there is on my device before allocating buffers. Is this possible? I know there's CL_DEVICE_GLOBAL_MEM_SIZE for total memory, and CL_DEVICE_MAX_MEM_ALLOC_SIZE for max size of a single object, but I would like to know the current memory state.

As it stands I'm probably going to have to use OpenGL vendor-specific extensions.

+1  A: 

No, there is no way, and there is no need to know it, GPU memory can be virtualized and the driver will swap in/out memory from the GPU when it is/not needed.

Matias Valdenegro
It's good to know there's no way, but why would you say there's no need? I don't want to swap in/out memory, and since I'm working with GL as well, I don't want to eat up all of GL's memory.
nullspace
There is no need because the driver takes care of that. GL resources are also virtualized. Swapping is not really bad, it just will copy data in VRAM to RAM, and viceversa when necessary. What would you do if you find out there's not enough VRAM left?
Matias Valdenegro
Currently, it's crashing the GL subsytem and waits for TDR to restart it. It's possible this is due to a bug in my code, but allocating smaller buffers fixes it. I would like to determine an optimal buffer size. So it's more of a preventative thing.
nullspace
That looks like a bug in the GL/CL implementation, your code should not crash the GL/CL impl.
Matias Valdenegro
Well it looks like the "bug" was actually my kernels taking so long to complete, TDM would reset the display driver. I disabled TDM and everything works fine. Not really sure what to do about this though.
nullspace
A: 

You can use GL_NVX_gpu_memory_info on nVidia.

Calvin1602
That's what I ended up using, and ATI_meminfo on ATI, but that's GL, not CL.
nullspace