[Beignet] [PATCH 08/19] OCL20: add beignet_20.pch and beignet_20.bc.
Yang Rong
rong.r.yang at intel.com
Mon Nov 28 11:32:34 UTC 2016
Always build beignet.pch and beignet.pch, and build beignet_20.bc and
beignet_20.pch when enable OpenCL 2.0.
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
backend/CMakeLists.txt | 3 +-
backend/src/CMakeLists.txt | 12 ++++
backend/src/GBEConfig.h.in | 2 +
backend/src/libocl/CMakeLists.txt | 111 +++++++++++++++++++--------------
backend/src/libocl/src/ocl_vload_20.cl | 2 +-
5 files changed, 81 insertions(+), 49 deletions(-)
diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt
index 915d60f..57df8a5 100644
--- a/backend/CMakeLists.txt
+++ b/backend/CMakeLists.txt
@@ -50,7 +50,8 @@ set(LOCAL_GBE_OBJECT_DIR ${LOCAL_GBE_OBJECT_DIR} PARENT_SCOPE)
set(LOCAL_INTERP_OBJECT_DIR ${LOCAL_INTERP_OBJECT_DIR} PARENT_SCOPE)
set (GBE_BIN_GENERATER
- env OCL_BITCODE_LIB_PATH=${LOCAL_OCL_BITCODE_BIN} OCL_HEADER_FILE_DIR=${LOCAL_OCL_HEADER_DIR} OCL_PCH_PATH=${LOCAL_OCL_PCH_OBJECT})
+ env OCL_BITCODE_LIB_PATH=${LOCAL_OCL_BITCODE_BIN} OCL_HEADER_FILE_DIR=${LOCAL_OCL_HEADER_DIR} OCL_PCH_PATH=${LOCAL_OCL_PCH_OBJECT}
+ OCL_BITCODE_LIB_20_PATH=${LOCAL_OCL_BITCODE_BIN_20} OCL_PCH_20_PATH=${LOCAL_OCL_PCH_OBJECT_20})
if (USE_STANDALONE_GBE_COMPILER STREQUAL "true")
set (GBE_BIN_GENERATER
diff --git a/backend/src/CMakeLists.txt b/backend/src/CMakeLists.txt
index 6ff25e7..2af0844 100644
--- a/backend/src/CMakeLists.txt
+++ b/backend/src/CMakeLists.txt
@@ -3,6 +3,10 @@ set (OCL_HEADER_DIR "${BEIGNET_INSTALL_DIR}/include")
set (OCL_PCH_OBJECT "${BEIGNET_INSTALL_DIR}/beignet.pch")
set (GBE_OBJECT_DIR "${BEIGNET_INSTALL_DIR}/libgbe.so")
set (INTERP_OBJECT_DIR "${BEIGNET_INSTALL_DIR}/libgbeinterp.so")
+if (ENABLE_OPENCL_20)
+set (OCL_BITCODE_BIN_20 "${BEIGNET_INSTALL_DIR}/beignet_20.bc")
+set (OCL_PCH_OBJECT_20 "${BEIGNET_INSTALL_DIR}/beignet_20.pch")
+endif (ENABLE_OPENCL_20)
configure_file (
"GBEConfig.h.in"
@@ -19,6 +23,10 @@ set (LOCAL_INTERP_OBJECT_DIR "${CMAKE_CURRENT_BINARY_DIR}/libgbeinterp.so" PAREN
set (LOCAL_OCL_BITCODE_BIN "${OCL_OBJECT_DIR}/beignet.bc" PARENT_SCOPE)
set (LOCAL_OCL_HEADER_DIR "${OCL_OBJECT_DIR}/include/" PARENT_SCOPE)
set (LOCAL_OCL_PCH_OBJECT "${OCL_OBJECT_DIR}/beignet.local.pch" PARENT_SCOPE)
+if (ENABLE_OPENCL_20)
+set (LOCAL_OCL_BITCODE_BIN_20 "${OCL_OBJECT_DIR}/beignet_20.bc" PARENT_SCOPE)
+set (LOCAL_OCL_PCH_OBJECT_20 "${OCL_OBJECT_DIR}/beignet_20.local.pch" PARENT_SCOPE)
+endif (ENABLE_OPENCL_20)
set (GBE_SRC
${ocl_blob_file}
@@ -197,6 +205,10 @@ endif ()
install (TARGETS gbe LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR})
install (FILES ${OCL_OBJECT_DIR}/beignet.bc DESTINATION ${BEIGNET_INSTALL_DIR})
install (FILES ${OCL_OBJECT_DIR}/beignet.pch DESTINATION ${BEIGNET_INSTALL_DIR})
+if (ENABLE_OPENCL_20)
+install (FILES ${OCL_OBJECT_DIR}/beignet_20.bc DESTINATION ${BEIGNET_INSTALL_DIR})
+install (FILES ${OCL_OBJECT_DIR}/beignet_20.pch DESTINATION ${BEIGNET_INSTALL_DIR})
+endif (ENABLE_OPENCL_20)
install (FILES ${OCL_HEADER_FILES} DESTINATION ${BEIGNET_INSTALL_DIR}/include)
endif (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true"))
diff --git a/backend/src/GBEConfig.h.in b/backend/src/GBEConfig.h.in
index b5bec14..9514483 100644
--- a/backend/src/GBEConfig.h.in
+++ b/backend/src/GBEConfig.h.in
@@ -6,3 +6,5 @@
#define OCL_BITCODE_BIN "@OCL_BITCODE_BIN@"
#define OCL_HEADER_DIR "@OCL_HEADER_DIR@"
#define OCL_PCH_OBJECT "@OCL_PCH_OBJECT@"
+#define OCL_BITCODE_BIN_20 "@OCL_BITCODE_BIN_20@"
+#define OCL_PCH_OBJECT_20 "@OCL_PCH_OBJECT_20@"
diff --git a/backend/src/libocl/CMakeLists.txt b/backend/src/libocl/CMakeLists.txt
index e828fd0..a4f575f 100644
--- a/backend/src/libocl/CMakeLists.txt
+++ b/backend/src/libocl/CMakeLists.txt
@@ -68,7 +68,7 @@ FOREACH(M ${OCL_COPY_MODULES_12})
COPY_THE_SOURCE(OCL_SOURCE_FILES_12 ${M})
ENDFOREACH(M)
-SET (OCL_COPY_MODULES_20 ocl_vload_20 ocl_atom ocl_atom_20 ocl_pipe)
+SET (OCL_COPY_MODULES_20 ocl_vload_20 ocl_atom_20 ocl_pipe)
FOREACH(M ${OCL_COPY_MODULES_20})
COPY_THE_HEADER(${M})
COPY_THE_SOURCE(OCL_SOURCE_FILES_20 ${M})
@@ -156,15 +156,15 @@ FOREACH(M ${OCL_BASH_GENERATED_MODULES})
GENERATE_SOURCE_BASH(${M})
ENDFOREACH(M)
+SET (CLANG_OCL_FLAGS -fno-builtin -ffp-contract=off -triple spir -cl-kernel-arg-info -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND "-cl-std=CL1.2" -D__OPENCL_C_VERSION__=120)
+SET (CLANG_OCL_FLAGS_20 -fno-builtin -ffp-contract=off -triple spir64 -cl-kernel-arg-info -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND "-cl-std=CL2.0" -D__OPENCL_C_VERSION__=200)
-SET (CLANG_OCL_FLAGS -fno-builtin -ffp-contract=off -cl-kernel-arg-info -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND "-cl-std=CL1.2")
-MACRO(ADD_CL_TO_BC_TARGET _file)
+MACRO(ADD_CL_TO_BC_TARGET _file _output _clang_flag)
# CMake seems can not add pattern rule, use MACRO to replace.
- STRING(REGEX REPLACE "${LIBOCL_BINARY_DIR}/src/\(o.*\)\\.cl" "${OCL_OBJECT_DIR}/\\1.bc" output_name ${_file})
- ADD_CUSTOM_COMMAND(OUTPUT ${output_name}
+ ADD_CUSTOM_COMMAND(OUTPUT ${_output}
COMMAND mkdir -p ${OCL_OBJECT_DIR}/
- #COMMAND echo ${LLVM_INSTALL_DIR}clang -cc1 ${CLANG_OCL_FLAGS} -I ${LIBOCL_BINARY_DIR}/include/ -emit-llvm-bc -triple spir -o ${output_name} -x cl ${_file}
- COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS} -I ${OCL_OBJECT_DIR}/include/ -emit-llvm-bc -triple spir -o ${output_name} -x cl ${_file}
+ #COMMAND echo ${LLVM_INSTALL_DIR}clang -cc1 ${CLANG_OCL_FLAGS} -I ${LIBOCL_BINARY_DIR}/include/ -emit-llvm-bc -o ${output_name} -x cl ${_file}
+ COMMAND ${CLANG_EXECUTABLE} -cc1 ${_clang_flag} -I ${OCL_OBJECT_DIR}/include/ -emit-llvm-bc -o ${_output} -x cl ${_file}
DEPENDS ${_file} ${OCL_HEADER_FILES}
COMMENT "Compiling ${_file}"
)
@@ -172,21 +172,15 @@ ENDMACRO(ADD_CL_TO_BC_TARGET)
FOREACH(f ${OCL_SOURCE_FILES})
- ADD_CL_TO_BC_TARGET(${f})
STRING(REGEX REPLACE "${LIBOCL_BINARY_DIR}/src/\(o.*\)\\.cl" "${OCL_OBJECT_DIR}/\\1.bc" bc_name ${f})
- SET(OCL_BC_FILES ${OCL_BC_FILES} ${bc_name})
+ SET(OCL_BC_FILES_12 ${OCL_BC_FILES_12} ${bc_name})
+ ADD_CL_TO_BC_TARGET(${f} ${bc_name} "${CLANG_OCL_FLAGS}")
ENDFOREACH(f)
FOREACH(f ${OCL_SOURCE_FILES_12})
- ADD_CL_TO_BC_TARGET(${f})
STRING(REGEX REPLACE "${LIBOCL_BINARY_DIR}/src/\(o.*\)\\.cl" "${OCL_OBJECT_DIR}/\\1.bc" bc_name ${f})
SET(OCL_BC_FILES_12 ${OCL_BC_FILES_12} ${bc_name})
-ENDFOREACH(f)
-
-FOREACH(f ${OCL_SOURCE_FILES_20})
- ADD_CL_TO_BC_TARGET(${f})
- STRING(REGEX REPLACE "${LIBOCL_BINARY_DIR}/src/\(o.*\)\\.cl" "${OCL_OBJECT_DIR}/\\1.bc" bc_name ${f})
- SET(OCL_BC_FILES_20 ${OCL_BC_FILES_20} ${bc_name})
+ ADD_CL_TO_BC_TARGET(${f} ${bc_name} "${CLANG_OCL_FLAGS}")
ENDFOREACH(f)
# handle the ll files
@@ -213,19 +207,11 @@ MACRO(ADD_LL_TO_BC_TARGET M)
#COMMAND echo ${LLVM_INSTALL_DIR}llvm-as -o ${output_name} ${srcll_name}
COMMAND ${LLVM_AS_EXECUTABLE} -o ${output_name} ${srcll_name}
DEPENDS ${srcll_name}
- COMMENT "Compiling ${srcll_name}"
+ COMMENT "Compiling ${output_name}"
)
ENDMACRO(ADD_LL_TO_BC_TARGET)
-SET (OCL_LL_MODULES ocl_barrier ocl_clz)
-FOREACH(f ${OCL_LL_MODULES})
- COPY_THE_LL(${f})
- ADD_LL_TO_BC_TARGET(${f})
- STRING(REGEX REPLACE "\(o.*\)" "${OCL_OBJECT_DIR}/\\1.bc" bc_name ${f})
- SET(OCL_BC_FILES ${OCL_BC_FILES} ${bc_name})
-ENDFOREACH(f)
-
-SET (OCL_LL_MODULES_12 ocl_ctz)
+SET (OCL_LL_MODULES_12 ocl_barrier ocl_clz ocl_ctz)
FOREACH(f ${OCL_LL_MODULES_12})
COPY_THE_LL(${f})
ADD_LL_TO_BC_TARGET(${f})
@@ -233,47 +219,78 @@ FOREACH(f ${OCL_LL_MODULES_12})
SET(OCL_BC_FILES_12 ${OCL_BC_FILES_12} ${bc_name})
ENDFOREACH(f)
-SET (OCL_LL_MODULES_20 ocl_ctz_20 ocl_atomic_20)
-FOREACH(f ${OCL_LL_MODULES_20})
- COPY_THE_LL(${f})
- ADD_LL_TO_BC_TARGET(${f})
- STRING(REGEX REPLACE "\(o.*\)" "${OCL_OBJECT_DIR}/\\1.bc" bc_name ${f})
- SET(OCL_BC_FILES_20 ${OCL_BC_FILES_20} ${bc_name})
-ENDFOREACH(f)
-
ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet.bc
COMMAND mkdir -p ${LIBOCL_BINARY_DIR}/lib/
- #COMMAND echo llvm-link -o ${LIBOCL_BINARY_DIR}/lib/beignet.bc ${OCL_BC_FILES}
- COMMAND ${LLVM_LINK_EXECUTABLE} -o ${OCL_OBJECT_DIR}/beignet.bc ${OCL_BC_FILES} ${OCL_BC_FILES_12}
- DEPENDS ${OCL_BC_FILES} ${OCL_BC_FILES_12}
+ #COMMAND echo llvm-link -o ${LIBOCL_BINARY_DIR}/lib/beignet.bc ${OCL_BC_FILES12}
+ COMMAND ${LLVM_LINK_EXECUTABLE} -o ${OCL_OBJECT_DIR}/beignet.bc ${OCL_BC_FILES_12}
+ DEPENDS ${OCL_BC_FILES_12}
COMMENT "Generate the bitcode file: ${OCL_OBJECT_DIR}/beignet.bc"
)
+ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet.local.pch
+ COMMAND mkdir -p ${OCL_OBJECT_DIR}
+ COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS} -I ${OCL_OBJECT_DIR}/include/ -emit-pch -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet.local.pch
+ DEPENDS ${OCL_HEADER_FILES}
+ COMMENT "Generate the pch file: ${OCL_OBJECT_DIR}/beignet.local.pch"
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet.pch
+ COMMAND mkdir -p ${OCL_OBJECT_DIR}
+ COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS} -I ${OCL_OBJECT_DIR}/include/ --relocatable-pch -emit-pch -isysroot ${LIBOCL_BINARY_DIR} -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet.pch
+ DEPENDS ${OCL_HEADER_FILES}
+ COMMENT "Generate the pch file: ${OCL_OBJECT_DIR}/beignet.pch"
+ )
+
+
if (ENABLE_OPENCL_20)
-ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet_20.bc
+ FOREACH(f ${OCL_SOURCE_FILES})
+ STRING(REGEX REPLACE "${LIBOCL_BINARY_DIR}/src/\(o.*\)\\.cl" "${OCL_OBJECT_DIR}/\\1_20.bc" bc_name ${f})
+ SET(OCL_BC_FILES_20 ${OCL_BC_FILES_20} ${bc_name})
+ ADD_CL_TO_BC_TARGET(${f} ${bc_name} "${CLANG_OCL_FLAGS_20}")
+ ENDFOREACH(f)
+
+ FOREACH(f ${OCL_SOURCE_FILES_20})
+ STRING(REGEX REPLACE "${LIBOCL_BINARY_DIR}/src/\(o.*\)\\.cl" "${OCL_OBJECT_DIR}/\\1.bc" bc_name ${f})
+ SET(OCL_BC_FILES_20 ${OCL_BC_FILES_20} ${bc_name})
+ ADD_CL_TO_BC_TARGET(${f} ${bc_name} "${CLANG_OCL_FLAGS_20}")
+ ENDFOREACH(f)
+
+ SET (OCL_LL_MODULES_20 ocl_barrier_20 ocl_clz_20 ocl_ctz_20 ocl_atomic_20)
+ FOREACH(f ${OCL_LL_MODULES_20})
+ COPY_THE_LL(${f})
+ ADD_LL_TO_BC_TARGET(${f})
+ STRING(REGEX REPLACE "\(o.*\)" "${OCL_OBJECT_DIR}/\\1.bc" bc_name ${f})
+ SET(OCL_BC_FILES_20 ${OCL_BC_FILES_20} ${bc_name})
+ ENDFOREACH(f)
+
+ ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet_20.bc
COMMAND mkdir -p ${LIBOCL_BINARY_DIR}/lib/
#COMMAND echo llvm-link -o ${LIBOCL_BINARY_DIR}/lib/beignet.bc ${OCL_BC_FILES}
- COMMAND ${LLVM_LINK_EXECUTABLE} -o ${OCL_OBJECT_DIR}/beignet_20.bc ${OCL_BC_FILES} ${OCL_BC_FILES_20}
- DEPENDS ${OCL_BC_FILES} ${OCL_BC_FILES_20}
+ COMMAND ${LLVM_LINK_EXECUTABLE} -o ${OCL_OBJECT_DIR}/beignet_20.bc ${OCL_BC_FILES_20}
+ DEPENDS ${OCL_BC_FILES_20}
COMMENT "Generate the bitcode file: ${OCL_OBJECT_DIR}/beignet_20.bc"
)
-endif (ENABLE_OPENCL_20)
-ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet.local.pch
+ ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet_20.local.pch
COMMAND mkdir -p ${OCL_OBJECT_DIR}
- COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS} -triple spir -I ${OCL_OBJECT_DIR}/include/ -emit-pch -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet.local.pch
+ COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS_20} -I ${OCL_OBJECT_DIR}/include/ -emit-pch -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet_20.local.pch
DEPENDS ${OCL_HEADER_FILES}
- COMMENT "Generate the pch file: ${OCL_OBJECT_DIR}/beignet.local.pch"
+ COMMENT "Generate the pch file: ${OCL_OBJECT_DIR}/beignet_20.local.pch"
)
-ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet.pch
+ ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet_20.pch
COMMAND mkdir -p ${OCL_OBJECT_DIR}
- COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS} -triple spir -I ${OCL_OBJECT_DIR}/include/ --relocatable-pch -emit-pch -isysroot ${LIBOCL_BINARY_DIR} -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet.pch
+ COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS_20} -I ${OCL_OBJECT_DIR}/include/ --relocatable-pch -emit-pch -isysroot ${LIBOCL_BINARY_DIR} -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet_20.pch
DEPENDS ${OCL_HEADER_FILES}
- COMMENT "Generate the pch file: ${OCL_OBJECT_DIR}/beignet.pch"
+ COMMENT "Generate the pch file: ${OCL_OBJECT_DIR}/beignet_20.pch"
)
+endif (ENABLE_OPENCL_20)
+if (ENABLE_OPENCL_20)
+add_custom_target(beignet_bitcode ALL DEPENDS ${OCL_OBJECT_DIR}/beignet.bc ${OCL_OBJECT_DIR}/beignet_20.bc ${OCL_OBJECT_DIR}/beignet.pch ${OCL_OBJECT_DIR}/beignet_20.pch ${OCL_OBJECT_DIR}/beignet.local.pch ${OCL_OBJECT_DIR}/beignet_20.local.pch)
+else(ENABLE_OPENCL_20)
add_custom_target(beignet_bitcode ALL DEPENDS ${OCL_OBJECT_DIR}/beignet.bc ${OCL_OBJECT_DIR}/beignet.pch ${OCL_OBJECT_DIR}/beignet.local.pch)
+endif (ENABLE_OPENCL_20)
SET (OCL_OBJECT_DIR ${OCL_OBJECT_DIR} PARENT_SCOPE)
SET (OCL_HEADER_FILES ${OCL_HEADER_FILES} PARENT_SCOPE)
diff --git a/backend/src/libocl/src/ocl_vload_20.cl b/backend/src/libocl/src/ocl_vload_20.cl
index a629f13..ab06aa2 100644
--- a/backend/src/libocl/src/ocl_vload_20.cl
+++ b/backend/src/libocl/src/ocl_vload_20.cl
@@ -16,7 +16,7 @@
*
*/
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-#include "ocl_vload20.h"
+#include "ocl_vload_20.h"
#include "ocl_relational.h"
// These loads and stores will use untyped reads and writes, so we can just
--
2.1.4
More information about the Beignet
mailing list