109 template <
typename... Ts> [[nodiscard]] MPI_Datatype
get_mpi_type(std::tuple<Ts...> tup) {
110 static constexpr int N =
sizeof...(Ts);
114 std::array<int, N> blocklen;
115 for (
int i = 0; i < N; ++i) { blocklen[i] = 1; }
118 std::array<MPI_Aint, N> disp;
120 []<
size_t... Is>(std::index_sequence<Is...>,
auto &t, MPI_Aint *d) {
121 ((d[Is] = (
char *)&std::get<Is>(t) - (
char *)&std::get<0>(t)), ...);
123 auto min_el = *std::min_element(d, d +
sizeof...(Ts));
124 ((d[Is] -= min_el), ...);
125 }(std::index_sequence_for<Ts...>{}, tup, disp.data());
129 check_mpi_call(MPI_Type_create_struct(N, blocklen.data(), disp.data(), types.data(), &cty),
"MPI_Type_create_struct");