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

Use correct stream for output. #17024

Merged
merged 2 commits into from
May 16, 2024
Merged

Conversation

bangerth
Copy link
Member

Many of the autodifferentiation tests output parts to deallog and other parts of their output to std::cout. The latter is not captured in the .output files and consequently not checked. I think that this is accidental.

Addresses part of #16534, though there is more to do.

Copy link
Member

@tamiko tamiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the current logic is that the output of deallog will be used if output is present. If nothing is printed to deallog then everything piped to std::cout is used for comparison instead.

If I remember correctly, it was not possible to combine both, i.e., using deallog and std::cout together for comparison, back when we introduced that behavior because that lead to quite a number of failing tests.

@bangerth
Copy link
Member Author

Yes, not worth trying to support outputting to both.

Comment on lines 509 to 541
#ifdef DEBUG
print(std::cout, "symb_st", symb_st);
print(std::cout, "symb_t", symb_t);
print(std::cout, "symb_v", symb_v);
print(std::cout, "symb_s", symb_s);

print(std::cout, "symb_psi", symb_psi);

print(std::cout, "symb_dpsi_dst", symb_dpsi_dst);
print(std::cout, "symb_dpsi_dt", symb_dpsi_dt);
print(std::cout, "symb_dpsi_dv", symb_dpsi_dv);
print(std::cout, "symb_dpsi_ds", symb_dpsi_ds);

print(std::cout, "symb_d2psi_dst_x_dst", symb_d2psi_dst_x_dst);
print(std::cout, "symb_d2psi_dst_x_dt", symb_d2psi_dst_x_dt);
print(std::cout, "symb_d2psi_dst_x_dv", symb_d2psi_dst_x_dv);
print(std::cout, "symb_d2psi_dst_x_ds", symb_d2psi_dst_x_ds);

print(std::cout, "symb_d2psi_dt_x_dst", symb_d2psi_dt_x_dst);
print(std::cout, "symb_d2psi_dt_x_dt", symb_d2psi_dt_x_dt);
print(std::cout, "symb_d2psi_dt_x_dv", symb_d2psi_dt_x_dv);
print(std::cout, "symb_d2psi_dt_x_ds", symb_d2psi_dt_x_ds);

print(std::cout, "symb_d2psi_dv_x_dst", symb_d2psi_dv_x_dst);
print(std::cout, "symb_d2psi_dv_x_dt", symb_d2psi_dv_x_dt);
print(std::cout, "symb_d2psi_dv_x_dv", symb_d2psi_dv_x_dv);
print(std::cout, "symb_d2psi_dv_x_ds", symb_d2psi_dv_x_ds);

print(std::cout, "symb_d2psi_ds_x_dst", symb_d2psi_ds_x_dst);
print(std::cout, "symb_d2psi_ds_x_dt", symb_d2psi_ds_x_dt);
print(std::cout, "symb_d2psi_ds_x_dv", symb_d2psi_ds_x_dv);
print(std::cout, "symb_d2psi_ds_x_ds", symb_d2psi_ds_x_ds);
print(deallog, "symb_st", symb_st);
print(deallog, "symb_t", symb_t);
print(deallog, "symb_v", symb_v);
print(deallog, "symb_s", symb_s);

print(deallog, "symb_psi", symb_psi);

print(deallog, "symb_dpsi_dst", symb_dpsi_dst);
print(deallog, "symb_dpsi_dt", symb_dpsi_dt);
print(deallog, "symb_dpsi_dv", symb_dpsi_dv);
print(deallog, "symb_dpsi_ds", symb_dpsi_ds);

print(deallog, "symb_d2psi_dst_x_dst", symb_d2psi_dst_x_dst);
print(deallog, "symb_d2psi_dst_x_dt", symb_d2psi_dst_x_dt);
print(deallog, "symb_d2psi_dst_x_dv", symb_d2psi_dst_x_dv);
print(deallog, "symb_d2psi_dst_x_ds", symb_d2psi_dst_x_ds);

print(deallog, "symb_d2psi_dt_x_dst", symb_d2psi_dt_x_dst);
print(deallog, "symb_d2psi_dt_x_dt", symb_d2psi_dt_x_dt);
print(deallog, "symb_d2psi_dt_x_dv", symb_d2psi_dt_x_dv);
print(deallog, "symb_d2psi_dt_x_ds", symb_d2psi_dt_x_ds);

print(deallog, "symb_d2psi_dv_x_dst", symb_d2psi_dv_x_dst);
print(deallog, "symb_d2psi_dv_x_dt", symb_d2psi_dv_x_dt);
print(deallog, "symb_d2psi_dv_x_dv", symb_d2psi_dv_x_dv);
print(deallog, "symb_d2psi_dv_x_ds", symb_d2psi_dv_x_ds);

print(deallog, "symb_d2psi_ds_x_dst", symb_d2psi_ds_x_dst);
print(deallog, "symb_d2psi_ds_x_dt", symb_d2psi_ds_x_dt);
print(deallog, "symb_d2psi_ds_x_dv", symb_d2psi_ds_x_dv);
print(deallog, "symb_d2psi_ds_x_ds", symb_d2psi_ds_x_ds);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is guarded by DEBUG and so you will get different output in Debug and Release mode but there is only one output file AFAICT.

@bangerth
Copy link
Member Author

I fixed the issue @masterleinad points out by always outputting. I also fixed a few other places where we were writing to std::cout. This required restricting output operators in the library for some custom enum types to std::ostream from a general template, because the general template was ambiguous to operator<< (LogStream &, T &). I put that into the very first commit. These output operators are sufficiently obscure and almost certainly not widely used that I didn't care too much about the compatibility impact.

@@ -97,7 +97,7 @@ namespace Step44

if (debug)
{
SD::Utilities::print_substitution_map(std::cout, sub_vals);
SD::Utilities::print_substitution_map(deallog, sub_vals);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output here depends on a bool variable that is false. If someone was to change that, the test would then fail. Ultimately, it seems that this output is not intended to be recorded in an output file but only printed to the screen for debugging purposes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. There are other places where these programs have #ifdef DEBUG_EXTRA. It is true that one could address all of these things, but that's more work than I'm willing to put in at the moment. I'm just trying to make things better, not optimal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

@masterleinad masterleinad merged commit bdf3ad0 into dealii:master May 16, 2024
15 of 16 checks passed
@bangerth bangerth deleted the stream-for-output branch May 16, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants