Open GF-Huang opened 6 months ago
0
is a perfectly valid device value, they are more or less equal to the device ID.
(In very old Cuda versions, the value used to be a 32-bit pointer, hence the name in the structure, but in current versions, the value mostly corresponds to the device ID)
Michael
But the Pointer
is zero as an IntPtr
which used for other 3rd library, is it really OK?
For example MarshalInterface<IDirect3DDevice>.FromAbi(device.Pointer)
will return null
.
CUdevice.Pointer
is just an int
, not an IntPtr
. CUdevice
is also a Cuda specific type and is not supposed to be used outside of the Cuda API. Your example with MarshalInterface<IDirect3DDevice>.FromAbi(device.Pointer)
can't work with a Cuda-API provided value, it will only work with adapter.NativePointer
.
In the orginal C++ header CUdevice
is defined as following:
typedef int CUdevice_v1; /**< CUDA device */
typedef CUdevice_v1 CUdevice; /**< CUDA device */
As C# does not have something like a typedef in C++, I use structs to define the custom type. At the end it is just an int
. Hope that clarifies things.