I have an IntPtr hData
that points to the beginning of an array of data that is stored in unmanaged memory. When I try to pass it using the CUDA kernel described below, I get a System.Exception: i64 is not a struct type
. How should I be passing in a pointer to an array in unmanaged memory using an Alea CUDA kernel?
unsafe private static void CopyDataToDeviceMemory(
IntPtr hData,
deviceptr<float> dData,
int dataLength)
{
int start = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (int i = start; i < dataLength; i += stride)
{
dData[i] = DeviceFunction.Convert<ushort, float>(
*((ushort*)(hData + i * 2)));
}
}