我想制作一个内核,它带有许多未设置的参数.这可能吗?
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?
推荐答案如果您要询问典型的C风格变量,则不可以.
if you are asking about typical C style vargs, then no.
但是,因为内核支持C ++链接,所以存在一些模板和名称修饰技巧,可用于实例化具有长度和不同类型的参数列表的内核的不同版本.还请注意,CUDA 7.0引入了C ++ 11可变参数模板支持.
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.
[此答案由评论汇总而成,并作为社区Wiki条目添加,以使问题摆脱未答复的队列]
[This answer assembled from comments and added as a community wiki entry to get the question off the unanswered queue]
更多推荐
是否有可能具有数量不同的CUDA内核?
发布评论