Table of Contents

Class CudaArray

Namespace
JYPPX.CudaSharp
Assembly
JYPPX.CudaSharp.dll

Wraps a CUDA array allocation and its copy helpers. 封装 CUDA array 分配对象及其复制辅助方法。

public sealed class CudaArray : IDisposable
Inheritance
CudaArray
Implements
Inherited Members

Constructors

CudaArray(CudaChannelFormatDescriptor, ulong, ulong, CudaArrayCreationFlags)

Allocates a 1D or 2D CUDA array. 分配一个一维或二维 CUDA array。

public CudaArray(CudaChannelFormatDescriptor descriptor, ulong width, ulong height = 0, CudaArrayCreationFlags flags = CudaArrayCreationFlags.Default)

Parameters

descriptor CudaChannelFormatDescriptor
width ulong
height ulong
flags CudaArrayCreationFlags

Properties

ChannelDescriptor

Gets the channel descriptor copied from CUDA. 获取从 CUDA 读取的通道描述符。

public CudaChannelFormatDescriptor ChannelDescriptor { get; }

Property Value

CudaChannelFormatDescriptor

Descriptor

Gets the logical channel descriptor used for this array. 获取该 array 使用的逻辑通道描述符。

public CudaChannelFormatDescriptor Descriptor { get; }

Property Value

CudaChannelFormatDescriptor

Extent

Gets the array extent. 获取 array 的范围信息。

public CudaArrayExtent Extent { get; }

Property Value

CudaArrayExtent

Flags

Gets the creation flags supplied when the array was created. 获取创建该 array 时使用的标志。

public CudaArrayCreationFlags Flags { get; }

Property Value

CudaArrayCreationFlags

Info

Gets native metadata reported by CUDA for this array. 获取 CUDA 为该 array 报告的原生元数据。

public CudaArrayInfo Info { get; }

Property Value

CudaArrayInfo

Methods

CopyFrom(byte[])

Copies the full source byte array into this CUDA array. 将整个源字节数组复制到当前 CUDA array。

public void CopyFrom(byte[] source)

Parameters

source byte[]

CopyFrom(byte[], int)

Copies a fixed number of bytes into this CUDA array. 将固定字节数复制到当前 CUDA array。

public void CopyFrom(byte[] source, int byteCount)

Parameters

source byte[]
byteCount int

CopyFrom(byte[], int, int, int)

Copies bytes into this CUDA array at the specified 2D offset. 在指定二维偏移处把字节复制到当前 CUDA array。

public void CopyFrom(byte[] source, int destinationXBytes, int destinationY, int byteCount)

Parameters

source byte[]
destinationXBytes int
destinationY int
byteCount int

CopyFrom2D(byte[], int, int, int)

Copies a 2D managed byte buffer into this CUDA array. 将二维托管字节缓冲区复制到当前 CUDA array。

public void CopyFrom2D(byte[] source, int sourcePitch, int widthBytes, int height)

Parameters

source byte[]
sourcePitch int
widthBytes int
height int

CopyFrom2D(byte[], int, int, int, int, int)

Copies a 2D managed byte buffer into this CUDA array at the specified destination offset. 在指定目标偏移处复制二维托管字节缓冲区。

public void CopyFrom2D(byte[] source, int sourcePitch, int destinationXBytes, int destinationY, int widthBytes, int height)

Parameters

source byte[]
sourcePitch int
destinationXBytes int
destinationY int
widthBytes int
height int

CopyFrom2DAsync(CudaPinnedMemory, int, int, int, CudaStream)

Copies a 2D pinned host buffer into this CUDA array asynchronously. 异步把二维 pinned host 缓冲区复制到当前 CUDA array。

public void CopyFrom2DAsync(CudaPinnedMemory source, int sourcePitch, int widthBytes, int height, CudaStream stream)

Parameters

source CudaPinnedMemory
sourcePitch int
widthBytes int
height int
stream CudaStream

CopyFrom2DAsync(CudaPinnedMemory, int, int, int, int, int, CudaStream)

Copies a 2D pinned host buffer into this CUDA array asynchronously at the specified destination offset. 在指定目标偏移处异步复制二维 pinned host 缓冲区。

public void CopyFrom2DAsync(CudaPinnedMemory source, int sourcePitch, int destinationXBytes, int destinationY, int widthBytes, int height, CudaStream stream)

Parameters

source CudaPinnedMemory
sourcePitch int
destinationXBytes int
destinationY int
widthBytes int
height int
stream CudaStream

CopyFrom3D(byte[], int, int, int, int, int, int)

Copies a 3D managed byte buffer into this CUDA array. 将三维托管字节缓冲区复制到当前 CUDA array。

public void CopyFrom3D(byte[] source, int sourcePitch, int sourceWidthBytes, int sourceHeight, int widthBytes, int height, int depth)

Parameters

source byte[]
sourcePitch int
sourceWidthBytes int
sourceHeight int
widthBytes int
height int
depth int

CopyFrom3D(byte[], int, int, int, int, int, int, int, int, int)

Copies a 3D managed byte buffer into this CUDA array at the specified destination offset. 在指定目标偏移处把三维托管字节缓冲区复制到当前 CUDA array。

public void CopyFrom3D(byte[] source, int sourcePitch, int sourceWidthBytes, int sourceHeight, int destinationXBytes, int destinationY, int destinationZ, int widthBytes, int height, int depth)

Parameters

source byte[]
sourcePitch int
sourceWidthBytes int
sourceHeight int
destinationXBytes int
destinationY int
destinationZ int
widthBytes int
height int
depth int

CopyFrom3DAsync(CudaPinnedMemory, int, int, int, int, int, int, CudaStream)

Copies a 3D pinned host buffer into this CUDA array asynchronously. 异步把三维 pinned host 缓冲区复制到当前 CUDA array。

public void CopyFrom3DAsync(CudaPinnedMemory source, int sourcePitch, int sourceWidthBytes, int sourceHeight, int widthBytes, int height, int depth, CudaStream stream)

Parameters

source CudaPinnedMemory
sourcePitch int
sourceWidthBytes int
sourceHeight int
widthBytes int
height int
depth int
stream CudaStream

CopyFrom3DAsync(CudaPinnedMemory, int, int, int, int, int, int, int, int, int, CudaStream)

Copies a 3D pinned host buffer into this CUDA array asynchronously at the specified destination offset. 在指定目标偏移处异步复制三维 pinned host 缓冲区。

public void CopyFrom3DAsync(CudaPinnedMemory source, int sourcePitch, int sourceWidthBytes, int sourceHeight, int destinationXBytes, int destinationY, int destinationZ, int widthBytes, int height, int depth, CudaStream stream)

Parameters

source CudaPinnedMemory
sourcePitch int
sourceWidthBytes int
sourceHeight int
destinationXBytes int
destinationY int
destinationZ int
widthBytes int
height int
depth int
stream CudaStream

CopyFromAsync(CudaPinnedMemory, int, CudaStream)

Copies bytes from pinned host memory into this CUDA array asynchronously. 以异步方式把 pinned host memory 复制到当前 CUDA array。

public void CopyFromAsync(CudaPinnedMemory source, int byteCount, CudaStream stream)

Parameters

source CudaPinnedMemory
byteCount int
stream CudaStream

CopyFromAsync(CudaPinnedMemory, int, int, int, CudaStream)

Copies bytes from pinned host memory into this CUDA array asynchronously at the specified 2D offset. 在指定二维偏移处异步复制 pinned host memory。

public void CopyFromAsync(CudaPinnedMemory source, int destinationXBytes, int destinationY, int byteCount, CudaStream stream)

Parameters

source CudaPinnedMemory
destinationXBytes int
destinationY int
byteCount int
stream CudaStream

CopyTo(CudaArray, int)

Copies bytes from this CUDA array into another CUDA array. 将当前 CUDA array 的字节复制到另一个 CUDA array。

public void CopyTo(CudaArray destination, int byteCount)

