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

Fix regional dependencies for sub-TaskLists and make solvers work for abitrary partitioning #1132

Merged
merged 35 commits into from
Jul 25, 2024

Conversation

lroberts36
Copy link
Collaborator

@lroberts36 lroberts36 commented Jun 26, 2024

PR Summary

Currently, sublists of TaskLists do not have their regional dependencies set correctly. This results in the bug described in #1125. This PR changes TaskRegion::BuildGraph() to correctly register regional dependencies among all TaskLists and closes #1125.

Additionally, it takes a second step to make the multigrid solver work when parthenon/mesh/pack_size != -1 by including "self-communication" between coarse blocks on a finer two-level composite grid and fine leaf blocks on the next coarser two-level composite grid. Although no data is communicated in these communication channels, this introduces a dependency (outside of the tasking framework) that ensures operations on these blocks that are part of multiple gmg levels occur in the correct order.

Getting the multigrid stuff to work was a painful debugging process. As a result, I introduced some capability for more customized naming of tasks and the ability to write task labels to screen as the tasks are called. This turned out to be fairly useful for debugging what was going on.

PR Checklist

  • Code passes cpplint
  • New features are documented.
  • Adds a test for any bugs fixed. Adds tests for new features.
  • Code is formatted
  • Changes are summarized in CHANGELOG.md
  • Change is breaking (API, behavior, ...)
    • Change is additionally added to CHANGELOG.md in the breaking section
    • PR is marked as breaking
    • Short summary API changes at the top of the PR (plus optionally with an automated update/fix script)
  • CI has been triggered on Darwin for performance regression tests.
  • Docs build
  • (@lanl.gov employees) Update copyright on changed files

@lroberts36 lroberts36 changed the title WIP: Fix regional dependencies for sublists WIP: Fix regional dependencies for sub-TaskLists Jun 26, 2024
@Yurlungur Yurlungur requested a review from jdolence June 26, 2024 21:14
Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

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

I really feel like @jdolence should look at this one.

@@ -177,7 +177,7 @@ CalcIndices(const NeighborBlock &nb, MeshBlock *pmb,
(neighbor_bounds[dir].e - neighbor_bounds[dir].s + 1);
s[dir] += nb.origin_loc.l(dir) % 2 == 1 ? extra_zones - interior_offset : 0;
e[dir] -= nb.origin_loc.l(dir) % 2 == 0 ? extra_zones - interior_offset : 0;
if (ir_type == IndexRangeType::InteriorSend) {
if (ir_type == IndexRangeType::InteriorSend && !prores) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changes to CalcIndices are required since we are actually passing the correct neighbor information in GetInterior*.

@@ -59,6 +59,7 @@ struct BndInfo {
bool allocated = true;
bool buf_allocated = true;
int alloc_status;
bool same_to_same = false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This flag denotes that this buffer represents a communication from this block to itself and that the buffer does not need to be filled (a message just needs to be sent).

Comment on lines +49 to +53
int other = (nb.gid == pmb->gid && (btype == BoundaryType::gmg_restrict_recv ||
btype == BoundaryType::gmg_restrict_send))
? 1
: 0;
return {sender_id, receiver_id, pcv->label(), location_idx, other};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add more information to the communication key so that we can represent same-to-same restriction and same-to-same prolongation as different channels.

Comment on lines +116 to +120
: Task(std::forward<TID>(dep), label, 0, func, limits) {}
template <typename TID>
Task(TID &&dep, const std::string &label, int verbose_level,
const std::function<TaskStatus()> &func, std::pair<int, int> limits = {1, 1})
: label_(label), verbose_level_(verbose_level), f(func), exec_limits(limits) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add verbosity flag to tasks, if verbose_level_ > 0 the task will print its name out to stdout before starting the task. Useful for debugging.

Copy link
Collaborator

@pdmullen pdmullen Jul 25, 2024

Choose a reason for hiding this comment

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

This is a useful feature. I wonder if the verbosity should be blanket applied to all tasks based off a verbose flag set in pin, rather than enrolled via each AddTask?

EDIT: this proposal could actually be handled via the downstream app

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree that would be nice, but I think that it requires a bit of threading to make it work (since the tasking stuff doesn't directly access pin currently). I would leave this for a future PR.

In practice, I just manually comment out the verbose_level_ > 0 test and recompile if I want to see everything...

Comment on lines +289 to +293
return AddTaskImpl(tq, dep, std::forward<Arg1>(arg1), 0,
std::forward<Args>(args)...);
} else if constexpr (is_tuple_t<Arg1>::value) {
return AddTaskImpl(tq, dep, std::get<0>(arg1), std::get<1>(arg1), std::get<2>(arg1),
std::forward<Args>(args)...);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Allow passing a tuple containing the name of the task, the verbosity level of the task, and the task function itself. Allows easy print out of the order in which tasks are run.

Comment on lines +434 to +438
std::vector<TaskList *> GetAllTaskLists() {
std::vector<TaskList *> list;
GetAllTaskListsInternal(list);
return list;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Necessary for linking regional tasks in iterative task lists.

@lroberts36 lroberts36 changed the title WIP: Fix regional dependencies for sub-TaskLists Fix regional dependencies for sub-TaskLists and make solvers work for abitrary partitioning Jul 23, 2024
Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

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

Very minor nitpicks on the debugging code. Otherwise LGTM.

src/bvals/comms/bnd_info.cpp Outdated Show resolved Hide resolved
src/tasks/tasks.hpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@pdmullen pdmullen left a comment

Choose a reason for hiding this comment

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

LGTM! I have tested this in a downstream app invoking iterative tasking. This MR fixes (1) hangs and (2) undefined behavior when invoking pack_size = 1 that currently exist with parthenon/develop.

src/interface/mesh_data.hpp Show resolved Hide resolved
Comment on lines +116 to +120
: Task(std::forward<TID>(dep), label, 0, func, limits) {}
template <typename TID>
Task(TID &&dep, const std::string &label, int verbose_level,
const std::function<TaskStatus()> &func, std::pair<int, int> limits = {1, 1})
: label_(label), verbose_level_(verbose_level), f(func), exec_limits(limits) {
Copy link
Collaborator

@pdmullen pdmullen Jul 25, 2024

Choose a reason for hiding this comment

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

This is a useful feature. I wonder if the verbosity should be blanket applied to all tasks based off a verbose flag set in pin, rather than enrolled via each AddTask?

EDIT: this proposal could actually be handled via the downstream app

@lroberts36 lroberts36 enabled auto-merge July 25, 2024 17:32
@lroberts36 lroberts36 merged commit ea1039f into develop Jul 25, 2024
53 checks passed
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.

TaskQualifier::*_sync does not work for iterative task lists
3 participants