Exemple #1
0
        public static async Task Main()
        {
            using (ControlSpace cs = new ControlSpace("Example"))
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                int N = 150;
                await cs.AddDirectoryAsync(Directory.GetCurrentDirectory());

                var points = new Point[N];
                var tasks  = new Task <string> [N];
                for (int i = 0; i < N; i++)
                {
                    points[i] = await cs.CreatePointAsync(i.ToString(), PointType.Remote, ChannelType.TCP);

                    await points[i].AddChannelAsync(cs.CurrentPoint.Channel);
                    await points[i].RunAsync(new PointStartInfo(Tests.TestParcsPoints));
                    await points[i].SendAsync(i);
                    tasks[i] = points[i].GetAsync <string>();
                }
                await Task.WhenAll(tasks);

                foreach (var item in tasks)
                {
                    Console.WriteLine(item.Result);
                }
                Console.WriteLine("Done " + sw.Elapsed);
                Console.ReadKey();
            }
        }
Exemple #2
0
        static async Task Main(string[] args)
        {
            int    N       = 2048; //int.Parse(Console.ReadLine());// 1024;
            Matrix matrixA = new Matrix(N, N);

            matrixA.RandomFill(10);
            Matrix matrixB = new Matrix(N, N);

            matrixB.RandomFill(10);
            Stopwatch sw = new Stopwatch();

            //File.WriteAllBytes("A.txt", matrixA.ToByteArray());
            //File.WriteAllBytes("B.txt", matrixB.ToByteArray());
            sw.Start();
            using (ControlSpace cs = new ControlSpace("MatrixMult"))
            {
                await cs.AddDirectoryAsync(Directory.GetCurrentDirectory());

                var point = await cs.CreatePointAsync();

                await point.RunAsync(new PointStartInfo(MatrixMultiplicationParcsMethod.MultStart));

                point.SendAsync(matrixA);
                point.SendAsync(matrixB);
                //Console.WriteLine(matrixA.ToString());
                //Console.WriteLine(matrixB.ToString());
                var matr = await point.GetAsync <Matrix>();

                File.WriteAllText("Result.txt", matr.ToString());


                Console.WriteLine("ParcsResult");
                Console.WriteLine(sw.Elapsed);
                Console.WriteLine("Ordinal result");
                sw.Restart();
                await Task.Factory.StartNew(() => matrixA.MultiplyBy(matrixB));

                Console.WriteLine(sw.Elapsed);
                File.WriteAllText("RealResult.txt", matrixA.ToString());
                Console.WriteLine("Done");
                Console.ReadKey();
            }
        }