Reputation: 62439
I keep reading and reading this matrix multiplication kernel code and I just don't get why the call to clBuildProgram
returns CL_BUILD_PROGRAM_FAILURE
. Here is my kernel code:
__kernel void MatMulKernel(__global const float* A,
__global const float* B,
float* C,
const int size1,
const int size2,
const int size3)
{
int k = get_global_id(0);
int i;
int line = k / size3;
int column = k % size3;
float partial = 0;
for(i = 0; i < size2; i++)
{
partial += A[line * size2 + i] * B[i * size3 + column];
}
C[k] = partial;
}
Can anyone spot the problem? Thank you.
Note: The code that does the initializations is correct, as I have tested with other kernels and they compile correctly.
Edit: Ok prunge's answer did the trick, but now I'm running into a different problem. The kernel execution actually causes a crash. Here is the code:
err = clSetKernelArg(hKernel, 0, sizeof(cl_mem), (void *)&hDeviceMemA);
err = clSetKernelArg(hKernel, 1, sizeof(cl_mem), (void *)&hDeviceMemB);
err = clSetKernelArg(hKernel, 2, sizeof(cl_mem), (void *)&hDeviceMemC);
err = clSetKernelArg(hKernel, 3, sizeof(cl_int), (void *)&s1);
err = clSetKernelArg(hKernel, 4, sizeof(cl_int), (void *)&s2);
err = clSetKernelArg(hKernel, 5, sizeof(cl_int), (void *)&s3);
cl_event events[1];
// execute kernel
start = clock();
err = clEnqueueNDRangeKernel(hCmdQueue, hKernel, 1, 0, (const size_t *)BENCH_SIZE_COMP, 0, 0, 0, &events[0]);
clWaitForEvents(1, events);
All err values for the calls to clSetKernelArg
are CL_SUCCESS
. When the program reaches clEnqueueNDRangeKernel
it crashes.
Upvotes: 0
Views: 1205
Reputation: 23238
This is the error I got:
error: kernel pointer arguments must point to addrSpace global, local, or constant
The float* C
parameter should probably be __global
. All kernel pointer arguments need an address space qualifier.
Upvotes: 2