I’m trying to implement an OpenCL application that sums two matrices together, using the following kernel:
[codebox]__kernel void MatrixSum (__global float* a, __global float* b, __global float* c)
{
int address = get_global_id(0) + get_global_id(1)*get_global_size(0);
c[address]=a[address]+b[address];
}[/codebox]
The Kernel builds without errors when calling clCreateProgramWithSource() targeting the x64 platform in Visual Studio 2010.
(I’m using VS2010 on Win7 x64)
However, if i switch the target architecture to x86, clCreateProgramWithSource fails with the error: CL_BINARY_INVALID (-42).
Now, if I change the code such as the first line is typecasted to float, the Kernel builds and works fine!?!?!?!:
[codebox]__kernel void MatrixSum (__global float* a, __global float* b, __global float* c)
{
int address = (float)get_global_id(0) + get_global_id(1)*get_global_size(0);
c[address]=a[address]+b[address];
}[/codebox]
I would say a type error should be thrown?
Also, if I change one of the float arrays to an Integer array instead, the code also builds fine:
[codebox]__kernel void MatrixSum (__global int* a, __global float* b, __global float* c)
{
int address = get_global_id(0) + get_global_id(1)*get_global_size(0);
c[address]=a[address]+b[address];
}[/codebox]
I’m using Toolkit v3.2.
I think theres a bug in the 32bit version of the compiler.
Anyone had similar problems?
Thanks.