Class CudaPitchedMemory
Managed wrapper around a CUDA pitched device allocation for 2D tensor/image-like data. 面向二维张量或图像类数据的 CUDA pitched 设备内存托管封装。
public sealed class CudaPitchedMemory : IDisposable
- Inheritance
-
CudaPitchedMemory
- Implements
- Inherited Members
Constructors
CudaPitchedMemory(int, int)
Allocates CUDA pitched device memory for a 2D logical region. 为二维逻辑区域分配 CUDA pitched 设备内存。
public CudaPitchedMemory(int widthInBytes, int height)
Parameters
widthInBytesintThe logical row width in bytes. 逻辑每行宽度,单位为字节。
heightintThe logical height in rows. 逻辑高度,单位为行。
Properties
Height
Gets the logical height in rows. 获取逻辑高度,单位为行。
public int Height { get; }
Property Value
PitchInBytes
Gets the allocated pitch in bytes. 获取实际分配的 pitch,单位为字节。
public int PitchInBytes { get; }
Property Value
WidthInBytes
Gets the logical width in bytes. 获取逻辑宽度,单位为字节。
public int WidthInBytes { get; }
Property Value
Methods
Allocate3D(int, int, int)
Allocates pitched CUDA memory for a logical 3D region. 为逻辑 3D 区域分配 CUDA pitched memory。
public static CudaPitchedMemory Allocate3D(int widthInBytes, int height, int depth)
Parameters
widthInBytesintThe width of each row in bytes. 每行宽度,单位为字节。
heightintThe height of each slice. 每个 slice 的高度。
depthintThe number of slices. slice 数量。
Returns
- CudaPitchedMemory
A pitched allocation large enough for
height*depthrows. 足以容纳 height * depth 行的 pitched allocation。
CopyFrom2D(byte[], int)
Copies a logical 2D host buffer into this pitched allocation. 将逻辑 2D 主机缓冲区复制到当前 pitched 分配。
public void CopyFrom2D(byte[] source, int sourcePitch)
Parameters
sourcebyte[]The host source buffer. 主机源缓冲区。
sourcePitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
CopyFrom2D(byte[], int, int, int)
Copies a logical 2D host subregion into this pitched allocation. 将逻辑 2D 主机子区域复制到当前 pitched 分配。
public void CopyFrom2D(byte[] source, int sourcePitch, int widthInBytes, int height)
Parameters
sourcebyte[]The host source buffer. 主机源缓冲区。
sourcePitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe number of copied rows. 要复制的行数。
CopyFrom2DAsync(CudaPinnedMemory, int, CudaStream)
Asynchronously copies pinned 2D host memory into this pitched allocation. 异步将 pinned 2D 主机内存复制到当前 pitched 分配。
public void CopyFrom2DAsync(CudaPinnedMemory source, int sourcePitch, CudaStream stream)
Parameters
sourceCudaPinnedMemoryThe pinned host source buffer. pinned 主机源缓冲区。
sourcePitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
CopyFrom2DAsync(CudaPinnedMemory, int, int, int, CudaStream)
Asynchronously copies a pinned 2D host subregion into this pitched allocation. 异步将 pinned 2D 主机子区域复制到当前 pitched 分配。
public void CopyFrom2DAsync(CudaPinnedMemory source, int sourcePitch, int widthInBytes, int height, CudaStream stream)
Parameters
sourceCudaPinnedMemoryThe pinned host source buffer. pinned 主机源缓冲区。
sourcePitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe number of copied rows. 要复制的行数。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
CopyFrom3D(byte[], int, int, int)
Copies a logical 3D host buffer into this pitched device allocation. 将逻辑 3D 主机缓冲区复制到当前 pitched 设备分配。
public void CopyFrom3D(byte[] source, int sourcePitch, int height, int depth)
Parameters
sourcebyte[]The host source buffer. 主机源缓冲区。
sourcePitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
CopyFrom3D(byte[], int, int, int, int)
Copies a logical 3D host subregion into this pitched device allocation. 将逻辑 3D 主机子区域复制到当前 pitched 设备分配。
public void CopyFrom3D(byte[] source, int sourcePitch, int widthInBytes, int height, int depth)
Parameters
sourcebyte[]The host source buffer. 主机源缓冲区。
sourcePitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
CopyFrom3DAsync(CudaPinnedMemory, int, int, int, CudaStream)
Asynchronously copies pinned logical 3D host memory into this pitched device allocation. 异步将 pinned 逻辑 3D 主机内存复制到当前 pitched 设备分配。
public void CopyFrom3DAsync(CudaPinnedMemory source, int sourcePitch, int height, int depth, CudaStream stream)
Parameters
sourceCudaPinnedMemoryThe pinned host source memory. pinned 主机源内存。
sourcePitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
CopyFrom3DAsync(CudaPinnedMemory, int, int, int, int, CudaStream)
Asynchronously copies pinned logical 3D host memory into this pitched device allocation. 异步将 pinned 逻辑 3D 主机内存复制到当前 pitched 设备分配。
public void CopyFrom3DAsync(CudaPinnedMemory source, int sourcePitch, int widthInBytes, int height, int depth, CudaStream stream)
Parameters
sourceCudaPinnedMemoryThe pinned host source memory. pinned 主机源内存。
sourcePitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
CopyTo(CudaPitchedMemory)
Copies the overlapping 2D region to another pitched allocation. 将重叠的 2D 区域复制到另一个 pitched 分配。
public void CopyTo(CudaPitchedMemory destination)
Parameters
destinationCudaPitchedMemoryThe destination pitched allocation. 目标 pitched 分配。
CopyTo2D(byte[], int)
Copies this pitched allocation into a logical 2D host buffer. 将当前 pitched 分配复制到逻辑 2D 主机缓冲区。
public void CopyTo2D(byte[] destination, int destinationPitch)
Parameters
destinationbyte[]The host destination buffer. 主机目标缓冲区。
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
CopyTo2D(byte[], int, int, int)
Copies a logical 2D device subregion into a host buffer. 将逻辑 2D 设备子区域复制到主机缓冲区。
public void CopyTo2D(byte[] destination, int destinationPitch, int widthInBytes, int height)
Parameters
destinationbyte[]The host destination buffer. 主机目标缓冲区。
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe number of copied rows. 要复制的行数。
CopyTo2DAsync(CudaPinnedMemory, int, CudaStream)
Asynchronously copies this pitched allocation into pinned 2D host memory. 异步将当前 pitched 分配复制到 pinned 2D 主机内存。
public void CopyTo2DAsync(CudaPinnedMemory destination, int destinationPitch, CudaStream stream)
Parameters
destinationCudaPinnedMemoryThe pinned host destination buffer. pinned 主机目标缓冲区。
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
CopyTo2DAsync(CudaPinnedMemory, int, int, int, CudaStream)
Asynchronously copies a logical 2D device subregion into pinned host memory. 异步将逻辑 2D 设备子区域复制到 pinned 主机内存。
public void CopyTo2DAsync(CudaPinnedMemory destination, int destinationPitch, int widthInBytes, int height, CudaStream stream)
Parameters
destinationCudaPinnedMemoryThe pinned host destination buffer. pinned 主机目标缓冲区。
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe number of copied rows. 要复制的行数。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
CopyTo3D(CudaPitchedMemory, int, int, int)
Copies a logical 3D region from this pitched allocation to another pitched allocation. 将当前 pitched 分配中的逻辑 3D 区域复制到另一个 pitched 分配。
public void CopyTo3D(CudaPitchedMemory destination, int widthInBytes, int height, int depth)
Parameters
destinationCudaPitchedMemoryThe destination pitched allocation. 目标 pitched 分配。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
CopyTo3D(byte[], int, int, int)
Copies this pitched device allocation into a logical 3D host buffer. 将当前 pitched 设备分配复制到逻辑 3D 主机缓冲区。
public void CopyTo3D(byte[] destination, int destinationPitch, int height, int depth)
Parameters
destinationbyte[]The host destination buffer. 主机目标缓冲区。
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
CopyTo3D(byte[], int, int, int, int)
Copies a logical 3D device subregion into a host buffer. 将逻辑 3D 设备子区域复制到主机缓冲区。
public void CopyTo3D(byte[] destination, int destinationPitch, int widthInBytes, int height, int depth)
Parameters
destinationbyte[]The host destination buffer. 主机目标缓冲区。
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
CopyTo3DAsync(CudaPinnedMemory, int, int, int, CudaStream)
Asynchronously copies this pitched device allocation into pinned logical 3D host memory. 异步将当前 pitched 设备分配复制到 pinned 逻辑 3D 主机内存。
public void CopyTo3DAsync(CudaPinnedMemory destination, int destinationPitch, int height, int depth, CudaStream stream)
Parameters
destinationCudaPinnedMemoryThe pinned host destination memory. pinned 主机目标内存。
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
CopyTo3DAsync(CudaPinnedMemory, int, int, int, int, CudaStream)
Asynchronously copies a logical 3D device subregion into pinned host memory. 异步将逻辑 3D 设备子区域复制到 pinned 主机内存。
public void CopyTo3DAsync(CudaPinnedMemory destination, int destinationPitch, int widthInBytes, int height, int depth, CudaStream stream)
Parameters
destinationCudaPinnedMemoryThe pinned host destination memory. pinned 主机目标内存。
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
CopyTo3DAsync(CudaPitchedMemory, int, int, int, CudaStream)
Asynchronously copies a logical 3D region to another pitched allocation. 异步将逻辑 3D 区域复制到另一个 pitched 分配。
public void CopyTo3DAsync(CudaPitchedMemory destination, int widthInBytes, int height, int depth, CudaStream stream)
Parameters
destinationCudaPitchedMemoryThe destination pitched allocation. 目标 pitched 分配。
widthInBytesintThe copied row width in bytes. 要复制的每行字节数。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
CopyToAsync(CudaPitchedMemory, CudaStream)
Asynchronously copies the overlapping 2D region to another pitched allocation. 异步将重叠的 2D 区域复制到另一个 pitched 分配。
public void CopyToAsync(CudaPitchedMemory destination, CudaStream stream)
Parameters
destinationCudaPitchedMemoryThe destination pitched allocation. 目标 pitched 分配。
streamCudaStreamThe CUDA stream that orders the copy. 用于排序复制操作的 CUDA stream。
Dispose()
Releases the pitched allocation. 释放 pitched 分配。
public void Dispose()
Fill2D(byte)
Fills the full logical 2D allocation with a byte value. 使用指定字节值填充完整的逻辑二维分配区域。
public void Fill2D(byte value)
Parameters
valuebyteThe byte value used by CUDA memset. CUDA memset 使用的字节值。
Fill2D(byte, int, int)
Fills a logical 2D subregion with a byte value. 使用指定字节值填充逻辑二维子区域。
public void Fill2D(byte value, int widthInBytes, int height)
Parameters
valuebyteThe byte value used by CUDA memset. CUDA memset 使用的字节值。
widthInBytesintThe row width to fill in bytes. 要填充的每行字节数。
heightintThe number of rows to fill. 要填充的行数。
Fill2DAsync(byte, CudaStream)
Asynchronously fills the full logical 2D allocation with a byte value. 使用指定字节值异步填充完整的逻辑二维分配区域。
public void Fill2DAsync(byte value, CudaStream stream)
Parameters
valuebyteThe byte value used by CUDA memset. CUDA memset 使用的字节值。
streamCudaStreamThe CUDA stream that orders the fill. 用于排序填充操作的 CUDA stream。
Fill2DAsync(byte, int, int, CudaStream)
Asynchronously fills a logical 2D subregion with a byte value. 使用指定字节值异步填充逻辑二维子区域。
public void Fill2DAsync(byte value, int widthInBytes, int height, CudaStream stream)
Parameters
valuebyteThe byte value used by CUDA memset. CUDA memset 使用的字节值。
widthInBytesintThe row width to fill in bytes. 要填充的每行字节数。
heightintThe number of rows to fill. 要填充的行数。
streamCudaStreamThe CUDA stream that orders the fill. 用于排序填充操作的 CUDA stream。
Fill3D(byte, int, int)
Fills a logical 3D region with a byte value. 使用指定字节值填充逻辑 3D 区域。
public void Fill3D(byte value, int height, int depth)
Parameters
valuebyteThe byte value used by CUDA memset. CUDA memset 使用的字节值。
heightintThe height of one logical slice. 单个逻辑 slice 的高度。
depthintThe number of logical slices. 逻辑 slice 数量。
Fill3D(byte, int, int, int)
Fills a logical 3D subregion with a byte value. 使用指定字节值填充逻辑 3D 子区域。
public void Fill3D(byte value, int widthInBytes, int height, int depth)
Parameters
valuebyteThe byte value used by CUDA memset. CUDA memset 使用的字节值。
widthInBytesintThe row width to fill in bytes. 要填充的每行字节数。
heightintThe height of one logical slice. 单个逻辑 slice 的高度。
depthintThe number of logical slices. 逻辑 slice 数量。
Fill3DAsync(byte, int, int, CudaStream)
Asynchronously fills a logical 3D region with a byte value. 异步使用指定字节值填充逻辑 3D 区域。
public void Fill3DAsync(byte value, int height, int depth, CudaStream stream)
Parameters
valuebyteThe byte value used by CUDA memset. CUDA memset 使用的字节值。
heightintThe height of one logical slice. 单个逻辑 slice 的高度。
depthintThe number of logical slices. 逻辑 slice 数量。
streamCudaStreamThe CUDA stream that orders the fill. 用于排序填充操作的 CUDA stream。
Fill3DAsync(byte, int, int, int, CudaStream)
Asynchronously fills a logical 3D subregion with a byte value. 异步使用指定字节值填充逻辑 3D 子区域。
public void Fill3DAsync(byte value, int widthInBytes, int height, int depth, CudaStream stream)
Parameters
valuebyteThe byte value used by CUDA memset. CUDA memset 使用的字节值。
widthInBytesintThe row width to fill in bytes. 要填充的每行字节数。
heightintThe height of one logical slice. 单个逻辑 slice 的高度。
depthintThe number of logical slices. 逻辑 slice 数量。
streamCudaStreamThe CUDA stream that orders the fill. 用于排序填充操作的 CUDA stream。
ToArray2D(int)
Copies this pitched allocation to a newly allocated logical 2D host buffer. 将当前 pitched 分配复制到新建的逻辑 2D 主机缓冲区。
public byte[] ToArray2D(int destinationPitch)
Parameters
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
Returns
- byte[]
The copied host buffer. 复制得到的主机缓冲区。
ToArray3D(int, int, int)
Copies this pitched allocation to a newly allocated logical 3D host buffer. 将当前 pitched 分配复制到新建的逻辑 3D 主机缓冲区。
public byte[] ToArray3D(int destinationPitch, int height, int depth)
Parameters
destinationPitchintThe byte pitch of each host row. 主机每行 pitch,单位为字节。
heightintThe height of one slice. 单个 slice 的高度。
depthintThe number of slices. slice 数量。
Returns
- byte[]
The copied host buffer. 复制得到的主机缓冲区。