From f27d835b48c88cd65ba1788a5c33dbb499f10a60 Mon Sep 17 00:00:00 2001
From: Olivier Coulaud <olivier.coulaud@inria.fr>
Date: Mon, 7 Oct 2024 11:33:42 +0200
Subject: [PATCH] Adding dependencies to serialize communications in the L2L
 operator

---
 include/scalfmm/algorithms/mpi/downward.hpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/include/scalfmm/algorithms/mpi/downward.hpp b/include/scalfmm/algorithms/mpi/downward.hpp
index ee8418c7..dfefbda3 100644
--- a/include/scalfmm/algorithms/mpi/downward.hpp
+++ b/include/scalfmm/algorithms/mpi/downward.hpp
@@ -88,6 +88,7 @@ namespace scalfmm::algorithms::mpi::pass
         int tag_data = 2201 + 10 * level;
         std::vector<dep_type> dependencies_in;
         //
+	auto ptr_tree = &tree; 
         auto const& distrib = tree.get_cell_distribution(child_level);
         std::clog << "distrib me [" << distrib[rank][0] << "," << distrib[rank][1] << "]\n";
         // Send to the right the last locals
@@ -118,8 +119,8 @@ namespace scalfmm::algorithms::mpi::pass
                 // std::cout << " downward dep(in) on groupe dep_parent  " << dep_parent << std::endl << std::flush;
                 // depend(iterator(std::size_t it = 0 dependencies.size()), inout : (dependencies[it])[0]),
 
-                // #pragma omp task default(none) firstprivate(comm, rank, tag_data, it_last_parent_group, last_child_index)              \
-//   shared(std::cout) depend(in : dep_parent[0]) priority(prio)
+#pragma omp task default(none) firstprivate(comm, rank, tag_data, it_last_parent_group, last_child_index) \
+  shared(std::clog) depend(in : dep_parent[0], ptr_tree[0]) priority(prio)
                 {
                     // I have to send a message from my right to update the multipoles of the first
                     // cells of the right ghosts.
@@ -184,8 +185,8 @@ namespace scalfmm::algorithms::mpi::pass
                 auto dep_ghost_parent = &(it_last_parent_group->get()->ccomponent(0).clocals(0));
                 // std::cout << " downward(receive) dependencies(out): " << dep_ghost_parent << std::endl << std::flush;
 
-                // #pragma omp task default(none) firstprivate(comm, rank, tag_data, size_local, it_last_parent_group) shared(std::cout)  \
-//   depend(out : dep_ghost_parent[0]) priority(prio)
+#pragma omp task default(none) firstprivate(comm, rank, tag_data, size_local, it_last_parent_group) shared(std::clog) \
+  depend(out : dep_ghost_parent[0], ptr_tree[0]) priority(prio)
                 {
                     std::clog << "      Same parent\n ";
                     // Same parent, I have to receive a message from my left
-- 
GitLab