问题描述
我已经使用Intel IPP构建了OpenCV,所以我想只要有可能就使用它(例如矩阵乘法).
I've built OpenCV using Intel IPP, so I suppose that whenever possible it's used (e.g. matrix multiplication).
我想通过与并行版本进行比较来测试并行应用程序的可伸缩性.为了做到这一点,我什么时候做:
I want to test the scalability of my parallel application by comparing it with a serial version. In order to do so, when it I do:
omp_set_num_threads(1);
cv::setNumThreads(1);
但是,通过监视CPU使用率,我看到仍在使用多个CPU.这是为什么?以及如何仅使用一个CPU来强制程序执行?
However, by monitoring the CPU usage I see that multiple CPUs are still used. Why is that? And how can I force the program execution by using just one CPU?
推荐答案
使用以下CMake参数从源重新构建OpenCV应该可以:
Re-building OpenCV from source with following CMake parameters should works:
cmake .. -DWITH_IPP=OFF -DWITH_TBB=OFF -DWITH_OPENMP=OFF -DWITH_PTHREADS_PF=OFF
,您会发现 ="=" nofollow noreferrer>模块/核心/src/parallel.cpp :
#if defined HAVE_TBB
# define CV_PARALLEL_FRAMEWORK "tbb"
#elif defined HAVE_HPX
# define CV_PARALLEL_FRAMEWORK "hpx"
#elif defined HAVE_OPENMP
# define CV_PARALLEL_FRAMEWORK "openmp"
#elif defined HAVE_GCD
# define CV_PARALLEL_FRAMEWORK "gcd"
#elif defined WINRT
# define CV_PARALLEL_FRAMEWORK "winrt-concurrency"
#elif defined HAVE_CONCURRENCY
# define CV_PARALLEL_FRAMEWORK "ms-concurrency"
#elif defined HAVE_PTHREADS_PF
# define CV_PARALLEL_FRAMEWORK "pthreads"
#endif
这篇关于如何在OpenCV中禁用并行性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!