什么应该取代“memcpy”?在 OpenCL 内核中?
OpenCL语言扩展了C99,不提供memcpy函数。应该用什么来代替?
The OpenCL language, which extends C99, does not provide the memcpy function. What should be used instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,OpenCL 中没有类似的定义。 OpenCL 不提供动态内存之类的概念,因此不需要此类功能。
您可以使用 for 运行数组并逐个元素复制数据。但是,由于需要在编译时指定数组长度,目标数组的大小是固定的。
另一方面,OpenCL(以及作为一种起源的 OpenGL)以更静态的方式定义。需要将数据提供给 GPU 并且需要定义结果大小。 GPU 计算输入到预定义的输出位置。它并不是要在 GPU 内创建更多进程,也不是要动态分配内存以不干扰执行此操作的主机。
As far as I know, there is nothing like that defined in OpenCL. OpenCL does not provide a concept like dynamic memory and therefore, such functionality is not needed.
You could just run over your array with for and copy the data element by element. But, the target array is of fixed size due to the need to specify the array length at compile time.
On the other side, OpenCL (and OpenGL as a kind of origin) was defined in a more static way. The data needs to be provided to the GPU and the result size needs to be defined. The GPU calculates the input to the pre-defined output location. It is not meant to create more processes within the GPU and it is also not meant to allocate dynamically memory to not disturbed the host doing it.