Documentation 6b54b78464
Loading...
Searching...
No Matches

Classes to represent graphs and functions to manipulate them (coloring, etc.). More...

Collaboration diagram for Graph operations:

Classes

class  CCompressedSparsePattern< Index_t >
 A simple class to store adjacency information in a compressed format suitable for sparse matrix operations. If built for row-major storage the inner indices are column indices and the pattern should be used as (row,icol), otherwise as (col,irow). More...
 
struct  GridColor< T >
 A way to represent one grid color that allows range-for syntax. More...
 
struct  DummyGridColor< T >
 A way to represent natural coloring {0,1,2,...,size-1} with zero overhead (behaves like looping with an integer index, after optimization...). More...
 
class  CGraphColoringStructure
 Class, which provides distributed graph coloring algorithms. More...
 

Typedefs

template<typename Index_t >
using CEdgeToNonZeroMap = C2DContainer< unsigned long, Index_t, StorageType::RowMajor, 64, DynamicSize, 2 >
 Alias a type of container as the edge map class, this is a N by 2 container that maps the two sparse entries referenced by an edge (ij and ji) to two non zero entries of a sparse pattern.
 
using CCompressedSparsePatternUL = CCompressedSparsePattern< su2uint >
 
using CCompressedSparsePatternL = CCompressedSparsePattern< su2int >
 
using CEdgeToNonZeroMapUL = CEdgeToNonZeroMap< su2uint >
 

Enumerations

enum class  ConnectivityType { ConnectivityType::FiniteVolume = 0 , ConnectivityType::FiniteElement = 1 }
 In FVM points are connected by the edges (faces) of the grid. In FEM, two points are connected if they have an element in common. More...
 

Functions

template<class Geometry_t , typename Index_t >
CCompressedSparsePattern< Index_t > buildCSRPattern (Geometry_t &geometry, ConnectivityType type, Index_t fillLvl)
 Build a sparse pattern from geometry information, of type FVM or FEM, for a given fill-level. At fill-level N, the immediate neighbors of the points in level N-1 are also considered neighbors of the base point. The resulting pattern is that of A^{N+1} where A is the sparse matrix of immediate neighbors.
 
template<typename Index_t >
CCompressedSparsePattern< Index_t > buildLowerPattern (const CCompressedSparsePattern< Index_t > &csr)
 Extract the strictly-lower part of a symmetric compressed sparse pattern. For each row i, the lower entries are those at positions [outerPtr[i], diagPtr[i]).
 
template<typename Index_t >
CCompressedSparsePattern< Index_t > buildUpperPattern (const CCompressedSparsePattern< Index_t > &csr)
 Extract the strictly-upper part of a symmetric compressed sparse pattern. For each row i, the upper entries are those at positions (diagPtr[i], outerPtr[i+1]).
 
template<typename Index_t >
void buildLUTransposeMaps (const CCompressedSparsePattern< Index_t > &pattern_l, const CCompressedSparsePattern< Index_t > &pattern_u, su2vector< Index_t > &l_to_u, su2vector< Index_t > &u_to_l)
 Build bijective maps between strictly-lower (L) and strictly-upper (U) non-zero entries that are each other's transposes. Requires a symmetric pattern. l_to_u[k_l] = k_u such that U-entry k_u is the transpose of L-entry k_l, and vice-versa.
 
template<class T = CCompressedSparsePatternUL, class Index_t = typename T::IndexType>
T createNaturalColoring (Index_t numInnerIndexes)
 Create the natural coloring (equivalent to the normal sequential loop order) for a given number of inner indexes.
 
template<typename Color_t = unsigned char, size_t MaxColors = 255, size_t MaxMB = 128, class T >
T colorSparsePattern (const T &pattern, size_t groupSize=1, bool includeOuterIdx=false, bool balanceColors=false, std::vector< Color_t > *indexColor=nullptr)
 Color contiguous groups of outer indices of a sparse pattern such that within each color, any two groups do not have inner indices in common.
 
template<class SparsePattern >
su2double coloringEfficiency (const SparsePattern &coloring, int numThreads, int chunkSize)
 Computes the efficiency of a grid coloring for given number of threads and chunk size.
 
template<class T >
T computeLevels (const T &pattern)
 Compute the levels for the lower part of a sparse pattern. For example, corresponding to the dependencies of forward substitution.
 

Detailed Description

Classes to represent graphs and functions to manipulate them (coloring, etc.).

Typedef Documentation

◆ CCompressedSparsePatternL

◆ CCompressedSparsePatternUL

◆ CEdgeToNonZeroMap

template<typename Index_t >
using CEdgeToNonZeroMap = C2DContainer<unsigned long, Index_t, StorageType::RowMajor, 64, DynamicSize, 2>

Alias a type of container as the edge map class, this is a N by 2 container that maps the two sparse entries referenced by an edge (ij and ji) to two non zero entries of a sparse pattern.

◆ CEdgeToNonZeroMapUL

Enumeration Type Documentation

◆ ConnectivityType

enum class ConnectivityType
strong

In FVM points are connected by the edges (faces) of the grid. In FEM, two points are connected if they have an element in common.

