Skip to content

Commit

Permalink
Keep prior combineData for backwards compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
jblueh committed Feb 28, 2024
1 parent bf1a608 commit c255654
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions include/codi/tapes/misc/tapeValues.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ namespace codi {
* - formatRow(): Output the data in this object in one row. One column per entry.
*
* - Misc:
* - combineData(): Perform element-wise addition with other tape values.
* - combineDataMPI(): Perform an MPI_Allreduce on MPI_COMM_WORLD.
* - combineData(TapeVales const& other): Perform element-wise addition with other tape values.
* - combineData(): Deprecated. Kept for backwards compatibility. Perform an MPI_Allreduce on MPI_COMM_WORLD.
* - combineDataMPI(): Perform an MPI_Allreduce on a given communicator.
* - getAllocatedMemorySize(): Get the allocated memory size.
* - getUsedMemorySize(): Get the used memory size.
*/
Expand Down Expand Up @@ -248,15 +249,23 @@ namespace codi {
}

/// Perform an MPI_Allreduce with MPI_COMM_WORLD.
void combineDataMPI() {
/// This method is deprecated and only kept for backwards compatibility. combineDataMPI should be used instead.
void combineData() {
#ifdef MPI_VERSION
MPI_Allreduce(MPI_IN_PLACE, doubleData.data(), doubleData.size(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(MPI_IN_PLACE, longData.data(), longData.size(), MPI_LONG, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(MPI_IN_PLACE, unsignedLongData.data(), unsignedLongData.size(), MPI_UNSIGNED_LONG, MPI_SUM,
MPI_COMM_WORLD);
combineDataMPI(MPI_COMM_WORLD);
#endif
}

#ifdef MPI_VERSION
/// Perform an MPI_Allreduce with the given communicator.
void combineDataMPI(MPI_Comm communicator) {
MPI_Allreduce(MPI_IN_PLACE, doubleData.data(), doubleData.size(), MPI_DOUBLE, MPI_SUM, communicator);
MPI_Allreduce(MPI_IN_PLACE, longData.data(), longData.size(), MPI_LONG, MPI_SUM, communicator);
MPI_Allreduce(MPI_IN_PLACE, unsignedLongData.data(), unsignedLongData.size(), MPI_UNSIGNED_LONG, MPI_SUM,
communicator);
}
#endif

/// Get the allocated memory in bytes.
double getAllocatedMemorySize() {
return doubleData[allocatedMemoryIndex];
Expand Down

0 comments on commit c255654

Please sign in to comment.