Exemplo n.º 1
0
        public static Span256 <T> ToSpan256 <T>(this Vec256 <T> src)
            where T : struct
        {
            var dst = Span256.AllocBlocks <T>(1);

            vstore(src, ref dst[0]);
            return(dst);
        }
Exemplo n.º 2
0
        public static Span256 <T> ToSpan256 <T>(this Vec512 <T> src)
            where T : struct
        {
            var dst = Span256.AllocBlocks <T>(2);

            vstore(src.lo, ref dst[0]);
            vstore(src.hi, ref dst[32]);
            return(dst);
        }
Exemplo n.º 3
0
        public static Span256 <T> ToSpan256 <T>(this Vec1024 <T> src)
            where T : struct
        {
            var dst = Span256.AllocBlocks <T>(4);

            vstore(src.v00, ref dst[0]);
            vstore(src.v01, ref dst[32]);
            vstore(src.v10, ref dst[64]);
            vstore(src.v10, ref dst[96]);
            return(dst);
        }
Exemplo n.º 4
0
 public static Span256 <T> Alloc <T>(int minlen, T?fill = null)
     where T : struct
 {
     Span256.Alignment <T>(minlen, out int blocklen, out int fullBlocks, out int remainder);
     if (remainder == 0)
     {
         return(AllocBlocks <T>(fullBlocks, fill));
     }
     else
     {
         return(Span256.AllocBlocks <T>(fullBlocks + 1, fill));
     }
 }
Exemplo n.º 5
0
        public static void VerifyBinOp <T>(IPolyrand random, int blocks, Vector256BinOp <T> inXOp, Func <T, T, T> primalOp)
            where T : unmanaged
        {
            var blocklen = Span256 <T> .BlockLength;

            var lhs = random.ReadOnlySpan256 <T>(blocks);

            Claim.eq(blocks * blocklen, lhs.Length);

            var rhs = random.ReadOnlySpan256 <T>(blocks);

            Claim.eq(blocks * blocklen, rhs.Length);

            var expect = Span256.AllocBlocks <T>(blocks);

            Claim.eq(blocks, expect.BlockCount);

            var actual = Span256.AllocBlocks <T>(blocks);

            Claim.eq(blocks, actual.BlockCount);

            var tmp = new T[blocklen];

            for (var block = 0; block < blocks; block++)
            {
                var offset = block * blocklen;
                for (var i = 0; i < blocklen; i++)
                {
                    tmp[i] = primalOp(lhs[offset + i], rhs[offset + i]);
                }

                var vExpect = Vec256.LoadVector <T>(ref tmp[0]);

                var vX      = lhs.LoadVec256(block);
                var vY      = rhs.LoadVec256(block);
                var vActual = inXOp(vX, vY);

                Claim.eq(vExpect, vActual);

                ginx.store(vExpect, ref expect.Block(block));
                ginx.store(vActual, ref actual.Block(block));
            }
            Claim.eq(expect, actual);
        }
Exemplo n.º 6
0
 public static Span256 <T> AllocBlock <T>(T?fill = null)
     where T : struct
 => Span256 <T> .AllocBlocks(1, fill);
Exemplo n.º 7
0
 public static Span256 <T> AllocBlocks <T>(int blocks, T?fill = null)
     where T : struct
 => Span256 <T> .AllocBlocks(blocks, fill);