Enumerator
FiniteVolume 
FiniteElement 

Function Documentation

◆ buildCSRPattern()

template<class Geometry_t , typename Index_t >
CCompressedSparsePattern< Index_t > buildCSRPattern ( Geometry_t &  geometry,
ConnectivityType  type,
Index_t  fillLvl 
)

Build a sparse pattern from geometry information, of type FVM or FEM, for a given fill-level. At fill-level N, the immediate neighbors of the points in level N-1 are also considered neighbors of the base point. The resulting pattern is that of A^{N+1} where A is the sparse matrix of immediate neighbors.

Note
Algorithm is equivalent to the implementation by F. Palacios, A. Bueno, and T. Economon from CSysMatrix.
Parameters
[in]geometry- Definition of the grid.
[in]type- Of connectivity.
[in]fillLvl- Target degree of neighborhood (immediate neighbors always added).
Returns
Compressed-Storage-Row sparse pattern.

◆ buildLowerPattern()

template<typename Index_t >
CCompressedSparsePattern< Index_t > buildLowerPattern ( const CCompressedSparsePattern< Index_t > &  csr)

Extract the strictly-lower part of a symmetric compressed sparse pattern. For each row i, the lower entries are those at positions [outerPtr[i], diagPtr[i]).

Parameters
[in]csr- Full symmetric pattern with diagonal pointer already built.
Returns
Strictly-lower CSR pattern.

◆ buildLUTransposeMaps()

template<typename Index_t >
void buildLUTransposeMaps ( const CCompressedSparsePattern< Index_t > &  pattern_l,
const CCompressedSparsePattern< Index_t > &  pattern_u,
su2vector< Index_t > &  l_to_u,
su2vector< Index_t > &  u_to_l 
)

Build bijective maps between strictly-lower (L) and strictly-upper (U) non-zero entries that are each other's transposes. Requires a symmetric pattern. l_to_u[k_l] = k_u such that U-entry k_u is the transpose of L-entry k_l, and vice-versa.

Parameters
[in]pattern_l- Strictly-lower CSR pattern.
[in]pattern_u- Strictly-upper CSR pattern.
[out]l_to_u- For each L-entry index, the U-entry index of its transpose.
[out]u_to_l- For each U-entry index, the L-entry index of its transpose.

◆ buildUpperPattern()

template<typename Index_t >
CCompressedSparsePattern< Index_t > buildUpperPattern ( const CCompressedSparsePattern< Index_t > &  csr)

Extract the strictly-upper part of a symmetric compressed sparse pattern. For each row i, the upper entries are those at positions (diagPtr[i], outerPtr[i+1]).

Parameters
[in]csr- Full symmetric pattern with diagonal pointer already built.
Returns
Strictly-upper CSR pattern.

◆ coloringEfficiency()

template<class SparsePattern >
su2double coloringEfficiency ( const SparsePattern &  coloring,
int  numThreads,
int  chunkSize 
)

Computes the efficiency of a grid coloring for given number of threads and chunk size.

◆ colorSparsePattern()

template<typename Color_t = unsigned char, size_t MaxColors = 255, size_t MaxMB = 128, class T >
T colorSparsePattern ( const T &  pattern,
size_t  groupSize = 1,
bool  includeOuterIdx = false,
bool  balanceColors = false,
std::vector< Color_t > *  indexColor = nullptr 
)

Color contiguous groups of outer indices of a sparse pattern such that within each color, any two groups do not have inner indices in common.

Note
Within a group, two outer indices will generally have common inner indices. The coloring is returned as a compressed sparse pattern where the colors are outer indices, and the outer indices of the input pattern are the inner indices of the coloring. A simple greedy algorithm is used. Using a sparse pattern as input allows "anything" to be colored e.g. FVM edges, FEM elements, the rows/columns of a sparse matrix, etc.
The worst that can happen in this method is needing an unreasonable number of colors, or too much memory due to a large range of the inner indices. The last two template parameters limit both, in case of failure an empty pattern is returned.
Parameters
[in]pattern- Sparse pattern to be colored.
[in]groupSize- Size of the outer index groups, default 1.
[in]includeOuterIdx- If the outer indices are the same type of entity as the inner indices this must be true. For example, when both are point indices, i.e. the pattern is the adjacency matrix.
[in]balanceColors- Try to balance number of indexes per color, tends to result in worse locality (thus false by default).
[out]indexColor- Optional, vector with colors given to the outer indices.
Returns
Coloring in the same type of the input pattern.

◆ computeLevels()

template<class T >
T computeLevels ( const T &  pattern)

Compute the levels for the lower part of a sparse pattern. For example, corresponding to the dependencies of forward substitution.

◆ createNaturalColoring()

template<class T = CCompressedSparsePatternUL, class Index_t = typename T::IndexType>
T createNaturalColoring ( Index_t  numInnerIndexes)

Create the natural coloring (equivalent to the normal sequential loop order) for a given number of inner indexes.

Note
This is to reduce overhead in "OpenMP-ready" code when only 1 thread is used.
Parameters
[in]numInnerIndexes- Number of indexes that are to be colored.
Returns
Natural (sequential) coloring of the inner indices.