Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'OpenCL outmem error' topicStudent Support Forum > General > "OpenCL outmem error"

Help | Reply To Topic
Author Comment/Response
Michael Schreier
05/04/12 04:59am

I've been playing around with openCL lately and ran into some kind of memory management error.
The following code (a simplified example):


src = "
__kernel void isTwo_kernel(__global mint * arry, mint len, mint \
len2) {
   int indexX = get_global_id(0);
   int indexY = get_global_id(1);

   if (indexX >= len || indexY >= len2) return;

arry[indexX+indexY*len] = 2;
isTwo = OpenCLFunctionLoad[src,
"isTwo_kernel", {{_Integer}, _Integer, _Integer}, {16, 16},
"ShellOutputFunction" -> Print]

n = 140;
m = 55;

a = ConstantArray[1, {n, m}];

For[i = 1, i <= 20000, i++,
a = isTwo[a, n, m][[1]];


returns the following error after around 15k or so iterations:
"OpenCLFunction::outmem: OpenCLLink ran out of available memory, possibly due to not freeing memory using the memory manager."

It seems as if Mathematica doesn't free up the GPU memory after each call of the routine. I tried to circumvent the problem by loading and unloading the matrix "a" manually but that didn't help.

I guess my mistake is something very basic and rather obvious but any help is highly appreciated.

URL: ,
Help | Reply To Topic