Hello!
I’m new to the forum and i really hope that i picked the right to post my question. I am currently in the process of learning OpenCL with a book called “OpenCL Programming by Example”. Now i came across a problem that i cannot solve. And although i have some programming background and in general get the idea what is wrong i don’t understand why the error exists. As mentioned in the title a “Linking globals named ‘MatrixMul_kernel_basic’: symbol multiply defined!” is thrown during “clBuildProgram”. I am unable to find any multiple declaration for the kerne/kernelname and therefore i’m a little bit stuck. I’ve already tried google and other search engines without luck, any help is greatly appreciated.
Kernelcode:
__kernel
void MatrixMul_kernel_basic(int dim,
__global float* A,
__global float* B,
__global float* C)
{
//Get index of work item
int col = get_global_id(0);
int row = get_global_id(1);
float result = 0.f;
//Calculate row * col for one element
for(int i = 0; i < dim; ++i)
{
result += A[row * dim + i] * B[i * dim + col];
}
C[row * dim + col] = result;
}
Hostcode:
char* firstKernel;
ReadKernelFile("MatrixMul_kernel_basic.cl", firstKernel);
cl_program program = clCreateProgramWithSource(
context,
1,
(const char**)&firstKernel,
NULL,
&clStatus);
LOG_OCL_ERROR(clStatus, "clCreateProgramWithSource failed.");
clStatus = clBuildProgram(
program,
1,
devices,
NULL,
NULL,
NULL
);
If you want to see the code to query platforms, devices, etc i will provide it later. After clBuildProgram() i am getting the build log which shows the error mentioned above.
Thank you in advance for your help!