Example #1
0
        public int ArrayCompositeSumRewritten()
        {
            var sum = ExtendedLinq.Range(0, ArraySource.Length / 10, 10)
                      .Sum(x => ArraySource.Skip(x).Take(10).Sum());

            sum += ArraySource.Skip(ArraySource.Length / 10 * 10).Sum();
            return(sum);
        }
Example #2
0
        public int ArraySIMDSum()
        {
            var simdLength = Vector <int> .Count;
            var vectorSum  = ExtendedLinq.Range(0, ArraySource.Length / simdLength, simdLength)
                             .Aggregate(Vector <int> .Zero, (x, y) => Vector.Add(x, new Vector <int>(ArraySource, y)));

            return(Enumerable.Range(0, simdLength).Sum(i => vectorSum[i])
                   + ArraySource.Skip(ArraySource.Length / simdLength * simdLength).Sum());
        }
Example #3
0
        public int ArraySIMDSumRewritten()
        {
            var          simdLength = Vector <int> .Count;
            Vector <int> vsum       = Vector <int> .Zero;

            ExtendedLinq.Range(0, ArraySource.Length / simdLength, simdLength)
            .ForEach(x => vsum = Vector.Add(vsum, new Vector <int>(ArraySource, x)));
            return(Enumerable.Range(0, simdLength).Sum(i => vsum[i])
                   + ArraySource.Skip(ArraySource.Length / simdLength * simdLength).Sum());
        }