mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #24179 from Kumataro:fix24145
* core:add OPENCV_IPP_MEAN/MINMAX/SUM option to enable IPP optimizations * fix: to use guard HAVE_IPP and ocv_append_source_file_compile_definitions() macro. * support OPENCV_IPP_ENABLE_ALL * add document for OPENCV_IPP_ENABLE_ALL * fix OPENCV_IPP_ENABLE_ALL comment
This commit is contained in:
parent
bb43927077
commit
81cc89a3ce
@ -224,6 +224,16 @@ Following options can be used to produce special builds with instrumentation or
|
|||||||
@see [Link time optimization](https://gcc.gnu.org/wiki/LinkTimeOptimization)
|
@see [Link time optimization](https://gcc.gnu.org/wiki/LinkTimeOptimization)
|
||||||
@see [ThinLTO](https://clang.llvm.org/docs/ThinLTO.html)
|
@see [ThinLTO](https://clang.llvm.org/docs/ThinLTO.html)
|
||||||
|
|
||||||
|
## Enable IPP optimization
|
||||||
|
|
||||||
|
Following options can be used to enables IPP optimizations for each functions but increases the size of the opencv library. All options are disabled by default.
|
||||||
|
|
||||||
|
| Option | Functions | + roughly size |
|
||||||
|
| -------| --------- | -------------- |
|
||||||
|
| `OPENCV_IPP_GAUSSIAN_BLUR` | GaussianBlur() | +8Mb |
|
||||||
|
| `OPENCV_IPP_MEAN` | mean() / meanStdDev() | +0.2Mb |
|
||||||
|
| `OPENCV_IPP_MINMAX` | minMaxLoc() / minMaxIdx() | +0.2Mb |
|
||||||
|
| `OPENCV_IPP_SUM` | sum() | +0.1Mb |
|
||||||
|
|
||||||
# Functional features and dependencies {#tutorial_config_reference_func}
|
# Functional features and dependencies {#tutorial_config_reference_func}
|
||||||
|
|
||||||
@ -565,6 +575,7 @@ Following options can be used to change installation layout for common scenarios
|
|||||||
| ------ | ------- | ----------- |
|
| ------ | ------- | ----------- |
|
||||||
| `OPENCV_ENABLE_NONFREE` | _OFF_ | Some algorithms included in the library are known to be protected by patents and are disabled by default. |
|
| `OPENCV_ENABLE_NONFREE` | _OFF_ | Some algorithms included in the library are known to be protected by patents and are disabled by default. |
|
||||||
| `OPENCV_FORCE_3RDPARTY_BUILD`| _OFF_ | Enable all `BUILD_` options at once. |
|
| `OPENCV_FORCE_3RDPARTY_BUILD`| _OFF_ | Enable all `BUILD_` options at once. |
|
||||||
|
| `OPENCV_IPP_ENABLE_ALL`| _OFF_ | Enable all `OPENCV_IPP_` options at once. |
|
||||||
| `ENABLE_CCACHE` | _ON_ (on Unix-like platforms) | Enable [ccache](https://en.wikipedia.org/wiki/Ccache) auto-detection. This tool wraps compiler calls and caches results, can significantly improve re-compilation time. |
|
| `ENABLE_CCACHE` | _ON_ (on Unix-like platforms) | Enable [ccache](https://en.wikipedia.org/wiki/Ccache) auto-detection. This tool wraps compiler calls and caches results, can significantly improve re-compilation time. |
|
||||||
| `ENABLE_PRECOMPILED_HEADERS` | _ON_ (for MSVC) | Enable precompiled headers support. Improves build time. |
|
| `ENABLE_PRECOMPILED_HEADERS` | _ON_ (for MSVC) | Enable precompiled headers support. Improves build time. |
|
||||||
| `BUILD_DOCS` | _OFF_ | Enable documentation build (_doxygen_, _doxygen_cpp_, _doxygen_python_, _doxygen_javadoc_ targets). [Doxygen](http://www.doxygen.org/index.html) must be installed for C++ documentation build. Python and [BeautifulSoup4](https://en.wikipedia.org/wiki/Beautiful_Soup_(HTML_parser)) must be installed for Python documentation build. Javadoc and Ant must be installed for Java documentation build (part of Java SDK). |
|
| `BUILD_DOCS` | _OFF_ | Enable documentation build (_doxygen_, _doxygen_cpp_, _doxygen_python_, _doxygen_javadoc_ targets). [Doxygen](http://www.doxygen.org/index.html) must be installed for C++ documentation build. Python and [BeautifulSoup4](https://en.wikipedia.org/wiki/Beautiful_Soup_(HTML_parser)) must be installed for Python documentation build. Javadoc and Ant must be installed for Java documentation build (part of Java SDK). |
|
||||||
|
@ -60,6 +60,26 @@ if(CV_TRACE AND HAVE_ITT)
|
|||||||
add_definitions(-DOPENCV_WITH_ITT=1)
|
add_definitions(-DOPENCV_WITH_ITT=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# https://github.com/opencv/opencv/issues/24145
|
||||||
|
if(HAVE_IPP)
|
||||||
|
OCV_OPTION(OPENCV_IPP_ENABLE_ALL "Enable all OPENCV_IPP_ options at once" OFF)
|
||||||
|
OCV_OPTION(OPENCV_IPP_MEAN "Enable IPP optimizations for mean (+200Kb in binary size)" OPENCV_IPP_ENABLE_ALL)
|
||||||
|
OCV_OPTION(OPENCV_IPP_MINMAX "Enable IPP optimizations for minMaxLoc/minMaxIdx (+200Kb in binary size)" OPENCV_IPP_ENABLE_ALL)
|
||||||
|
OCV_OPTION(OPENCV_IPP_SUM "Enable IPP optimizations for sum (+100Kb in binary size)" OPENCV_IPP_ENABLE_ALL)
|
||||||
|
|
||||||
|
if(OPENCV_IPP_MEAN)
|
||||||
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/mean.dispatch.cpp "OPENCV_IPP_MEAN=1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(OPENCV_IPP_MINMAX)
|
||||||
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/minmax.cpp "OPENCV_IPP_MINMAX=1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(OPENCV_IPP_SUM)
|
||||||
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/sum.dispatch.cpp "OPENCV_IPP_SUM=1")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
file(GLOB lib_cuda_hdrs
|
file(GLOB lib_cuda_hdrs
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.hpp"
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.hpp"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.h")
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.h")
|
||||||
|
@ -8,20 +8,24 @@
|
|||||||
#include "opencv2/core/openvx/ovx_defs.hpp"
|
#include "opencv2/core/openvx/ovx_defs.hpp"
|
||||||
#include "stat.hpp"
|
#include "stat.hpp"
|
||||||
|
|
||||||
|
#ifndef OPENCV_IPP_MEAN
|
||||||
#undef HAVE_IPP
|
#undef HAVE_IPP
|
||||||
#undef CV_IPP_RUN_FAST
|
#undef CV_IPP_RUN_FAST
|
||||||
#define CV_IPP_RUN_FAST(f, ...)
|
#define CV_IPP_RUN_FAST(f, ...)
|
||||||
#undef CV_IPP_RUN
|
#undef CV_IPP_RUN
|
||||||
#define CV_IPP_RUN(c, f, ...)
|
#define CV_IPP_RUN(c, f, ...)
|
||||||
|
#endif // OPENCV_IPP_MEAN
|
||||||
|
|
||||||
#include "mean.simd.hpp"
|
#include "mean.simd.hpp"
|
||||||
#include "mean.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
|
#include "mean.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
|
||||||
|
|
||||||
|
#ifndef OPENCV_IPP_MEAN
|
||||||
#undef HAVE_IPP
|
#undef HAVE_IPP
|
||||||
#undef CV_IPP_RUN_FAST
|
#undef CV_IPP_RUN_FAST
|
||||||
#define CV_IPP_RUN_FAST(f, ...)
|
#define CV_IPP_RUN_FAST(f, ...)
|
||||||
#undef CV_IPP_RUN
|
#undef CV_IPP_RUN
|
||||||
#define CV_IPP_RUN(c, f, ...)
|
#define CV_IPP_RUN(c, f, ...)
|
||||||
|
#endif // OPENCV_IPP_MEAN
|
||||||
|
|
||||||
namespace cv {
|
namespace cv {
|
||||||
|
|
||||||
|
@ -11,11 +11,13 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifndef OPENCV_IPP_MINMAX
|
||||||
#undef HAVE_IPP
|
#undef HAVE_IPP
|
||||||
#undef CV_IPP_RUN_FAST
|
#undef CV_IPP_RUN_FAST
|
||||||
#define CV_IPP_RUN_FAST(f, ...)
|
#define CV_IPP_RUN_FAST(f, ...)
|
||||||
#undef CV_IPP_RUN
|
#undef CV_IPP_RUN
|
||||||
#define CV_IPP_RUN(c, f, ...)
|
#define CV_IPP_RUN(c, f, ...)
|
||||||
|
#endif // OPENCV_IPP_MINMAX
|
||||||
|
|
||||||
#define IPP_DISABLE_MINMAXIDX_MANY_ROWS 1 // see Core_MinMaxIdx.rows_overflow test
|
#define IPP_DISABLE_MINMAXIDX_MANY_ROWS 1 // see Core_MinMaxIdx.rows_overflow test
|
||||||
|
|
||||||
|
@ -10,11 +10,13 @@
|
|||||||
#include "sum.simd.hpp"
|
#include "sum.simd.hpp"
|
||||||
#include "sum.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
|
#include "sum.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
|
||||||
|
|
||||||
|
#ifndef OPENCV_IPP_SUM
|
||||||
#undef HAVE_IPP
|
#undef HAVE_IPP
|
||||||
#undef CV_IPP_RUN_FAST
|
#undef CV_IPP_RUN_FAST
|
||||||
#define CV_IPP_RUN_FAST(f, ...)
|
#define CV_IPP_RUN_FAST(f, ...)
|
||||||
#undef CV_IPP_RUN
|
#undef CV_IPP_RUN
|
||||||
#define CV_IPP_RUN(c, f, ...)
|
#define CV_IPP_RUN(c, f, ...)
|
||||||
|
#endif // OPENCV_IPP_SUM
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
@ -12,8 +12,10 @@ ocv_add_dispatched_file(smooth SSE2 SSE4_1 AVX2)
|
|||||||
ocv_add_dispatched_file(sumpixels SSE2 AVX2 AVX512_SKX)
|
ocv_add_dispatched_file(sumpixels SSE2 AVX2 AVX512_SKX)
|
||||||
ocv_define_module(imgproc opencv_core WRAP java objc python js)
|
ocv_define_module(imgproc opencv_core WRAP java objc python js)
|
||||||
|
|
||||||
ocv_check_environment_variables(OPENCV_IPP_GAUSSIAN_BLUR)
|
if(HAVE_IPP)
|
||||||
option(OPENCV_IPP_GAUSSIAN_BLUR "Enable IPP optimizations for GaussianBlur (+8Mb in binary size)" OFF)
|
# OPENCV_IPP_ENABLE_ALL is defined in modules/core/CMakeList.txt
|
||||||
if(OPENCV_IPP_GAUSSIAN_BLUR)
|
OCV_OPTION(OPENCV_IPP_GAUSSIAN_BLUR "Enable IPP optimizations for GaussianBlur (+8Mb in binary size)" OPENCV_IPP_ENABLE_ALL)
|
||||||
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/smooth.dispatch.cpp "ENABLE_IPP_GAUSSIAN_BLUR=1")
|
if(OPENCV_IPP_GAUSSIAN_BLUR)
|
||||||
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/smooth.dispatch.cpp "ENABLE_IPP_GAUSSIAN_BLUR=1")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user