如何在OpenCV中禁用并行性?

编程入门 行业动态 更新时间:2024-10-09 02:29:58
本文介绍了如何在OpenCV中禁用并行性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经使用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中禁用并行性?

本文发布于:2023-11-23 21:33:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622921.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   OpenCV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!