[Beignet] [PATCH OCL20 v2] Backend: Refine typedef of ptrint_t
Xiuli Pan
xiuli.pan at intel.com
Fri Mar 25 07:57:50 UTC 2016
From: Pan Xiuli <xiuli.pan at intel.com>
V2: refined with clang macro __INTPTR_WIDTH__ and
clang built-in types __INTXX_TYPE__
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
backend/src/backend/program.cpp | 4 ++++
backend/src/libocl/CMakeLists.txt | 16 +++++++++++-----
backend/src/libocl/include/ocl_types.h | 9 +++++++--
src/cl_gt_device.h | 2 +-
4 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 6c5761c..08b604f 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -561,7 +561,11 @@ namespace gbe {
args.push_back("-x");
args.push_back("cl");
args.push_back("-triple");
+if(sizeof(int*) == 8) {
args.push_back("spir64");
+} else {
+ args.push_back("spir");
+}
#endif /* LLVM_VERSION_MINOR <= 2 */
args.push_back("stringInput.cl");
args.push_back("-ffp-contract=off");
diff --git a/backend/src/libocl/CMakeLists.txt b/backend/src/libocl/CMakeLists.txt
index d7ed841..bda7793 100644
--- a/backend/src/libocl/CMakeLists.txt
+++ b/backend/src/libocl/CMakeLists.txt
@@ -130,14 +130,20 @@ FOREACH(M ${OCL_BASH_GENERATED_MODULES})
ENDFOREACH(M)
-SET (CLANG_OCL_FLAGS -fno-builtin -ffp-contract=off -cl-kernel-arg-info -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND "-cl-std=CL2.0")
+if(NOT SPIRTARGET)
+ set(SPIRTARGET spir)
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(SPIRTARGET spir64)
+ endif()
+endif()
+SET (CLANG_OCL_FLAGS -fno-builtin -ffp-contract=off -cl-kernel-arg-info -triple ${SPIRTARGET} -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND -cl-std=CL2.0)
MACRO(ADD_CL_TO_BC_TARGET _file)
# 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}
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 spir64 -o ${output_name} -x cl ${_file}
- COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS} -I ${OCL_OBJECT_DIR}/include/ -emit-llvm-bc -triple spir64 -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_OCL_FLAGS} -I ${OCL_OBJECT_DIR}/include/ -emit-llvm-bc -o ${output_name} -x cl ${_file}
DEPENDS ${_file} ${OCL_HEADER_FILES}
COMMENT "Compiling ${_file}"
)
@@ -201,14 +207,14 @@ ADD_CUSTOM_COMMAND(OUTPUT ${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} -triple spir64 -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} -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} -triple spir64 -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} -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"
)
diff --git a/backend/src/libocl/include/ocl_types.h b/backend/src/libocl/include/ocl_types.h
index 824262d..1031178 100644
--- a/backend/src/libocl/include/ocl_types.h
+++ b/backend/src/libocl/include/ocl_types.h
@@ -47,8 +47,13 @@ typedef unsigned int uint;
typedef unsigned long ulong;
typedef __typeof__(sizeof(int)) size_t;
typedef __typeof__((int *)0-(int *)0) ptrdiff_t;
-typedef signed int intptr_t;
-typedef unsigned int uintptr_t;
+#define __int_t_type(a,b,c) a##b##c
+#define __int_type(type,n) __int_t_type(type,n,_TYPE__)
+typedef __int_type(__INT,__INTPTR_WIDTH__) intptr_t;
+typedef __int_type(__UINT,__INTPTR_WIDTH__) uintptr_t;
+#undef __int_type
+#undef __int_t_type
+
/////////////////////////////////////////////////////////////////////////////
// OpenCL address space
diff --git a/src/cl_gt_device.h b/src/cl_gt_device.h
index 041ddaa..35a6ff5 100644
--- a/src/cl_gt_device.h
+++ b/src/cl_gt_device.h
@@ -40,7 +40,7 @@
.native_vector_width_double = 2,
.native_vector_width_half = 8,
.preferred_wg_sz_mul = 16,
-.address_bits = 64,
+.address_bits = sizeof(size_t)*8,
.svm_capabilities = CL_DEVICE_SVM_COARSE_GRAIN_BUFFER,
.preferred_platform_atomic_alignment = 0,
.preferred_global_atomic_alignment = 0,
--
2.5.0
More information about the Beignet
mailing list