Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default off for VERIFY_WRITTEN_PACKETS_FILES #122

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions sn3d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand Down