Weired OpenCL Build Program Error

Hey guys,

I’m trying to access an array of structs with an index. But since I do that, I got an error and the build program function fails. Additionally, the function doesn’t exit with CL_BUILD_PROGRAM_FAILURE. If I comment out the part with the array access, the program builds without errors. Can anyone help me?

The opencl code is as follows:

__kernel void 

calc_triangle_mapping(__global const Mesh* mesh, __global const Triangle* triangles, 

						const int res_x, const int res_y, __global int* triangle_mapping, 

						__global Color* pixels) {

	int index = get_global_id(0);

	Triangle t;

	Point2D top, bottom, middle;

	float inc, inc_bottom_top, inc_bottom_middle, inc_middle_top;

	bool right_side = false;

	int begin, end;

	// check bounds

	if (index >= mesh->num_triangles)

		return;

	// get the triangle of the current thread

	t = triangles[index];

}

Thanks in advance.

Daniel

You really need to call clGetProgramBuildInfo, when clBuildProgram does not work. Depending on the implementation, you get lines in error & descriptions of the problem. Any setup required for clGetProgramBuildInfo is definitely worth it. This will not be the last compile problem you will ever have.

I do not know what a Triangle is (Not trying to be obtuse). I assume it is a structure? My old specification, #43, does say a buffer memory object can be declared as a pointer to a user-defined struct in section 6.5.1 . I am a Java guy, so I have avoid the use of structures, which a sort of pre-OO. Sorry.

I already use clGetProgramBuildInfo. As you read, I’m already checking for CL_BUILD_PROGRAM_FAILURE. But since this doesn’t occur, the usage of clGetProgramBuildInfo would make no sense.

Triangle is a user-defined structure in my code. And I want to make use of arrays of user-defined stuctures, but when I’m trying to access the array, an error occurs.

Can anyone help me? Thanks a lot.

Daniel

Sorry, I forgot to paste the host code. When building a program the following code is executed:

// build

	ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

	// avoid abortion due to CL_BILD_PROGRAM_FAILURE

	if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

		return EXIT_FAILURE; 

	cl_build_status build_status;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

	if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

	// if program built fails, print out error messages

	if (build_status != CL_SUCCESS) {

		char *build_log;

		size_t ret_val_size;

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		build_log = new char[ret_val_size+1];

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		// to be carefully, terminate with 

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with 
// build

	ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

	// avoid abortion due to CL_BILD_PROGRAM_FAILURE

	if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

		return EXIT_FAILURE; 

	cl_build_status build_status;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

	if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

	// if program built fails, print out error messages

	if (build_status != CL_SUCCESS) {

		char *build_log;

		size_t ret_val_size;

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		build_log = new char[ret_val_size+1];

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		// to be carefully, terminate with 

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with \0

	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '\0';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}

		// there's no information in the reference whether the string is 0 terminated or not

		build_log[ret_val_size] = '

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with \0

	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '\0';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}
';

		cout << "BUILD LOG: " << endl;

		cout << build_log << endl;

		delete[] build_log;

		return EXIT_FAILURE;

	}
	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '
// build

	ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

	// avoid abortion due to CL_BILD_PROGRAM_FAILURE

	if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

		return EXIT_FAILURE; 

	cl_build_status build_status;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

	if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

	// if program built fails, print out error messages

	if (build_status != CL_SUCCESS) {

		char *build_log;

		size_t ret_val_size;

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		build_log = new char[ret_val_size+1];

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		// to be carefully, terminate with 

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with \0

	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '\0';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}

		// there's no information in the reference whether the string is 0 terminated or not

		build_log[ret_val_size] = '

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with \0

	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '\0';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}
';

		cout << "BUILD LOG: " << endl;

		cout << build_log << endl;

		delete[] build_log;

		return EXIT_FAILURE;

	}

';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}

		// there's no information in the reference whether the string is 0 terminated or not

		build_log[ret_val_size] = '

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with 
// build

	ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

	// avoid abortion due to CL_BILD_PROGRAM_FAILURE

	if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

		return EXIT_FAILURE; 

	cl_build_status build_status;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

	if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

	// if program built fails, print out error messages

	if (build_status != CL_SUCCESS) {

		char *build_log;

		size_t ret_val_size;

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		build_log = new char[ret_val_size+1];

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		// to be carefully, terminate with 

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with \0

	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '\0';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}

		// there's no information in the reference whether the string is 0 terminated or not

		build_log[ret_val_size] = '

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with \0

	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '\0';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}
';

		cout << "BUILD LOG: " << endl;

		cout << build_log << endl;

		delete[] build_log;

		return EXIT_FAILURE;

	}
	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '
