DOLFINx 0.12.0.0
DOLFINx C++
Loading...
Searching...
No Matches
dolfinx::graph::build Namespace Reference

Functions

std::tuple< graph::AdjacencyList< std::int64_t >, std::vector< int >, std::vector< std::int64_t >, std::vector< int > > distribute (MPI_Comm comm, const graph::AdjacencyList< std::int64_t > &list, const graph::AdjacencyList< std::int32_t > &destinations)
 Distribute adjacency list nodes to destination ranks.
std::tuple< std::vector< std::int64_t >, std::vector< int >, std::vector< std::int64_t >, std::vector< int > > distribute (MPI_Comm comm, std::span< const std::int64_t > list, std::array< std::size_t, 2 > shape, const graph::AdjacencyList< std::int32_t > &destinations)
 Distribute rows of a fixed-degree array to destination ranks.
std::vector< std::int64_t > compute_ghost_indices (MPI_Comm comm, std::span< const std::int64_t > owned_indices, std::span< const std::int64_t > ghost_indices, std::span< const int > ghost_owners, int num_threads)
 Take a set of distributed input global indices, including ghosts, and determine the new global indices after remapping.
std::vector< std::int64_t > compute_local_to_global (std::span< const std::int64_t > global, std::span< const std::int32_t > local)
std::vector< std::int32_t > compute_local_to_local (std::span< const std::int64_t > local0_to_global, std::span< const std::int64_t > local1_to_global)
 Compute a local0-to-local1 map from two local-to-global maps with common global indices.

Detailed Description

Tools for distributed graphs

Todo
Add a function that sends data to the 'owner'

Function Documentation

◆ compute_ghost_indices()

std::vector< std::int64_t > compute_ghost_indices ( MPI_Comm comm,
std::span< const std::int64_t > owned_indices,
std::span< const std::int64_t > ghost_indices,
std::span< const int > ghost_owners,
int num_threads )

Take a set of distributed input global indices, including ghosts, and determine the new global indices after remapping.

Each rank receive 'input' global indices [i0, i1, ..., i(m-1), im, ..., i(n-1)], where the first m indices are owned by the caller and the remainder are 'ghosts' indices that are owned by other ranks.

Each rank assigns new global indices to its owned indices. The new index is the rank offset (scan of the number of indices owned by the lower rank processes, typically computed using MPI_Exscan with MPI_SUM), i.e. i1 -> offset + 1, i2 -> offset + 2, etc. Ghost indices are number by the remote owning processes. The function returns the new ghost global indices by retrieving the new indices from the owning ranks.

Parameters
[in]commMPI communicator
[in]owned_indicesList of owned global indices. It should not contain duplicates, and these indices must not appear in owned_indices on other ranks.
[in]ghost_indicesList of ghost global indices.
[in]ghost_ownersThe owning rank for each entry in ghost_indices.
[in]num_threadsNumber of threads to use.
Returns
New global indices for the ghost indices.

◆ compute_local_to_global()

std::vector< std::int64_t > compute_local_to_global ( std::span< const std::int64_t > global,
std::span< const std::int32_t > local )

Given an adjacency list with global, possibly non-contiguous, link indices and a local adjacency list with contiguous link indices starting from zero, compute a local-to-global map for the links. Both adjacency lists must have the same shape.

Parameters
[in]globalAdjacency list with global link indices.
[in]localAdjacency list with local, contiguous link indices.
Returns
Map from local index to global index, which if applied to the local adjacency list indices would yield the global adjacency list.

◆ compute_local_to_local()

std::vector< std::int32_t > compute_local_to_local ( std::span< const std::int64_t > local0_to_global,
std::span< const std::int64_t > local1_to_global )

Compute a local0-to-local1 map from two local-to-global maps with common global indices.

Parameters
[in]local0_to_globalMap from local0 indices to global indices
[in]local1_to_globalMap from local1 indices to global indices
Returns
Map from local0 indices to local1 indices

◆ distribute() [1/2]

std::tuple< graph::AdjacencyList< std::int64_t >, std::vector< int >, std::vector< std::int64_t >, std::vector< int > > distribute ( MPI_Comm comm,
const graph::AdjacencyList< std::int64_t > & list,
const graph::AdjacencyList< std::int32_t > & destinations )

Distribute adjacency list nodes to destination ranks.

The global index of the ith node (row) in list is assumed to be i plus the offset for this rank, i.e. the number of nodes owned by lower-ranked processes.

Note
Collective.
The neighbourhood communicator is built with MPI::compute_graph_edges_nbx, which discovers incoming edges from the outgoing edges alone via the scalable NBX consensus algorithm, keeping the communication pattern sparse. This is not free: it costs one or more non-blocking consensus rounds, so calling this function repeatedly (e.g. once per cell type) has a real cost.
Parameters
[in]commMPI Communicator that list/destinations are distributed across.
[in]listThe adjacency list to distribute.
[in]destinationsDestination rank(s) for the ith node in list. The first rank is the 'owner' of the node; any further ranks receive it as a ghost.
Returns
  1. Received adjacency list for this process. Nodes owned by this process come first, followed by any ghost nodes.
  2. Source rank of each node in (1), i.e. the rank it was sent from.
  3. Original global index of each node in (1).
  4. Owning rank of the ghost nodes among (1). This has one entry per ghost node – the trailing entries of (1) – not one entry per node of (1).

◆ distribute() [2/2]

std::tuple< std::vector< std::int64_t >, std::vector< int >, std::vector< std::int64_t >, std::vector< int > > distribute ( MPI_Comm comm,
std::span< const std::int64_t > list,
std::array< std::size_t, 2 > shape,
const graph::AdjacencyList< std::int32_t > & destinations )

Distribute rows of a fixed-degree array to destination ranks.

The global index of the ith row of list is assumed to be i plus the offset for this rank, i.e. the number of rows owned by lower-ranked processes.

Note
Collective.
The neighbourhood communicator is built with MPI::compute_graph_edges_nbx, which discovers incoming edges from the outgoing edges alone via the scalable NBX consensus algorithm, keeping the communication pattern sparse. This is not free: it costs one or more non-blocking consensus rounds, so calling this function repeatedly (e.g. once per cell type) has a real cost.
Parameters
[in]commMPI Communicator that list/destinations are distributed across.
[in]listConstant degree (valency) data, flattened row-major with shape shape.
[in]shapeShape (num_nodes, degree) of list.
[in]destinationsDestination rank(s) for the ith row of list. The first rank is the 'owner' of the row; any further ranks receive it as a ghost.
Returns
  1. Received rows for this process, flattened row-major with shape (num_nodes, degree). Rows owned by this process come first, followed by any ghost rows.
  2. Source rank of each row in (1), i.e. the rank it was sent from.
  3. Original global index of each row in (1).
  4. Owning rank of the ghost rows among (1). This has one entry per ghost row – the trailing rows of (1) – not one entry per row of (1).