summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorPan Xiuli <xiuli.pan@intel.com>2017-02-13 09:51:45 +0800
committerYang Rong <rong.r.yang@intel.com>2017-02-14 15:23:24 +0800
commit9e96ddfce7120e48730e39f4ce5a9d2e4fab10e9 (patch)
tree8048928a5edc3f9c204fdda2157bff2b88106a62 /CMakeLists.txt
parent3c31216a4ef148ba2e6048e30c62a7a7209407cb (diff)
downloadbeignet-9e96ddfce7120e48730e39f4ce5a9d2e4fab10e9.tar.gz
Enable OpenCL 2.0 only where supported
This allows a single beignet binary to both offer 2.0 where available, and still work on older hardware. V2: Default to 1.2 when -cl-std is not set (required by the OpenCL spec, and also likely to be faster). V3: Only enable OpenCL 2.0 when llvm version is 39. V4: Only enable OpenCL 2.0 on x64 host. V5: Always return 32 as address bits. Contributor: Rebecca N. Palmer <rebecca_palmer@zoho.com> Signed-off-by: Pan Xiuli <xiuli.pan@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt46
1 files changed, 32 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b6d7928c..a111fe2a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -231,20 +231,18 @@ IF (EXPERIMENTAL_DOUBLE)
ADD_DEFINITIONS(-DENABLE_FP64)
ENDIF(EXPERIMENTAL_DOUBLE)
-OPTION(ENABLE_OPENCL_20 "Enable opencl 2.0 support" OFF)
-IF (ENABLE_OPENCL_20)
- Find_Program(LSPCI lspci)
- IF (NOT LSPCI)
- MESSAGE(FATAL_ERROR "Looking for lspci - not found")
- ENDIF (NOT LSPCI)
- EXECUTE_PROCESS(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/GetGenID.sh"
- RESULT_VARIABLE SUPPORT_OCL20_DEVICE
- OUTPUT_VARIABLE PCI_ID_NOT_USED)
-
- IF (NOT SUPPORT_OCL20_DEVICE EQUAL 1)
- MESSAGE(FATAL_ERROR "Only SKL and newer devices support OpenCL 2.0 now, your device don't support.")
- ENDIF (NOT SUPPORT_OCL20_DEVICE EQUAL 1)
+SET(CAN_OPENCL_20 ON)
+IF (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ SET(CAN_OPENCL_20 OFF)
+ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
+IF (NOT HAVE_DRM_INTEL_BO_SET_SOFTPIN)
+ SET(CAN_OPENCL_20 OFF)
+ENDIF (NOT HAVE_DRM_INTEL_BO_SET_SOFTPIN)
+IF (LLVM_VERSION_NODOT VERSION_LESS 39)
+ SET(CAN_OPENCL_20 OFF)
+ENDIF (LLVM_VERSION_NODOT VERSION_LESS 39)
+IF (ENABLE_OPENCL_20)
IF (NOT HAVE_DRM_INTEL_BO_SET_SOFTPIN)
MESSAGE(FATAL_ERROR "Please update libdrm to version 2.4.66 or later to enable OpenCL 2.0.")
ENDIF (NOT HAVE_DRM_INTEL_BO_SET_SOFTPIN)
@@ -253,9 +251,29 @@ IF (ENABLE_OPENCL_20)
MESSAGE(FATAL_ERROR "Please update LLVM to version 3.9 or later to enable OpenCL 2.0.")
ENDIF (LLVM_VERSION_NODOT VERSION_LESS 39)
- ADD_DEFINITIONS(-DENABLE_OPENCL_20)
+ IF (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ MESSAGE(FATAL_ERROR "Please use x64 host to enable OpenCL 2.0.")
+ ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
ENDIF(ENABLE_OPENCL_20)
+IF (DEFINED ENABLE_OPENCL_20)
+ IF (ENABLE_OPENCL_20 AND CAN_OPENCL_20)
+ SET(CAN_OPENCL_20 ON)
+ ELSE(ENABLE_OPENCL_20 AND CAN_OPENCL_20)
+ SET(CAN_OPENCL_20 OFF)
+ ENDIF (ENABLE_OPENCL_20 AND CAN_OPENCL_20)
+ENDIF (DEFINED ENABLE_OPENCL_20)
+
+OPTION(ENABLE_OPENCL_20 "Enable opencl 2.0 support" ${CAN_OPENCL_20})
+
+IF (CAN_OPENCL_20)
+ SET (ENABLE_OPENCL_20 ON)
+ MESSAGE(STATUS "Building with OpenCL 2.0.")
+ ADD_DEFINITIONS(-DENABLE_OPENCL_20)
+ELSE (CAN_OPENCL_20)
+ MESSAGE(STATUS "Building with OpenCL 1.2.")
+ENDIF(CAN_OPENCL_20)
+
set (LIBCL_DRIVER_VERSION_MAJOR 1)
set (LIBCL_DRIVER_VERSION_MINOR 4)
if (ENABLE_OPENCL_20)