public void sumoverthreadsandmpi() { for (int ThreadNo = 0; ThreadNo < NumberofThreads; ThreadNo++) { if (IndexValue[ThreadNo] < 0) { continue; } TotalNumberofPoints += NumberofPoints[ThreadNo]; if (MinMaxPointer != 0) { if ((TotalIndexValue >= 0) && (TotalMaxOrMin > MaxOrMinvalue[ThreadNo])) { continue; } } else { if ((TotalIndexValue >= 0) && (TotalMaxOrMin <= MaxOrMinvalue[ThreadNo])) { continue; } } TotalMaxOrMin = MaxOrMinvalue[ThreadNo]; TotalIndexValue = IndexValue[ThreadNo]; } if (DAVectorUtility.MPI_Size > 1) { DAVectorUtility.StartSubTimer(DAVectorUtility.MPIREDUCETiming1); if (MinMaxPointer != 0) { DAVectorUtility.AllReduceMaxWithIndex(ref TotalMaxOrMin, ref TotalIndexValue); } else { DAVectorUtility.AllReduceMinWithIndex(ref TotalMaxOrMin, ref TotalIndexValue); } TotalNumberofPoints = DAVectorUtility.MPI_communicator.Allreduce <double>(TotalNumberofPoints, Operation <double> .Add); DAVectorUtility.StopSubTimer(DAVectorUtility.MPIREDUCETiming1); } return; }
public void sumoverthreadsandmpi() { for (int storeloop = 0; storeloop < Numbertofind; storeloop++) { TotalMinValue[storeloop] = -1.0; TotalIndexValue[storeloop] = -1; } TotalWorst = -1; for (int ThreadNo = 0; ThreadNo < NumberofThreads; ThreadNo++) { for (int storeloop = 0; storeloop < Numbertofind; storeloop++) { if (IndexValuebythread[ThreadNo][storeloop] < 0) { continue; // End this thread } FindMinimumSet(MinValuebythread[ThreadNo][storeloop], IndexValuebythread[ThreadNo][storeloop], ref TotalWorst, TotalMinValue, TotalIndexValue, Numbertofind); } } if (DAVectorUtility.MPI_Size > 1) { DAVectorUtility.StartSubTimer(DAVectorUtility.MPIREDUCETiming1); TotalNumberofPoints = DAVectorUtility.MPI_communicator.Allreduce <double>(TotalNumberofPoints, Operation <double> .Add); DAVectorUtility.StopSubTimer(DAVectorUtility.MPIREDUCETiming1); } // Sort in absolute order and accumulate over processes. This takes Numbertofindsteps for (int OrderLoop = 0; OrderLoop < Numbertofind; OrderLoop++) { int localindex = -1; // unset double localvalue = -1.0; int loopused = -1; for (int internalloop = 0; internalloop < Numbertofind; internalloop++) { // Find minimum if (TotalIndexValue[internalloop] < 0) { continue; } if ((localindex < 0) || (TotalMinValue[internalloop] < localvalue)) { localindex = TotalIndexValue[internalloop]; localvalue = TotalMinValue[internalloop]; loopused = internalloop; } } int oldlocalindex = localindex; if (DAVectorUtility.MPI_Size > 1) { DAVectorUtility.StartSubTimer(DAVectorUtility.MPIREDUCETiming1); DAVectorUtility.AllReduceMinWithIndex(ref localvalue, ref localindex); DAVectorUtility.StopSubTimer(DAVectorUtility.MPIREDUCETiming1); } OrderedMinValue[OrderLoop] = localvalue; OrderedIndexValue[OrderLoop] = localindex; if ((oldlocalindex >= 0) && (OrderedIndexValue[OrderLoop] == oldlocalindex)) { TotalIndexValue[loopused] = -1; TotalMinValue[loopused] = -1.0; } } // Loop over Order Loop return; }