cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

twiig
Journeyman III

static arrays in kernels

I have been having a bit of trouble compiling a kernel with a static array of integers.  When compiling the kernel (see code below) on the GPU, I receive the following:

 

For test only: Expires on Sun Feb 28 00:00:00 2010

CL Error: clBuildProgram (-11)

Build Log:

Link failed

Press any key to continue . . .

And, when compiled for the CPU, I receive:
For test only: Expires on Sun Feb 28 00:00:00 2010
C:\Users\tyler\AppData\Local\Temp\OCLB365.tmp.obj:fake.text+0x2c): undefined reference to `__vla_alloc'
C:\Users\tyler\AppData\Local\Temp\OCLB365.tmp.obj:fake.text+0xba): undefined reference to `__vla_dealloc'
C:\Users\tyler\AppData\Local\Temp\OCLB365.tmp.obj:fake.text+0x18e): undefined reference to `__vla_alloc'
C:\Users\tyler\AppData\Local\Temp\OCLB365.tmp.obj:fake.text+0x21d): undefined reference to `__vla_dealloc'
CL Error: clBuildProgram (-11)
Build Log:
Compilation failed
Press any key to continue . . .
Any ideas?  Note that if the only line of code in the kernel is the array declaration, the same result is obtained.


__kernel void combination(const int n, const int k, __global int *out) { size_t gid = get_global_id(0); int a; int index = gid*100; for(int i = 0; i < k; i++) a = gid+i; while(index != -1) { for(int i = 0; i < k; i++) out[index++] = a; int j = k - 1; if(a < n - 1) { ++a; continue; } while(a - a[j-1] == 1) --j; if(j == 1) { index = -1; continue; } int z = ++a[j-1]; while(j < k) { a = ++z; ++j; } } }

0 Likes
3 Replies

twiig,
This is not possible in OpenCL and violates the spec, section 6.8.d. "Variable length arrays and structures with flexible(or unsized) arrays are not supported."
0 Likes

Ok, thanks!  I guess I missed that.

Just to follow up, if I wanted some form of addressable ray in which I don't know the size beforehand, I should use a pre-allocated local memory array passed in?

0 Likes

Twiig,
In this case you want to pass it in as an argument to the kernel.
0 Likes