CL_MEM_USE_HOST_PTR Vs CL_MEM_COPY_HOST_PTR Vs CL_MEM_ALLOC_HOST_PTR [英] CL_MEM_USE_HOST_PTR Vs CL_MEM_COPY_HOST_PTR Vs CL_MEM_ALLOC_HOST_PTR

查看:234
本文介绍了CL_MEM_USE_HOST_PTR Vs CL_MEM_COPY_HOST_PTR Vs CL_MEM_ALLOC_HOST_PTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在《 OpenCl By Action》一书中,我读到了这一点:

In the book OpenCl By Action I read this:

CL_MEM_USE_HOST_PTR::内存对象将访问主机指定的内存区域 指针.

CL_MEM_USE_HOST_PTR: The memory object will access the memory region specified by the host pointer.

CL_MEM_COPY_HOST_PTR::内存对象将设置主机指针指定的内存区域.

CL_MEM_COPY_HOST_PTR: The memory object will set the memory region specified by the host pointer.

CL_MEM_ALLOC_HOST_PTR::主机可访问内存中的区域将被分配用于数据传输.

CL_MEM_ALLOC_HOST_PTR: A region in host-accessible memory will be allocated for use in data transfer.

我对这三个标志完全感到困惑.

I am utterly confused o these three flags.

我想至少知道前两个有何不同.

I would like to know at least how are the first two different.

1-在CL_MEM_USE_HOST_PTR中,存储对象将访问,而在CL_MEM_COPY_HOST_PTR中,存储对象将设置(由主机指定).此设置和访问方式有何不同? 然后第三个人又让我很困惑.

1-In CL_MEM_USE_HOST_PTR Memory Object will access the memory region while in CL_MEM_COPY_HOST_PTR Memory Object will set the memory region (specified by host in both cases). How is this setting and accessing different ? Then the third one is again confusing me a lot.

2-是否所有这些固定的内存分配?

2- Are all of these pinned memory allocation?

推荐答案

CL_MEM_COPY_HOST_PTR只是在创建缓冲区时复制值.

CL_MEM_COPY_HOST_PTR simply copies the values at a time of creation of the buffer.

CL_MEM_USE_HOST_PTR维护对该内存区域的引用,并且根据实现的不同,它可能会在内核执行时直接访问它或将其缓存.如果要使用此功能编写跨平台代码,则必须使用mapbuffer提供同步点.

CL_MEM_USE_HOST_PTR maintains a reference to that memory area and depending on the implementation it might access it directly while kernels are executing or it might cache it. You must use mapbuffer to provide synchronization points if you want to write cross platform code using this.

CL_MEM_ALLOC_HOST_PTR是唯一经常固定的内存.例如,在AMD上,这会分配一个固定的内存区域.通常,如果您使用CL_MEM_USE_HOST_PTR,它将在内部简单地固定到固定的内存区域并使用它.通过使用ALLOC_HOST_PTR,您可以避免这种情况.但这又取决于实现方式,您必须阅读制造商文档,以了解是否会为您提供固定的内存.

CL_MEM_ALLOC_HOST_PTR is the only one that is often pinned memory. As an example on AMD this one allocates a pinned memory area. Often if you use CL_MEM_USE_HOST_PTR it will simply memcpy internally to a pinned memory area and use that. By using ALLOC_HOST_PTR you will avoid that. But yet again this depends on the implementation and you must read the manufacturers documentation on if this will provide you with pinned memory or not.

这篇关于CL_MEM_USE_HOST_PTR Vs CL_MEM_COPY_HOST_PTR Vs CL_MEM_ALLOC_HOST_PTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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