Example #1
0
        private static void RunLinpackRandom()
        {
            var problems     = Enumerable.Range(1, 12).Select(n => (int)Math.Pow(2, n)).Select(s => MatrixSummer.Setup(s)).ToArray();
            var problemSizes = Enumerable.Range(1, 12).Select(n => (int)Math.Pow(2, n)).ToArray();
            var linpackSeq   = new MorellRunner <long[, ], long>(MatrixSummer.SumSeq, problems, problemSizes);
            var linpackMR    = new MorellRunner <long[, ], long>(MatrixSummer.SumMapReduce, problems, problemSizes);
            var linpackP     = new MorellRunner <long[, ], long>(MatrixSummer.SumParallel, problems, problemSizes);
            var linpackT     = new MorellRunner <long[, ], Task <long> >(MatrixSummer.SumTask, problems, problemSizes);

            linpackSeq.Run(100);
            linpackMR.Run(100);
            linpackP.Run(100);
            linpackT.Run(100);

            const string fileName = "linpack-rand.csv";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            var f = new StreamWriter(fileName);

            f.WriteLine("Problem Size,Sequential,Sequential Error,Map Reduce,Map Reduce Error,Parallel Foreach,Parallel Foreach Error, Tasks, Tasks Error");

            foreach (var res in linpackSeq.Results)
            {
                var mr = linpackMR.Results[res.Key];
                var p  = linpackP.Results[res.Key];
                var t  = linpackT.Results[res.Key];
                f.WriteLine($"{res.Key},{res.Value.Mean},{res.Value.StandardDeviation},{mr.Mean},{mr.StandardDeviation},{p.Mean},{p.StandardDeviation},{t.Mean},{t.StandardDeviation}");
            }

            f.Flush();
            f.Close();
        }
Example #2
0
        private static void RunAccumulationRandom()
        {
            var problems = Enumerable.Range(1, BenchmarkTreeSize)
                           .Select(n => (int)Math.Pow(2, n))
                           .Select(s => TreeGenerator.CreateTree(s, () => Rnd.Next(int.MinValue, int.MaxValue)))
                           .ToArray();
            var problemSizes = Enumerable.Range(1, BenchmarkTreeSize).Select(n => (int)Math.Pow(2, n)).ToArray();
            var accumSeq     = new MorellRunner <Tree <int>, List <int> >(TreeAccumulator.AccumulateLeaves, problems, problemSizes);
            var accumFJ      = new MorellRunner <Tree <int>, List <int> >(TreeAccumulator.AccumulateLeavesForkJoin, problems, problemSizes);
            var accumL       = new MorellRunner <Tree <int>, List <int> >(TreeAccumulator.AccumulateLeavesLenient, problems, problemSizes);

            accumSeq.Run(100);
            accumFJ.Run(100);
            accumL.Run(100);

            const string fileName = "accumulation-rand.csv";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            var f = new StreamWriter(fileName);

            f.WriteLine("Problem Size,Sequential,Sequential Error,Fork Join,Fork Join Error,Lenient,Lenient Error");

            foreach (var res in accumSeq.Results)
            {
                var fj = accumFJ.Results[res.Key];
                var l  = accumL.Results[res.Key];
                f.WriteLine($"{res.Key},{res.Value.Mean},{res.Value.StandardDeviation},{fj.Mean},{fj.StandardDeviation},{l.Mean},{l.StandardDeviation}");
            }

            f.Flush();
            f.Close();
        }