Ejemplo n.º 1
0
    public unsafe void SGEMM(float *Ap, int AN, int AM, float *Bp, int BN, int BM, float *Cp, int CN, int CM, int bs,
                             bool transposeA = false, bool transposeB = false)
    {
        if (transposeA)
        {
            var tmp = AN; AN = AM; AM = tmp;
        }
        if (transposeB)
        {
            var tmp = BN; BN = BM; BM = tmp;
        }

        UnsafeMatrixBlockMultiplyUnrolled8xhJob job = new UnsafeMatrixBlockMultiplyUnrolled8xhJob();

        job.A          = Ap;
        job.AN         = AN;
        job.AM         = AM;
        job.B          = Bp;
        job.BN         = BN;
        job.BM         = BM;
        job.C          = Cp;
        job.CN         = CN;
        job.CM         = CM;
        job.bs         = bs;
        job.transposeA = transposeA;
        job.transposeB = transposeB;

        var fence = job.Schedule((BM / bs) + (BM % bs > 0 ? 1 : 0), 4);

        fence.Complete();
    }
Ejemplo n.º 2
0
 public bool IsCurrentPlatformSupported()
 {
     try
     {
         // Sanity test if all the dependencies of the job are met at runtime
         // Also prevent compiler from optimising this out
         var test = new UnsafeMatrixBlockMultiplyUnrolled8xhJob();
         D.Log($"Loaded: {test}");
     }
     catch (Exception e)
     {
         D.Log($"C# Job system not found. Disabling {this.GetType()}. Error: {e}");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
    public unsafe void SGEMM(float *Ap, int AN, int AM, float *Bp, int BN, int BM, float *Cp, int CN, int CM, int bs,
                             bool transposeA = false, bool transposeB = false)
    {
        if (transposeA)
        {
            var tmp = AN; AN = AM; AM = tmp;
        }
        if (transposeB)
        {
            var tmp = BN; BN = BM; BM = tmp;
        }

        UnsafeMatrixBlockMultiplyUnrolled8xhJob job = new UnsafeMatrixBlockMultiplyUnrolled8xhJob();

        job.A          = Ap;
        job.AN         = AN;
        job.AM         = AM;
        job.B          = Bp;
        job.BN         = BN;
        job.BM         = BM;
        job.C          = Cp;
        job.CN         = CN;
        job.CM         = CM;
        job.bs         = bs;
        job.transposeA = transposeA;
        job.transposeB = transposeB;

        //D.Log($"Matrix mul {AN},{AM} x {BN},{BM}");

        JobHandle fence;

        if (AN < BM)
        {
            job.scheduleRowA = false;
            fence            = job.Schedule((BM / bs) + (BM % bs > 0 ? 1 : 0), 1);
        }
        else
        {
            job.scheduleRowA = true;
            fence            = job.Schedule((AN / bs) + (AN % bs > 0 ? 1 : 0), 1);
        }

        fence.Complete();
    }