mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 11:45:30 +08:00
Merge pull request #19747 from alalek:issue_19733
This commit is contained in:
commit
94f00cf096
@ -18,8 +18,12 @@ ocv_add_dispatched_file_force_all(test_intrin256 TEST AVX2 AVX512_SKX)
|
||||
ocv_add_dispatched_file_force_all(test_intrin512 TEST AVX512_SKX)
|
||||
|
||||
|
||||
set(PARALLEL_ENABLE_PLUGINS_DEFAULT ON)
|
||||
if(EMSCRIPTEN OR IOS OR WINRT)
|
||||
set(PARALLEL_ENABLE_PLUGINS_DEFAULT OFF)
|
||||
endif()
|
||||
# parallel backends configuration
|
||||
set(PARALLEL_ENABLE_PLUGINS "ON" CACHE BOOL "Allow building parallel plugin support")
|
||||
set(PARALLEL_ENABLE_PLUGINS "${PARALLEL_ENABLE_PLUGINS_DEFAULT}" CACHE BOOL "Allow building parallel plugin support")
|
||||
# TODO building plugins with OpenCV is not supported yet
|
||||
#set(PARALLEL_PLUGIN_LIST "" CACHE STRING "List of parallel backends to be compiled as plugins (tbb, openmp or special value 'all')")
|
||||
#string(REPLACE "," ";" PARALLEL_PLUGIN_LIST "${PARALLEL_PLUGIN_LIST}") # support comma-separated list (,) too
|
||||
|
@ -63,7 +63,11 @@ std::shared_ptr<ParallelForAPI> createParallelForAPI()
|
||||
try
|
||||
{
|
||||
CV_LOG_DEBUG(NULL, "core(parallel): trying backend: " << info.name << " (priority=" << info.priority << ")");
|
||||
CV_Assert(info.backendFactory);
|
||||
if (!info.backendFactory)
|
||||
{
|
||||
CV_LOG_DEBUG(NULL, "core(parallel): factory is not available (plugins require filesystem support): " << info.name);
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<ParallelForAPI> backend = info.backendFactory->create();
|
||||
if (!backend)
|
||||
{
|
||||
|
@ -6,17 +6,23 @@
|
||||
// Not a standalone header, part of parallel.cpp
|
||||
//
|
||||
|
||||
#include "opencv2/core/utils/filesystem.private.hpp" // OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
|
||||
namespace cv { namespace parallel {
|
||||
|
||||
#if OPENCV_HAVE_FILESYSTEM_SUPPORT && defined(PARALLEL_ENABLE_PLUGINS)
|
||||
#define DECLARE_DYNAMIC_BACKEND(name) \
|
||||
ParallelBackendInfo { \
|
||||
1000, name, createPluginParallelBackendFactory(name) \
|
||||
}
|
||||
},
|
||||
#else
|
||||
#define DECLARE_DYNAMIC_BACKEND(name) /* nothing */
|
||||
#endif
|
||||
|
||||
#define DECLARE_STATIC_BACKEND(name, createBackendAPI) \
|
||||
ParallelBackendInfo { \
|
||||
1000, name, std::make_shared<cv::parallel::StaticBackendFactory>([=] () -> std::shared_ptr<cv::parallel::ParallelForAPI> { return createBackendAPI(); }) \
|
||||
}
|
||||
},
|
||||
|
||||
static
|
||||
std::vector<ParallelBackendInfo>& getBuiltinParallelBackendsInfo()
|
||||
@ -24,14 +30,14 @@ std::vector<ParallelBackendInfo>& getBuiltinParallelBackendsInfo()
|
||||
static std::vector<ParallelBackendInfo> g_backends
|
||||
{
|
||||
#ifdef HAVE_TBB
|
||||
DECLARE_STATIC_BACKEND("TBB", createParallelBackendTBB),
|
||||
DECLARE_STATIC_BACKEND("TBB", createParallelBackendTBB)
|
||||
#elif defined(PARALLEL_ENABLE_PLUGINS)
|
||||
DECLARE_DYNAMIC_BACKEND("ONETBB"), // dedicated oneTBB plugin (interface >= 12000, binary incompatibe with TBB 2017-2020)
|
||||
DECLARE_DYNAMIC_BACKEND("TBB"), // generic TBB plugins
|
||||
DECLARE_DYNAMIC_BACKEND("ONETBB") // dedicated oneTBB plugin (interface >= 12000, binary incompatibe with TBB 2017-2020)
|
||||
DECLARE_DYNAMIC_BACKEND("TBB") // generic TBB plugins
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENMP
|
||||
DECLARE_STATIC_BACKEND("OPENMP", createParallelBackendOpenMP),
|
||||
DECLARE_STATIC_BACKEND("OPENMP", createParallelBackendOpenMP)
|
||||
#elif defined(PARALLEL_ENABLE_PLUGINS)
|
||||
DECLARE_DYNAMIC_BACKEND("OPENMP") // TODO Intel OpenMP?
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user