是否有可能具有数量不同的CUDA内核? [英] Is it possible to have a CUDA kernel with varying number of parameters?

查看:63
本文介绍了是否有可能具有数量不同的CUDA内核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个内核,它带有许多未设置的参数.这可能吗?

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内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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