Exemple #1
0
        private void SendData(ComputationData[] level)
        {
            for (int j = 0; j < level.Length; j++)
            {
                ComputationData  cData  = level[j];
                ComputationBlock cBlock = cData.computationBlock;
                cBlock.SetOperands(computationResults[cData.operandAName], computationResults[cData.operandBName]);

                if (availableProcesses.Count > 0)
                {
                    int processRank = availableProcesses.Dequeue();
                    SendMessage(Message.BlockSend, processRank);
                    communicator.Send(cBlock, processRank, 0);
                    busyProcesses.Enqueue(new KeyValuePair <int, ComputationData>(processRank, cData));
                }

                else
                {
                    DisplayOperation(cData.blockName, cData.operandAName, cData.operandBName, cBlock.operandA, cBlock.operandB);
                    Matrix result = cBlock.Execute();
                    DisplayResult(cData.blockName, result);
                    SaveResult(cData.blockName, result);
                }
            }
        }
Exemple #2
0
        private void CollectResults()
        {
            while (busyProcesses.Count > 0)
            {
                var              pair        = busyProcesses.Dequeue();
                int              processRank = pair.Key;
                ComputationData  cData       = pair.Value;
                ComputationBlock cBlock      = cData.computationBlock;
                Matrix           result      = communicator.Receive <Matrix>(processRank, 0);

                availableProcesses.Enqueue(processRank);
                DisplayOperation(cData.blockName, cData.operandAName, cData.operandBName, cBlock.operandA, cBlock.operandB);
                DisplayResult(cData.blockName, result);

                SaveResult(pair.Value.blockName, result);
            }
        }