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

Loop: Check for symmetry boundaries in outermost interior loops #300

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

chcheng3
Copy link
Contributor

The loop_outermost_int and loop_outermost_int_device routines used in NewRadX should check for symmetry boundaries. This is so that at symmetry boundaries, the radiative boundary conditions are applied if and only if they are also adjacent to physical boundaries.

This pull request also updates TestLoopX with the new loop syntax, so that symmetry information is passed into the loop from the patch data. The test case is also updated with reflection symmetry and periodic boundary conditions enabled.

@rhaas80
Copy link
Member

rhaas80 commented Aug 31, 2024

Ticket is here: #300

Copy link
Contributor

@lucass-carneiro lucass-carneiro left a comment

Choose a reason for hiding this comment

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

Overall the patch appears to be well written. It contains test cases demonstrating its effectiveness.

The patch changes the loop_outermost_int API, which may break existing codes that are using that loop construct. Since to my knowledge, this is used only in boundary codes such as NewRadX, this should be OK.

I have very minor comments on adjustments, after which I would recommend for this PR to be merged

TestLoopX/src/testloop.cxx Outdated Show resolved Hide resolved
TestLoopX/test/testloopx_outermost_interior.par Outdated Show resolved Hide resolved
@@ -14,6 +14,7 @@ USES INCLUDE HEADER: vect.hxx
USES INCLUDE HEADER: loop.hxx
USES INCLUDE HEADER: loop_device.hxx

INCLUDES HEADER: driver.hxx IN driver.hxx
Copy link
Member

Choose a reason for hiding this comment

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

This change should be in a commit CarpetX:  and not Loop.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You cannot include CarpetX files from Loop because Carpetx depends on Loop, and this would create a circular dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eschnett In the patch here, driver.hxx from CarpetX is only used in the thorns that want to use loop_outermost_int, such as TestLoopX and NewRadX. The Loop thorn itself does not depend on driver.hxx directly, but it receives the symmetry information as an argument in loop_outermost_int from the thorns that call it. Would this be sufficient to bypass the circular dependency? I'm able to compile the code with the patch and pass all test cases.

Copy link
Member

Choose a reason for hiding this comment

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

huh. I am speaking out of turn, I guess, yet: Uh, if Loop does not use the functionality from driver.hxx the I think I should not say uses include header: driver.hxx. By the same reasoning if the client thorns (say NewRadX ) directly use the information then they should contain the uses include header: driver.hxx statement.

Copy link
Member

Choose a reason for hiding this comment

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

My take is that circularity is an issue for the REQUIRE: statements (they affect compilation order so circles are not allowed) but not the USES INCLUDE HEADER statements I would say (handled before dependency is even known to Cactus).

I agree with Erik's concern wrt CarpetX / Loop depending on each other in #300 (comment)  (since we'd want a REQUIRE to go along with the uses include header).

Copy link
Member

Choose a reason for hiding this comment

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

Do we need this include in Loop? Since if there is the include I'd normally add a REQUIRE (otherwise Cactus may silently give you an empty include file). But the REQUIRE will introduce a circular dependency between Loop and CarpetX

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, what I'm proposing here would not need the include (and hence the REQUIRE) in Loop. By itself, the loop_outermost_int routine does not use any information from the driver. On the other hand, the client thorns that intend to take the symmetry information from the driver and pass it to loop_outermost_int, do need the include.

Copy link
Member

Choose a reason for hiding this comment

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

The change still shows up in files changed as adding INCLUDE HEADER "...". So if it is not used by Loop I'd suggest to remove the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, from what I'm seeing the USES INCLUDE HEADER is only in TestLoopX, but not Loop. Can you point me to where it is?

Copy link
Member

Choose a reason for hiding this comment

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

oha, sorry yes you are correct. I was looking at the very wrong file. In fact not even had I confused the thorn but also INCLUDE HEADER and USES INCLUDE HEADER.

Copy link
Member

@rhaas80 rhaas80 left a comment

Choose a reason for hiding this comment

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

please use one commit per thorn that you modify, eg if modifying CarpetX the commit message should start with CarpetX:

@chcheng3
Copy link
Contributor Author

