[FFmpeg-devel] [PATCH 2/3] avutil/opencl: Display build log on compile error

Timo Rothenpieler timo at rothenpieler.org
Thu Sep 24 17:12:24 CEST 2015


---
 libavutil/opencl.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/libavutil/opencl.c b/libavutil/opencl.c
index 8686493..2469ba4 100644
--- a/libavutil/opencl.c
+++ b/libavutil/opencl.c
@@ -452,8 +452,9 @@ cl_program av_opencl_compile(const char *program_name, const char *build_opts)
     cl_int status;
     int kernel_code_idx = 0;
     const char *kernel_source;
-    size_t kernel_code_len;
+    size_t kernel_code_len, build_log_len;
     char* ptr = NULL;
+    char* build_log = NULL;
     cl_program program = NULL;
 
     LOCK_OPENCL;
@@ -485,6 +486,19 @@ cl_program av_opencl_compile(const char *program_name, const char *build_opts)
     if (status != CL_SUCCESS) {
         av_log(&opencl_ctx, AV_LOG_ERROR,
                "Compilation failed with OpenCL program: %s\n", program_name);
+
+        status = clGetProgramBuildInfo(program, opencl_ctx.device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_len);
+        if (status != CL_SUCCESS)
+            goto end;
+
+        build_log = av_malloc(build_log_len);
+
+        status = clGetProgramBuildInfo(program, opencl_ctx.device_id, CL_PROGRAM_BUILD_LOG, build_log_len, build_log, NULL);
+        if (status != CL_SUCCESS)
+            goto end;
+
+        av_log(&opencl_ctx, AV_LOG_DEBUG, "OpenCL Build Log:\n%s\n", build_log);
+
         program = NULL;
         goto end;
     }
@@ -492,6 +506,7 @@ cl_program av_opencl_compile(const char *program_name, const char *build_opts)
     opencl_ctx.kernel_code[kernel_code_idx].is_compiled = 1;
 end:
     UNLOCK_OPENCL;
+    av_free(build_log);
     return program;
 }
 
-- 
2.5.3



More information about the ffmpeg-devel mailing list