This project is read-only.

bool array length...

Apr 8, 2014 at 4:09 AM
Edited Apr 8, 2014 at 4:15 AM
Hi, i'm try to copy data from device to host, but crash...
bool[] ivBIDXtemp = new bool[ivNum * 9]; // ivNum * 9 = 493104
//ivCDV_BIDX = ivBIDX; // Crash

ivSizeB = new SizeT(ivNum * sizeof(bool));
ivCDV_BIDX = new CudaDeviceVariable<bool>(ivSizeB * 9);//has initial

ivBIDXtemp = ivCDV_BIDX; //Crash
//ivCDV_BIDX.CopyToHost(ivBIDXtemp); // Crash
,and I try lower the array length 200000,It will be OK.
Is anyone have idea?
Apr 8, 2014 at 8:52 AM
the problem is the type bool. Bool is not blitable, which means it has (or can have) a different representation in managed memory than in native memory. Try it with an array of bytes in C# and an unsigned char in Cuda.
Second, CudaDeviceVariable takes the size in number of elements and not in bytes, and when using CopyToHost, the size (in elements) times the size of the type internally stored in CudaDeviceMemory gives the number of bytes to copy. If this doesn't fit into the destination array you'll get an error, too.