Exemplo n.º 1
0
    public void Execute(int colB)
    {
        unsafe
        {
            int sz = bs * bs * 4;

            ;           float *blockA = (float *)UnsafeUtility.Malloc(sz, 4, Allocator.TempJob);
            float *            blockB = (float *)UnsafeUtility.Malloc(sz, 4, Allocator.TempJob);
            float *            blockC = (float *)UnsafeUtility.Malloc(sz, 4, Allocator.TempJob);

            for (int rowA = 0; rowA < AN; rowA += bs)
            {
                //for (int colB = 0; colB < BM; colB += bs)
                {
                    for (int l = 0; l < AM; l += bs)
                    {
                        MatrixUtils.CopyBlockWithPadding(A, rowA, AN, l, AM, blockA, bs, transposeA);
                        MatrixUtils.CopyBlockWithPadding(B, l, BN, colB * bs, BM, blockB, bs, transposeB);
                        MatrixUtils.CopyBlockWithPadding(C, rowA, CN, colB * bs, CM, blockC, bs);

                        MatrixUtils.MultiplyBlockUnroll8xhPadded(blockA, blockB, blockC, bs);

                        MatrixUtils.CopyBlockWithPadding(blockC, C, rowA, CN, colB * bs, CM, bs);
                    }
                }
            }

            UnsafeUtility.Free(blockA, Allocator.TempJob);
            UnsafeUtility.Free(blockB, Allocator.TempJob);
            UnsafeUtility.Free(blockC, Allocator.TempJob);
        }
    }
Exemplo n.º 2
0
    private unsafe void ExecutOverRowA(float *blockA, float *blockB, float *blockC, int rowA)
    {
        //for (int rowA = 0; rowA < AN; rowA += bs)
        {
            for (int colB = 0; colB < BM; colB += bs)
            {
                for (int l = 0; l < AM; l += bs)
                {
                    MatrixUtils.CopyBlockWithPadding(A, rowA, AN, l, AM, blockA, bs, transposeA);
                    MatrixUtils.CopyBlockWithPadding(B, l, BN, colB, BM, blockB, bs, transposeB);
                    MatrixUtils.CopyBlockWithPadding(C, rowA, CN, colB, CM, blockC, bs);

                    MatrixUtils.MultiplyBlockUnroll8xhPadded(blockA, blockB, blockC, bs);

                    MatrixUtils.CopyBlockWithPadding(blockC, C, rowA, CN, colB, CM, bs);
                }
            }
        }
    }