我有一个IntPtr hData
指向存储在非托管内存中的数据数组的开头。当我尝试使用下面描述的CUDA内核传递它时,我得到System.Exception: i64 is not a struct type
。我应该如何使用Alea CUDA内核传入指向非托管内存中的数组的指针?
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)));
}
}