Parameters

destination CudaArray
byteCount int

CopyTo(CudaArray, int, int, int, int, int)

Copies bytes between two CUDA arrays using explicit source and destination offsets. 使用显式源/目标偏移在两个 CUDA array 之间复制字节。

public void CopyTo(CudaArray destination, int destinationXBytes, int destinationY, int sourceXBytes, int sourceY, int byteCount)

Parameters

destination CudaArray
destinationXBytes int
destinationY int
sourceXBytes int
sourceY int
byteCount int

CopyTo(byte[])

Copies the full contents of this CUDA array into a managed byte array. 将当前 CUDA array 的全部内容复制到托管字节数组。

public void CopyTo(byte[] destination)

Parameters

destination byte[]

CopyTo(byte[], int)

Copies a fixed number of bytes from this CUDA array into a managed byte array. 将固定字节数从当前 CUDA array 复制到托管字节数组。

public void CopyTo(byte[] destination, int byteCount)

Parameters

destination byte[]
byteCount int

CopyTo(byte[], int, int, int)

Copies bytes from this CUDA array at the specified 2D offset into a managed byte array. 从指定二维偏移把字节复制到托管字节数组。

public void CopyTo(byte[] destination, int sourceXBytes, int sourceY, int byteCount)

Parameters

destination byte[]
sourceXBytes int
sourceY int
byteCount int

CopyTo2D(CudaArray, int, int)

Copies a 2D region from this CUDA array into another CUDA array. 将当前 CUDA array 的二维区域复制到另一个 CUDA array。

public void CopyTo2D(CudaArray destination, int widthBytes, int height)

Parameters

destination CudaArray
widthBytes int
height int

CopyTo2D(CudaArray, int, int, int, int, int, int)

Copies a 2D region between CUDA arrays using explicit source and destination offsets. 使用显式源/目标偏移在 CUDA array 之间复制二维区域。

public void CopyTo2D(CudaArray destination, int destinationXBytes, int destinationY, int sourceXBytes, int sourceY, int widthBytes, int height)

Parameters

destination CudaArray
destinationXBytes int
destinationY int
sourceXBytes int
sourceY int
widthBytes int
height int

CopyTo2D(byte[], int, int, int)

Copies a 2D region from this CUDA array into a managed byte buffer. 将当前 CUDA array 的二维区域复制到托管字节缓冲区。

public void CopyTo2D(byte[] destination, int destinationPitch, int widthBytes, int height)

Parameters

destination byte[]
destinationPitch int
widthBytes int
height int

CopyTo2D(byte[], int, int, int, int, int)

Copies a 2D region from this CUDA array into a managed byte buffer using an explicit source offset. 使用显式源偏移复制二维区域到托管字节缓冲区。

public void CopyTo2D(byte[] destination, int destinationPitch, int sourceXBytes, int sourceY, int widthBytes, int height)

Parameters

destination byte[]
destinationPitch int
sourceXBytes int
sourceY int
widthBytes int
height int

CopyTo2DAsync(CudaPinnedMemory, int, int, int, CudaStream)

Copies a 2D region from this CUDA array into pinned host memory asynchronously. 异步把当前 CUDA array 的二维区域复制到 pinned host memory。

public void CopyTo2DAsync(CudaPinnedMemory destination, int destinationPitch, int widthBytes, int height, CudaStream stream)

Parameters

destination CudaPinnedMemory
destinationPitch int
widthBytes int
height int
stream CudaStream

CopyTo2DAsync(CudaPinnedMemory, int, int, int, int, int, CudaStream)

Copies a 2D region from this CUDA array into pinned host memory asynchronously with an explicit source offset. 使用显式源偏移异步复制二维区域到 pinned host memory。

public void CopyTo2DAsync(CudaPinnedMemory destination, int destinationPitch, int sourceXBytes, int sourceY, int widthBytes, int height, CudaStream stream)

Parameters

destination CudaPinnedMemory
destinationPitch int
sourceXBytes int
sourceY int
widthBytes int
height int
stream CudaStream

