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原子操作,则可以使用它们来提供对内存一致性的细粒度控制。
Granularity of sharing 共享的粒度 | Memory Allocation 内存分配 | Mechanisms to enforce Consistency 实现一致性的机制 | Explicit updates between host and device 主机和设备之间的显式更新 | |
---|---|---|---|---|
Non-SVM buffers 非SVM缓冲区 | OpenCL Memory objects(buffer) OpenCL内存对象(缓冲区) | 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内存对象(缓冲区) | Host synchronization points between devices 设备之间的主机同步点 | yes, through Map and Unmap commands. 是的,通过“映射”和“取消映射”命令。 | |
Fine-Grained buffer SVM 细粒缓冲SVM | Bytes within OpenCL Memory objects (buffer) OpenCL内存对象(缓冲区)内的字节数 | 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机制。