mirror of
https://github.com/opencv/opencv.git
synced 2024-12-04 00:39:11 +08:00
ocl: force to use Khronos OpenCL headers
This commit is contained in:
parent
9d380ecc08
commit
6344da9ac3
@ -862,11 +862,10 @@ endif()
|
||||
if(HAVE_OPENCL)
|
||||
status("")
|
||||
status(" OpenCL:")
|
||||
set(__opencl_ver "invalid")
|
||||
if(HAVE_OPENCL12)
|
||||
set(__opencl_ver "1.2")
|
||||
elseif(HAVE_OPENCL11)
|
||||
set(__opencl_ver "1.1")
|
||||
if(HAVE_OPENCL_STATIC)
|
||||
set(__opencl_ver "static")
|
||||
else()
|
||||
set(__opencl_ver "dynamic")
|
||||
endif()
|
||||
status(" Version:" ${__opencl_ver})
|
||||
if(OPENCL_INCLUDE_DIR)
|
||||
|
@ -3,58 +3,37 @@ if(APPLE)
|
||||
set(OPENCL_LIBRARY "-framework OpenCL" CACHE STRING "OpenCL library")
|
||||
set(OPENCL_INCLUDE_DIR "" CACHE STRING "OpenCL include directory")
|
||||
mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
|
||||
set(HAVE_OPENCL_STATIC ON)
|
||||
else(APPLE)
|
||||
#find_package(OpenCL QUIET)
|
||||
|
||||
if(NOT OPENCL_FOUND)
|
||||
find_path(OPENCL_ROOT_DIR
|
||||
NAMES OpenCL/cl.h CL/cl.h include/CL/cl.h include/nvidia-current/CL/cl.h
|
||||
PATHS ENV OCLROOT ENV AMDAPPSDKROOT ENV CUDA_PATH ENV INTELOCLSDKROOT
|
||||
DOC "OpenCL root directory"
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
find_path(OPENCL_INCLUDE_DIR
|
||||
NAMES OpenCL/cl.h CL/cl.h
|
||||
HINTS ${OPENCL_ROOT_DIR}
|
||||
PATH_SUFFIXES include include/nvidia-current
|
||||
DOC "OpenCL include directory"
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
set(OPENCL_LIBRARY "OPENCL_DYNAMIC_LOAD")
|
||||
|
||||
mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENCL DEFAULT_MSG OPENCL_LIBRARY OPENCL_INCLUDE_DIR )
|
||||
endif()
|
||||
set(OPENCL_FOUND YES)
|
||||
set(HAVE_OPENCL_STATIC OFF)
|
||||
set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2")
|
||||
endif(APPLE)
|
||||
|
||||
if(OPENCL_FOUND)
|
||||
try_compile(HAVE_OPENCL11
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/opencl11.cpp"
|
||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENCL_INCLUDE_DIR}"
|
||||
)
|
||||
if(NOT HAVE_OPENCL11)
|
||||
message(STATUS "OpenCL 1.1 not found, ignore OpenCL SDK")
|
||||
return()
|
||||
endif()
|
||||
try_compile(HAVE_OPENCL12
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/opencl12.cpp"
|
||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENCL_INCLUDE_DIR}"
|
||||
)
|
||||
if(NOT HAVE_OPENCL12)
|
||||
message(STATUS "OpenCL 1.2 not found, will use OpenCL 1.1")
|
||||
if(NOT HAVE_OPENCL_STATIC)
|
||||
try_compile(__VALID_OPENCL
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/opencl.cpp"
|
||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENCL_INCLUDE_DIR}"
|
||||
OUTPUT_VARIABLE TRY_OUT
|
||||
)
|
||||
if(NOT TRY_OUT MATCHES "OpenCL is valid")
|
||||
message(WARNING "Can't use OpenCL")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(HAVE_OPENCL 1)
|
||||
set(OPENCL_INCLUDE_DIRS ${OPENCL_INCLUDE_DIR})
|
||||
if(OPENCL_LIBRARY MATCHES "OPENCL_DYNAMIC_LOAD")
|
||||
unset(OPENCL_LIBRARIES)
|
||||
else()
|
||||
|
||||
if(HAVE_OPENCL_STATIC)
|
||||
set(OPENCL_LIBRARIES "${OPENCL_LIBRARY}")
|
||||
else()
|
||||
unset(OPENCL_LIBRARIES)
|
||||
endif()
|
||||
|
||||
set(OPENCL_INCLUDE_DIRS ${OPENCL_INCLUDE_DIR})
|
||||
|
||||
if(WITH_OPENCLAMDFFT)
|
||||
find_path(CLAMDFFT_ROOT_DIR
|
||||
NAMES include/clAmdFft.h
|
||||
|
@ -7,8 +7,9 @@
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#ifdef CL_VERSION_1_2
|
||||
#error OpenCL is valid
|
||||
#else
|
||||
#error OpenCL 1.2 not found
|
||||
#error OpenCL check failed
|
||||
#endif
|
||||
return 0;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#if defined __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#ifdef CL_VERSION_1_1
|
||||
#else
|
||||
#error OpenCL 1.1 not found
|
||||
#endif
|
||||
return 0;
|
||||
}
|
@ -108,8 +108,7 @@
|
||||
|
||||
/* OpenCL Support */
|
||||
#cmakedefine HAVE_OPENCL
|
||||
#cmakedefine HAVE_OPENCL11
|
||||
#cmakedefine HAVE_OPENCL12
|
||||
#cmakedefine HAVE_OPENCL_STATIC
|
||||
|
||||
/* OpenEXR codec */
|
||||
#cmakedefine HAVE_OPENEXR
|
||||
|
@ -5,4 +5,4 @@ endif()
|
||||
|
||||
set(the_description "OpenCL-accelerated Computer Vision")
|
||||
ocv_define_module(ocl opencv_core opencv_imgproc opencv_features2d opencv_objdetect opencv_video opencv_calib3d opencv_ml "${OPENCL_LIBRARIES}")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wundef)
|
||||
|
@ -3,14 +3,20 @@
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
#if defined(HAVE_OPENCL12)
|
||||
#include "cl_runtime_opencl12.hpp"
|
||||
#elif defined(HAVE_OPENCL11)
|
||||
#include "cl_runtime_opencl11.hpp"
|
||||
#if defined(HAVE_OPENCL_STATIC)
|
||||
|
||||
#if defined __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#error Invalid OpenCL configuration
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#else // HAVE_OPENCL_STATIC
|
||||
|
||||
#include "cl_runtime_opencl.hpp"
|
||||
|
||||
#endif // HAVE_OPENCL_STATIC
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
#endif // __OPENCV_OCL_CL_RUNTIME_HPP__
|
||||
|
@ -1,13 +1,6 @@
|
||||
#include "precomp.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCL) && (!defined(__APPLE__) || defined(IOS))
|
||||
|
||||
#if defined(BUILD_SHARED_LIBS) && (defined WIN32 || defined _WIN32 || defined WINCE)
|
||||
#define CL_RUNTIME_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define CL_RUNTIME_EXPORT
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENCL) && !defined(HAVE_OPENCL_STATIC)
|
||||
|
||||
#include "opencv2/ocl/cl_runtime/cl_runtime.hpp"
|
||||
|
||||
@ -94,12 +87,6 @@ static void* opencl_check_fn(int ID)
|
||||
return func;
|
||||
}
|
||||
|
||||
#if defined(HAVE_OPENCL12)
|
||||
#include "cl_runtime_opencl12_impl.hpp"
|
||||
#elif defined(HAVE_OPENCL11)
|
||||
#include "cl_runtime_opencl11_impl.hpp"
|
||||
#else
|
||||
#error Invalid OpenCL configuration
|
||||
#endif
|
||||
#include "cl_runtime_opencl_impl.hpp"
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
#!/bin/bash -e
|
||||
echo "Generate files for CL runtime..."
|
||||
cat sources/opencl11/cl.h | python parser_cl.py cl_runtime_opencl11
|
||||
cat sources/opencl12/cl.h | python parser_cl.py cl_runtime_opencl12
|
||||
cat sources/cl.h | python parser_cl.py cl_runtime_opencl
|
||||
cat sources/clAmdBlas.h | python parser_clamdblas.py
|
||||
cat sources/clAmdFft.h | python parser_clamdfft.py
|
||||
echo "Generate files for CL runtime... Done"
|
||||
|
@ -1,12 +1,6 @@
|
||||
#ifndef __OPENCV_OCL_CL_RUNTIME_OPENCL_HPP__
|
||||
#define __OPENCV_OCL_CL_RUNTIME_OPENCL_HPP__
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
#if defined __APPLE__ && !defined(IOS)
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
|
||||
@CL_REMAP_ORIGIN@
|
||||
|
||||
#if defined __APPLE__
|
||||
@ -27,8 +21,4 @@
|
||||
|
||||
@CL_FN_DECLARATIONS@
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __OPENCV_OCL_CL_RUNTIME_OPENCL_HPP__
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "opencl_kernels.hpp"
|
||||
|
||||
// TODO Remove this after HAVE_CLAMDBLAS eliminating
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user