CopyTo3D(CudaArray, int, int, int)

Copies a 3D region from this CUDA array into another CUDA array. 将当前 CUDA array 的三维区域复制到另一个 CUDA array。

public void CopyTo3D(CudaArray destination, int widthBytes, int height, int depth)

Parameters

destination CudaArray
widthBytes int
height int
depth int

CopyTo3D(CudaArray, int, int, int, int, int, int, int, int, int)

Copies a 3D region between CUDA arrays using explicit source and destination offsets. 使用显式源/目标偏移在两个 CUDA array 之间复制三维区域。

public void CopyTo3D(CudaArray destination, int destinationXBytes, int destinationY, int destinationZ, int sourceXBytes, int sourceY, int sourceZ, int widthBytes, int height, int depth)

Parameters

destination CudaArray
destinationXBytes int
destinationY int
destinationZ int
sourceXBytes int
sourceY int
sourceZ int
widthBytes int
height int
depth int

CopyTo3D(byte[], int, int, int, int, int, int)

Copies a 3D region from this CUDA array into a managed byte buffer. 将当前 CUDA array 的三维区域复制到托管字节缓冲区。

public void CopyTo3D(byte[] destination, int destinationPitch, int destinationWidthBytes, int destinationHeight, int widthBytes, int height, int depth)

Parameters

destination byte[]
destinationPitch int
destinationWidthBytes int
destinationHeight int
widthBytes int
height int
depth int

CopyTo3D(byte[], int, int, int, int, int, int, int, int, int)

Copies a 3D region from this CUDA array into a managed byte buffer using an explicit source offset. 使用显式源偏移将三维区域复制到托管字节缓冲区。

public void CopyTo3D(byte[] destination, int destinationPitch, int destinationWidthBytes, int destinationHeight, int sourceXBytes, int sourceY, int sourceZ, int widthBytes, int height, int depth)

Parameters

destination byte[]
destinationPitch int
destinationWidthBytes int
destinationHeight int
sourceXBytes int
sourceY int
sourceZ int
widthBytes int
height int
depth int

CopyTo3DAsync(CudaArray, int, int, int, CudaStream)

Copies a 3D region from this CUDA array into another CUDA array asynchronously. 异步把当前 CUDA array 的三维区域复制到另一个 CUDA array。

public void CopyTo3DAsync(CudaArray destination, int widthBytes, int height, int depth, CudaStream stream)

Parameters

destination CudaArray
widthBytes int
height int
depth int
stream CudaStream

CopyTo3DAsync(CudaArray, int, int, int, int, int, int, int, int, int, CudaStream)

Copies a 3D region between CUDA arrays asynchronously using explicit source and destination offsets. 使用显式源/目标偏移异步复制三维区域。

public void CopyTo3DAsync(CudaArray destination, int destinationXBytes, int destinationY, int destinationZ, int sourceXBytes, int sourceY, int sourceZ, int widthBytes, int height, int depth, CudaStream stream)

Parameters

destination CudaArray
destinationXBytes int
destinationY int
destinationZ int
sourceXBytes int
sourceY int
sourceZ int
widthBytes int
height int
depth int
stream CudaStream

CopyTo3DAsync(CudaPinnedMemory, int, int, int, int, int, int, CudaStream)

Copies a 3D region from this CUDA array into pinned host memory asynchronously. 异步把当前 CUDA array 的三维区域复制到 pinned host memory。

public void CopyTo3DAsync(CudaPinnedMemory destination, int destinationPitch, int destinationWidthBytes, int destinationHeight, int widthBytes, int height, int depth, CudaStream stream)

Parameters

destination CudaPinnedMemory
destinationPitch int
destinationWidthBytes int
destinationHeight int
widthBytes int
height int
depth int
stream CudaStream

CopyTo3DAsync(CudaPinnedMemory, int, int, int, int, int, int, int, int, int, CudaStream)

Copies a 3D region from this CUDA array into pinned host memory asynchronously using an explicit source offset. 使用显式源偏移异步复制三维区域到 pinned host memory。

