Tôi đang sử dụng card đồ họa ATI RV770, OpenCl 1.0 và ati-stream-sdk-v2.3-lnx64 trên Linux.mã lỗi (-11) :: tất cả các lý do có thể có lỗi là gì "cl_build_program_failure" trong OpenCL?
Trong khi chạy mã máy chủ lưu trữ của tôi bao gồm hai phần sau để xây dựng chương trình hạt nhân, tôi nhận được mã lỗi (-11) tức là cl_build_program_failure
. Liệu nó có nghĩa là chương trình hạt nhân được biên dịch, nếu không thì nó được biên dịch và sửa lỗi như thế nào?
const char* KernelPath = "abc_kernel.cl"; //kernel program is in separate file but in same directory of host code..
/* Tạo đối tượng Chương trình từ nguồn kernel * ** * ** */
char* sProgramSource = readKernelSource(KernelPath);
size_t sourceSize = strlen(sProgramSource) ;
program = clCreateProgramWithSource(context, 1,(const char **) &sProgramSource,&sourceSize, &err);
checkStatus("error while creating program",err);
/* xây dựng (biên dịch & Link) Chương trình * ** * ***/
char* options = (char*)malloc(10*sizeof(char));
strcpy(options, "-g");
err = clBuildProgram(program, num_devices, devices_id, options, NULL, NULL);
checkStatus("Build Program Failed", err); //This line throwing the error....
chức năng để đọc chương trình hạt nhân là như sau ::
tập tin/* nguồn chương trình đọc */
char* readKernelSource(const char* kernelSourcePath){
FILE *fp = NULL;
size_t sourceLength;
char *sourceString ;
fp = fopen(kernelSourcePath , "r");
if(fp == 0)
{
printf("failed to open file");
return NULL;
}
// get the length of the source code
fseek(fp, 0, SEEK_END);
sourceLength = ftell(fp);
rewind(fp);
// allocate a buffer for the source code string and read it in
sourceString = (char *)malloc(sourceLength + 1);
if(fread(sourceString, 1, sourceLength, fp) !=sourceLength)
{
printf("\n\t Error : Fail to read file ");
return 0;
}
sourceString[sourceLength+1]='\0';
fclose(fp);
return sourceString;
} // kết thúc của readKernelSource
Có ai biết cách sửa nó không?
Liệu điều đó có nghĩa rằng đó là lỗi biên dịch OpenCl trong thời gian chạy hay cái gì khác?
// In thông tin build_log bằng cách sử dụng clGetProgramBuildInfo() như dưới đây, Nhưng tại sao lại không in được gì?
char * build_log; size_t log_size;
// First call to know the proper size
err = clGetProgramBuildInfo(program, devices_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
build_log = (char*)malloc((log_size+1));
// Second call to get the log
err = clGetProgramBuildInfo(program, devices_id, CL_PROGRAM_BUILD_LOG, log_size, build_log, NULL);
build_log[log_size] = '\0';
printf("--- Build log ---\n ");
fprintf(stderr, "%s\n", build_log);
free(build_log);
Bạn đã dán nguồn hạt nhân vào công cụ của bên thứ ba thuộc loại nào chưa? Một hồ sơ có thể? Khi tôi gặp lỗi xây dựng, chúng thường là cú pháp trong chính chương trình. – mfa