Compile error for float4 array

Hi there,

I am trying to initialize the following array:

__constant float4 splitter_cache[2] like this:

__constant float4 splitter_cache[2] = { (float4)(0.0f,0.0f,0.0f,0.0f), (float4)(0.0f,0.0f,0.0f,0.0f) };

But I get a compile error. What’s the problem?


clBuildProgram() failed: -11
<:5: error: incompatible type initializing 'float4', expected 'float'
__constant float4 splitter_cache[2] = { (float4)(0.0f,0.0f,0.0f,0.0f), (float4)(0.0f,0.0f,0.0f,0.0f) };
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
:5: error: incompatible type initializing 'float4', expected 'float'
__constant float4 splitter_cache[2] = { (float4)(0.0f,0.0f,0.0f,0.0f), (float4)(0.0f,0.0f,0.0f,0.0f) };
                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Try this:

__constant float4 splitter_cache[2] = { 0.0f, 0.0f };

I think float gets promoted to float4 in this assignment, i.e. all components of float4 will be initialized to 0. Haven’t tried it though.

It compiles fine on the implementation I have available. You might want to report that as a bug to your implementation vendor(s). Do you still get an error if you just mark it const so that it is instead in private memory?

Yes, same error.

Well, on my system (Mac OS X 10.6.6, ATI HD 5750)

the following code compiles well in a kernel function.

const float4 kernel_x[3] = {
			(float4)(-1,0,1,0), 
			(float4)(-2,0,2,0), 
			(float4)(-1,0,1,0)
};