diff options
author | Luo Xionghu <xionghu.luo@intel.com> | 2015-11-26 14:00:00 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2016-03-15 16:21:45 +0800 |
commit | 98f4932986a51ea92b9c2e3c0b6d3a1bcdd36ebe (patch) | |
tree | 3d741b108ca19baa44cf775af9b1f44be8fa9144 | |
parent | a0fc923b249eb3669821387f3e58964111824e75 (diff) | |
download | beignet-98f4932986a51ea92b9c2e3c0b6d3a1bcdd36ebe.tar.gz |
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.c | 1 | ||||
-rw-r--r-- | src/cl_program.c | 17 | ||||
-rw-r--r-- | src/cl_program.h | 1 |
3 files changed, 6 insertions, 13 deletions
diff --git a/src/cl_api.c b/src/cl_api.c index ee0691e2..f7b43e06 100644 --- a/src/cl_api.c +++ b/src/cl_api.c @@ -1349,6 +1349,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 ffdb2a11..1a99aba3 100644 --- a/src/cl_program.c +++ b/src/cl_program.c @@ -27,6 +27,7 @@ #include "cl_gbe_loader.h" #include "CL/cl.h" #include "CL/cl_intel.h" +#include "CL/cl_ext.h" #include <stdio.h> #include <stdlib.h> @@ -289,6 +290,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; @@ -569,17 +571,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; } @@ -675,7 +670,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++; } } @@ -785,14 +781,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; } @@ -856,7 +848,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 083d66a6..70c6aeb1 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:2; /* Built from binary, source or LLVM */ uint32_t is_built:1; /* Did we call clBuildProgram on it? */ |