From 3d8ea972a4a825b12c2b7deb41edf87b6e338f5d Mon Sep 17 00:00:00 2001 From: Guo Yejun Date: Tue, 27 May 2014 07:10:04 +0800 Subject: 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 Reviewed-by: "Yang, Rong R" Tested-by: Zhigang Gong --- src/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/CMakeLists.txt') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 20e1a4c6..4c2b0277 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,6 +54,7 @@ set(OPENCL_SRC cl_alloc.c cl_kernel.c cl_program.c + cl_gbe_loader.cpp cl_sampler.c cl_event.c cl_enqueue.c @@ -98,12 +99,14 @@ link_directories (${LLVM_LIBRARY_DIR}) add_library(cl SHARED ${OPENCL_SRC}) target_link_libraries( cl - gbe + interp ${XLIB_LIBRARY} ${XEXT_LIBRARIES} ${XFIXES_LIBRARIES} ${DRM_INTEL_LIBRARIES} ${DRM_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_DL_LIBS} ${OPENGL_LIBRARIES} ${OPTIONAL_EGL_LIBRARY}) install (TARGETS cl LIBRARY DESTINATION ${LIB_INSTALL_DIR}/beignet) -- cgit v1.2.3