// build

	ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

	// avoid abortion due to CL_BILD_PROGRAM_FAILURE

	if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

		return EXIT_FAILURE; 

	cl_build_status build_status;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

	if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

	// if program built fails, print out error messages

	if (build_status != CL_SUCCESS) {

		char *build_log;

		size_t ret_val_size;

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		build_log = new char[ret_val_size+1];

		ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

		if (ciErr1 != CL_SUCCESS)

			return EXIT_FAILURE; 

		// to be carefully, terminate with 

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with \0

	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '\0';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}

		// there's no information in the reference whether the string is 0 terminated or not

		build_log[ret_val_size] = '

// build

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

// avoid abortion due to CL_BILD_PROGRAM_FAILURE

if (ciErr1 != CL_SUCCESS && ciErr1 != CL_BUILD_PROGRAM_FAILURE)

	return EXIT_FAILURE; 

cl_build_status build_status;

ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL);

if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

// if program built fails, print out error messages

if (build_status != CL_SUCCESS) {

	char *build_log;

	size_t ret_val_size;

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	build_log = new char[ret_val_size+1];

	ciErr1 = clGetProgramBuildInfo(cpProgram, cdDevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);

	if (ciErr1 != CL_SUCCESS)

		return EXIT_FAILURE; 

	// to be carefully, terminate with \0

	// there's no information in the reference whether the string is 0 terminated or not

	build_log[ret_val_size] = '\0';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}
';

		cout << "BUILD LOG: " << endl;

		cout << build_log << endl;

		delete[] build_log;

		return EXIT_FAILURE;

	}

';

	cout << "BUILD LOG: " << endl;

	cout << build_log << endl;

	delete[] build_log;

	return EXIT_FAILURE;

}
';

		cout << "BUILD LOG: " << endl;

		cout << build_log << endl;

		delete[] build_log;

		return EXIT_FAILURE;

	}

So far…

Knowing what a return code is not, is not as good knowing what it is. I count 11 non success returns for clBuildProgram. True, only CL_BUILD_PROGRAM_FAILURE seems relevant to source. Looking at your source, first you need to log what ciErr1 is from the first call, or you are not going to get anywhere easily. I built a java method which maybe you can adapt to get a description of a return code. I NEVER not know what my reported error is! I’ll put it at the bottom.

Commenting out some of these if’s would not hurt till you got it fixed. The build info is there in the case of success as well. I get this for successful builds:

GeForce 8800 GTX

: Retrieving binary for ‘anonymous_jit_identity’, for gpu=‘sm_10’, usage mode=’

Not useful by itself, but it could provide some clue, as you may be in no-mans land.

