Class CudaDeviceVariable<T>
A variable located in CUDA device memory
Inheritance
Implements
Inherited Members
Namespace: ManagedCuda
Assembly: ManagedCuda.dll
Syntax
public class CudaDeviceVariable<T> : IDisposable where T : struct
Type Parameters
Name | Description |
---|---|
T | variable base type |
Constructors
| Improve this Doc View SourceCudaDeviceVariable(CUdeviceptr)
Creates a new CudaDeviceVariable from an existing CUdeviceptr. The allocated size is gethered via the CUDA API. devPtr won't be freed while disposing.
Declaration
public CudaDeviceVariable(CUdeviceptr devPtr)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | devPtr |
CudaDeviceVariable(CUdeviceptr, SizeT)
Creates a new CudaDeviceVariable from an existing CUdeviceptr. devPtr won't be freed while disposing.
Declaration
public CudaDeviceVariable(CUdeviceptr devPtr, SizeT size)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | devPtr | |
SizeT | size | Size in Bytes |
CudaDeviceVariable(CUdeviceptr, Boolean)
Creates a new CudaDeviceVariable from an existing CUdeviceptr. The allocated size is gethered via the CUDA API.
Declaration
public CudaDeviceVariable(CUdeviceptr devPtr, bool isOwner)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | devPtr | |
System.Boolean | isOwner | The CUdeviceptr will be freed while disposing, if the CudaDeviceVariable is the owner |
CudaDeviceVariable(CUdeviceptr, Boolean, SizeT)
Creates a new CudaDeviceVariable from an existing CUdeviceptr.
Declaration
public CudaDeviceVariable(CUdeviceptr devPtr, bool isOwner, SizeT size)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | devPtr | |
System.Boolean | isOwner | The CUdeviceptr will be freed while disposing, if the CudaDeviceVariable is the owner |
SizeT | size | Size in Bytes |
CudaDeviceVariable(CUmodule, String)
Creates a new CudaDeviceVariable from definition in cu-file.
Declaration
public CudaDeviceVariable(CUmodule module, string name)
Parameters
Type | Name | Description |
---|---|---|
CUmodule | module | The module where the variable is defined in. |
System.String | name | The variable name as defined in the cu-file. |
CudaDeviceVariable(SizeT)
Creates a new CudaDeviceVariable and allocates the memory on the device
Declaration
public CudaDeviceVariable(SizeT size)
Parameters
Type | Name | Description |
---|---|---|
SizeT | size | In elements |
CudaDeviceVariable(CudaKernel, String)
Creates a new CudaDeviceVariable from definition in cu-file.
Declaration
public CudaDeviceVariable(CudaKernel kernel, string name)
Parameters
Type | Name | Description |
---|---|---|
CudaKernel | kernel | The kernel which module defines the variable. |
System.String | name | The variable name as defined in the cu-file. |
Properties
| Improve this Doc View SourceDevicePointer
Device pointer
Declaration
public CUdeviceptr DevicePointer { get; }
Property Value
Type | Description |
---|---|
CUdeviceptr |
IsOwner
If the wrapper class instance is the owner of a CUDA handle, it will be destroyed while disposing.
Declaration
public bool IsOwner { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Item[SizeT]
Access array elements directly from host.
Each single access invokes a device to host or host to device copy. Access is therefor rather slow.
Declaration
public T this[SizeT index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
SizeT | index | index in elements |
Property Value
Type | Description |
---|---|
T |
Null
Gets a null-pointer equivalent
Declaration
public static CudaDeviceVariable<T> Null { get; }
Property Value
Type | Description |
---|---|
CudaDeviceVariable<T> |
Size
Size in elements
Declaration
public SizeT Size { get; }
Property Value
Type | Description |
---|---|
SizeT |
SizeInBytes
Size in bytes
Declaration
public SizeT SizeInBytes { get; }
Property Value
Type | Description |
---|---|
SizeT |
TypeSize
Type size in bytes
Declaration
public SizeT TypeSize { get; }
Property Value
Type | Description |
---|---|
SizeT |
Methods
| Improve this Doc View SourceAsyncCopyToDevice(CUdeviceptr, CUstream)
Async Copy data from device to device memory
Declaration
public void AsyncCopyToDevice(CUdeviceptr source, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | source | Source pointer to device memory |
CUstream | stream |
AsyncCopyToDevice(CUdeviceptr, SizeT, SizeT, SizeT, CUstream)
Async Copy data from device to device memory
Declaration
public void AsyncCopyToDevice(CUdeviceptr source, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | source | Source pointer to device memory |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
CUstream | stream |
AsyncCopyToDevice(CUdeviceptr, SizeT, SizeT, SizeT, CudaStream)
Async Copy data from device to device memory
Declaration
public void AsyncCopyToDevice(CUdeviceptr source, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes, CudaStream stream)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | source | Source pointer to device memory |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
CudaStream | stream |
AsyncCopyToDevice(CUdeviceptr, CudaStream)
Async Copy data from device to device memory
Declaration
public void AsyncCopyToDevice(CUdeviceptr source, CudaStream stream)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | source | Source pointer to device memory |
CudaStream | stream |
AsyncCopyToDevice(CudaDeviceVariable<T>, CUstream)
Async Copy data from device to device memory
Declaration
public void AsyncCopyToDevice(CudaDeviceVariable<T> source, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaDeviceVariable<T> | source | Source |
CUstream | stream |
AsyncCopyToDevice(CudaDeviceVariable<T>, SizeT, SizeT, SizeT, CUstream)
Async Copy data from device to device memory
Declaration
public void AsyncCopyToDevice(CudaDeviceVariable<T> source, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaDeviceVariable<T> | source | Source |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
CUstream | stream |
AsyncCopyToDevice(CudaDeviceVariable<T>, SizeT, SizeT, SizeT, CudaStream)
Async Copy data from device to device memory
Declaration
public void AsyncCopyToDevice(CudaDeviceVariable<T> source, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes, CudaStream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaDeviceVariable<T> | source | Source |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
CudaStream | stream |
AsyncCopyToDevice(CudaDeviceVariable<T>, CudaStream)
Async Copy data from device to device memory
Declaration
public void AsyncCopyToDevice(CudaDeviceVariable<T> source, CudaStream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaDeviceVariable<T> | source | Source |
CudaStream | stream |
AsyncCopyToDevice(CudaPitchedDeviceVariable<T>, CUstream)
Async Copy from device to device memory
Declaration
public void AsyncCopyToDevice(CudaPitchedDeviceVariable<T> deviceSrc, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaPitchedDeviceVariable<T> | deviceSrc | Source |
CUstream | stream |
AsyncCopyToDevice(CudaPitchedDeviceVariable<T>, SizeT, SizeT, SizeT, SizeT, CUstream)
Async Copy from device to device memory
Declaration
public void AsyncCopyToDevice(CudaPitchedDeviceVariable<T> deviceSrc, SizeT offsetSrc, SizeT offsetDest, SizeT width, SizeT height, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaPitchedDeviceVariable<T> | deviceSrc | Source |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | width | Width of 2D memory to copy in bytes |
SizeT | height | Height in elements |
CUstream | stream |
AsyncCopyToDevice(CudaPitchedDeviceVariable<T>, SizeT, SizeT, SizeT, SizeT, CudaStream)
Async Copy from device to device memory
Declaration
public void AsyncCopyToDevice(CudaPitchedDeviceVariable<T> deviceSrc, SizeT offsetSrc, SizeT offsetDest, SizeT width, SizeT height, CudaStream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaPitchedDeviceVariable<T> | deviceSrc | Source |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | width | Width of 2D memory to copy in bytes |
SizeT | height | Height in elements |
CudaStream | stream |
AsyncCopyToDevice(CudaPitchedDeviceVariable<T>, CudaStream)
Async Copy from device to device memory
Declaration
public void AsyncCopyToDevice(CudaPitchedDeviceVariable<T> deviceSrc, CudaStream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaPitchedDeviceVariable<T> | deviceSrc | Source |
CudaStream | stream |
CopyToDevice(T)
Copy data from host to device memory
Declaration
public void CopyToDevice(T source)
Parameters
Type | Name | Description |
---|---|---|
T | source | Source pointer to host memory |
CopyToDevice(T, SizeT)
Copy data from host to device memory
Declaration
public void CopyToDevice(T source, SizeT offsetDest)
Parameters
Type | Name | Description |
---|---|---|
T | source | Source pointer to host memory |
SizeT | offsetDest | Offset to destination pointer in bytes |
CopyToDevice(T[])
Copy data from host to device memory
Declaration
public void CopyToDevice(T[] source)
Parameters
Type | Name | Description |
---|---|---|
T[] | source | Source pointer to host memory |
CopyToDevice(T[], SizeT, SizeT, SizeT)
Copy data from host to device memory
Declaration
public void CopyToDevice(T[] source, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
T[] | source | Source pointer to host memory |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
CopyToDevice(CUdeviceptr)
Copy data from device to device memory
Declaration
public void CopyToDevice(CUdeviceptr source)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | source | Source pointer to device memory |
CopyToDevice(CUdeviceptr, SizeT, SizeT, SizeT)
Copy data from device to device memory
Declaration
public void CopyToDevice(CUdeviceptr source, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | source | Source pointer to device memory |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
CopyToDevice(CudaDeviceVariable<T>)
Copy data from device to device memory
Declaration
public void CopyToDevice(CudaDeviceVariable<T> source)
Parameters
Type | Name | Description |
---|---|---|
CudaDeviceVariable<T> | source | Source |
CopyToDevice(CudaDeviceVariable<T>, SizeT, SizeT, SizeT)
Copy data from device to device memory
Declaration
public void CopyToDevice(CudaDeviceVariable<T> source, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
CudaDeviceVariable<T> | source | Source |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
CopyToDevice(CudaPitchedDeviceVariable<T>)
Copy from device to device memory
Declaration
public void CopyToDevice(CudaPitchedDeviceVariable<T> deviceSrc)
Parameters
Type | Name | Description |
---|---|---|
CudaPitchedDeviceVariable<T> | deviceSrc | Source |
CopyToDevice(CudaPitchedDeviceVariable<T>, SizeT, SizeT, SizeT, SizeT)
Copy from device to device memory
Declaration
public void CopyToDevice(CudaPitchedDeviceVariable<T> deviceSrc, SizeT offsetSrc, SizeT offsetDest, SizeT widthInBytes, SizeT height)
Parameters
Type | Name | Description |
---|---|---|
CudaPitchedDeviceVariable<T> | deviceSrc | Source |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | widthInBytes | Width of 2D memory to copy in bytes |
SizeT | height | Height in elements |
CopyToDevice(Array)
Copy from Host to device memory. Array elements can be of any (value)type, but total size in bytes must match to allocated device memory.
Declaration
public void CopyToDevice(Array hostSrc)
Parameters
Type | Name | Description |
---|---|---|
System.Array | hostSrc | Source |
CopyToDevice(IntPtr)
Copy data from host to device memory
Declaration
public void CopyToDevice(IntPtr source)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | source | Source pointer to host memory |
CopyToDevice(IntPtr, SizeT)
Copy data from host to device memory
Declaration
public void CopyToDevice(IntPtr source, SizeT offsetDest)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | source | Source pointer to host memory |
SizeT | offsetDest | Offset to destination pointer in bytes |
CopyToDevice(IntPtr, SizeT, SizeT, SizeT)
Copy data from host to device memory
Declaration
public void CopyToDevice(IntPtr source, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | source | Source pointer to host memory |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
CopyToHost(ref T)
Copy data from device to host memory
Declaration
public void CopyToHost(ref T dest)
Parameters
Type | Name | Description |
---|---|---|
T | dest | Destination data in host memory |
CopyToHost(ref T, SizeT)
Copy data from device to host memory
Declaration
public void CopyToHost(ref T dest, SizeT offsetSrc)
Parameters
Type | Name | Description |
---|---|---|
T | dest | Destination data in host memory |
SizeT | offsetSrc | Offset to source pointer in bytes |
CopyToHost(T[])
Copy data from device to host memory
Declaration
public void CopyToHost(T[] dest)
Parameters
Type | Name | Description |
---|---|---|
T[] | dest | Destination pointer to host memory |
CopyToHost(T[], SizeT, SizeT, SizeT)
Copy data from device to host memory
Declaration
public void CopyToHost(T[] dest, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
T[] | dest | Destination pointer to host memory |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
CopyToHost(Array)
Copy data from this device to host memory. Array elements can be of any (value)type, but total size in bytes must match to allocated device memory.
Declaration
public void CopyToHost(Array hostDest)
Parameters
Type | Name | Description |
---|---|---|
System.Array | hostDest | Destination |
CopyToHost(IntPtr)
Copy data from device to host memory
Declaration
public void CopyToHost(IntPtr dest)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | dest | Destination pointer to host memory |
CopyToHost(IntPtr, SizeT)
Copy data from device to host memory
Declaration
public void CopyToHost(IntPtr dest, SizeT offsetSrc)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | dest | Destination data in host memory |
SizeT | offsetSrc | Offset to source pointer in bytes |
CopyToHost(IntPtr, SizeT, SizeT, SizeT)
Copy data from device to host memory
Declaration
public void CopyToHost(IntPtr dest, SizeT offsetSrc, SizeT offsetDest, SizeT sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | dest | Destination pointer to host memory |
SizeT | offsetSrc | Offset to source pointer in bytes |
SizeT | offsetDest | Offset to destination pointer in bytes |
SizeT | sizeInBytes | Size to copy in bytes |
Dispose()
Dispose
Declaration
public void Dispose()
Dispose(Boolean)
For IDisposable
Declaration
protected virtual void Dispose(bool fDisposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | fDisposing |
Finalize()
For dispose
Declaration
protected void Finalize()
Memset(Byte)
Memset
Declaration
public void Memset(byte aValue)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | aValue |
Memset(UInt16)
Memset
Declaration
public void Memset(ushort aValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | aValue |
Memset(UInt32)
Memset
Declaration
public void Memset(uint aValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | aValue |
MemsetAsync(Byte, CUstream)
Memset
Declaration
public void MemsetAsync(byte aValue, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | aValue | |
CUstream | stream |
MemsetAsync(UInt16, CUstream)
Memset
Declaration
public void MemsetAsync(ushort aValue, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | aValue | |
CUstream | stream |
MemsetAsync(UInt32, CUstream)
Memset
Declaration
public void MemsetAsync(uint aValue, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | aValue | |
CUstream | stream |
PeerCopyToDevice(CudaContext, CUdeviceptr, CudaContext)
Copies from device memory in one context to device memory in another context
Declaration
public void PeerCopyToDevice(CudaContext destCtx, CUdeviceptr source, CudaContext sourceCtx)
Parameters
Type | Name | Description |
---|---|---|
CudaContext | destCtx | Destination context |
CUdeviceptr | source | Source pointer to device memory |
CudaContext | sourceCtx | Source context |
PeerCopyToDevice(CudaContext, CUdeviceptr, CudaContext, CUstream)
Async-Copies from device memory in one context to device memory in another context
Declaration
public void PeerCopyToDevice(CudaContext destCtx, CUdeviceptr source, CudaContext sourceCtx, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaContext | destCtx | Destination context |
CUdeviceptr | source | Source pointer to device memory |
CudaContext | sourceCtx | Source context |
CUstream | stream |
PeerCopyToDevice(CudaContext, CudaDeviceVariable<T>, CudaContext)
Copies from device memory in one context to device memory in another context
Declaration
public void PeerCopyToDevice(CudaContext destCtx, CudaDeviceVariable<T> source, CudaContext sourceCtx)
Parameters
Type | Name | Description |
---|---|---|
CudaContext | destCtx | Destination context |
CudaDeviceVariable<T> | source | Source pointer to device memory |
CudaContext | sourceCtx | Source context |
PeerCopyToDevice(CudaContext, CudaDeviceVariable<T>, CudaContext, CUstream)
Async-Copies from device memory in one context to device memory in another context
Declaration
public void PeerCopyToDevice(CudaContext destCtx, CudaDeviceVariable<T> source, CudaContext sourceCtx, CUstream stream)
Parameters
Type | Name | Description |
---|---|---|
CudaContext | destCtx | Destination context |
CudaDeviceVariable<T> | source | Source pointer to device memory |
CudaContext | sourceCtx | Source context |
CUstream | stream |
Operators
| Improve this Doc View SourceImplicit(T to CudaDeviceVariable<T>)
Converts a host array to a newly allocated device variable.
Declaration
public static implicit operator CudaDeviceVariable<T>(T d)
Parameters
Type | Name | Description |
---|---|---|
T | d | host array |
Returns
Type | Description |
---|---|
CudaDeviceVariable<T> | newly allocated device variable with values from host memory |
Implicit(T[] to CudaDeviceVariable<T>)
Converts a host array to a newly allocated device variable.
Declaration
public static implicit operator CudaDeviceVariable<T>(T[] d)
Parameters
Type | Name | Description |
---|---|---|
T[] | d | host array |
Returns
Type | Description |
---|---|
CudaDeviceVariable<T> | newly allocated device variable with values from host memory |
Implicit(CudaDeviceVariable<T> to T)
Converts a device variable to a host value. In case of multiple device values, only the first value is copied.
Declaration
public static implicit operator T(CudaDeviceVariable<T> d)
Parameters
Type | Name | Description |
---|---|---|
CudaDeviceVariable<T> | d | device variable |
Returns
Type | Description |
---|---|
T | newly allocated host variable with value from device memory |
Implicit(CudaDeviceVariable<T> to T[])
Converts a device variable to a host array
Declaration
public static implicit operator T[](CudaDeviceVariable<T> d)
Parameters
Type | Name | Description |
---|---|---|
CudaDeviceVariable<T> | d | device variable |
Returns
Type | Description |
---|---|
T[] | newly allocated host array with values from device memory |