Ejemplo n.º 1
0
        public RowTree ProcessRow(SliceInfo data)
        {
            //var data = new SliceInfo
            //{
            //    TotalNonZeros = 4,
            //    Branches = new ushort[] { 10, 12, 60, 80 },
            //    Leaves = new int[] { 0, 3, 4, 5 },
            //};
            var masks  = mRuler.GetBitMasks(data.TotalNonZeros);
            var branch = CreateRowBranch(data.TotalNonZeros);

            CopyBranchNodes(data.Branches, 0, data.TotalNonZeros, branch.Keys.Length, branch);

            // Build test chunk
            // 1. branch vector
            // 2. leaf offset
            // 3. leaf array
            mRuler.GetChunkInfo(data.TotalNonZeros, out int wholeBuckets, out int remainder);

            var chunks = new TestChunk[branch.NoOfBuckets];
            var offset = 0;

            for (var i = 0; i < branch.NoOfBuckets; i += 1)
            {
                chunks[i] = new TestChunk
                {
                    KeyOffset  = offset,
                    LeafOffset = offset,
                    LeafLength = (i < wholeBuckets) ? mRuler.BucketSize : remainder,
                };

                offset += mRuler.BucketSize;
            }

            // generate instruction set
            // 1. set chunk no
            // 2. branch mask
            var instructions = new Instruction[masks.Length];

            if (masks.Length <= 1)
            {
                instructions[0] = new Instruction
                {
                    Chunk = 0,
                    Mask  = masks[0],
                };
            }

            if (masks.Length <= 2)
            {
                instructions[1] = new Instruction
                {
                    Chunk = 0,
                    Mask  = masks[1],
                };
            }

            for (var i = 2; i < masks.Length; i += 1)
            {
                instructions[i] = new Instruction
                {
                    Chunk = i - 1,
                    Mask  = masks[i],
                };
            }

            return(new RowTree
            {
                Branches = data.Branches,
                Leaves = data.Leaves,
                TestChunks = chunks,
                Instructions = instructions,
            });
        }
Ejemplo n.º 2
0
        public uint Evaluate(TestChunk testChunk, ushort[] branches, ushort singleValue)
        {
            var nodeSpace = new Span <ushort>(branches, testChunk.KeyOffset, testChunk.LeafLength);

            return(SetMask16_SIMD_Optimized_1(nodeSpace, singleValue));
        }