@rhaas80 To create a separate commit for the change to CarpetX, I reverted to the commit a3b4594 and separated out the commits to CarpetX and TestLoopX.

@chcheng3 chcheng3 requested a review from rhaas80 October 30, 2024 17:15
#include <cctk_Arguments.h>
#include <cctk_Parameters.h>
#include <loop.hxx>
#include <loop_device.hxx>
#include <driver.hxx>
Copy link
Member

Choose a reason for hiding this comment

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

I'd use the double quote form of include using " instead of hte <> form since none of these files are system include files.

See

https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

for the details (there won't be a difference in Cactus using gcc since we use -I to add the extra paths).

The C99 standard say (in https://en.cppreference.com/w/cpp/preprocessor/include) that the double quote variant

The intent of syntax (2) is to search for the files that are not controlled by the implementation.

ie include files not provided by the compiler.

Exactly where you put that cut-off between " and <> is a matter of some choice it seems.

@@ -541,6 +541,7 @@ public:
template <int CI, int CJ, int CK, int VS = 1, int N = 1, typename F>
inline CCTK_ATTRIBUTE_ALWAYS_INLINE void
loop_outermost_int(const vect<int, dim> &group_nghostzones,
const vect<vect<bool, dim>, 2> &is_sym_bnd,
Copy link
Member

Choose a reason for hiding this comment

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

I'd document what is_sym_bnd[f][d] stands for. Does this order (f then d) match what is used eg in cctk_bbox (see https://www.einsteintoolkit.org/usersguide/UsersGuide.html#x1-98000C1.6.2). Looking at the Cactus example it does seem to be different since the Cactus code uses:

An array of 2cctk_dim integers (in the order [dim_0^{min}, dim_0^{max}, dim_1^{min}, dim_1^{max}, ... ]), ...

Copy link
Contributor Author

@chcheng3 chcheng3 Oct 31, 2024

Choose a reason for hiding this comment

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

The is_sym_bnd array follows the layout of the symmetry array from driver.hxx, which seems to be arranged in a different order from what Cactus does:

std::array<std::array<symmetry_t, dim>, 2> symmetries;

So the patch here is consistent with CarpetX, but not Cactus, which might be confusing.

@@ -275,6 +275,7 @@ public:
int NT = AMREX_GPU_MAX_THREADS, typename F>
inline CCTK_ATTRIBUTE_ALWAYS_INLINE void
loop_outermost_int_device(const vect<int, dim> &group_nghostzones,
const vect<vect<bool, dim>, 2> &is_sym_bnd,
Copy link
Member

Choose a reason for hiding this comment

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

same comment as above.

@chcheng3
Copy link
Contributor Author

chcheng3 commented Nov 6, 2024

@eschnett Could you take a moment to review this pull request and let me know your comments? The changes to CarpetX and Loop here are necessary for the NewRadX pull request review (EinsteinToolkit/SpacetimeX#39) to be proceed. Thank you!

@eschnett
Copy link
Collaborator

eschnett commented Nov 6, 2024

Why do you need to know whether a particular boundary is a symmetry boundary? I think what you actually need to know if a particular boundaries is a newrad boundary.

@chcheng3
Copy link
Contributor Author

chcheng3 commented Nov 7, 2024

Yes, we are actually checking whether a certain boundary is a NewRad boundary. This would consist of the points that correspond to the physical outer boundary, but belong to the interior from CarpetX's point of view. If a symmetry is applied to a boundary, then that boundary would not be an outer boundary and not a NewRad boundary. We would need to know which boundaries are symmetry boundaries, so that they can be excluded from the "outermost interior" loops.

@eschnett
Copy link
Collaborator

Should we wait until after the release branches have been created?

@rhaas80
Copy link
Member

rhaas80 commented Nov 12, 2024

I am not too worried about this pull request since it only changes C++ code in Loop that so far is only used by NewRadX, though if applying this one also requires the corresponding SpacetiomeX/NewRadX pull request then one needs to be a bit more careful since then the change becomes "user visible".

It is less urgent to include this is in the release now that Z4c has been bumped to the 2025_05 release then it was when Z4c was to be included in 2024_11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants