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;
/* 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;
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) {
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;
}
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;
}
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;
}
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) {
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;
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. */