Run-time error in clBuildProgram(-11)

Currently in my Fedora 13 Linux system I have two Nvidia cards, a 9400GT and a GTX480. I have installed AMD’s ati-stream-sdk-v2.2-lnx64 in my home directory. My goal was to get OpenCL programs to run on the CPU (i7 930). I have installed the Nvidia OpenCL 1.1 compatible driver and the ATI stream v2.2 is OpenCL 1.1 compatible too. When I run the Ruby-OpenCL version of the code (0.7, also OpenCL 1.1 compatible), I can run on the CPU no problems. It’s only when I try to run the C++ bindings version of my code that I start to have kernel build problems.

The C++ version of my openclinfo program sees the CPU as a valid OpenCL device and responds that it is a 1.1 capable device. But when it tries to build the kernel I get the following error:

$ ./opencl-ifs
Devices found - 1
Error in clBuildProgram(-11)

Which is the CL_BUILD_PROGRAM_FAILURE error. I have set the $ATISTREAMSDKROOT environment variable and it points to the directory where I installed ati-stream-sdk-v2.2-lnx64. All of the ATI and Nvidia ICDs are installed in the /etc/OpenCL/vendor directory. I have tried to compile the program with two different g++ commands. The first is using the Nvidia includes and lib, the second is using the ATI includes and lib. At least I think that is what is happening, either way they both die with the same error. It’s almost like the OpenCL lib isn’t picking up the correct libs?

g++ opencl-ifs.cpp -o opencl-ifs -Wall -g -I /usr/include/CL -lOpenCL pkg-config gtkmm-2.4 --cflags --libs

g++ opencl-ifs.cpp -o opencl-ifs -Wall -I $ATISTREAMSDKROOT/include -I /usr/include/CL -L $ATISTREAMSDKROOT/lib/x86_64 -lOpenCL pkg-config gtkmm-2.4 --cflags --libs

Am I doing some thing wrong? I can’t find where the problem is, so any ideas or help would be most appreciated. Thanks,

Grimm

If you post the relevant source code we would probably be able to help you better.

I had the same error yesterday and it turns out I was calling clBuildProgram with the wrong arguments (I wasn’t creating the program object properly before trying to build it).

Also, I’m curious as to what your program build info log looks like. You can find it with the following snippet of code from http://opencl.codeplex.com/wikipage?tit … 0Tutorials:


// Shows the log
char* build_log;
size_t log_size;
// First call to know the proper size
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
build_log = new char[log_size+1];
// Second call to get the log
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, log_size, build_log, NULL);
build_log[log_size] = '\0';
cout << build_log << endl;
delete[] build_log;
 

Thanks, here is the code snippet of the build:

  // Build the ifs kernel
  std::vector<cl::Device> tempdev;
  cl::Program::Sources fract_source( 1, std::make_pair( fractal.c_str(),
      fractal.length()+1 ));
  const cl::Program ifs_program( myopencl[device_num]->getContext(), fract_source );
  cl::Error err = ifs_program.build( tempdev, "" );
  cl::Kernel frac_kernel( ifs_program, "ifs_gen" );

I’m not sure if it would be a problem with the arguments, given that this code works fine on the GPU. I tried to set up the build log code, but I had trouble converting it to C++. It doesn’t appear that the C++ bindings will allow this:

// First call to know the proper size
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);

The closest I could find in the C++ binding spec is this:

template <typename T>
cl_int cl::Program::getBuildInfo(cl_program_build_info name,
                                T * param)

So I tried this C++ code:

try
  {
  cl::Error err = ifs_program.build( tempdev, "" );
  }
catch( cl::Error err )
  {
  cl::STRING_CLASS buildlog;
  ifs_program.getBuildInfo( (cl_program_build_info)CL_PROGRAM_BUILD_LOG, buildlog );
  std::cout << buildlog << std::endl;
  }

I’m getting an error when I try to compile it. I’m new to C++ so it’s probably something I’m doing wrong even though it looks like that is what it wants per the spec? :frowning: Here is the compile error I’m getting:

opencl-ifs.cpp:258: error: no matching function for call to ‘cl::Program::getBuildInfo(cl_program_build_info, cl::STRING_CLASS*) const’

Thanks again for your help.

Grimm

Ok, I got it working. I looked into the binding source code and the function needed the device as the first parameter. So I changed my code to the following:

ifs_program.getBuildInfo( myopencl[device_num]->getDevice(), (cl_program_build_info)CL_PROGRAM_BUILD_LOG, &buildlog );

And now the log output works and reported the following error:

/tmp/OCLFKMjnx.cl(1): error: can't enable all OpenCL extensions or
          unrecognized OpenCL extension
  #pragma OPENCL EXTENSION cl_khr_icd : enable

So I removed the pragma from my kernel code and it was able to run. My only question is, what happened? Why does the pragma difference between the GPU and the CPU matter? I’m still really fuzzy on the ICD stuff, does anyone know a good reference for it? Thanks again,

Grimm

http://www.khronos.org/registry/cl/exte … hr_icd.txt

It’s not an opencl C language extension. It’s just extension that enable different implementation (platforms) to be used in the same program. So it’s quasi transparent for the opencl developper ;).

Thanks for the link matrem. So this is no longer necessary/useful for OpenCL 1.1?

Grimm

You just don’t have to think about it, it’s automatic :wink:

When you call clGetPlatformIds, you get all the ICD compliant platforms, because OpenCL.so/dll is a small piece of code (writen by I guess, by the khronos group) that read the ICD Loader Vendor Enumeration (/etc/OpenCL/vendors or windows registry), to retrieve OpenCL vendor implementation (for example nvcuda.so/dll or atiocl.so/dll).

If you want to write your OpenCL implementation, you’ll have to follow the ICD spec.