OpenCL™规范 3.3.3共享虚拟内存

本文介绍了OpenCL中的三种共享虚拟内存(SVM)类型:粗粒度和细粒度缓冲区SVM,以及细粒度系统SVM。重点讲解了它们的粒度、内存分配、一致性机制以及与主机内存的交互方式。粗粒度SVM是核心规范要求,细粒度选项为可选特性。
摘要由CSDN通过智能技术生成
3.3.3. Shared Virtual Memory
3.3.3共享虚拟内存

Shared virtual memory is missing before version 2.0.

​2.0版本之前缺少共享虚拟内存。​

OpenCL extends the global memory region into the host memory region through a shared virtual memory (SVM) mechanism. There are three types of SVM in OpenCL

OpenCL通过共享虚拟存储器(SVM)机制将全局存储器区域扩展到主机存储器区域中。OpenCL中有三种类型的SVM

  • Coarse-Grained buffer SVM: Sharing occurs at the granularity of regions of OpenCL buffer memory objects. Consistency is enforced at synchronization points and with map/unmap commands to drive updates between the host and the device. This form of SVM is similar to non-SVM use of memory; however, it lets kernel-instances share pointer-based data structures (such as linked-lists) with the host program. Program scope global variables are treated as per-device coarse-grained SVM for addressing and sharing purposes.

  • 粗粒度缓冲区SVM:共享发生在OpenCL缓冲区内存对象区域的粒度上。在同步点和映射/取消映射命令上强制执行一致性,以驱动主机和设备之间的更新。这种形式的SVM类似于非SVM使用内存;但是,它允许内核实例与主机程序共享基于指针的数据结构(如链表)。出于寻址和共享目的,程序范围全局变量被视为每个设备的粗粒度SVM。

  • Fine-Grained buffer SVM: Sharing occurs at the granularity of individual loads/stores into bytes within OpenCL buffer memory objects. Loads and stores may be cached. This means consistency is guaranteed at synchronization points. If the optional OpenCL atomics are supported, they can be used to provide fine-grained control of memory consistency.

  • 细粒度缓冲区SVM:共享发生在OpenCL缓冲区内存对象中单个加载/存储到字节的粒度上。加载和存储可以被缓存。这意味着在同步点可以保证一致性。如果支持可选的OpenCL原子,则可以使用它们来提供对内存一致性的细粒度控制。

  • Fine-Grained system SVM: Sharing occurs at the granularity of individual loads/stores into bytes occurring anywhere within the host memory. Loads and stores may be cached so consistency is guaranteed at synchronization points. If the optional OpenCL atomics are supported, they can be used to provide fine-grained control of memory consistency.

  • 细粒度系统SVM:共享发生在主机内存中任何位置的单个加载/存储字节的粒度上。可以缓存加载和存储,从而保证同步点的一致性。如果支持可选的OpenCL原子操作,则可以使用它们来提供对内存一致性的细粒度控制。

Table 2. A summary of shared virtual memory (SVM) options in OpenCL

表2 OpenCL中共享虚拟内存(SVM)选项概述

Granularity of sharing

共享的粒度

Memory Allocation

内存分配

Mechanisms to enforce Consistency

实现一致性的机制

Explicit updates between host and device

主机和设备之间的显式更新

Non-SVM buffers

非SVM缓冲区

OpenCL Memory objects(buffer)

OpenCL内存对象(缓冲区)

clCreateBuffer
clCreateBufferWithProperties

Host synchronization points on the same or between devices.

主机同步点位于同一设备上或设备之间。

yes, through Map and Unmap commands.

是的,通过“映射”和“取消映射”命令。

Coarse-Grained buffer SVM

粗粒度缓冲SVM

OpenCL Memory objects (buffer)

OpenCL内存对象(缓冲区)

clSVMAlloc

Host synchronization points between devices

设备之间的主机同步点

yes, through Map and Unmap commands.

是的,通过“映射”和“取消映射”命令。

Fine-Grained buffer SVM

细粒缓冲SVM

Bytes within OpenCL Memory objects (buffer)

OpenCL内存对象(缓冲区)内的字节数

clSVMAlloc

Synchronization points plus atomics (if supported)

同步点加原子操作(如果支持)

No

Fine-Grained system SVM

细粒度系统SVM

Bytes within Host memory (system)

主机内存(系统)中的字节数

Host memory allocation mechanisms (e.g. malloc)

主机内存分配机制(例如malloc)

Synchronization points plus atomics (if supported)

同步点加原子操作(如果支持)

No

Coarse-Grained buffer SVM is required in the core OpenCL specification. The two finer grained approaches are optional features in OpenCL. The various SVM mechanisms to access host memory from the work-items associated with a kernel instance are summarized above.

​核心OpenCL规范中要求使用粗粒度缓冲SVM。这两种更细粒度的方法是OpenCL中的可选功能。上面总结了从与内核实例相关联的工作项访问主机内存的各种SVM机制。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值