This project is read-only.

improper type of CUdeviceptr.Pointer

Feb 15, 2014 at 11:51 AM

CUdeviceptr.Pointer in managedcuda is of type SizeT. The type of the backing field for the value of SizeT is of type IntPtr.
This causes problems because CUDA device pointers can have values that do not fit into IntPtr (for example if you are running a 32-bit process, the maximum value for IntPtr is 2GB but the CUDA context can return a device pointers with an address up to 4GB). IMHO the proper type for CUDA pointer is UIntPtr. The CUDA toolkit defines CUdeviceptr as unsigned int for 32-bit processes and as unsigned long long for 64-bit processes.
I had to change the type of value inside SizeT to UIntPtr to get my program working, otherwise i was getting overflow errors while doing pointer arithmetic.

Feb 15, 2014 at 11:01 PM
Hi Robert,

nice catch! UIntPtr is definitely the better choice as inner type for SizeT. I will test and probably change it in the upcoming Cuda 6 release.