コード例 #1
0
        void Permute4i32(int cycles = DefaltCycleCount, bool trace = false)
        {
            var pSrc = Random.EnumStream <Perm4>(x => (byte)x > 5);

            for (var i = 0; i < cycles; i++)
            {
                var v1 = Random.CpuVec128 <int>();
                var p  = pSrc.First();

                // Disassemble the spec
                var p0 = Bits.gather((byte)p, (byte)0b11);
                var p1 = Bits.gather((byte)p, (byte)0b1100);
                var p2 = Bits.gather((byte)p, (byte)0b110000);
                var p3 = Bits.gather((byte)p, (byte)0b11000000);

                // Reassemble the spec
                Perm4 q = (Perm4)(p0 | p1 << 2 | p2 << 4 | p3 << 6);

                // Same?
                Claim.eq(p, q);

                // Permute vector via api
                var v2 = dinx.permute(v1, p);

                // Permute vector manually
                var v3 = Vec128.FromParts(v1[p0], v1[p1], v1[p2], v1[p3]);

                // Same?
                Claim.eq(v3, v2);

                if (trace)
                {
                    Trace("v1", v1.FormatHex());
                    Trace("p", p.Format());
                    Trace("perm(v1,p)", v2.FormatHex());
                }
            }
        }
コード例 #2
0
 public static string Format(this Perm4 src)
 => $"{src} = {((byte)src).ToBitString()} = {((byte)src).FormatHex()}";