Skip to content

Commit 8cedcbc

Browse files
committed
IOSS: Expand open/close debug otuput to serial and flush
1 parent 0294be1 commit 8cedcbc

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright(C) 1999-2024 National Technology & Engineering Solutions
1+
// Copyright(C) 1999-2025 National Technology & Engineering Solutions
22
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
// NTESS, the U.S. Government retains certain rights in this software.
44
//
@@ -266,6 +266,8 @@ namespace Ioex {
266266

267267
// See if there are any properties that need to (or can) be
268268
// handled prior to opening/creating database...
269+
Ioss::Utils::check_set_bool_property(properties, "IOSS_TIME_FILE_OPEN_CLOSE", timeFileOpenCloseFlush);
270+
269271
if (properties.exists("FILE_TYPE")) {
270272
std::string type = properties.get("FILE_TYPE").get_string();
271273
type = Ioss::Utils::lowercase(type);
@@ -437,15 +439,11 @@ namespace Ioex {
437439
int BaseDatabaseIO::free_file_pointer() const
438440
{
439441
if (m_exodusFilePtr != -1) {
440-
bool do_timer = false;
441-
if (isParallel) {
442-
Ioss::Utils::check_set_bool_property(properties, "IOSS_TIME_FILE_OPEN_CLOSE", do_timer);
443-
}
444-
double t_begin = (do_timer ? Ioss::Utils::timer() : 0);
442+
double t_begin = (timeFileOpenCloseFlush ? Ioss::Utils::timer() : 0);
445443

446444
ex_close(m_exodusFilePtr);
447445
close_dw();
448-
if (do_timer && isParallel) {
446+
if (timeFileOpenCloseFlush) {
449447
double t_end = Ioss::Utils::timer();
450448
double duration = util().global_minmax(t_end - t_begin, Ioss::ParallelUtils::DO_MAX);
451449
if (myProcessor == 0) {
@@ -2571,9 +2569,17 @@ namespace Ioex {
25712569
void BaseDatabaseIO::flush_database_nl() const
25722570
{
25732571
if (!is_input()) {
2572+
double t_begin = (timeFileOpenCloseFlush ? Ioss::Utils::timer() : 0);
25742573
if (isParallel || myProcessor == 0) {
25752574
ex_update(get_file_pointer());
25762575
}
2576+
if (timeFileOpenCloseFlush) {
2577+
double t_end = Ioss::Utils::timer();
2578+
double duration = util().global_minmax(t_end - t_begin, Ioss::ParallelUtils::DO_MAX);
2579+
if (myProcessor == 0) {
2580+
fmt::print(Ioss::DebugOut(), "File Flush Time = {} ({})\n", duration, get_filename());
2581+
}
2582+
}
25772583
}
25782584
}
25792585

packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright(C) 1999-2024 National Technology & Engineering Solutions
1+
// Copyright(C) 1999-2025 National Technology & Engineering Solutions
22
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
// NTESS, the U.S. Government retains certain rights in this software.
44
//
@@ -409,6 +409,7 @@ namespace Ioex {
409409
int flushInterval{-1};
410410
int m_timestepCount{0};
411411

412+
bool timeFileOpenCloseFlush{false};
412413
mutable bool fileExists{false}; // False if file has never been opened/created
413414
mutable bool minimizeOpenFiles{false};
414415

packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,20 +265,17 @@ namespace Ioex {
265265
}
266266
#endif
267267

268-
bool do_timer = false;
269-
Ioss::Utils::check_set_bool_property(properties, "IOSS_TIME_FILE_OPEN_CLOSE", do_timer);
270-
double t_begin = ((do_timer && isParallel) ? Ioss::Utils::timer() : 0);
268+
double t_begin = (timeFileOpenCloseFlush ? Ioss::Utils::timer() : 0);
271269

272270
int app_opt_val = ex_opts(EX_VERBOSE);
273271
m_exodusFilePtr = ex_open(decoded_filename().c_str(), EX_READ | mode, &cpu_word_size,
274272
&io_word_size, &version);
275273

276-
if (do_timer && isParallel) {
274+
if (timeFileOpenCloseFlush) {
277275
double t_end = Ioss::Utils::timer();
278276
double duration = util().global_minmax(t_end - t_begin, Ioss::ParallelUtils::DO_MAX);
279277
if (myProcessor == 0) {
280-
fmt::print(Ioss::DebugOut(), "Input File Open Time = {} ({})\n", duration,
281-
decoded_filename());
278+
fmt::print(Ioss::DebugOut(), "Input File Open Time = {} ({})\n", duration, decoded_filename());
282279
}
283280
}
284281

@@ -340,6 +337,7 @@ namespace Ioex {
340337
}
341338
#endif
342339
int app_opt_val = ex_opts(EX_VERBOSE);
340+
double t_begin = (timeFileOpenCloseFlush ? Ioss::Utils::timer() : 0);
343341
if (fileExists) {
344342
m_exodusFilePtr = ex_open(decoded_filename().c_str(), EX_WRITE | mode, &cpu_word_size,
345343
&io_word_size, &version);
@@ -362,6 +360,13 @@ namespace Ioex {
362360
m_exodusFilePtr =
363361
ex_create(decoded_filename().c_str(), mode, &cpu_word_size, &dbRealWordSize);
364362
}
363+
if (timeFileOpenCloseFlush) {
364+
double t_end = Ioss::Utils::timer();
365+
double duration = util().global_minmax(t_end - t_begin, Ioss::ParallelUtils::DO_MAX);
366+
if (myProcessor == 0) {
367+
fmt::print(Ioss::DebugOut(), "File {} Time = {} ({})\n", fileExists ? "Open" : "Create", duration, decoded_filename());
368+
}
369+
}
365370

366371
is_ok = check_valid_file_ptr(write_message, error_msg, bad_count, abort_if_error);
367372

packages/seacas/libraries/ioss/src/exodus/Ioex_ParallelDatabaseIO.C

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// strange cases
66
//
77
//
8-
// Copyright(C) 1999-2024 National Technology & Engineering Solutions
8+
// Copyright(C) 1999-2025 National Technology & Engineering Solutions
99
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
1010
// NTESS, the U.S. Government retains certain rights in this software.
1111
//
@@ -527,15 +527,13 @@ namespace Ioex {
527527
}
528528
#endif
529529

530-
bool do_timer = false;
531-
Ioss::Utils::check_set_bool_property(properties, "IOSS_TIME_FILE_OPEN_CLOSE", do_timer);
532-
double t_begin = (do_timer ? Ioss::Utils::timer() : 0);
530+
double t_begin = (timeFileOpenCloseFlush ? Ioss::Utils::timer() : 0);
533531

534532
int app_opt_val = ex_opts(EX_VERBOSE);
535533
m_exodusFilePtr = ex_open_par(filename.c_str(), EX_READ | mode, &cpu_word_size, &io_word_size,
536534
&version, util().communicator(), info);
537535

538-
if (do_timer) {
536+
if (timeFileOpenCloseFlush) {
539537
double t_end = Ioss::Utils::timer();
540538
double duration = util().global_minmax(t_end - t_begin, Ioss::ParallelUtils::DO_MAX);
541539
if (myProcessor == 0) {
@@ -624,9 +622,7 @@ namespace Ioex {
624622
(void)chdir(path.c_str());
625623
#endif
626624

627-
bool do_timer = false;
628-
Ioss::Utils::check_set_bool_property(properties, "IOSS_TIME_FILE_OPEN_CLOSE", do_timer);
629-
double t_begin = (do_timer ? Ioss::Utils::timer() : 0);
625+
double t_begin = (timeFileOpenCloseFlush ? Ioss::Utils::timer() : 0);
630626

631627
if (fileExists) {
632628
m_exodusFilePtr = ex_open_par(filename.c_str(), EX_WRITE | mode, &cpu_word_size,
@@ -666,7 +662,7 @@ namespace Ioex {
666662
util().communicator(), info);
667663
}
668664

669-
if (do_timer) {
665+
if (timeFileOpenCloseFlush) {
670666
double t_end = Ioss::Utils::timer();
671667
double duration = util().global_minmax(t_end - t_begin, Ioss::ParallelUtils::DO_MAX);
672668
std::string open_create = fileExists ? "Open" : "Create";

0 commit comments

Comments
 (0)