KaMPIng 0.1.1
Flexible and (near) zero-overhead C++ bindings for MPI
Loading...
Searching...
No Matches
num_numa_nodes.hpp
1#pragma once
2
3#include "kamping/collectives/allreduce.hpp"
4#include "kamping/communicator.hpp"
5
6template <
7 template <typename...>
8 typename DefaultContainerType,
9 template <typename, template <typename...> typename>
10 typename... Plugins>
12 // Split this communicator into NUMA nodes.
13 Communicator numa_comm = split_to_shared_memory();
14
15 // Determine the lowest rank on each NUMA node.
16 size_t const numa_representative = numa_comm.allreduce_single(send_buf(rank()), op(ops::min<>{}));
17
18 // Determine the number of NUMA nodes by counting the number of distinct lowest ranks.
19 size_t const num_numa_nodes =
20 allreduce_single(send_buf(numa_representative == rank() ? 1ul : 0ul), op(ops::plus<>{}));
21
22 return num_numa_nodes;
23}
Wrapper for MPI communicator providing access to rank() and size() of the communicator....
Definition communicator.hpp:49
size_t num_numa_nodes() const
Number of NUMA nodes (different shared memory regions) in this communicator. This operation is expens...
Definition num_numa_nodes.hpp:11
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
internal::OperationBuilder< Op, Commutative > op(Op &&op, Commutative commute=ops::internal::undefined_commutative_tag{})
Passes a reduction operation to ther underlying call. Accepts function objects, lambdas,...
Definition named_parameters.hpp:1155
auto send_buf(internal::ignore_t< Data > ignore)
Generates a dummy send buf that wraps a nullptr.
Definition named_parameters.hpp:51
std::plus< T > plus
builtin summation operation (aka MPI_SUM)
Definition mpi_ops.hpp:153
Wrapper struct for std::min.
Definition mpi_ops.hpp:74