简体   繁体   English

如果我在内核函数中调用OpenCV GPU模块中的函数,它会起作用并且会更快吗?

[英]Would it work and be faster if I call function in OpenCV GPU module in my kernel function?

OpenCV has a gpu. GPU-accelerated Computer Vision OpenCV有一个gpu. GPU-accelerated Computer Vision gpu. GPU-accelerated Computer Vision module ( http://docs.opencv.org/modules/gpu/doc/gpu.html ). gpu. GPU-accelerated Computer Vision模块( http://docs.opencv.org/modules/gpu/doc/gpu.html )。 There are many functions which is already use GPU techniques. 有许多功能已在使用GPU技术。 So I can directly use the function OpenCV applies. 所以我可以直接使用OpenCV适用的功能。 But I wonder whether it would be faster if I write my own kernel and in each kernel I call function of OpenCV GPU module. 但是我想知道如果我编写自己的内核并在每个内核中调用OpenCV GPU模块的功能是否会更快。 This is in the case I have many images. 在我有很多图像的情况下。 To handle each image I call OpenCV funtion in GPU module. 为了处理每个图像,我在GPU模块中调用OpenCV功能。 Then it would be parallel-nested-parallel. 那么它将是并行嵌套并行的。

Your question is not entirely clear to me, but I would like to say this: it's impossible to say which would be faster, unless somebody already implemented that same algorithm using the approach you have in mind, and then shared a report about the benchmark tests. 您的问题对我来说并不完全清楚,但是我想说一下:不可能说出哪个更快,除非有人已经使用您所想到的方法实现了相同的算法,然后分享了有关基准测试的报告。

There's a number of factors involved: 涉及许多因素:

  • It depends on the type of operation you are trying to implement : techniques that have a high arithmetic intensity are better fit for GPUs for sure, however, not all problems can be modeled for GPUs. 这取决于您要实现的操作类型 :算术强度高的技术可以肯定地更适合GPU,但是,并非所有问题都可以为GPU建模。
  • The size of the input images matter : wasting time sending data from RAM to the GPU might not compensate in the end, so running the algorithm on the CPU can be faster for small images. 输入图像的大小很重要 :浪费时间从RAM向GPU发送数据最终可能无法补偿,因此对于小图像,在CPU上运行算法可以更快。
  • The model/power of the CPU/GPU : if the computer has a really crappy GPU, then it's probably better to run the algorithms on the CPU. CPU / GPU的型号/功能 :如果计算机具有非常笨拙的GPU,则最好在CPU上运行算法。

What I'm saying is: don't assume OpenCV GPU's module will always run it's algorithms faster than the CPU you got. 我的意思是:不要以为OpenCV GPU的模块将始终以比您拥有的CPU更快的速度运行它的算法。 Test it, measure it! 测试,测量! The only way to know for sure is through experimentation and benchmark. 唯一可以肯定的方法是通过实验和基准测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM