如何修复“ CUDAFY CUDA上出现错误719”

时间:2018-09-28 03:32:13

标签: c# cudafy.net

jest

我在github上使用Konrad-Ziarko的代码。但是当我放

[Cudafy]
        private static void LevenshteinGpu3(GThread thread, char[] source, char[] pattern, int firstDim, byte compareLength, byte[] dev_results)
        {
            int tid = thread.threadIdx.x + thread.blockIdx.x * thread.blockDim.x;
            byte[,,] dev_levMatrix_1 = _gpu.Allocate<byte>(20, 20, 20);
            for (byte j = 0; j <= compareLength; j++)
            {
                dev_levMatrix_1[tid, 0, j] = j;
                dev_levMatrix_1[tid, j, 0] = j;
            }

            if (tid < firstDim)
            {
                for (int i = 1; i <= compareLength; i++)
                {
                    for (int j = 1; j <= compareLength; j++)
                    {
                        int iMinusOne = i - 1;
                        int jMinusOne = j - 1;

                        if (tid + iMinusOne < source.Length && source[tid + iMinusOne] == pattern[jMinusOne])
                        {
                            dev_levMatrix_1[tid, i, j] = dev_levMatrix_1[tid, iMinusOne, jMinusOne];
                        }
                        else
                        {
                            byte x = dev_levMatrix_1[tid, iMinusOne, j];
                            if (x > dev_levMatrix_1[tid, i, jMinusOne])
                                x = dev_levMatrix_1[tid, i, jMinusOne];
                            if (x > dev_levMatrix_1[tid, iMinusOne, jMinusOne])
                                x = dev_levMatrix_1[tid, iMinusOne, jMinusOne];
                            dev_levMatrix_1[tid, i, j] = ++x;
                        }
                    }
                }
                dev_results[tid] = dev_levMatrix_1[tid, compareLength, compareLength];
            }
        }

在代码中运行。 CUDA显示错误719。

但是,如果我像下面这样放置byte[,,] dev_levMatrix_1 = _gpu.Allocate<byte>(20, 20, 20); ,它将起作用:

dev_levMatrix_1

我可以将private static void LevenshteinGpu3(GThread thread, char[] source, char[] pattern, dev_levMatrix_1, int firstDim, byte compareLength, byte[] dev_results) 放在函数中吗?

1 个答案:

答案 0 :(得分:0)

来晚了,但是...

您不能在Cudafy装饰函数内分配GPU内存。 应该在将参数传递给内核之前进行分配。 在内核函数中,您可以创建局部变量并使用它们。

此外,您可以在其他地方而不是其他地方提问题更快地找到帮助。