clBuildProgram fails after clRetainProgram

Discussion created by dikobraz on Nov 19, 2012

I get CL_INVALID_OPERATION trying to build OpenCL program, but it compiles fine in AMD KernelAnalyzer 2. After a bit of debugging, I foound that the problem is caused by clRetainProgram. My code looks approximately as follows:


std::string source = <some source>;

cl_int errCode = 0;

cl_program program = clCreateProgramWithSource(context, 1, source.c_str(), 0, &errCode);

// clRetainProgram(program); // causes CL_INVALID_OPERATION in clBuildProgram

errCode = clBuildProgram(program, 0, 0, "-cl-fast-relaxed-math", 0);


Hope this will be helpful. I've attached program source code, just in case.