【问题标题】:Does CUDA kernel not support strncpyCUDA内核不支持strncpy吗
【发布时间】:2012-04-12 19:16:28
【问题描述】:

我收到以下错误:

error: calling a host function("strcpy") from a __device__/__global__ function("doDecompression") is not allowed
error: calling a host function("strlen") from a __device__/__global__ function("doDecompression") is not allowed
error: calling a host function("strlen") from a __device__/__global__ function("doDecompression") is not allowed

这是真的还是我的编译器表现得好笑??

【问题讨论】:

标签: cuda nvidia


【解决方案1】:

没有。内核代码不支持标准 C 库中的函数(如 strcpy)。

这些函数是为在 CPU 上工作而设计和编写的,很难让它们在设备上为大量线程工作。

【讨论】:

  • 那么你将如何在 GPU 上比较两个字符串。我们可以使用C库中的strcmp函数,把device放在前面吗?
  • 程序员:不,那行不通。您要么需要一个 GPU 字符串库,要么只编写自己的内核来进行比较。
  • 你能帮我写一个吗?自过去 4 小时以来我一直在尝试,但它不起作用
  • @Programmer:互联网上肯定有数百个 strcmp 实现——包括 BSD、GNU 和 Microsoft libc 版本。您确定找到可以帮助您选择的搜索引擎的内容吗?
猜你喜欢
  • 2012-01-09
  • 1970-01-01
  • 2011-04-08
  • 1970-01-01
  • 2015-01-27
  • 1970-01-01
  • 2020-10-01
  • 2018-06-28
  • 1970-01-01
相关资源
最近更新 更多