PDA

View Full Version : initializing __constant vector arrays



yuvi
09-16-2009, 02:55 PM
As a global variable, I have

__constant int2 diamond[2][2] =
{
{(int2)(-1,0), (int2)(0, 1)},
{(int2)( 1,0), (int2)(0,-1)}
};This doesn't compile on snow leopard targeting a GF 8600M, with the error "Error while compiling the ptx module: CLH_ERROR_NO_BINARY_FOR_GPU"

Is this correct syntax? If not, what is the correct way to have array of vectors in constant memory without initializing it from the host?

PaulS
09-18-2009, 07:49 AM
I've just cut and pasted that snippet into the top of my kernel, and compiled it fine for the CPU and GPU. I think that means the syntax is OK, but then I'm not actually accessing it so it's probably optimised out.

I've also had that error from the SL compiler for the 8xxx series.

For me it seemed to be related to accessing arrays which were memory objects.

e.g. (heavily simplified):

kernel void particle(float * positions) {
float4 position = vload4(0, positions + i * 3);


I'm not sure if it's the possible mis-aligned load that's causing the problem, but I'd be interested to see if you have something similar.

This was in a context with shared OpenGL objects, on 10.6.1. Compiling for the CPU gives no problems. It may also be working in a non-shared context on the GPU, but I'm having other problem with that that may be clouding the issue.

PaulS
09-22-2009, 06:51 AM
I've found it was nothing to do with accessing anything, just that it seems having arrays defined as constant seems to blow things up.

Mine were "constant float *". Making that "global float *" solved the problem for me.