// End AllReduceMinWithIndex // Return Value and Index corresponding to maximum over all MPI Processes // Replace Input values by maximum values public static void AllReduceMaxWithIndex(ref double ProcessValue, ref int ProcessIndex) { if (MPI_Size > 1) { var LocalStructure = new MPIReducePlusIndex(ProcessIndex, ProcessValue); MPIReducePlusIndex TotalStructure = MPI_communicator.Allreduce(LocalStructure, MaxwithIndex); ProcessValue = TotalStructure.value; ProcessIndex = TotalStructure.index; } }
} // End AllReduceMinWithIndex // Return Value and Index corresponding to maximum over all MPI Processes // Replace Input values by maximum values public static void AllReduceMaxWithIndex(ref double ProcessValue, ref int ProcessIndex) { if (DAVectorUtility.MPI_Size > 1) { MPIReducePlusIndex LocalStructure = new MPIReducePlusIndex(ProcessIndex, ProcessValue); MPIReducePlusIndex TotalStructure = DAVectorUtility.MPI_communicator.Allreduce <MPIReducePlusIndex>(LocalStructure, MaxwithIndex); ProcessValue = TotalStructure.value; ProcessIndex = TotalStructure.index; } } // End AllReduceMaxWithIndex
public static MPIReducePlusIndex MaxwithIndex(MPIReducePlusIndex one, MPIReducePlusIndex two) { if (one.index < 0) { return(two); } if (two.index < 0) { return(one); } if (one.value > two.value) { return(one); } else { return(two); } }