Class CudaPinnedMemory
Managed wrapper around CUDA pinned host memory. CUDA pinned host memory 的托管封装。
public sealed class CudaPinnedMemory : IDisposable
- Inheritance
-
CudaPinnedMemory
- Implements
- Inherited Members
Constructors
CudaPinnedMemory(int)
Allocates pinned host memory with default CUDA flags. 使用默认 CUDA 标志分配 pinned host memory。
public CudaPinnedMemory(int sizeInBytes)
Parameters
sizeInBytesintThe allocation size in bytes. 分配大小,单位为字节。
CudaPinnedMemory(int, CudaPinnedMemoryAllocationFlags)
Allocates pinned host memory with explicit CUDA flags. 使用显式 CUDA 标志分配 pinned host memory。
public CudaPinnedMemory(int sizeInBytes, CudaPinnedMemoryAllocationFlags flags)
Parameters
sizeInBytesintThe allocation size in bytes. 分配大小,单位为字节。
flagsCudaPinnedMemoryAllocationFlagsThe pinned-memory allocation flags. pinned memory 分配标志。
Properties
Flags
Gets the CUDA flags used for the pinned allocation. 获取该 pinned 分配使用的 CUDA 标志。
public CudaPinnedMemoryAllocationFlags Flags { get; }
Property Value
IsMapped
Gets whether the pinned allocation is mapped into device address space. 获取该 pinned 分配是否已映射到设备地址空间。
public bool IsMapped { get; }
Property Value
MappedDevicePointerAddress
Gets the mapped device pointer address when the allocation is mapped. 在分配已映射时获取其对应的设备指针地址。
public ulong MappedDevicePointerAddress { get; }
Property Value
SizeInBytes
Gets the allocation size in bytes. 获取分配大小,单位为字节。
public int SizeInBytes { get; }
Property Value
Methods
CopyFrom(byte[])
Copies a byte array into the pinned allocation. 将字节数组复制到 pinned 分配中。
public void CopyFrom(byte[] source)
Parameters
sourcebyte[]The source byte array. 源字节数组。
CopyFrom(byte[], int)
Copies a specific byte count into the pinned allocation. 将指定字节数复制到 pinned 分配中。
public void CopyFrom(byte[] source, int count)
Parameters
CopyFrom(float[])
Copies a float array into the pinned allocation. 将浮点数组复制到 pinned 分配中。
public void CopyFrom(float[] source)
Parameters
sourcefloat[]The source float array. 源浮点数组。
CopyTo(byte[])
Copies the pinned allocation into a byte array. 将 pinned 分配复制到字节数组中。
public void CopyTo(byte[] destination)
Parameters
destinationbyte[]The destination byte array. 目标字节数组。
CopyTo(byte[], int)
Copies a specific byte count from the pinned allocation into a byte array. 将 pinned 分配中的指定字节数复制到字节数组中。
public void CopyTo(byte[] destination, int count)
Parameters
destinationbyte[]The destination byte array. 目标字节数组。
countintThe number of bytes to copy. 要复制的字节数。
CopyTo(float[])
Copies the pinned allocation into a float array. 将 pinned 分配复制到浮点数组中。
public void CopyTo(float[] destination)
Parameters
destinationfloat[]The destination float array. 目标浮点数组。
Dispose()
Releases the pinned allocation. 释放 pinned 分配。
public void Dispose()
ToArray(int)
Materializes a byte array from the pinned allocation. 从 pinned 分配中生成字节数组。
public byte[] ToArray(int count)
Parameters
countintThe number of bytes to copy. 要复制的字节数。
Returns
- byte[]
A managed byte array copy. 托管字节数组副本。
ToSingleArray(int)
Materializes a float array from the pinned allocation. 从 pinned 分配中生成浮点数组。
public float[] ToSingleArray(int elementCount)
Parameters
elementCountintThe number of single-precision elements to copy. 要复制的单精度元素数量。
Returns
- float[]
A managed float array copy. 托管浮点数组副本。