CL_BUILD_PROGRAM_FAILURE but Build Log empty

Hi,

When I try to run an OpenCL Kernel, the build doesn’t work and returns CL_BUILD_PROGRAM_FAILURE. But when I call

program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(devices[0])

I only get 3 weird characters, apparently random. Last time I got ¸Ûž, but I just reran it and got è߆.
How can I get the log ? There is no apparent syntax error, and the code worked when it was not in the kernel (I’m only adapting previously existing code to use it in OpenCL)

Basically the kernel looks like this :

#define MIN_OPACITY_LEVEL 5
#define MAX_LEVEL 255
#define MAX_OPACITY 255
#define FULL_OPACITY 0xff000000
#define HIGH_TRANSPARENCY 0x01000000
#define FULL_TRANSPARENCY 0x00000000

#define OUT_OF_CUBE FULL_TRANSPARENCY
#define OUT_OF_CLIPPING HIGH_TRANSPARENCY

#include "foo.h"
#include <windef.h>

	int __opacity_function(int x, int index, int * table)
{
		//stuff
	}
	
	bool __cumulate_opacity_SIMPLE(const int pix, int opacity_index, int & light, int & opacity, int * table)
{

		//stuff
	}

	int compute_spatial_interpolation_orig(const point4 & point, BYTE * buffer, int * widthTable)
{
		//stuff


	}
	DWORD __compute_cubic_pixel_low_res(point4 & point, int nr_sheet, int opacity_index, point4 & step, BYTE * buffer, int * width, bool inside, int * table)
{
		//stuff
	}

	__kernel void calculPoint(__global point4* P, __global int* nr_sheet, __global int* opacity_index, __global point4* step, __global int* index, __global DWORD* bitmap, __global int* bitmap_width, __global BYTE* buffer, __global int* width, __global bool* inside, __global int* table)
{
		//stuff
	}

And I get the log using

	fprintf(fp, "Build Log:	%s
 ", program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(devices[0]));

I don’t know if the problem is really a bug in my kernel, or if there is another reason.

Thank you very much for your help !

The getBuildInfo() method will return a C++ string for CL_PROGRAM_BUILD_LOG, whereas your fprintf format expects a C string. You can use the c_str() method to print the log:

fprintf(fp, "Build Log:	%s
 ", program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(devices[0]).c_str());