summaryrefslogtreecommitdiff
path: root/src/cl_program.c
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@intel.com>2013-11-26 18:39:59 +0800
committerZhigang Gong <zhigang.gong@intel.com>2013-11-27 16:27:02 +0800
commit47a0573bf406dc6185733d8d4059ba9385b1fdc7 (patch)
treec281d82667bc962e1d6cd89a94c5e6e3cc9341b8 /src/cl_program.c
parent2b2fe68a424444c901a50a045124be17a7790ac6 (diff)
Runtime: implement the get build log function and fix one build error check issue.
According to spec, we need to support CL_PROGRAM_BUILD_LOG which is used to get the build log of a cl kernel. And we also need to check whether a build failure is a generic build fail or a build option error. This commit also fix the piglit case: API/clBuildProgram. Another change in this commit is that it reroute all the output of the clang excution to internal buffer and don't print to the console directly. If the user want to get the detail build log, the CL_PROGRAM_BUILD_LOG could be used. v2: include both clang error messages and the llvm-to-gen error messages. Also refine the checking for the error buffer parameter. If there is no error buffer specified, always flush the build log to llvm::errs(). Signed-off-by: Zhigang Gong <zhigang.gong@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src/cl_program.c')
-rw-r--r--src/cl_program.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/cl_program.c b/src/cl_program.c
index df2f1e09..d6d68c07 100644
--- a/src/cl_program.c
+++ b/src/cl_program.c
@@ -109,7 +109,9 @@ cl_program_new(cl_context ctx)
p->ref_n = 1;
p->magic = CL_MAGIC_PROGRAM_HEADER;
p->ctx = ctx;
-
+ p->build_log = calloc(200, sizeof(char));
+ if (p->build_log)
+ p->build_log_max_sz = 200;
/* The queue also belongs to its context */
cl_context_add_ref(ctx);
@@ -223,7 +225,7 @@ cl_program_create_from_llvm(cl_context ctx,
INVALID_VALUE_IF (file_name == NULL);
program = cl_program_new(ctx);
- program->opaque = gbe_program_new_from_llvm(file_name, 0, NULL, NULL);
+ program->opaque = gbe_program_new_from_llvm(file_name, program->build_log_max_sz, program->build_log, &program->build_log_sz);
if (UNLIKELY(program->opaque == NULL)) {
err = CL_INVALID_PROGRAM;
goto error;
@@ -324,9 +326,12 @@ cl_program_build(cl_program p, const char *options)
}
if (p->source_type == FROM_SOURCE) {
- p->opaque = gbe_program_new_from_source(p->source, 0, options, NULL, NULL);
+ p->opaque = gbe_program_new_from_source(p->source, p->build_log_max_sz, options, p->build_log, &p->build_log_sz);
if (UNLIKELY(p->opaque == NULL)) {
- err = CL_BUILD_PROGRAM_FAILURE;
+ if (p->build_log_sz > 0 && strstr(p->build_log, "error: error reading 'options'"))
+ err = CL_INVALID_BUILD_OPTIONS;
+ else
+ err = CL_BUILD_PROGRAM_FAILURE;
goto error;
}