mirror of
https://github.com/opencv/opencv.git
synced 2024-12-05 01:39:13 +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)
|
if(HAVE_OPENCL)
|
||||||
status("")
|
status("")
|
||||||
status(" OpenCL:")
|
status(" OpenCL:")
|
||||||
set(__opencl_ver "invalid")
|
if(HAVE_OPENCL_STATIC)
|
||||||
if(HAVE_OPENCL12)
|
set(__opencl_ver "static")
|
||||||
set(__opencl_ver "1.2")
|
else()
|
||||||
elseif(HAVE_OPENCL11)
|
set(__opencl_ver "dynamic")
|
||||||
set(__opencl_ver "1.1")
|
|
||||||
endif()
|
endif()
|
||||||
status(" Version:" ${__opencl_ver})
|
status(" Version:" ${__opencl_ver})
|
||||||
if(OPENCL_INCLUDE_DIR)
|
if(OPENCL_INCLUDE_DIR)
|
||||||
|
@ -3,58 +3,37 @@ if(APPLE)
|
|||||||
set(OPENCL_LIBRARY "-framework OpenCL" CACHE STRING "OpenCL library")
|
set(OPENCL_LIBRARY "-framework OpenCL" CACHE STRING "OpenCL library")
|
||||||
set(OPENCL_INCLUDE_DIR "" CACHE STRING "OpenCL include directory")
|
set(OPENCL_INCLUDE_DIR "" CACHE STRING "OpenCL include directory")
|
||||||
mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
|
mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
|
||||||
|
set(HAVE_OPENCL_STATIC ON)
|
||||||
else(APPLE)
|
else(APPLE)
|
||||||
#find_package(OpenCL QUIET)
|
set(OPENCL_FOUND YES)
|
||||||
|
set(HAVE_OPENCL_STATIC OFF)
|
||||||
if(NOT OPENCL_FOUND)
|
set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2")
|
||||||
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()
|
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
if(OPENCL_FOUND)
|
if(OPENCL_FOUND)
|
||||||
try_compile(HAVE_OPENCL11
|
if(NOT HAVE_OPENCL_STATIC)
|
||||||
|
try_compile(__VALID_OPENCL
|
||||||
"${OpenCV_BINARY_DIR}"
|
"${OpenCV_BINARY_DIR}"
|
||||||
"${OpenCV_SOURCE_DIR}/cmake/checks/opencl11.cpp"
|
"${OpenCV_SOURCE_DIR}/cmake/checks/opencl.cpp"
|
||||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENCL_INCLUDE_DIR}"
|
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENCL_INCLUDE_DIR}"
|
||||||
|
OUTPUT_VARIABLE TRY_OUT
|
||||||
)
|
)
|
||||||
if(NOT HAVE_OPENCL11)
|
if(NOT TRY_OUT MATCHES "OpenCL is valid")
|
||||||
message(STATUS "OpenCL 1.1 not found, ignore OpenCL SDK")
|
message(WARNING "Can't use OpenCL")
|
||||||
return()
|
return()
|
||||||
endif()
|
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")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(HAVE_OPENCL 1)
|
set(HAVE_OPENCL 1)
|
||||||
set(OPENCL_INCLUDE_DIRS ${OPENCL_INCLUDE_DIR})
|
|
||||||
if(OPENCL_LIBRARY MATCHES "OPENCL_DYNAMIC_LOAD")
|
if(HAVE_OPENCL_STATIC)
|
||||||
unset(OPENCL_LIBRARIES)
|
|
||||||
else()
|
|
||||||
set(OPENCL_LIBRARIES "${OPENCL_LIBRARY}")
|
set(OPENCL_LIBRARIES "${OPENCL_LIBRARY}")
|
||||||
|
else()
|
||||||
|
unset(OPENCL_LIBRARIES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(OPENCL_INCLUDE_DIRS ${OPENCL_INCLUDE_DIR})
|
||||||
|
|
||||||
if(WITH_OPENCLAMDFFT)
|
if(WITH_OPENCLAMDFFT)
|
||||||
find_path(CLAMDFFT_ROOT_DIR
|
find_path(CLAMDFFT_ROOT_DIR
|
||||||
NAMES include/clAmdFft.h
|
NAMES include/clAmdFft.h
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
#ifdef CL_VERSION_1_2
|
#ifdef CL_VERSION_1_2
|
||||||
|
#error OpenCL is valid
|
||||||
#else
|
#else
|
||||||
#error OpenCL 1.2 not found
|
#error OpenCL check failed
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
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 */
|
/* OpenCL Support */
|
||||||
#cmakedefine HAVE_OPENCL
|
#cmakedefine HAVE_OPENCL
|
||||||
#cmakedefine HAVE_OPENCL11
|
#cmakedefine HAVE_OPENCL_STATIC
|
||||||
#cmakedefine HAVE_OPENCL12
|
|
||||||
|
|
||||||
/* OpenEXR codec */
|
/* OpenEXR codec */
|
||||||
#cmakedefine HAVE_OPENEXR
|
#cmakedefine HAVE_OPENEXR
|
||||||
|
@ -5,4 +5,4 @@ endif()
|
|||||||
|
|
||||||
set(the_description "OpenCL-accelerated Computer Vision")
|
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_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
|
#ifdef HAVE_OPENCL
|
||||||
|
|
||||||
#if defined(HAVE_OPENCL12)
|
#if defined(HAVE_OPENCL_STATIC)
|
||||||
#include "cl_runtime_opencl12.hpp"
|
|
||||||
#elif defined(HAVE_OPENCL11)
|
#if defined __APPLE__
|
||||||
#include "cl_runtime_opencl11.hpp"
|
#include <OpenCL/cl.h>
|
||||||
#else
|
#else
|
||||||
#error Invalid OpenCL configuration
|
#include <CL/cl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#else // HAVE_OPENCL_STATIC
|
||||||
|
|
||||||
|
#include "cl_runtime_opencl.hpp"
|
||||||
|
|
||||||
|
#endif // HAVE_OPENCL_STATIC
|
||||||
|
|
||||||
|
#endif // HAVE_OPENCL
|
||||||
|
|
||||||
#endif // __OPENCV_OCL_CL_RUNTIME_HPP__
|
#endif // __OPENCV_OCL_CL_RUNTIME_HPP__
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
#if defined(HAVE_OPENCL) && (!defined(__APPLE__) || defined(IOS))
|
#if defined(HAVE_OPENCL) && !defined(HAVE_OPENCL_STATIC)
|
||||||
|
|
||||||
#if defined(BUILD_SHARED_LIBS) && (defined WIN32 || defined _WIN32 || defined WINCE)
|
|
||||||
#define CL_RUNTIME_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define CL_RUNTIME_EXPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include "opencv2/ocl/cl_runtime/cl_runtime.hpp"
|
#include "opencv2/ocl/cl_runtime/cl_runtime.hpp"
|
||||||
|
|
||||||
@ -94,12 +87,6 @@ static void* opencl_check_fn(int ID)
|
|||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_OPENCL12)
|
#include "cl_runtime_opencl_impl.hpp"
|
||||||
#include "cl_runtime_opencl12_impl.hpp"
|
|
||||||
#elif defined(HAVE_OPENCL11)
|
|
||||||
#include "cl_runtime_opencl11_impl.hpp"
|
|
||||||
#else
|
|
||||||
#error Invalid OpenCL configuration
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
echo "Generate files for CL runtime..."
|
echo "Generate files for CL runtime..."
|
||||||
cat sources/opencl11/cl.h | python parser_cl.py cl_runtime_opencl11
|
cat sources/cl.h | python parser_cl.py cl_runtime_opencl
|
||||||
cat sources/opencl12/cl.h | python parser_cl.py cl_runtime_opencl12
|
|
||||||
cat sources/clAmdBlas.h | python parser_clamdblas.py
|
cat sources/clAmdBlas.h | python parser_clamdblas.py
|
||||||
cat sources/clAmdFft.h | python parser_clamdfft.py
|
cat sources/clAmdFft.h | python parser_clamdfft.py
|
||||||
echo "Generate files for CL runtime... Done"
|
echo "Generate files for CL runtime... Done"
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#ifndef __OPENCV_OCL_CL_RUNTIME_OPENCL_HPP__
|
#ifndef __OPENCV_OCL_CL_RUNTIME_OPENCL_HPP__
|
||||||
#define __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@
|
@CL_REMAP_ORIGIN@
|
||||||
|
|
||||||
#if defined __APPLE__
|
#if defined __APPLE__
|
||||||
@ -27,8 +21,4 @@
|
|||||||
|
|
||||||
@CL_FN_DECLARATIONS@
|
@CL_FN_DECLARATIONS@
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // __OPENCV_OCL_CL_RUNTIME_OPENCL_HPP__
|
#endif // __OPENCV_OCL_CL_RUNTIME_OPENCL_HPP__
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#include "opencl_kernels.hpp"
|
#include "opencl_kernels.hpp"
|
||||||
|
|
||||||
// TODO Remove this after HAVE_CLAMDBLAS eliminating
|
// 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"
|
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user