Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
mpi_wrappers.hpp
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2//
3// Copyright (C) 2024 - 2026 by the Vulpes authors.
4// This file is part of Vulpes.
5//
6// Vulpes is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Vulpes is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Vulpes. If not, see <http://www.gnu.org/licenses/>.
18//
19// ----------------------------------------------------------------------
20
21// Author: Francesco Rosnati <francesco.rosnati@polimi.it>
22// Author: Matteo Caldana <matteo.caldana@polimi.it>
23// Author: Pedro Peixoto <ppeixoto@usp.br>
24
25#ifndef VULPES_UTILS_MPI_WRAPPERS_HPP_
26#define VULPES_UTILS_MPI_WRAPPERS_HPP_
27
28#include <mpi.h>
29#include <petsc.h>
30
31#include <cassert>
32#include <iostream>
33#include <stdexcept>
34#include <string>
35#include <vector>
36
37#include <Eigen/Dense>
38
42
43namespace vulpes {
44namespace mpi {
45
47static inline constexpr int s_default_tag = 0;
48
55template <typename T>
56MPI_Datatype getMpiType() {
57 if constexpr (std::is_same_v<T, unsigned char>) {
58 return MPI_UNSIGNED_CHAR;
59 } else if constexpr (std::is_same_v<T, char>) {
60 return MPI_CHAR;
61 } else if constexpr (std::is_same_v<T, short>) { // NOLINT(runtime/int)
62 return MPI_SHORT;
63 } else if constexpr (std::is_same_v<T, int>) {
64 return MPI_INT;
65 } else if constexpr (std::is_same_v<T, long>) { // NOLINT(runtime/int)
66 return MPI_LONG;
67 } else if constexpr (std::is_same_v<T, long long>) { // NOLINT(runtime/int)
68 return MPI_LONG_LONG;
69 } else if constexpr (std::is_same_v<
70 T, unsigned short>) { // NOLINT(runtime/int)
71 return MPI_UNSIGNED_SHORT;
72 } else if constexpr (std::is_same_v<T, unsigned int>) {
73 return MPI_UNSIGNED;
74 } else if constexpr (std::is_same_v<
75 T, unsigned long>) { // NOLINT(runtime/int)
76 return MPI_UNSIGNED_LONG;
77 } else if constexpr (std::is_same_v<
78 T, unsigned long long>) { // NOLINT(runtime/int)
79 return MPI_UNSIGNED_LONG_LONG;
80 } else if constexpr (std::is_same_v<T, float>) {
81 return MPI_FLOAT;
82 } else if constexpr (std::is_same_v<T, double>) {
83 return MPI_DOUBLE;
84 } else if constexpr (std::is_same_v<T, long double>) {
85 return MPI_LONG_DOUBLE;
86 } else {
87 static_assert(sizeof(T) * 0 && "Unknown conversion to MPI type.");
88 }
89}
90
92inline static bool isInitialized() {
93 int mpi_is_initialized;
94 const int mpi_err = MPI_Initialized(&mpi_is_initialized);
95 return (mpi_err == MPI_SUCCESS) && mpi_is_initialized;
96}
97
98inline static bool isPetscInitialized() {
99 PetscBool petsc_is_initialized;
100 PetscCall(PetscInitialized(&petsc_is_initialized));
101 return petsc_is_initialized;
102}
103
104inline static bool isFinalized() {
105 int mpi_is_finalized;
106 const int mpi_err = MPI_Finalized(&mpi_is_finalized);
107 return (mpi_err == MPI_SUCCESS) && mpi_is_finalized;
108}
109
110inline static bool isPetscFinalized() {
111 PetscBool petsc_is_finalized;
112 PetscCall(PetscFinalized(&petsc_is_finalized));
113 return petsc_is_finalized;
114}
115
116inline static int rank() {
117 static int world_rank = -1;
118 if (world_rank == -1) {
119 MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
120 }
121 return world_rank;
122}
123
124inline static int size() {
125 static int world_size = -1;
126 if (world_size == -1) {
127 MPI_Comm_size(MPI_COMM_WORLD, &world_size);
128 }
129 return world_size;
130}
131
132inline static bool root() {
133 return rank() == 0;
134}
135
137// send
139
148template <typename T>
149void send(
150 const T* data,
151 int count,
152 int destination,
153 MPI_Comm communicator = MPI_COMM_WORLD) {
154 Profiler::startInterval("MPI-send");
155 MPI_Send(
156 data, count, getMpiType<T>(), destination, s_default_tag, communicator);
157 Profiler::stopInterval("MPI-send");
158}
159
167template <typename T>
168void send(
169 const T& data, int destination, MPI_Comm communicator = MPI_COMM_WORLD) {
170 Profiler::startInterval("MPI-send");
171 MPI_Send(&data, 1, getMpiType<T>(), destination, s_default_tag, communicator);
172 Profiler::stopInterval("MPI-send");
173}
174
182template <typename T>
183void send(
184 const std::vector<T>& data,
185 int destination,
186 MPI_Comm communicator = MPI_COMM_WORLD) {
187 const std::size_t count = data.size();
188 Profiler::startInterval("MPI-send");
189 MPI_Send(
190 &count, 1, getMpiType<std::size_t>(), destination, s_default_tag,
191 communicator);
192 MPI_Send(
193 data.data(), data.size(), getMpiType<T>(), destination, s_default_tag,
194 communicator);
195 Profiler::stopInterval("MPI-send");
196}
197
204inline void send(
205 const std::string& data,
206 int destination,
207 MPI_Comm communicator = MPI_COMM_WORLD) {
208 const std::size_t count = data.size();
209 Profiler::startInterval("MPI-send");
210 MPI_Send(
211 &count, 1, getMpiType<std::size_t>(), destination, s_default_tag,
212 communicator);
213 MPI_Send(
214 data.data(), count, getMpiType<char>(), destination, s_default_tag,
215 communicator);
216 Profiler::stopInterval("MPI-send");
217}
218
227template <typename T, std::size_t N>
228void send(
229 const std::vector<std::array<T, N>>& data,
230 int destination,
231 MPI_Comm communicator = MPI_COMM_WORLD) {
232 const std::size_t count = data.size();
233 Profiler::startInterval("MPI-send");
234 MPI_Send(
235 &count, 1, getMpiType<std::size_t>(), destination, s_default_tag,
236 communicator);
237 if (count) {
238 MPI_Send(
239 data[0].data(), data.size() * N, getMpiType<T>(), destination,
240 s_default_tag, communicator);
241 }
242 Profiler::stopInterval("MPI-send");
243}
244
256template <typename T, int N, int M, int Options>
257void send(
258 const std::vector<Eigen::Matrix<T, N, M, Options>>& data,
259 int destination,
260 MPI_Comm communicator = MPI_COMM_WORLD) {
261 static_assert(N > 0 && M > 0);
262 const std::size_t count = data.size();
263 Profiler::startInterval("MPI-send");
264 MPI_Send(
265 &count, 1, getMpiType<std::size_t>(), destination, s_default_tag,
266 communicator);
267 if (count) {
268 MPI_Send(
269 data[0].data(), data.size() * N, getMpiType<T>(), destination,
270 s_default_tag, communicator);
271 }
272 Profiler::stopInterval("MPI-send");
273}
274
284template <
285 typename DataType,
286 typename IndexType,
287 IndexType RowSize = IndexType(-1)>
288void send(
290 int destination,
291 MPI_Comm communicator = MPI_COMM_WORLD) {
292 send(map.data(), destination, communicator);
293 send(map.indices(), destination, communicator);
294}
295
297// recv
299
310template <typename T>
311void recv(
312 T* data,
313 int count,
314 int source,
315 MPI_Comm communicator = MPI_COMM_WORLD,
316 MPI_Status* status = MPI_STATUS_IGNORE) {
317 Profiler::startInterval("MPI-recv");
318 MPI_Recv(
319 data, count, getMpiType<T>(), source, s_default_tag, communicator,
320 status);
321 Profiler::stopInterval("MPI-recv");
322}
323
332template <typename T>
334 int source,
335 MPI_Comm communicator = MPI_COMM_WORLD,
336 MPI_Status* status = MPI_STATUS_IGNORE) {
337 T data;
338 recv(&data, 1, source, communicator, status);
339 return data;
340}
341
351template <typename T>
352void recv(
353 std::vector<T>& data,
354 int source,
355 MPI_Comm communicator = MPI_COMM_WORLD,
356 MPI_Status* status = MPI_STATUS_IGNORE) {
357 std::size_t count;
358 Profiler::startInterval("MPI-recv");
359 MPI_Recv(
360 &count, 1, getMpiType<std::size_t>(), source, s_default_tag, communicator,
361 status);
362 data.resize(count);
363 MPI_Recv(
364 data.data(), count, getMpiType<T>(), source, s_default_tag, communicator,
365 status);
366 Profiler::stopInterval("MPI-recv");
367}
368
377inline void recv(
378 std::string& data,
379 int source,
380 MPI_Comm communicator = MPI_COMM_WORLD,
381 MPI_Status* status = MPI_STATUS_IGNORE) {
382 std::size_t count;
383 Profiler::startInterval("MPI-recv");
384 MPI_Recv(
385 &count, 1, getMpiType<std::size_t>(), source, s_default_tag, communicator,
386 status);
387 data.resize(count);
388 MPI_Recv(
389 data.data(), count, getMpiType<char>(), source, s_default_tag,
390 communicator, status);
391 Profiler::stopInterval("MPI-recv");
392}
393
404template <typename T, std::size_t N>
405void recv(
406 std::vector<std::array<T, N>>& data,
407 int source,
408 MPI_Comm communicator = MPI_COMM_WORLD,
409 MPI_Status* status = MPI_STATUS_IGNORE) {
410 std::size_t count;
411 Profiler::startInterval("MPI-recv");
412 MPI_Recv(
413 &count, 1, getMpiType<std::size_t>(), source, s_default_tag, communicator,
414 status);
415 data.resize(count);
416 if (count) {
417 MPI_Recv(
418 data[0].data(), count * N, getMpiType<T>(), source, s_default_tag,
419 communicator, status);
420 }
421 Profiler::stopInterval("MPI-recv");
422}
423
436template <typename T, int N, int M, int Options>
437void recv(
438 std::vector<Eigen::Matrix<T, N, M, Options>>& data,
439 int source,
440 MPI_Comm communicator = MPI_COMM_WORLD,
441 MPI_Status* status = MPI_STATUS_IGNORE) {
442 static_assert(N > 0 && M > 0);
443 std::size_t count;
444 Profiler::startInterval("MPI-recv");
445 MPI_Recv(
446 &count, 1, getMpiType<std::size_t>(), source, s_default_tag, communicator,
447 status);
448 data.resize(count);
449 if (count) {
450 MPI_Recv(
451 data[0].data(), count * N, getMpiType<T>(), source, s_default_tag,
452 communicator, status);
453 }
454 Profiler::stopInterval("MPI-recv");
455}
456
467template <
468 typename DataType,
469 typename IndexType,
470 IndexType RowSize = IndexType(-1)>
471void recv(
473 int source,
474 MPI_Comm communicator = MPI_COMM_WORLD,
475 MPI_Status* status = MPI_STATUS_IGNORE) {
476 Profiler::startInterval("MPI-recv");
477 recv(map.data(), source, communicator, status);
478 recv(map.indices(), source, communicator, status);
479 Profiler::stopInterval("MPI-recv");
480}
481
483// bcast
485
494template <typename T>
495void bcast(
496 T* data, int count, int root, MPI_Comm communicator = MPI_COMM_WORLD) {
497 Profiler::startInterval("MPI-bcast");
498 MPI_Bcast(data, count, getMpiType<T>(), root, communicator);
499 Profiler::stopInterval("MPI-bcast");
500}
501
509template <typename T>
510void bcast(T& data, int root, MPI_Comm communicator = MPI_COMM_WORLD) {
511 bcast(&data, 1, root, communicator);
512}
513
523template <typename T>
524void bcast(
525 std::vector<T>& data, int root, MPI_Comm communicator = MPI_COMM_WORLD) {
526 std::size_t count = 0;
527 if (vulpes::mpi::root()) {
528 count = data.size();
529 }
530 Profiler::startInterval("MPI-bcast");
531 MPI_Bcast(&count, 1, getMpiType<std::size_t>(), root, communicator);
532 data.resize(count);
533 MPI_Bcast(data.data(), count, getMpiType<T>(), root, communicator);
534 Profiler::stopInterval("MPI-bcast");
535}
536
544inline void bcast(
545 std::string& data, int root, MPI_Comm communicator = MPI_COMM_WORLD) {
546 std::size_t count = data.size();
547
548 Profiler::startInterval("MPI-bcast");
549
550 MPI_Bcast(&count, 1, getMpiType<std::size_t>(), root, communicator);
551 data.resize(count);
552 MPI_Bcast(data.data(), count, getMpiType<char>(), root, communicator);
553
554 Profiler::stopInterval("MPI-bcast");
555}
556
569template <typename T, int N, int M, int Options>
570void bcast(
571 Eigen::Matrix<T, N, M, Options>& data,
572 int root,
573 MPI_Comm communicator = MPI_COMM_WORLD) {
574 std::size_t nrows = 0, ncols = 0;
575 if (mpi::rank() == root) {
576 nrows = data.rows();
577 ncols = data.cols();
578 }
579 Profiler::startInterval("MPI-bcast");
580 MPI_Bcast(&nrows, 1, getMpiType<std::size_t>(), root, communicator);
581 MPI_Bcast(&ncols, 1, getMpiType<std::size_t>(), root, communicator);
582 if (!(mpi::rank() == root)) {
583 data.resize(nrows, ncols);
584 }
585 MPI_Bcast(data.data(), nrows * ncols, getMpiType<T>(), root, communicator);
586 Profiler::stopInterval("MPI-bcast");
587}
588
590// reduce
592
604template <typename T>
606 const T* send_data,
607 T* recv_data,
608 int count,
609 MPI_Op op,
610 int root,
611 MPI_Comm communicator = MPI_COMM_WORLD) {
612 Profiler::startInterval("MPI-reduce");
613 MPI_Reduce(
614 send_data, recv_data, count, getMpiType<T>(), op, root, communicator);
615 Profiler::stopInterval("MPI-reduce");
616}
617
627template <typename T>
629 const T& send_data,
630 MPI_Op op,
631 int root,
632 MPI_Comm communicator = MPI_COMM_WORLD) {
633 T recv_data;
634 Profiler::startInterval("MPI-reduce");
635 MPI_Reduce(
636 &send_data, &recv_data, 1, getMpiType<T>(), op, root, communicator);
637 Profiler::stopInterval("MPI-reduce");
638 return recv_data;
639}
640
642// utils
644
656// assume everyone knows count
657inline auto computeChuncks(int32_t count, int32_t stride = 1) {
658 const int32_t comm_size = mpi::size();
659 std::vector<int32_t> displacements(comm_size), counts(comm_size);
660
661 const int32_t chunck_sz = count / comm_size;
662
663 for (int32_t i = 0; i < comm_size; i++) {
664 counts[i] = stride * (chunck_sz + (i < (count % comm_size)));
665 }
666
667 displacements[0] = 0;
668 for (int32_t i = 1; i < comm_size; i++) {
669 displacements[i] = displacements[i - 1] + counts[i - 1];
670 }
671
672 return std::pair{displacements, counts};
673}
674
676// gather
678
691template <typename T>
693 const T* send_data,
694 int send_count,
695 T* recv_data,
696 int recv_count,
697 int root,
698 MPI_Comm communicator = MPI_COMM_WORLD) {
699 Profiler::startInterval("MPI-gather");
700 MPI_Gather(
701 send_data, send_count, getMpiType<T>(), recv_data, recv_count,
702 getMpiType<T>(), root, communicator);
703 Profiler::stopInterval("MPI-gather");
704}
705
717template <typename T>
719 const std::vector<T>& send_data,
720 std::vector<T>& recv_data,
721 int root,
722 MPI_Comm communicator = MPI_COMM_WORLD) {
723 int send_count = send_data.size();
724 int recv_count = recv_data.size() / size();
725 Profiler::startInterval("MPI-gather");
726 MPI_Gather(
727 send_data.data(), send_count, getMpiType<T>(), recv_data.data(),
728 recv_count, getMpiType<T>(), root, communicator);
729 Profiler::stopInterval("MPI-gather");
730}
731
745template <typename T>
747 const T* send_data,
748 int send_count,
749 T* recv_data,
750 int* recv_count,
751 int* displs,
752 int root,
753 MPI_Comm communicator = MPI_COMM_WORLD) {
754 Profiler::startInterval("MPI-gatherv");
755 MPI_Gatherv(
756 send_data, send_count, getMpiType<T>(), recv_data, recv_count, displs,
757 getMpiType<T>(), root, communicator);
758 Profiler::stopInterval("MPI-gatherv");
759}
760
762// scatter
764
777template <typename T>
779 const T* send_data,
780 int send_count,
781 T* recv_data,
782 int recv_count,
783 int root,
784 MPI_Comm communicator = MPI_COMM_WORLD) {
785 Profiler::startInterval("MPI-scatter");
786 MPI_Scatter(
787 send_data, send_count, getMpiType<T>(), recv_data, recv_count,
788 getMpiType<T>(), root, communicator);
789 Profiler::stopInterval("MPI-scatter");
790}
791
803template <typename T>
805 const std::vector<T>& send_data,
806 std::vector<T>& recv_data,
807 int root,
808 MPI_Comm communicator = MPI_COMM_WORLD) {
809 int recv_count = recv_data.size();
810 int send_count = send_data.size() / size();
811 Profiler::startInterval("MPI-scatter");
812 MPI_Scatter(
813 send_data.data(), send_count, getMpiType<T>(), recv_data.data(),
814 recv_count, getMpiType<T>(), root, communicator);
815 Profiler::stopInterval("MPI-scatter");
816}
817
834template <typename T>
836 const T* send_data,
837 int* send_counts,
838 int* displacements,
839 T* recv_data,
840 int recv_count,
841 int root,
842 MPI_Comm mpi_comm = MPI_COMM_WORLD,
843 MPI_Datatype send_t = getMpiType<T>(),
844 MPI_Datatype recv_t = getMpiType<T>()) {
845 Profiler::startInterval("MPI-scatterv");
846 MPI_Scatterv(
847 send_data, send_counts, displacements, send_t, recv_data, recv_count,
848 recv_t, root, mpi_comm);
849 Profiler::stopInterval("MPI-scatterv");
850}
851
852// all 2 all, v
853// broadcast
854// gather, v
855// all gather, v
856// reduce
857// scatter, v
858// all reduce
859
861 public:
863 static int init(
864 int& argc,
865 char**& argv,
866 int required = s_default_thread_required,
867 int* provided = nullptr) {
868 return init(&argc, &argv, required, provided);
869 }
870
871 static int init(
872 int* argc = nullptr,
873 char*** argv = nullptr,
874 int required = s_default_thread_required,
875 int* provided = nullptr) {
876 assert(!isInitialized() && "MPI already initialized!");
877 int mpi_res;
878 if (required == MPI_THREAD_SINGLE) {
879 mpi_res = MPI_Init(argc, argv);
880 } else {
881 mpi_res = MPI_Init_thread(argc, argv, required, provided);
882 }
883 if (mpi_res != MPI_SUCCESS) {
884 throw std::runtime_error("MPI_Init failed");
885 }
886 // Configure VTK before any VTK parallel operation.
888 // Initialize PETSc
889 PetscCall(PetscInitialize(argc, argv, nullptr, nullptr));
890 // PETSc has now loaded and initialized its BLAS backend.
892 // initialize the Mpi singleton.
893 singleton();
894 return 0;
895 }
896
897 private:
899 inline constexpr static int s_default_thread_required = MPI_THREAD_SINGLE;
902 static MpiHandle mpi;
903 return mpi;
904 }
905
906 static int finalize() {
908 PetscCall(PetscFinalize());
909 }
910 if (isInitialized() && !isFinalized()) {
911 MPI_Finalize();
912 }
913 return 0;
914 }
915
918 MpiHandle() = default;
919};
920
921} // namespace mpi
922} // namespace vulpes
923
924#endif // VULPES_UTILS_MPI_WRAPPERS_HPP_
static void startInterval(const char *label)
startInterval(label) when recording is on.
Definition profiler.hpp:96
static void stopInterval(const char *label)
stopInterval(label) when recording is on.
Definition profiler.hpp:102
Definition crs_map.hpp:72
const auto & indices() const
Constant accessor to the indices buffer.
Definition crs_map.hpp:442
const auto & data() const
Constant accessor to the data buffer.
Definition crs_map.hpp:438
MpiHandle()=default
Prevent direct construction of objects of this class.
static constexpr int s_default_thread_required
Default level of thread support for MPI_Init_thread.
Definition mpi_wrappers.hpp:899
static int init(int &argc, char **&argv, int required=s_default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::init(argc, argv).
Definition mpi_wrappers.hpp:863
static int init(int *argc=nullptr, char ***argv=nullptr, int required=s_default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::init().
Definition mpi_wrappers.hpp:871
~MpiHandle()
finalize MPI.
Definition mpi_wrappers.hpp:916
static int finalize()
finalize MPI and PETSc.
Definition mpi_wrappers.hpp:906
static MpiHandle & singleton()
initialize the Mpi singleton.
Definition mpi_wrappers.hpp:901
Definition mpi_wrappers.hpp:44
void recv(T *data, int count, int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
Receive count contiguous values of type T from a source rank.
Definition mpi_wrappers.hpp:311
static int rank()
Return the MPI rank in MPI_COMM_WORLD.
Definition mpi_wrappers.hpp:116
void gatherv(const T *send_data, int send_count, T *recv_data, int *recv_count, int *displs, int root, MPI_Comm communicator=MPI_COMM_WORLD)
Gather variable-length contiguous values of type T from every rank into recv_data on root.
Definition mpi_wrappers.hpp:746
static int size()
Return the size of MPI_COMM_WORLD.
Definition mpi_wrappers.hpp:124
static bool root()
Return true if the rank in MPI_COMM_WORLD is zero.
Definition mpi_wrappers.hpp:132
static bool isPetscFinalized()
Return true if PETSc has been finalized.
Definition mpi_wrappers.hpp:110
static bool isFinalized()
Return true if MPI has been finalized.
Definition mpi_wrappers.hpp:104
void send(const T *data, int count, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
Send count contiguous values of type T to a destination rank.
Definition mpi_wrappers.hpp:149
void scatter(const T *send_data, int send_count, T *recv_data, int recv_count, int root, MPI_Comm communicator=MPI_COMM_WORLD)
Scatter recv_count contiguous values of type T from root to every rank.
Definition mpi_wrappers.hpp:778
void reduce(const T *send_data, T *recv_data, int count, MPI_Op op, int root, MPI_Comm communicator=MPI_COMM_WORLD)
Reduce count contiguous values of type T onto root.
Definition mpi_wrappers.hpp:605
static bool isPetscInitialized()
Return true if PETSc has been initialized.
Definition mpi_wrappers.hpp:98
void scatterv(const T *send_data, int *send_counts, int *displacements, T *recv_data, int recv_count, int root, MPI_Comm mpi_comm=MPI_COMM_WORLD, MPI_Datatype send_t=getMpiType< T >(), MPI_Datatype recv_t=getMpiType< T >())
Scatter variable-length contiguous values of type T from root to every rank.
Definition mpi_wrappers.hpp:835
void gather(const T *send_data, int send_count, T *recv_data, int recv_count, int root, MPI_Comm communicator=MPI_COMM_WORLD)
Gather send_count contiguous values of type T from every rank into recv_data on root.
Definition mpi_wrappers.hpp:692
static bool isInitialized()
Return true if MPI has been initialized.
Definition mpi_wrappers.hpp:92
MPI_Datatype getMpiType()
Map a C++ arithmetic type to its corresponding MPI_Datatype.
Definition mpi_wrappers.hpp:56
void bcast(T *data, int count, int root, MPI_Comm communicator=MPI_COMM_WORLD)
Broadcast count contiguous values of type T from root.
Definition mpi_wrappers.hpp:495
auto computeChuncks(int32_t count, int32_t stride=1)
Split count elements into near-equal contiguous chunks, one per rank in the current communicator.
Definition mpi_wrappers.hpp:657
static constexpr int s_default_tag
Default MPI message tag used by all wrappers in this file.
Definition mpi_wrappers.hpp:47
void configureVtkThreading()
Configure the VTK SMP thread budget.
Definition threading.cpp:190
void checkOpenBlasThreading()
Validate the active OpenBLAS thread count.
Definition threading.cpp:195
Definition cell_manager.hpp:38
Thread configuration and runtime validation utilities.