OpenCV  4.10.0-dev
Open Source Computer Vision
Loading...
Searching...
No Matches
Classes | Functions
Parallel backends API

Detailed Description

API below is provided to resolve problem of CPU resource over-subscription by multiple thread pools from different multi-threading frameworks. This is common problem for cases when OpenCV compiled threading framework is different from the Users Applications framework.

Applications can replace OpenCV parallel_for() backend with own implementation (to reuse Application's thread pool).

Backend API usage examples

Intel TBB

OpenMP

Plugins support

Runtime configuration options:

Classes

class  cv::parallel::ParallelForAPI
 
class  cv::parallel::openmp::ParallelForBackend
 
class  cv::parallel::tbb::ParallelForBackend
 

Functions

void cv::parallel::setParallelForBackend (const std::shared_ptr< ParallelForAPI > &api, bool propagateNumThreads=true)
 Replace OpenCV parallel_for backend.
 
bool cv::parallel::setParallelForBackend (const std::string &backendName, bool propagateNumThreads=true)
 Change OpenCV parallel_for backend.
 

Function Documentation

◆ setParallelForBackend() [1/2]

void cv::parallel::setParallelForBackend ( const std::shared_ptr< ParallelForAPI > &  api,
bool  propagateNumThreads = true 
)
Python:
cv.parallel.setParallelForBackend(backendName[, propagateNumThreads]) -> retval

#include <opencv2/core/parallel/parallel_backend.hpp>

Replace OpenCV parallel_for backend.

Application can replace OpenCV parallel_for() backend with own implementation.

Note
This call is not thread-safe. Consider calling this function from the main() before any other OpenCV processing functions (and without any other created threads).

◆ setParallelForBackend() [2/2]

bool cv::parallel::setParallelForBackend ( const std::string &  backendName,
bool  propagateNumThreads = true 
)
Python:
cv.parallel.setParallelForBackend(backendName[, propagateNumThreads]) -> retval

#include <opencv2/core/parallel/parallel_backend.hpp>

Change OpenCV parallel_for backend.

Note
This call is not thread-safe. Consider calling this function from the main() before any other OpenCV processing functions (and without any other created threads).