关于OpenCL中cl_mem的问题

发布于 2024-09-27 07:11:54 字数 164 浏览 10 评论 0原文

我一直在我的一些 OpenCL 样板代码中使用 cl_mem,但我一直在上下文中使用它,并没有清楚地理解它到底是什么。我一直使用它作为我在板上推入和推出的内存的类型,到目前为止,它一直是浮动的。我尝试查看 OpenCL 文档,但 cl_mem 没有显示(是吗?)。有没有相关的文档,或者是否简单,有人可以解释一下。

I have been using cl_mem in some of my OpenCL boilerplate code, but I have been using it through context and not a sharp understanding of what exactly it is. I have been using it as a type for the memory I push on and off the board, which has so far been floats. I tried looking at the OpenCL docs, but cl_mem doesn't show up (does it?). Is there any documentation on it, or is it simple and can someone explain.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑忘罢 2024-10-04 07:11:54

cl_mem 类型是“内存对象”的句柄(如 OpenCL 1.1 规范)。这些本质上是 OpenCL 内核的输入和输出,并从主机代码中的 OpenCL API 调用返回,例如 clCreateBuffer

cl_mem  clCreateBuffer (cl_context context, cl_mem_flags flags,
                            size_t size, void *host_ptr, cl_int *errcode_ret) 

所表示的内存区域可以允许不同的访问模式,例如只读,或者分配在不同的内存区域,具体取决于设置的标志在创建缓冲区调用中。

句柄通常被存储以允许稍后调用释放内存,例如:

cl_int  clReleaseMemObject (cl_mem memobj)  

简而言之,它提供了对内存实际位置的抽象:您可以将数据复制到关联的内存中或通过 OpenCL API clEnqueueWriteBuffer 和 clEnqueueReadBuffer 退出,但 OpenCL 实现可以在需要的地方分配空间。

The cl_mem type is a handle to a "Memory Object" (as described in Section 3.5 of the OpenCL 1.1 Spec). These essentially are inputs and outputs for OpenCL kernels, and are returned from OpenCL API calls in host code such as clCreateBuffer

cl_mem  clCreateBuffer (cl_context context, cl_mem_flags flags,
                            size_t size, void *host_ptr, cl_int *errcode_ret) 

The memory areas represented can be permitted different access patterns e.g. Read Only, or be allocated in different memory regions, depending on the flags set in the create buffer calls.

The handle is typically stored to allow a later call to release the memory, e.g:

cl_int  clReleaseMemObject (cl_mem memobj)  

In short, it provides an abstraction over where the memory actually is: you can copy data into the associated memory or back out via the OpenCL APIs clEnqueueWriteBuffer and clEnqueueReadBuffer, but the OpenCL implementation can allocate the space where it wants.

晨曦÷微暖 2024-10-04 07:11:54

对于计算机来说,cl_mem 是一个数字(类似于 Linux 的文件处理程序),保留用作“内存标识符”(API/驱动程序将有关内存的信息存储在这个数字下,它知道它保存的内容/如何存储)它很大,诸如此类的东西)

For the computer a cl_mem is a number (like a file handler for Linux) that is reserved for the use as a "memory identifier"( the API/driver whatever stores information about your memory under this number that it knows what it holds/how big it is and stuff like that)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文