[codebox] public static String getErrorDesc(int err){

    switch (err){

        case OpenCLLibrary.CL_SUCCESS: return null;

        case OpenCLLibrary.CL_DEVICE_NOT_FOUND               : return "CL_DEVICE_NOT_FOUND";

        case OpenCLLibrary.CL_COMPILER_NOT_AVAILABLE         : return "CL_COMPILER_NOT_AVAILABLE";

        case OpenCLLibrary.CL_MEM_OBJECT_ALLOCATION_FAILURE  : return "CL_MEM_OBJECT_ALLOCATION_FAILURE";

        case OpenCLLibrary.CL_OUT_OF_RESOURCES               : return "CL_OUT_OF_RESOURCES";

        case OpenCLLibrary.CL_OUT_OF_HOST_MEMORY             : return "CL_OUT_OF_HOST_MEMORY";

        case OpenCLLibrary.CL_PROFILING_INFO_NOT_AVAILABLE   : return "CL_PROFILING_INFO_NOT_AVAILABLE";

        case OpenCLLibrary.CL_MEM_COPY_OVERLAP               : return "CL_MEM_COPY_OVERLAP";

        case OpenCLLibrary.CL_IMAGE_FORMAT_MISMATCH          : return "CL_IMAGE_FORMAT_MISMATCH";

        case OpenCLLibrary.CL_IMAGE_FORMAT_NOT_SUPPORTED     : return "CL_IMAGE_FORMAT_NOT_SUPPORTED";

        case OpenCLLibrary.CL_BUILD_PROGRAM_FAILURE          : return "CL_BUILD_PROGRAM_FAILURE";

        case OpenCLLibrary.CL_MAP_FAILURE                    : return "CL_MAP_FAILURE";

case OpenCLLibrary.CL_INVALID_VALUE : return “CL_INVALID_VALUE”;

        case OpenCLLibrary.CL_INVALID_DEVICE_TYPE            : return "CL_INVALID_DEVICE_TYPE";

        case OpenCLLibrary.CL_INVALID_PLATFORM               : return "CL_INVALID_PLATFORM";

        case OpenCLLibrary.CL_INVALID_DEVICE                 : return "CL_INVALID_DEVICE";

        case OpenCLLibrary.CL_INVALID_CONTEXT                : return "CL_INVALID_CONTEXT";

        case OpenCLLibrary.CL_INVALID_QUEUE_PROPERTIES       : return "CL_INVALID_QUEUE_PROPERTIES";

        case OpenCLLibrary.CL_INVALID_COMMAND_QUEUE          : return "CL_INVALID_COMMAND_QUEUE";

        case OpenCLLibrary.CL_INVALID_HOST_PTR               : return "CL_INVALID_HOST_PTR";

        case OpenCLLibrary.CL_INVALID_MEM_OBJECT             : return "CL_INVALID_MEM_OBJECT";

        case OpenCLLibrary.CL_INVALID_IMAGE_FORMAT_DESCRIPTOR: return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";

        case OpenCLLibrary.CL_INVALID_IMAGE_SIZE             : return "CL_INVALID_IMAGE_SIZE";

        case OpenCLLibrary.CL_INVALID_SAMPLER                : return "CL_INVALID_SAMPLER";

        case OpenCLLibrary.CL_INVALID_BINARY                 : return "CL_INVALID_BINARY";

        case OpenCLLibrary.CL_INVALID_BUILD_OPTIONS          : return "CL_INVALID_BUILD_OPTIONS";

        case OpenCLLibrary.CL_INVALID_PROGRAM                : return "CL_INVALID_PROGRAM";

        case OpenCLLibrary.CL_INVALID_PROGRAM_EXECUTABLE     : return "CL_INVALID_PROGRAM_EXECUTABLE";

        case OpenCLLibrary.CL_INVALID_KERNEL_NAME            : return "CL_INVALID_KERNEL_NAME";

        case OpenCLLibrary.CL_INVALID_KERNEL_DEFINITION      : return "CL_INVALID_KERNEL_DEFINITION";

        case OpenCLLibrary.CL_INVALID_KERNEL                 : return "CL_INVALID_KERNEL";

        case OpenCLLibrary.CL_INVALID_ARG_INDEX              : return "CL_INVALID_ARG_INDEX";

        case OpenCLLibrary.CL_INVALID_ARG_VALUE              : return "CL_INVALID_ARG_VALUE";

        case OpenCLLibrary.CL_INVALID_ARG_SIZE               : return "CL_INVALID_ARG_SIZE";

        case OpenCLLibrary.CL_INVALID_KERNEL_ARGS            : return "CL_INVALID_KERNEL_ARGS";

        case OpenCLLibrary.CL_INVALID_WORK_DIMENSION         : return "CL_INVALID_WORK_DIMENSION";

        case OpenCLLibrary.CL_INVALID_WORK_GROUP_SIZE        : return "CL_INVALID_WORK_GROUP_SIZE";

        case OpenCLLibrary.CL_INVALID_WORK_ITEM_SIZE         : return "CL_INVALID_WORK_ITEM_SIZE";

        case OpenCLLibrary.CL_INVALID_GLOBAL_OFFSET          : return "CL_INVALID_GLOBAL_OFFSET";

        case OpenCLLibrary.CL_INVALID_EVENT_WAIT_LIST        : return "CL_INVALID_EVENT_WAIT_LIST";

        case OpenCLLibrary.CL_INVALID_OPERATION              : return "CL_INVALID_OPERATION";

        case OpenCLLibrary.CL_INVALID_GL_OBJECT              : return "CL_INVALID_GL_OBJECT";

        case OpenCLLibrary.CL_INVALID_BUFFER_SIZE            : return "CL_INVALID_BUFFER_SIZE";

        case OpenCLLibrary.CL_INVALID_MIP_LEVEL              : return "CL_INVALID_MIP_LEVEL";

        default: return "unknown";

    }

}

[/codebox]

Ok, now I’m checking the error code and I’m getting a CL_INVALID_BINARY error. The opencl specification says, that such an error occurs if the program is created with clCreateWithProgramBinary and the devices listed in device_list do not have a valid program binary loaded. But I never call clCreateWithProgramBinary, I create the program with a source file. What’s wrong there. And why can’t I access an array of user-defined structures in opencl? Surely, I’m doing something wrong but I don’t know what. Can anyone help me please?

Sounds like another weird compiler bug. Try clGetProgramBuildInfo after this return code and I’m pretty sure you’ll see a ptx assembler error.

If I understand what’s happening correctly clBuildProgram runs the compiler and then calls clCreateWithProgramBinary with the generated ptx. Normally you should get a compile error instead of the compiler generating invalid ptx which the assembler runs into, but if the ptx is wrong the error code from the assembler passes through.

Hi,

now I’m using the oclLogBuildInfo()-function to output the build log if an error occurs and it says there’s an syntax error in the line where I define my structures. But thats weird, cause the first few structures seems to be recognized correcty by the compiler. The error message is: Retrieving binary for “anonymous_jit_identity”. I don’t know exactly what I’m doing wrong.

If I change the following line:

Triangle t = triangles[index];

to

Point3D p = triangle[index].v0;

then the build process exits without an error. Anyone knows what I’m doing wrong?