summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Xionghu <xionghu.luo@intel.com>2015-11-26 14:00:00 +0800
committerYang Rong <rong.r.yang@intel.com>2015-12-09 11:42:44 +0800
commitce989175e2aa88093da7748965cbafa086ab3305 (patch)
treea6e3da92edd970e0b90961c7eeaf24bb3452bc29
parentd47346045626e9f5023e0058b6e6d3ca72818a1f (diff)
runtime: fix clCompileProgram bug.
forgot to add FROM_LLVM_SPIR in compileProgram; the BINARY_TYPE is BINARY_TYPE_INTERMIDIATE if create from SPIR binary. v2: refine the source_type logic: source_type is already set in clCreateProgramWithSource or clCreateProgramWithBinary, shouldn't be set in clBuildProgram or clCompileProgram. Signed-off-by: Luo Xionghu <xionghu.luo@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--src/cl_api.c1
-rw-r--r--src/cl_program.c17
-rw-r--r--src/cl_program.h1
3 files changed, 6 insertions, 13 deletions
diff --git a/src/cl_api.c b/src/cl_api.c
index bb56cc53..3baf38ac 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -992,6 +992,7 @@ clCompileProgram(cl_program program ,
/* TODO support create program from binary */
assert(program->source_type == FROM_LLVM ||
program->source_type == FROM_SOURCE ||
+ program->source_type == FROM_LLVM_SPIR ||
program->source_type == FROM_BINARY);
if((err = cl_program_compile(program, num_input_headers, input_headers, header_include_names, options)) != CL_SUCCESS) {
goto error;
diff --git a/src/cl_program.c b/src/cl_program.c
index 1dca673f..16ab0bff 100644
--- a/src/cl_program.c
+++ b/src/cl_program.c
@@ -28,6 +28,7 @@
#include "cl_cmrt.h"
#include "CL/cl.h"
#include "CL/cl_intel.h"
+#include "CL/cl_ext.h"
#include <stdio.h>
#include <stdlib.h>
@@ -263,6 +264,7 @@ cl_program_create_from_binary(cl_context ctx,
}
program->source_type = FROM_LLVM_SPIR;
+ program->binary_type = CL_PROGRAM_BINARY_TYPE_INTERMEDIATE;
}else if(isLLVM_C_O((unsigned char*)program->binary) || isLLVM_LIB((unsigned char*)program->binary)) {
if(*program->binary == BHI_COMPIRED_OBJECT){
program->binary_type = CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
@@ -557,17 +559,10 @@ cl_program_build(cl_program p, const char *options)
}
TRY_ALLOC (p->build_opts, cl_calloc(strlen(options) + 1, sizeof(char)));
memcpy(p->build_opts, options, strlen(options));
-
- p->source_type = p->source ? FROM_SOURCE : p->binary ? FROM_BINARY : FROM_LLVM;
- if (strstr(options, "-x spir")) {
- p->source_type = FROM_LLVM_SPIR;
- }
}
}
if (options == NULL && p->build_opts) {
- p->source_type = p->source ? FROM_SOURCE : p->binary ? FROM_BINARY : FROM_LLVM;
-
cl_free(p->build_opts);
p->build_opts = NULL;
}
@@ -660,7 +655,8 @@ cl_program_link(cl_context context,
for(i = 0; i < num_input_programs; i++) {
//num_input_programs >0 and input_programs MUST not NULL, so compare with input_programs[0] directly.
if(input_programs[i]->binary_type == CL_PROGRAM_BINARY_TYPE_LIBRARY ||
- input_programs[i]->binary_type == CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT) {
+ input_programs[i]->binary_type == CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT ||
+ input_programs[i]->binary_type == CL_PROGRAM_BINARY_TYPE_INTERMEDIATE) {
avialable_program++;
}
}
@@ -766,14 +762,10 @@ cl_program_compile(cl_program p,
}
TRY_ALLOC (p->build_opts, cl_calloc(strlen(options) + 1, sizeof(char)));
memcpy(p->build_opts, options, strlen(options));
-
- p->source_type = p->source ? FROM_SOURCE : p->binary ? FROM_BINARY : FROM_LLVM;
}
}
if (options == NULL && p->build_opts) {
- p->source_type = p->source ? FROM_SOURCE : p->binary ? FROM_BINARY : FROM_LLVM;
-
cl_free(p->build_opts);
p->build_opts = NULL;
}
@@ -837,7 +829,6 @@ cl_program_compile(cl_program p,
}
/* Create all the kernels */
- p->source_type = FROM_LLVM;
p->binary_type = CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
}else if(p->source_type == FROM_BINARY){
err = CL_INVALID_OPERATION;
diff --git a/src/cl_program.h b/src/cl_program.h
index 899a31a7..b69e00c3 100644
--- a/src/cl_program.h
+++ b/src/cl_program.h
@@ -62,6 +62,7 @@ struct _cl_program {
char *binary; /* Program binary. */
size_t binary_sz; /* The binary size. */
uint32_t binary_type; /* binary type: COMPILED_OBJECT(LLVM IR), LIBRARY(LLVM IR with option "-create-library"), or EXECUTABLE(GEN binary). */
+ /* ext binary type: BINARY_TYPE_INTERMIDIATE. */
uint32_t ker_n; /* Number of declared kernels */
uint32_t source_type:3; /* Built from binary, source, CMRT or LLVM*/
uint32_t is_built:1; /* Did we call clBuildProgram on it? */