error when use clCompileProgram and clLinkProgram
in OpenCL1.2,I try to use clCompileProgram and clLinkProgram instead of using clBuildProgram.
but I failed.
I write a simple kernel of Matrix Multiplication ,and divided it to three parts.
//the original kernel
int f(int x, int y)
{
return x/y ;
}
int g(int x, int y)
{
return x%y ;
}
__kernel void
multiply(__global float* array_A, __global float* array_B, __global float* array_D,int M)
{
int global_id = get_global_id(0);
float buffer =0;
int line = f(global_id ,M);
int col = g(global_id ,M);
for(int i=0;i<M;i++)
{
buffer += array_A[line*M+i] *array_B[i*M+col];
}
array_D[global_id] =buffer;
}
//-------------
it is run ok ,when i use clBuildProgram.
status = clBuildProgram(program,1,&devices,NULL,NULL,NULL);
printf("clBuildProgram status =%d\n",status);
if(status != CL_SUCCESS)
{
printf("Error:Building program\
(clBuildProgram)\n");
return EXIT_FAILURE;
}
//--------------
and i divided the kernel to three parts.
multi.cl multi2.h multi3.h
//multi.cl
#include "multi2.h"
#include "multi3.h"
__kernel void
multiply(__global float* array_A, __global float* array_B, __global float* array_D,int M)
{
int global_id = get_global_id(0);
float buffer =0;
int line = f(global_id ,M);
int col = g(global_id ,M);
for(int i=0;i<M;i++)
{
buffer += array_A[line*M+i] *array_B[i*M+col];
}
array_D[global_id] =buffer;
}
//multi2.h
int f(int x, int y)
{
return x/y ;
}
//multi3.h
int g(int x, int y)
{
return x%y ;
}
//--------------
I use clCreateProgramWithSource to got three program ,
program_multi, program_multi2, program_multi3 corresponding multi.cl ,multi2.h ,multi3.h
cl_program input_headers[2] ={ program_multi2 ,program_multi3};
const char * input_header_names[2] = {"multi2.h" ,"multi3.h" };
status=clCompileProgram(program_multi,
0,
NULL,
0,
2,
input_headers,
input_header_names,
NULL,NULL);
printf("clCompileProgram status =%d\n",status);
but it error .the return status is -11 ,means CL_BUILD_PROGRAM_FAILURE
I am trying many times ,but still fail .
the first parameters of clCompileProgram ,is it right .
there are little formation about these two function ,so I try to get help from this forum .
Thanks !
Solved! Go to Solution.
Are you attempting to run on the CPU or GPU? There should be no problem running on the CPU, but neither of those GPU's are supported by our software stack.
I solve the problem ,it is my computer's problem. I change a computer and the program is OK.
my computer is too old .
I still don't know why the program failed on my computer ,but can run OK on the other computer .
my computer's cpu is Intel T6670 ,and gpu is GeForce GT 220M ,the Software installed correctly .
the other computer's hardware : AMD cpu ,Radeon 9500 gpu
Is the cause of the hardware ?
thanks
Are you attempting to run on the CPU or GPU? There should be no problem running on the CPU, but neither of those GPU's are supported by our software stack.
Thank you
,yes ,it can't run on the GPU.
clCompileProgram and clLinkProgram are features of OpenCL 1.2 specification. Currently the latest NVidia SDK supports only 1.1 OpenCL version (and nobody knows when they will support next one)... On the other hand ATI already supports OpenCL 1.2 in the latest AMD APP SDK 2.6... So, it is not surprising that your app works fine on AMD machine and at the same time doesn't work on NVidia system...