public void CopyTo3DAsync(CudaPinnedMemory destination, int destinationPitch, int destinationWidthBytes, int destinationHeight, int sourceXBytes, int sourceY, int sourceZ, int widthBytes, int height, int depth, CudaStream stream)

Parameters

destination CudaPinnedMemory
destinationPitch int
destinationWidthBytes int
destinationHeight int
sourceXBytes int
sourceY int
sourceZ int
widthBytes int
height int
depth int
stream CudaStream

CopyToAsync(CudaPinnedMemory, int, CudaStream)

Copies bytes from this CUDA array into pinned host memory asynchronously. 以异步方式把当前 CUDA array 复制到 pinned host memory。

public void CopyToAsync(CudaPinnedMemory destination, int byteCount, CudaStream stream)

Parameters

destination CudaPinnedMemory
byteCount int
stream CudaStream

CopyToAsync(CudaPinnedMemory, int, int, int, CudaStream)

Copies bytes from this CUDA array into pinned host memory asynchronously using an explicit 2D source offset. 使用显式二维源偏移异步复制到 pinned host memory。

public void CopyToAsync(CudaPinnedMemory destination, int sourceXBytes, int sourceY, int byteCount, CudaStream stream)

Parameters

destination CudaPinnedMemory
sourceXBytes int
sourceY int
byteCount int
stream CudaStream

Create3D(CudaChannelFormatDescriptor, CudaArrayExtent, CudaArrayCreationFlags)

Allocates a 3D CUDA array. 分配一个三维 CUDA array。

public static CudaArray Create3D(CudaChannelFormatDescriptor descriptor, CudaArrayExtent extent, CudaArrayCreationFlags flags = CudaArrayCreationFlags.Default)

Parameters

descriptor CudaChannelFormatDescriptor
extent CudaArrayExtent
flags CudaArrayCreationFlags

Returns

CudaArray

Dispose()

Releases the native CUDA array handle. 释放原生 CUDA array 句柄。

public void Dispose()

GetMemoryRequirements(int)

Queries the device-memory requirements for this array on the selected device. 查询该 array 在指定设备上的显存需求。

public CudaArrayMemoryRequirements GetMemoryRequirements(int device)

Parameters

device int

Returns

CudaArrayMemoryRequirements

GetSparseProperties()

Queries sparse-array metadata for this array. 查询该 array 的 sparse 元数据。

public CudaArraySparseProperties GetSparseProperties()

Returns

CudaArraySparseProperties

ToArray2D(int, int, int)

Materializes a 2D region as a managed byte array. 将二维区域物化为托管字节数组。

public byte[] ToArray2D(int pitch, int widthBytes, int height)

Parameters

pitch int
widthBytes int
height int

Returns

byte[]

ToArray3D(int, int, int, int, int, int)

Materializes a 3D region as a managed byte array. 将三维区域物化为托管字节数组。

public byte[] ToArray3D(int pitch, int pitchedWidthBytes, int pitchedHeight, int widthBytes, int height, int depth)

Parameters

pitch int
pitchedWidthBytes int
pitchedHeight int
widthBytes int
height int
depth int

Returns

byte[]

TryGetMemoryRequirements(int, out CudaArrayMemoryRequirements, out string)

Attempts to query device-memory requirements without surfacing a CUDA exception. 尝试查询显存需求而不直接抛出 CUDA 异常。

public bool TryGetMemoryRequirements(int device, out CudaArrayMemoryRequirements requirements, out string diagnostic)

Parameters

device int
requirements CudaArrayMemoryRequirements
diagnostic string

Returns

bool

TryGetSparseProperties(out CudaArraySparseProperties, out string)

Attempts to query sparse-array metadata without surfacing a CUDA exception. 尝试查询 sparse 元数据而不直接抛出 CUDA 异常。

public bool TryGetSparseProperties(out CudaArraySparseProperties properties, out string diagnostic)

Parameters

properties CudaArraySparseProperties
diagnostic string

Returns

bool