pyCUDA对C的性能差异? [英] pyCUDA vs C performance differences?

查看:296
本文介绍了pyCUDA对C的性能差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的CUDA编程,我想知道pyCUDA的性能怎么样是比较纯C语言实现的方案
将性能不相上下?是否有任何的瓶颈,我应该知道的?

I'm new to CUDA programming and I was wondering how the performance of pyCUDA is compared to programs implemented in plain C. Will the performance be roughly the same? Are there any bottle necks that I should be aware of?

编辑:
我显然试图首款谷歌这个问题,却惊讶地发现没有任何资料。即我会例外的pyCUDA人们在他们的FAQ已经回答了这个问题。

I obviously tried to google this issue first, and was surprised to not find any information. i.e. I would have excepted that the pyCUDA people have this question answered in their FAQ.

推荐答案

如果您在使用CUDA - 无论是直接通过C或用pyCUDA - 你正在做在执行上的内核完成繁重的数值工作GPU和(使用的elementwise内核由您直接,或间接的)都写在CUDA C。所以应该在你的code的部分在性能上没有真正的区别。

If you're using CUDA -- whether directly through C or with pyCUDA -- all the heavy numerical work you're doing is done in kernels that execute on the gpu and are written in CUDA C (directly by you, or indirectly with elementwise kernels). So there should be no real difference in performance in those parts of your code.

现在,数组的初始化,任何工作后分析,将在Python完成(可能与numpy的)如果你使用pyCUDA,这通常会比直接编译语言做显著慢(不过,如果你建立你的numpy的/ SciPy的这样一种方式,它直接链接到高性能库,那么至少这些电话将执行两种语言相同)。但我们希望,您的初始化和结束都是工作的总金额,你必须做的小部分,这样即使有显著的开销那里,它仍然希望不会对整体的运行产生巨大影响。

Now, the initialization of arrays, and any post-work analysis, will be done in python (probably with numpy) if you use pyCUDA, and that generally will be significantly slower than doing it directly in a compiled language (though if you've built your numpy/scipy in such a way that it links directly to high-performance libraries, then those calls at least would perform the same in either language). But hopefully, your initialization and finalization are small fractions of the total amount of work you have to do, so that even if there is significant overhead there, it still hopefully won't have a huge impact on overall runtime.

而事实上,如果事实证明,计算的Python部分不伤害你的应用程序的性能,开始了在做pyCUDA的发展仍可能上手一个很好的方式,因为发展是显著更容易,并且可以始终重新实现太慢P​​ython中直C中的code的那些部分,并呼吁那些蟒蛇,获得一些两全其美。

And in fact if it turns out that the python parts of the computation does hurt your application's performance, starting out doing your development in pyCUDA may still be an excellent way to get started, as the development is significantly easier, and you can always re-implement those parts of the code that are too slow in Python in straight C, and call those from python, gaining some of the best of both worlds.

这篇关于pyCUDA对C的性能差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