From a1cea3ed049d944b6a1a13146c636cd7039271b9 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Wed, 30 Jul 2025 09:27:02 +0200 Subject: [PATCH 01/12] use repartAllToAll --- include/OGL/CommunicationPattern.hpp | 6 ++++++ src/CommunicationPattern.cpp | 27 +++++++++++++++++++++++++++ src/MatrixWrapper/Distributed.cpp | 9 +++++---- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/include/OGL/CommunicationPattern.hpp b/include/OGL/CommunicationPattern.hpp index 7fcf542e..0bb6e477 100644 --- a/include/OGL/CommunicationPattern.hpp +++ b/include/OGL/CommunicationPattern.hpp @@ -19,6 +19,12 @@ struct AllToAllPattern { std::vector recv_offsets; }; +/* @brief computes AllToAllPattern for repart comm from global allToAll pattern + * + */ +AllToAllPattern compute_repart_allToall( + const ExecutorHandler &exec_handler, const AllToAllPattern allToAll); + /* @brief This function computes the send and recv counts vectors and the send * and recv offsets vectors for scattering from an owner to all ranks, including * owner itself diff --git a/src/CommunicationPattern.cpp b/src/CommunicationPattern.cpp index 192a7f6c..ba4c95e7 100644 --- a/src/CommunicationPattern.cpp +++ b/src/CommunicationPattern.cpp @@ -178,6 +178,33 @@ void communicate_values(const ExecutorHandler &exec_handler, // } } +AllToAllPattern compute_repart_allToall( + const ExecutorHandler &exec_handler, const AllToAllPattern allToAllIn) + { + auto host_comm = exec_handler.get_host_comm(); + auto repart_comm = exec_handler.get_repart_comm(); + auto ranks = repart_comm->size(); + + std::vector send_counts(ranks); + std::vector send_offsets(ranks+1); + std::vector recv_counts(ranks); + std::vector recv_offsets(ranks+1); + + label start_rank = host_comm->rank(); + for (auto i=0;i src_exec, std::shared_ptr target_exec, diff --git a/src/MatrixWrapper/Distributed.cpp b/src/MatrixWrapper/Distributed.cpp index 72eaae43..312a7346 100644 --- a/src/MatrixWrapper/Distributed.cpp +++ b/src/MatrixWrapper/Distributed.cpp @@ -384,7 +384,7 @@ void update_impl( std::map linops, label verbose) { auto comm = exec_handler.get_host_comm(); - // auto repart_comm = exec_handler.get_repart_comm(); + auto repart_comm = exec_handler.get_repart_comm(); auto ref_exec = exec_handler.get_ref_exec(); auto rank = exec_handler.get_host_rank(); auto device_exec = exec_handler.get_device_exec(); @@ -392,12 +392,13 @@ void update_impl( word fieldname = host_A->get_field_name(); // perform all-to-all updates first - auto all_to_all_update = [comm, ref_exec, device_exec, + auto all_to_all_update = [repart_comm, ref_exec, device_exec, all_to_all_update_data, host_A, - force_host_buffer]() { + force_host_buffer, exec_handler]() { for (auto [id, comm_pattern, data_ptr] : all_to_all_update_data) { + auto repartAllToAll = compute_repart_allToall(exec_handler, comm_pattern); auto [length, send_data_ptr] = host_A->get_interface_data(id); - communicate_values(ref_exec, device_exec, comm, comm_pattern, + communicate_values(ref_exec, device_exec, repart_comm, repartAllToAll, send_data_ptr, data_ptr, force_host_buffer); } }; From b38c4415ff5c00a5f0da4461fc1267800033b1ce Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 4 Aug 2025 17:32:23 +0200 Subject: [PATCH 02/12] format --- src/CommunicationPattern.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CommunicationPattern.cpp b/src/CommunicationPattern.cpp index ba4c95e7..0c7fe548 100644 --- a/src/CommunicationPattern.cpp +++ b/src/CommunicationPattern.cpp @@ -171,7 +171,8 @@ void communicate_values(const ExecutorHandler &exec_handler, // std::cout << __FILE__ << ":" << __LINE__ << " received " // << std::to_string(recv_size) << " elements of " // << std::to_string(recv_size * 8 / 1e9) - // << "[Gb] on device rank: " << std::to_string(rank) << " time " + // << "[Gb] on device rank: " << std::to_string(rank) << " + // time " // << std::to_string(delta_t) << "[ms] bandwidth: " // << std::to_string(recv_size * 8 / delta_t / 1e6) // << "[Gb/s] \n"; From 6e89aac3e398e580837c59cbbd10681021c93552 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 4 Aug 2025 17:35:52 +0200 Subject: [PATCH 03/12] init ginkgo comm --- src/Repartitioner.cpp | 2 -- test/unit/Repartitioner1D.cpp | 1 + test/unit/Repartitioner2D.cpp | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Repartitioner.cpp b/src/Repartitioner.cpp index 33269aee..fe26ecc4 100644 --- a/src/Repartitioner.cpp +++ b/src/Repartitioner.cpp @@ -27,7 +27,6 @@ Repartitioner::repartition_sparsity( { LOG_1(verbose_, "start repartition sparsity pattern") - auto exec = exec_handler.get_ref_exec(); auto comm = *exec_handler.get_host_comm().get(); label rank = exec_handler.get_host_rank(); @@ -67,7 +66,6 @@ Repartitioner::repartition_sparsity( return gather_closure(comm_pattern, tmp, offset); }; - /* Helper function, create and return gathered sparsity pattern based on * in_sparsity * */ diff --git a/test/unit/Repartitioner1D.cpp b/test/unit/Repartitioner1D.cpp index bec8af74..4305f025 100644 --- a/test/unit/Repartitioner1D.cpp +++ b/test/unit/Repartitioner1D.cpp @@ -136,6 +136,7 @@ TEST_P(RepartitionerFixture1D, can_repartition_sparsity_pattern) // Arrange auto ranks_per_gpu = GetParam(); auto repartitioner = Repartitioner(local_size, ranks_per_gpu, 0, exec); + exec.init_device_comm(); // std::vector