Struct CudaMemoryPool
Identifies a CUDA device memory pool without exposing the raw native handle to ordinary users. 标识一个 CUDA 设备内存池,同时避免向普通用户暴露原生句柄。
public readonly struct CudaMemoryPool
- Inherited Members
Properties
DeviceOrdinal
Gets the CUDA device ordinal that owns this memory pool. 获取拥有当前内存池的 CUDA 设备序号。
public int DeviceOrdinal { get; }
Property Value
ReleaseThresholdBytes
Gets or sets the release threshold in bytes. 获取或设置内存池释放阈值,单位为字节。
public long ReleaseThresholdBytes { get; set; }
Property Value
ReservedMemoryCurrentBytes
Gets the current number of reserved bytes reported by CUDA. 获取 CUDA 报告的当前已保留字节数。
public long ReservedMemoryCurrentBytes { get; }
Property Value
ReservedMemoryHighBytes
Gets the high-water reserved byte count reported by CUDA. 获取 CUDA 报告的已保留字节数峰值。
public long ReservedMemoryHighBytes { get; }
Property Value
UsedMemoryCurrentBytes
Gets the current number of used bytes reported by CUDA. 获取 CUDA 报告的当前已使用字节数。
public long UsedMemoryCurrentBytes { get; }
Property Value
UsedMemoryHighBytes
Gets the high-water used byte count reported by CUDA. 获取 CUDA 报告的已使用字节数峰值。
public long UsedMemoryHighBytes { get; }
Property Value
Methods
AllocateAsync(int, CudaStream)
Asynchronously allocates device memory from this CUDA memory pool. 从当前 CUDA memory pool 中异步分配设备内存。
public CudaMemory AllocateAsync(int sizeInBytes, CudaStream stream)
Parameters
sizeInBytesintThe allocation size in bytes. 分配大小,单位为字节。
streamCudaStreamThe CUDA stream that orders the allocation. 用于排序分配操作的 CUDA stream。
Returns
- CudaMemory
A managed CUDA memory allocation. CUDA 设备内存托管封装。
Create(int)
Creates a standalone CUDA memory pool owned by the returned managed object. 创建一个由返回托管对象拥有并负责释放的独立 CUDA 内存池。
public static CudaOwnedMemoryPool Create(int deviceOrdinal)
Parameters
deviceOrdinalintThe CUDA device ordinal. CUDA 设备序号。
Returns
- CudaOwnedMemoryPool
An owned memory-pool wrapper that must be disposed. 需要释放的 owned 内存池封装。
GetAccess(int)
Gets access permissions for this memory pool from a CUDA device. 查询指定 CUDA 设备访问当前 memory pool 的权限。
public CudaMemoryPoolAccessFlags GetAccess(int deviceOrdinal)
Parameters
deviceOrdinalintThe device ordinal to query. 要查询的设备序号。
Returns
- CudaMemoryPoolAccessFlags
The access flags reported by CUDA. CUDA 返回的访问权限标志。
GetAttribute(CudaMemoryPoolAttribute)
Gets a memory-pool attribute value. 获取内存池属性值。
public long GetAttribute(CudaMemoryPoolAttribute attribute)
Parameters
attributeCudaMemoryPoolAttributeThe memory-pool attribute to query. 要查询的内存池属性。
Returns
- long
The attribute value. 属性值。
GetCurrent(int)
Gets the current CUDA memory pool for a device. 获取指定设备当前使用的 CUDA 内存池。
public static CudaMemoryPool GetCurrent(int deviceOrdinal)
Parameters
deviceOrdinalintThe CUDA device ordinal. CUDA 设备序号。
Returns
- CudaMemoryPool
The current memory pool wrapper. 当前内存池封装。
GetDefault(int)
Gets the default CUDA memory pool for a device. 获取指定设备的默认 CUDA 内存池。
public static CudaMemoryPool GetDefault(int deviceOrdinal)
Parameters
deviceOrdinalintThe CUDA device ordinal. CUDA 设备序号。
Returns
- CudaMemoryPool
The default memory pool wrapper. 默认内存池封装。
MakeCurrent()
Makes this memory pool the current pool for its owning device. 将当前内存池设置为其所属 CUDA 设备的当前内存池。
public void MakeCurrent()
ResetReservedMemoryHigh()
Resets CUDA's reserved-memory high-water counter for this pool. 重置当前内存池的 CUDA 已保留内存峰值计数。
public void ResetReservedMemoryHigh()
ResetUsedMemoryHigh()
Resets CUDA's used-memory high-water counter for this pool. 重置当前内存池的 CUDA 已使用内存峰值计数。
public void ResetUsedMemoryHigh()
SetAccess(int, CudaMemoryPoolAccessFlags)
Sets access permissions for this memory pool from another CUDA device. 设置另一个 CUDA 设备访问当前 memory pool 的权限。
public void SetAccess(int deviceOrdinal, CudaMemoryPoolAccessFlags flags)
Parameters
deviceOrdinalintThe device ordinal whose access should be updated. 需要更新访问权限的设备序号。
flagsCudaMemoryPoolAccessFlagsThe requested access flags. 目标访问权限标志。
Remarks
This maps to CUDA's cudaMemPoolSetAccess safe subset with a device-location descriptor.
该方法映射到 CUDA cudaMemPoolSetAccess 的设备位置描述符安全子集。
SetAttribute(CudaMemoryPoolAttribute, long)
Sets a memory-pool attribute value. 设置内存池属性值。
public void SetAttribute(CudaMemoryPoolAttribute attribute, long value)
Parameters
attributeCudaMemoryPoolAttributeThe memory-pool attribute to update. 要更新的内存池属性。
valuelongThe new attribute value. 新属性值。
TrimTo(ulong)
Trims unused allocations in the CUDA memory pool. 裁剪 CUDA 内存池中未使用的缓存分配。
public void TrimTo(ulong minBytesToKeep)
Parameters
minBytesToKeepulongThe minimum number of bytes CUDA should keep cached. CUDA 至少应保留的缓存字节数。