如何使用Alea GPU进行矩阵乘法

时间:2019-04-30 23:50:17

标签: c# .net cuda gpgpu aleagpu

     [GpuParam] private readonly int Thread;
     [GpuParam] private readonly int Block;
   public void KernelMatrix(int[,] a,int[,] b,int[,] c)
        {
            var thrX = blockIdx.x * Thread + threadIdx.x;
            var thrY = blockIdx.y * Thread + threadIdx.y;
            int val = 0;
            for(int i = 0;i<Thread;i++)
            {
                val = 0;
                for (int k=0;k<Thread;k++)
                {
                    val += b[thrX,k] * a[k, thrY];
                }
                //Problem maybe originate from here but I dont know how to fix it.
                c[thrY,thrX] = val; 
            }
    }

它工作但不正确,由于某种原因,在将2X1和1X2之类的东西相乘时,它只给出2 16而不是4 16。

0 个答案:

没有答案