[Beignet] [PATCH 5/9] runtime: fix clCompileProgram bug.

xionghu.luo at intel.com xionghu.luo at intel.com
Thu Nov 12 00:41:51 PST 2015


From: Luo Xionghu <xionghu.luo at intel.com>

forgot to add FROM_LLVM_SPIR in compileProgram; the BINARY_TYPE is
BINARY_TYPE_INTERMIDIATE if create from SPIR binary.

Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
 src/cl_api.c     | 1 +
 src/cl_program.c | 5 ++++-
 src/cl_program.h | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/cl_api.c b/src/cl_api.c
index 9eb4ffd..e5ee002 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -987,6 +987,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 98b6d51..891d51a 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>
@@ -250,6 +251,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;
@@ -633,7 +635,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++;
     }
   }
diff --git a/src/cl_program.h b/src/cl_program.h
index 63ad16d..897f283 100644
--- a/src/cl_program.h
+++ b/src/cl_program.h
@@ -60,6 +60,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? */
-- 
1.9.1



More information about the Beignet mailing list