Is it possible to have a CUDA kernel with varying number of parameters?

那年仲夏 提交于 2020-01-25 20:22:27

问题


I would like to make a kernel which takes a number of arguments, that is not set. Is this possible?

I guess this does not work? But why?


回答1:


if you are asking about typical C style vargs, then no.

But because kernels support C++ linkage, there are template and name mangling tricks which can be used to instantiate different versions of a kernel with length and different types of argument lists. Note also that CUDA 7.0 introduces C++11 variadic template support.

So there are options to do this, but probably not the ones you were thinking of when you asked the question.

[This answer assembled from comments and added as a community wiki entry to get the question off the unanswered queue]



来源:https://stackoverflow.com/questions/30628859/is-it-possible-to-have-a-cuda-kernel-with-varying-number-of-parameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!