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

WIP: MeshData-based particle communication #1076

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
69 changes: 69 additions & 0 deletions src/bvals/comms/boundary_communication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,21 @@ ProlongateBounds<BoundaryType::nonlocal>(std::shared_ptr<MeshData<Real>> &);
template TaskStatus
ProlongateBounds<BoundaryType::gmg_prolongate_recv>(std::shared_ptr<MeshData<Real>> &);

TaskID AddSwarmBoundaryExchangeTasks(TaskID dependency, TaskList &tl,
std::shared_ptr<MeshData<Real>> &md) {
auto send = tl.AddTask(dependency, SendSwarmBoundaryBuffers, md);
auto recv = tl.AddTask(dependency, ReceiveSwarmBoundaryBuffers, md);
return recv;
}

TaskID AddSwarmBoundaryExchangeTasks(TaskID dependency, TaskList &tl,
std::shared_ptr<MeshData<Real>> &md,
std::vector<std::string> swarm_names) {
auto send = tl.AddTask(dependency, SendSwarmBoundaryBuffers, md, swarm_names);
auto recv = tl.AddTask(dependency, ReceiveSwarmBoundaryBuffers, md, swarm_names);
return recv;
}

// Adds all relevant boundary communication to a single task list
template <BoundaryType bounds>
TaskID AddBoundaryExchangeTasks(TaskID dependency, TaskList &tl,
Expand Down Expand Up @@ -441,4 +456,58 @@ TaskID AddFluxCorrectionTasks(TaskID dependency, TaskList &tl,
auto receive = tl.AddTask(dependency, ReceiveBoundBufs<BoundaryType::flxcor_recv>, md);
return tl.AddTask(receive, SetBounds<BoundaryType::flxcor_recv>, md);
}

TaskStatus SendSwarmBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md) {
const int nblocks = md->NumBlocks();
for (int n = 0; n < nblocks; n++) {
auto &sc = md->GetBlockData(n)->GetSwarmData();
sc->ResetCommunication();
// TODO(BRR) remove this BoundaryCommSubset argument?
sc->Send(BoundaryCommSubset::all);
}

return TaskStatus::complete;
}

TaskStatus SendSwarmBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md,
std::vector<std::string> swarm_names) {
const int nblocks = md->NumBlocks();
for (int n = 0; n < nblocks; n++) {
auto &sc = md->GetBlockData(n)->GetSwarmData();
sc->ResetCommunication(swarm_names);
sc->Send(BoundaryCommSubset::all, swarm_names);
}

return TaskStatus::complete;
}

TaskStatus ReceiveSwarmBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md) {
TaskStatus status = TaskStatus::complete;
const int nblocks = md->NumBlocks();
for (int n = 0; n < nblocks; n++) {
auto &sc = md->GetBlockData(n)->GetSwarmData();
auto local_status = sc->Receive(BoundaryCommSubset::all);
if (local_status == TaskStatus::incomplete) {
status = TaskStatus::incomplete;
}
}

return status;
}

TaskStatus ReceiveSwarmBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md,
std::vector<std::string> swarm_names) {
TaskStatus status = TaskStatus::complete;
const int nblocks = md->NumBlocks();
for (int n = 0; n < nblocks; n++) {
auto &sc = md->GetBlockData(n)->GetSwarmData();
auto local_status = sc->Receive(BoundaryCommSubset::all, swarm_names);
if (local_status == TaskStatus::incomplete) {
status = TaskStatus::incomplete;
}
}

return status;
}

} // namespace parthenon
14 changes: 14 additions & 0 deletions src/bvals/comms/bvals_in_one.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ static TaskStatus SetFluxCorrections(std::shared_ptr<MeshData<Real>> &md) {
return SetBounds<BoundaryType::flxcor_recv>(md);
}

TaskStatus SendSwarmBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md);
TaskStatus SendSwarmBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md,
std::vector<std::string> swarm_names);
TaskStatus ReceiveSwarmBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md);
TaskStatus ReceiveSwarmBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md,
std::vector<std::string> swarm_names);

// Adds all relevant boundary communication to a single task list
template <BoundaryType bounds = BoundaryType::any>
TaskID AddBoundaryExchangeTasks(TaskID dependency, TaskList &tl,
Expand All @@ -88,6 +95,13 @@ TaskID AddBoundaryExchangeTasks(TaskID dependency, TaskList &tl,
TaskID AddFluxCorrectionTasks(TaskID dependency, TaskList &tl,
std::shared_ptr<MeshData<Real>> &md, bool multilevel);

// Adds all relevant swarm boundary communication to a single task list
TaskID AddSwarmBoundaryExchangeTasks(TaskID dependency, TaskList &tl,
std::shared_ptr<MashData<Real>> &md);
TaskID AddSwarmBoundaryExchangeTasks(TaskID dependency, TaskList &tl,
std::shared_ptr<MashData<Real>> &md,
std::vector<std::string> swarm_names);

// These tasks should not be called in down stream code
TaskStatus BuildBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md);
TaskStatus BuildGMGBoundaryBuffers(std::shared_ptr<MeshData<Real>> &md);
Expand Down
Loading