summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@intel.com>2014-09-12 14:29:23 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-09-12 16:08:41 +0800
commit44a2c4f5455980221a179c95fb7f8a4c024bcb94 (patch)
treebb0acfa38294ceef551adf7519c5461a3ff3a68f
parent30e684ed12ac82c900cf985d7e5d0a4355035282 (diff)
runtime: fix build status handling.
According to the spec: The build status is to Returns the build, compile or link status, whichever was performed last on program for device. The previous implementation only consider the clProgramBuild and doesn't consider the compile. Now fix it. Signed-off-by: Zhigang Gong <zhigang.gong@intel.com> Reviewed-by: He Junyan <junyan.he@inbox.com> Tested-by: "Meng, Mengmeng" <mengmeng.meng@intel.com> Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
-rw-r--r--src/cl_api.c12
-rw-r--r--src/cl_program.c45
-rw-r--r--src/cl_program.h1
3 files changed, 35 insertions, 23 deletions
diff --git a/src/cl_api.c b/src/cl_api.c
index a8a4b74..50f258a 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -1140,17 +1140,7 @@ clGetProgramBuildInfo(cl_program program,
INVALID_DEVICE_IF (device != program->ctx->device);
if (param_name == CL_PROGRAM_BUILD_STATUS) {
- cl_build_status status;
-
- if (!program->is_built)
- status = CL_BUILD_NONE;
- else if (program->ker_n > 0)
- status = CL_BUILD_SUCCESS;
- else
- status = CL_BUILD_ERROR;
- // TODO: Support CL_BUILD_IN_PROGRESS ?
-
- FILL_GETINFO_RET (cl_build_status, 1, &status, CL_SUCCESS);
+ FILL_GETINFO_RET (cl_build_status, 1, &program->build_status, CL_SUCCESS);
} else if (param_name == CL_PROGRAM_BUILD_OPTIONS) {
if (program->is_built && program->build_opts)
ret_str = program->build_opts;
diff --git a/src/cl_program.c b/src/cl_program.c
index 022e893..79dff34 100644
--- a/src/cl_program.c
+++ b/src/cl_program.c
@@ -119,6 +119,7 @@ cl_program_new(cl_context ctx)
/* Allocate the structure */
TRY_ALLOC_NO_ERR (p, CALLOC(struct _cl_program));
SET_ICD(p->dispatch)
+ p->build_status = CL_BUILD_NONE;
p->ref_n = 1;
p->magic = CL_MAGIC_PROGRAM_HEADER;
p->ctx = ctx;
@@ -471,12 +472,15 @@ cl_program_build(cl_program p, const char *options)
int i = 0;
int copyed = 0;
- if (p->ref_n > 1)
- return CL_INVALID_OPERATION;
-
- if (!check_cl_version_option(p, options))
- return CL_BUILD_PROGRAM_FAILURE;
+ if (p->ref_n > 1) {
+ err = CL_INVALID_OPERATION;
+ goto error;
+ }
+ if (!check_cl_version_option(p, options)) {
+ err = CL_BUILD_PROGRAM_FAILURE;
+ goto error;
+ }
if (options) {
if(p->build_opts == NULL || strcmp(options, p->build_opts) != 0) {
if(p->build_opts) {
@@ -555,9 +559,12 @@ cl_program_build(cl_program p, const char *options)
memcpy(p->bin + copyed, interp_kernel_get_code(opaque), sz);
copyed += sz;
}
+ p->is_built = 1;
+ p->build_status = CL_BUILD_SUCCESS;
+ return CL_SUCCESS;
error:
- p->is_built = 1;
+ p->build_status = CL_BUILD_ERROR;
return err;
}
@@ -594,7 +601,7 @@ cl_program_link(cl_context context,
if(options && strstr(options, "-create-library")){
p->binary_type = CL_PROGRAM_BINARY_TYPE_LIBRARY;
- return p;
+ goto done;
}else{
p->binary_type = CL_PROGRAM_BINARY_TYPE_EXECUTABLE;
}
@@ -617,9 +624,17 @@ cl_program_link(cl_context context,
memcpy(p->bin + copyed, interp_kernel_get_code(opaque), sz);
copyed += sz;
}
+done:
+ p->is_built = 1;
+ p->build_status = CL_BUILD_SUCCESS;
+ if (errcode_ret)
+ *errcode_ret = err;
+ return p;
error:
- p->is_built = 1;
+ p->build_status = CL_BUILD_ERROR;
+ if (errcode_ret)
+ *errcode_ret = err;
return p;
}
@@ -633,11 +648,15 @@ cl_program_compile(cl_program p,
cl_int err = CL_SUCCESS;
int i = 0;
- if (p->ref_n > 1)
- return CL_INVALID_OPERATION;
+ if (p->ref_n > 1) {
+ err = CL_INVALID_OPERATION;
+ goto error;
+ }
- if (!check_cl_version_option(p, options))
- return CL_BUILD_PROGRAM_FAILURE;
+ if (!check_cl_version_option(p, options)) {
+ err = CL_BUILD_PROGRAM_FAILURE;
+ goto error;
+ }
if (options) {
if(p->build_opts == NULL || strcmp(options, p->build_opts) != 0) {
@@ -722,9 +741,11 @@ cl_program_compile(cl_program p,
p->binary_type = CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
}
p->is_built = 1;
+ p->build_status = CL_BUILD_SUCCESS;
return CL_SUCCESS;
error:
+ p->build_status = CL_BUILD_ERROR;
cl_program_delete(p);
p = NULL;
return err;
diff --git a/src/cl_program.h b/src/cl_program.h
index d0336d5..6dea29a 100644
--- a/src/cl_program.h
+++ b/src/cl_program.h
@@ -54,6 +54,7 @@ struct _cl_program {
uint32_t ker_n; /* Number of declared kernels */
uint32_t source_type:2; /* Built from binary, source or LLVM */
uint32_t is_built:1; /* Did we call clBuildProgram on it? */
+ int32_t build_status; /* build status. */
char *build_opts; /* The build options for this program */
size_t build_log_max_sz; /*build log maximum size in byte.*/
char *build_log; /* The build log for this program. */