From fd797635c58a93d1ff3dd79866e3496ebcb454d1 Mon Sep 17 00:00:00 2001 From: Luke Shingles Date: Tue, 3 Sep 2024 21:11:41 +0100 Subject: [PATCH] Default off for VERIFY_WRITTEN_PACKETS_FILES (#122) --- sn3d.cc | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/sn3d.cc b/sn3d.cc index 4ed7b98bc..ed1f306ac 100644 --- a/sn3d.cc +++ b/sn3d.cc @@ -65,6 +65,7 @@ std::mt19937 stdrng{std::random_device{}()}; std::ofstream output_file; namespace { +constexpr bool VERIFY_WRITTEN_PACKETS_FILES = false; FILE *linestat_file{}; auto real_time_start = -1; @@ -532,8 +533,8 @@ void save_grid_and_packets(const int nts, const int my_rank, const Packet *packe MPI_Barrier(MPI_COMM_WORLD); #endif - bool write_verified_success = false; - while (!write_verified_success) { + bool write_successful = false; + while (!write_successful) { const auto time_write_packets_file_start = std::time(nullptr); printout("time before write temporary packets file %ld\n", time_write_packets_file_start); @@ -542,33 +543,38 @@ void save_grid_and_packets(const int nts, const int my_rank, const Packet *packe vpkt_write_timestep(nts, my_rank, false); - const auto time_write_packets_file_finished = std::time(nullptr); + const auto time_write_packets_finished_thisrank = std::time(nullptr); #ifdef MPI_ON MPI_Barrier(MPI_COMM_WORLD); #endif + const auto timenow = std::time(nullptr); - printout("time after write temporary packets file %ld (took %ld seconds, waited %ld s for other ranks)\n", - std::time(nullptr), time_write_packets_file_finished - time_write_packets_file_start, - std::time(nullptr) - time_write_packets_file_finished); + printout("time after write temporary packets file %ld (took %lds, waited %lds, total %lds)\n", timenow, + time_write_packets_finished_thisrank - time_write_packets_file_start, + timenow - time_write_packets_finished_thisrank, timenow - time_write_packets_file_start); + if constexpr (VERIFY_WRITTEN_PACKETS_FILES) { #ifdef MPI_ON - MPI_Barrier(MPI_COMM_WORLD); + MPI_Barrier(MPI_COMM_WORLD); #endif - const auto time_readback_packets_start = std::time(nullptr); + const auto time_readback_packets_start = std::time(nullptr); - printout("reading back temporary packets file to check validity...\n"); + printout("reading back temporary packets file to check validity...\n"); - // read packets file back to check that the disk write didn't fail - write_verified_success = verify_temp_packetsfile(nts, my_rank, packets); + // read packets file back to check that the disk write didn't fail + write_successful = verify_temp_packetsfile(nts, my_rank, packets); #ifdef MPI_ON - MPI_Barrier(MPI_COMM_WORLD); + MPI_Barrier(MPI_COMM_WORLD); #endif - printout("Verifying packets files for all ranks took %ld seconds.\n", - std::time(nullptr) - time_readback_packets_start); + printout("Verifying packets files for all ranks took %ld seconds.\n", + std::time(nullptr) - time_readback_packets_start); + } else { + write_successful = true; + } } if (my_rank == 0) {