Tag: cuda

为什么在CUDA内核中z始终为零

我正在使用Cudafy在NVIDIA GPU上进行一些计算。 (Quadro K1100Mfunction3.0,如果重要的话) 我的问题是,当我使用以下内容时 cudaGpu.Launch(new dim3(44,8,num), new dim(8, 8)).MyKernel… 当我在内核中使用它时,为什么来自GThread实例的z索引总是为零? int z = thread.blockIdx.z * thread.blockDim.z + thread.threadIdx.z; 此外,如果我必须做类似的事情 cudaGpu.Launch(new dim3(44,8,num), new dim(8, 8, num)).MyKernel… z确实提供了不同的索引,但由于每个块的线程数限制,num不能很大。 有关如何解决这个问题的任何消息? 编辑 另一种表达方式。 当块大小仅为2D时,我可以在我的内核中使用thread.z(对于任何有用的东西)吗?

ManagedCuda:IllegalAddress; 在执行内核时

我在C#项目中使用ManagedCuda库来利用GPU,目前我正在跟随本教程,关于如何在使用OpenCV实现它之后编写C#和C ++之间兼容的代码。 我的代码似乎一切正常,内核被发现,构建并执行方法调用但是我收到一个错误: An unhandled exception of type ‘ManagedCuda.CudaException’ occurred in ManagedCuda.dll Additional information: ErrorIllegalAddress: While executing a kernel, the device encountered a load or store instruction on an invalid memory address. The context cannot be used, so it must be destroyed (and a new one should be created). 我知道C#抱怨在尝试将设备指针传递给内核时找不到有效地址,我在代码和引用教程中的post之间可以区分的唯一区别是ManagedCuda似乎最近有过一个允许用户使用Lambdas的整容,我已经做了一些阅读,并没有找到任何东西来澄清这是否是导致我的问题: static Func cudaAdd = (a, […]

循环使用CUDA内核中的数据会导致应用程序中止

问题: 当我增加在CUDA内部循环内处理的数据量时 – 它会导致应用程序中止! 例外: ManagedCuda.CudaException:’ErrorLaunchFailed:执行内核时设备发生exception。 常见原因包括解除引用无效设备指针和访问超出范围的共享内存。 题: 如果有人可以了解我正在使用当前实现的限制以及究竟是什么导致应用程序崩溃,我将不胜感激。 或者,我附加了一个完整的内核代码,以便有人可以说如何在没有抛出exception的情况下以这种方式重新建模。 我们的想法是,内核正在接受combinations ,然后对同一组data执行计算(在循环中)。 因此,内部的循环计算应是顺序的。 执行内核本身的顺序无关紧要。 这是组合学问题。 欢迎任何建议。 代码(短版本,足以中止应用程序): extern “C” { __device__ __constant__ int arraySize; __global__ void myKernel( unsigned char* __restrict__ output, const int* __restrict__ in1, const int* __restrict__ in2, const double* __restrict__ in3, const unsigned char* __restrict__ in4) { for (int row = 0; row […]