Преглед изворни кода

src/drivers/opencl/driver_opencl_utils.c: always display the output of the OpenCL compilation, and also check compilation status with clGetProgramBuildInfo(CL_PROGRAM_BUILD_STATUS)

Nathalie Furmento пре 13 година
родитељ
комит
16e7849761
1 измењених фајлова са 18 додато и 9 уклоњено
  1. 18 9
      src/drivers/opencl/driver_opencl_utils.c

+ 18 - 9
src/drivers/opencl/driver_opencl_utils.c

@@ -200,17 +200,26 @@ int starpu_opencl_load_opencl_from_string(const char *opencl_program_source, str
 
                 // Build the program executable
                 err = clBuildProgram(program, 1, &device, build_options, NULL, NULL);
-                if (err != CL_SUCCESS)
-		{
-                        size_t len;
-                        static char buffer[4096];
 
-                        _STARPU_DISP("Error: Failed to build program executable!\n");
-                        clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);
+		// Get the status
+		{
+		     cl_build_status status;
+		     size_t len;
+		     static char buffer[4096] = "";
+
+		     clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);
+		     if (len > 2)
+			  _STARPU_DISP("Compilation output\n%s\n", buffer);
+
+		     clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, sizeof(status), &status, NULL);
+		     if (err != CL_SUCCESS || status != CL_BUILD_SUCCESS)
+		     {
+			  _STARPU_DISP("Error: Failed to build program executable!\n");
+			  _STARPU_DISP("clBuildProgram: %d - clGetProgramBuildInfo: %d\n", err, status);
+			  return EXIT_FAILURE;
+		     }
 
-                        _STARPU_DISP("<%s>\n", buffer);
-                        return EXIT_FAILURE;
-                }
+		}
 
                 // Store program
                 opencl_programs->programs[dev] = program;