I'm trying to run the noise OpenCL sample project included in the XCode documentation.
I have one error that I don't understand:
----------------------------------------------------------------------
Using active OpenGL context...
----------------------------------------------------------------------
Connecting to NVIDIA GeForce 320M...
----------------------------------------------------------------------
Loading kernel source from file 'noise_kernel.cl'...
----------------------------------------------------------------------
Building compute program...
[CL_DEVICE_NOT_AVAILABLE] : OpenCL Error : Error: Build Program driver returned (10007)
Break on OpenCLErrorBreak to debug.
OpenCL Warning : clBuildProgram failed: could not build program for 0x1022600 (GeForce 320M) (err:-2)
Break on OpenCLWarningBreak to debug.
[CL_BUILD_ERROR] : OpenCL Build Error : Compiler build log:
<program source>:58:21: error: global variables must have a constant address space qualifier
static const float4 ZERO_F4 = (float4)(0.0f, 0.0f, 0.0f, 0.0f);
There is an error on this last line, which involves a const variable. How do you interpret this ? It looks like the compiler is rejecting ZERO_F4 because it's not const, but as you can see, it actually is.
It looks like the compiler is rejecting ZERO_F4 because it's not const, but as you can see, it actually is.
The compiler is rejecting it because ZERO_F4
is not in __constant
address space (this has nothing to do with const
). I believe it's a bug in the XCode samples, because the OpenCL C spec clearly says:
Section 6.5 Address space qualifiers:
All program scope variables must be declared in the
__constant
address space.
Therefore replace this:
static const float4 ZERO_F4 = (float4){ 0.0f, 0.0f, 0.0f, 0.0f };
static const float4 ONE_F4 = (float4){ 1.0f, 1.0f, 1.0f, 1.0f };
With this:
__constant float4 ZERO_F4 = (float4){ 0.0f, 0.0f, 0.0f, 0.0f };
__constant float4 ONE_F4 = (float4){ 1.0f, 1.0f, 1.0f, 1.0f };
And it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With