diff options
author | Guo Yejun <yejun.guo@intel.com> | 2014-05-27 07:10:04 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-05-28 09:08:38 +0800 |
commit | 3d8ea972a4a825b12c2b7deb41edf87b6e338f5d (patch) | |
tree | 5a8c2d6cc2ae3ebbd18799e333a5aa1c7fe683f1 /src/cl_program.c | |
parent | 604c0ee37c031a902f28a3a181e1314c8bab46f3 (diff) |
separate runtime(libcl.so) and compiler(libgbe.so)
On embedded/handheld devices, storage and memory are scarce, it is
necessary to provide only the OpenCL runtime library with small size,
and only the executable binary kernel will be supported on such device.
At the beginning of process (before function main), OpenCL runtime
(libcl.so) will try to load the compiler (libgbe.so), the system's
behavior is the same as before if successfully loaded, otherwise,
the runtime assumes no OpenCL compiler in the system, and the device
info will be changed as CL_DEVICE_COMPILER_AVAILABLE=false and
CL_DEVICE_PROFILE="EMBEDDED_PROFILE", the clBuildProgram returns
CL_COMPILER_NOT_AVAILABLE if the program is created with
clCreateProgramWithSource, following the OpenCL spec.
To simulate the case without OpenCL compiler, just delete the file
libgbe.so, or export OCL_NON_COMPILER=1.
Some explanation of the binary kernel interpreter (libinterp.a):
libinterp.a is used to interpret the binary kernel inside runtime,
and the runtime library libcl.so is built against libinterp.a.
Since the code to interpret binary kernel is tightly integrated inside
the compiler, to avoid code duplicate, a new file gbe_bin_interpreter.cpp
is created to include some other .cpp files; to make libinterp.a small
(the purpose to make libcl.so small), the macro GBE_COMPILER_AVAILABLE
is used to make only the needed code active when build for libinterp.a.
V2: code base is changed to call function gbe_set_image_base_index in
gbe_bin_generater, while this function is modified in this patch as
gbe_set_image_base_index_compiler, fix it accordingly.
Signed-off-by: Guo Yejun <yejun.guo@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
Tested-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'src/cl_program.c')
-rw-r--r-- | src/cl_program.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cl_program.c b/src/cl_program.c index 184d6b5a..c4e85d15 100644 --- a/src/cl_program.c +++ b/src/cl_program.c @@ -24,6 +24,7 @@ #include "cl_alloc.h" #include "cl_utils.h" #include "cl_khr_icd.h" +#include "cl_gbe_loader.h" #include "CL/cl.h" #include "CL/cl_intel.h" @@ -326,6 +327,11 @@ cl_program_build(cl_program p, const char *options) } if (p->source_type == FROM_SOURCE) { + if (!CompilerSupported()) { + err = CL_COMPILER_NOT_AVAILABLE; + goto error; + } + p->opaque = gbe_program_new_from_source(p->ctx->device->vendor_id, p->source, p->build_log_max_sz, options, p->build_log, &p->build_log_sz); if (UNLIKELY(p->opaque == NULL)) { if (p->build_log_sz > 0 && strstr(p->build_log, "error: error reading 'options'")) |