通过OpenCL中的__local内存传递参数 [英] Passing arguments through __local memory in OpenCL

查看:529
本文介绍了通过OpenCL中的__local内存传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对OpenCL中的__local内存感到困惑. 我读了一些规范说,数据流必须从主机到 __Global,然后__Local. 但是我也看到了一些这样的内核函数:

I am confused about the the __local memory in OpenCL here. I read some spec saying that the data flow has to be from Host to __Global, and then __Local. But I also see some kernel function like this:

__kernel void foo(__local float * a)

我想知道如何将数据直接传输到__local 以这种方式记忆吗?

I was wondering how the data was transferred directly into the __local memory in this way?

谢谢.

推荐答案

无法在主机端填充本地缓冲区.因此,您必须遵循流程宿主-> __global-> __local.

It is not possible to fill local buffer on the host side. Therefore you have to follow the flow host -> __global -> __local.

可以在主机端创建本地缓冲区,然后将其作为内核参数或在内核内部的gpu端进行传递. 在主机端创建本地缓冲区的好处是可以在运行内核之前决定其大小,如果每次运行内核时本地缓冲区的大小需要不同,则这很重要.

Local buffer can be either created on the host side and then it is passed as a kernel parameter or on gpu side inside the kernel. Creating local buffer on the host side gives the advantage to decide about its size before the kernel is run which can be important if the local buffer size needs to be different each time the kernel is run.

这篇关于通过OpenCL中的__local内存传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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