public ComputationData(string blockName, string operandA, string operandB, Func <Matrix, Matrix, Matrix> execute)
        {
            this.blockName    = blockName;
            this.operandAName = operandA;
            this.operandBName = operandB;

            LevelsData.RegisterOperation(blockName, execute);

            computationBlock = new ComputationBlock(blockName);
        }
        public Matrix Execute()
        {
            if (operandA == null)
            {
                throw new Exception("Error! Operands not set.");
            }

            try
            {
                Matrix result = LevelsData.ExecuteOperation(blockName, operandA, operandB);
                return(result);
            }

            catch (Exception e)
            {
                Console.WriteLine("Error in block :" + blockName);
                throw e;
            }
        }
Пример #3
0
        public MainProcess(Intracommunicator communicator, int size = 55) : base(communicator)
        {
            busyProcesses      = new Queue <KeyValuePair <int, ComputationData> >();
            computationResults = new Dictionary <string, Matrix>();
            availableProcesses = new Queue <int>();
            levelsData         = new LevelsData();
            inputData          = new InputData(size);
            timer = new Timer();

            SaveResult("y1", inputData.y1);
            SaveResult("y2", inputData.y2);
            SaveResult("Y3", inputData.Y3);
            SaveResult(string.Empty, null);

            Console.WriteLine("Operations logging: " + (Config.logOperations ? "enabled" : "disabled"));
            Console.WriteLine("Execution Type: " + (Config.multiProcess ? "parallel" : "single"));

            WriteTitle("COMPUTATION START");
            timer.Start();

            if (Config.multiProcess)
            {
                ComputeInMultiple();
            }
            else
            {
                ComputeInSingle();
            }

            timer.Stop();
            WriteTitle("COMPUTATION END");

            Console.WriteLine("Final Result:");
            computationResults[levelsData.FinalOperationName].Print();

            Console.WriteLine();
            Console.WriteLine($"Execution Time in ms: {timer.Elapsed}.0");
            Console.WriteLine();
        }