Esempio n. 1
0
        internal int[] MergeDataFromWorkers()
        {
            if (IsGlobalManager)
            {
                QSArray result = null;
                for (int process = 0; process < globalGroup.Total; process++)
                {
                    var array = ReceiveGlobalArrayFrom(process, Tags.Collect);

                    if (result == null)
                    {
                        result = array;
                    }
                    else
                    {
                        result = QSArray.Merge(result, array);
                    }
                }

                return(result.GetContent());
            }
            else
            {
                throw new InvalidOperationException($"Not Global Manager");
            }
        }
Esempio n. 2
0
        internal void PartitionAndPartsExchange()
        {
            currentArray.Partition(currentPivot, out QSArray low, out QSArray high);

            int partner = group.IsLeftHalf ?
                          group.Current + group.Total / 2 :
                          group.Current - group.Total / 2;

            if (group.IsLeftHalf)
            {
                group.Communicator.ImmediateSend <int[]>(high.GetContent(), partner, Tags.Exchange);
                high = ReceiveArrayFrom(partner, Tags.Exchange);
            }
            else
            {
                group.Communicator.ImmediateSend <int[]>(low.GetContent(), partner, Tags.Exchange);
                low = ReceiveArrayFrom(partner, Tags.Exchange);
            }

            currentArray = QSArray.Merge(low, high);
        }