summaryrefslogtreecommitdiff
path: root/src/cl_api.c
diff options
context:
space:
mode:
authorLuo <xionghu.luo@intel.com>2014-06-18 08:17:34 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-06-18 20:00:42 +0800
commit9ee75c0aa5906a9d727ad56a60eb73a87c1c021f (patch)
tree09ea3634d8dbe0e68b56f6cc8389b76ad6f0d807 /src/cl_api.c
parent853ac4d94de25cf2c29fb8225e2a7162f40bdc7d (diff)
add binary type support for compiled object and library.
save the llvm bitcode to program->binary: insert a byte in front of the bitcode stands for binary type(0 means GEN binary, 1 means COMPILED_OBJECT, 2 means LIBRARY); load the binary to module by ParseIR. create random directory to save compile header files. use strncpy and strncat to replace strcpy and strcat. v6: fix enqueue_copy_fill bug, use '\0' instead of 0 in the header. v7 binary header format issue: fix test_load_program_from_bin bug of standalone kernel generated by gbe_bin_generater. Signed-off-by: Luo <xionghu.luo@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
Diffstat (limited to 'src/cl_api.c')
-rw-r--r--src/cl_api.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/cl_api.c b/src/cl_api.c
index 327f02bd..c4a8730a 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -1065,8 +1065,16 @@ clGetProgramInfo(cl_program program,
FILL_GETINFO_RET (char, (strlen(program->source) + 1),
program->source, CL_SUCCESS);
} else if (param_name == CL_PROGRAM_BINARY_SIZES) {
- if (program->binary == NULL) {
- program->binary_sz = compiler_program_serialize_to_binary(program->opaque, &program->binary);
+ if (program->binary == NULL){
+ if( program->binary_type == CL_PROGRAM_BINARY_TYPE_EXECUTABLE) {
+ program->binary_sz = compiler_program_serialize_to_binary(program->opaque, &program->binary, 0);
+ }else if( program->binary_type == CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT) {
+ program->binary_sz = compiler_program_serialize_to_binary(program->opaque, &program->binary, 1);
+ }else if( program->binary_type == CL_PROGRAM_BINARY_TYPE_LIBRARY) {
+ program->binary_sz = compiler_program_serialize_to_binary(program->opaque, &program->binary, 2);
+ }else{
+ return CL_INVALID_BINARY;
+ }
}
if (program->binary == NULL || program->binary_sz == 0) {
@@ -1082,7 +1090,15 @@ clGetProgramInfo(cl_program program,
/* param_value points to an array of n
pointers allocated by the caller */
if (program->binary == NULL) {
- program->binary_sz = compiler_program_serialize_to_binary(program->opaque, &program->binary);
+ if( program->binary_type == CL_PROGRAM_BINARY_TYPE_EXECUTABLE) {
+ program->binary_sz = compiler_program_serialize_to_binary(program->opaque, &program->binary, 0);
+ }else if( program->binary_type == CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT) {
+ program->binary_sz = compiler_program_serialize_to_binary(program->opaque, &program->binary, 1);
+ }else if( program->binary_type == CL_PROGRAM_BINARY_TYPE_LIBRARY) {
+ program->binary_sz = compiler_program_serialize_to_binary(program->opaque, &program->binary, 2);
+ }else{
+ return CL_INVALID_BINARY;
+ }
}
if (program->binary == NULL || program->binary_sz == 0) {
@@ -1134,6 +1150,9 @@ clGetProgramBuildInfo(cl_program program,
FILL_GETINFO_RET (char, program->build_log_sz + 1, program->build_log, CL_SUCCESS);
if (param_value_size_ret)
*param_value_size_ret = program->build_log_sz + 1;
+ }else if (param_name == CL_PROGRAM_BINARY_TYPE){
+
+ FILL_GETINFO_RET (cl_uint, 1, &program->binary_type, CL_SUCCESS);
} else {
return CL_INVALID_VALUE;
}