开发者

determine global memory available on GPU with JOCL?

I'm writing a JOCl.org (whi开发者_如何学Cch is different then jogamps jocl) running on GPU. Were working with sufficient data that I need to be careful to stay under the GPU's global memory limit. To do this I need a way of programmatically determining how much memory the GPU has. I assume there must be a simple JOCL method/variable to do this, but for some reason I can't seem to figure out what it is. I've looked at the CL.CL_MEM_SIZE and CL_DEVICE_GLOBAL_MEM_CACHE_SIZE but these both return something around 4100; I know I'm currently working with a graphics card that is suppose to contain 512 MB.

Also, I can't seem to use nearly as much memory as I should. In my worst case scenario I have to run a kernel that processes frames of 2^22 floats and will internally require twice as much data as frame size. If I try to cache two frames (so 2 frames * 2^22 * 2^2 bytes/float * 2 for overhead = 2^26) I can cache without difficulty, but when I increase my caching so I process three frames at a time (or 2^25*3) I appear to run out of memory. However, I believe I should only be using ~100 of my 512 MB of global memory. I believe I'm properly freeing memory when not used, but apparently I'm either doing something wrong or am misinterpreting the GPU's advertised 512 MB. Can anyone help explain this confusion to me?

Is there a way I can profile the GPU to get a sense for actual memory usage?


CL.CL_MEM_SIZE and CL_DEVICE_GLOBAL_MEM_CACHE_SIZE are constant values which are used as parameters for clGetDeviceInfo to query the device.

http://www.jocl.org/doc/org/jocl/CL.html#clGetDeviceInfo(org.jocl.cl_device_id, int, long, org.jocl.Pointer, long[])

The method clGetDeviceInfo is the method you use to query the device information. It returns the value of the parameter you asked for in param_name. The link has a list of all the parameter names available with a brief explanation. (CL_DEVICE_GLOBAL_MEM_SIZE should be the one you are looking for).


take a look at the webstart CLInfo application: http://jogamp.org/deployment/webstart-next/jocl-demos/clinfo.jnlp (project: http://jogamp.org/jocl-demos/www/) or start the commandline version:

java -jar jocl.jar:gluegen-rt.jar -Djava.library.path="path/to/jocl/libs:path/to/gluegen-rt/libs" com.jogamp.opencl.util.CLInfo

it will display the full readout of all device properties. The CL_DEVICE_GLOBAL_MEM_SIZE and CL_DEVICE_MAX_MEM_ALLOC_SIZE properties are probably the props you are looking for.

[edit] properties are documented here: http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetDeviceInfo.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