kunzmi / managedCuda

ManagedCUDA aims an easy integration of NVidia's CUDA in .net applications written in C#, Visual Basic or any other .net language.
Other
440 stars 79 forks source link

Allocating a CudaPitchedDeviceVariable using a width and height throws an ErrorInvalidValue exception. #47

Closed dennisai closed 7 years ago

dennisai commented 7 years ago

Hello,

When I try to execute the following code, I get an ErrorInvalidValue exception.

CudaContext cudaContext = new CudaContext(CudaContext.GetMaxGflopsDeviceId());
CudaPitchedDeviceVariable<ushort> var = new CudaPitchedDeviceVariable<ushort>(
    2048, 160);

I have tried with multiple parameters, such as (16, 16) for my width and height. It appears to work with float but not with ushort. Any idea why it doesn't support ushort?

robik75 commented 7 years ago

Please see the CUDA DriverAPI documentation: http://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gcbe9b033f6c4de80f63cc6e58ed9a45a

ElementSizeBytes may be 4, 8 or 16 (since coalesced memory transactions are not possible on other data sizes).

ushort size is 2 bytes

dennisai commented 7 years ago

Great thank you RoBik75!