From 539002ae933218809c96f8918c2c4a2aab517d4c Mon Sep 17 00:00:00 2001 From: Gregor Weiss <gregor.weiss@hlrs.de> Date: Mon, 24 Apr 2023 14:58:50 +0200 Subject: [PATCH] ENH: optional removal --- .../heatTransfer/write/Settings.cpp | 19 ++++++++++++++++++- io-prototyping/heatTransfer/write/Settings.h | 3 ++- io-prototyping/heatTransfer/write/main.cpp | 18 ++++++++++-------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/io-prototyping/heatTransfer/write/Settings.cpp b/io-prototyping/heatTransfer/write/Settings.cpp index 5d6555a076e..2979216e083 100644 --- a/io-prototyping/heatTransfer/write/Settings.cpp +++ b/io-prototyping/heatTransfer/write/Settings.cpp @@ -54,12 +54,29 @@ Settings::Settings(int argc, char *argv[], int rank, int nproc) : rank{rank} steps = convertToUint("steps", argv[8]); iterations = convertToUint("iterations", argv[9]); - if ( argc == 11 ) { + if ( argc >= 11 ) { if ( std::string(argv[10]) == std::string("read") ) { read = true; } + if ( std::string(argv[10]) == std::string("remove") ) { + remove = true; + } } + if ( argc >= 12 ) { + if ( std::string(argv[10]) == std::string("read") + || + std::string(argv[11]) == std::string("read")) { + read = true; + } + if ( std::string(argv[10]) == std::string("remove") + || + std::string(argv[11]) == std::string("remove")) { + remove = true; + } + } + + if (npx * npy != this->nproc) { throw std::invalid_argument("N*M must equal the number of processes"); diff --git a/io-prototyping/heatTransfer/write/Settings.h b/io-prototyping/heatTransfer/write/Settings.h index 4dcc27d0fb1..ff7055e20c6 100644 --- a/io-prototyping/heatTransfer/write/Settings.h +++ b/io-prototyping/heatTransfer/write/Settings.h @@ -25,7 +25,8 @@ struct Settings unsigned int ndy; // Local array size in y dimension per process unsigned int steps; // Number of output steps unsigned int iterations; // Number of computing iterations between steps - bool read{ false }; // Number of computing iterations between steps + bool read{ false }; // Switch to turn on re-reading + bool remove{ false }; // Switch to turn on removal // calculated values from those arguments and number of processes unsigned int gndx; // Global array size in slow dimension diff --git a/io-prototyping/heatTransfer/write/main.cpp b/io-prototyping/heatTransfer/write/main.cpp index f823cbf33a8..b21d576c013 100644 --- a/io-prototyping/heatTransfer/write/main.cpp +++ b/io-prototyping/heatTransfer/write/main.cpp @@ -153,17 +153,19 @@ int main( int argc, char* argv[] ) { } } - MPI_Barrier(MPI_COMM_WORLD); - measTime = MPI_Wtime(); + if ( settings.remove ) { + MPI_Barrier(MPI_COMM_WORLD); + measTime = MPI_Wtime(); - io.remove( t ); + io.remove( t ); - MPI_Barrier(MPI_COMM_WORLD); - measTime = MPI_Wtime() - measTime; + MPI_Barrier(MPI_COMM_WORLD); + measTime = MPI_Wtime() - measTime; - MPI_Reduce( &measTime, &maxTime, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); - if ( rank == 0 ) { - printTime( "Removing step " + std::to_string( t ), maxTime ); + MPI_Reduce( &measTime, &maxTime, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); + if ( rank == 0 ) { + printTime( "Removing step " + std::to_string( t ), maxTime ); + } } } -- GitLab