Advanced Multi-Physics (AMP)
On-Line Documentation
MIS2Aggregator.h
Go to the documentation of this file.
1#ifndef included_AMP_MIS2Aggregator_H_
2#define included_AMP_MIS2Aggregator_H_
3
4#include "AMP/solvers/amg/AggregationSettings.h"
5#include "AMP/solvers/amg/Aggregator.h"
6
7#include <cstdint>
8#include <vector>
9
10namespace AMP::Solver::AMG {
11
12// This aggregator is based on an MIS-2 classification of the vertices.
13// The implementation mostly follows Sandia report SAND2022-2930C titled "Parallel, portable
14// algorithms for distance-2 maximal independent set and graph coarsening" by Brian Kelley and
15// Sivasankaran Rajamanickam.
16// It also takes inspiration from "A GPU accelerated aggregation algebraic multigrid method" by
17// Rajesh Gandham, Kenneth Esler, and Yongpeng Zhang. http://dx.doi.org/10.1016/j.camwa.2014.08.022
19 MIS2Aggregator( const CoarsenSettings &settings ) : Aggregator( settings ) {}
20
21 // Necessary overrides from base class
22 int assignLocalAggregates( std::shared_ptr<LinearAlgebra::Matrix> A, int *agg_ids ) override;
23
24 // type specific aggregator, dispatches to host/device versions
25 template<typename Config>
26 int assignLocalAggregates( std::shared_ptr<LinearAlgebra::CSRMatrix<Config>> A, int *agg_ids );
27
28 // classify vertices as in or out of MIS-2
29 template<typename Config>
31 const uint64_t num_gbl,
32 typename Config::lidx_t *worklist,
33 typename Config::lidx_t worklist_len,
34 uint64_t *Tv,
35 uint64_t *Tv_hat );
36
37 // helper function to choose bits for id part of packed tuples
38 uint64_t getIdMask( uint64_t num_global ) const
39 {
40 // the packed representation uses minimal number of bits for ID part
41 // of tuple, get log_2 of (num_gbl + 2)
42 AMP_ASSERT( num_global < ( std::numeric_limits<uint64_t>::max() - 33 ) );
43 const auto id_shift = []( uint64_t ng ) -> uint8_t {
44 // log2 from stackoverflow. If only bit_width was c++17...
45 uint8_t s = 1;
46 while ( ng >>= 1 )
47 ++s;
48 return s;
49 }( num_global );
50 return std::numeric_limits<uint64_t>::max() >> ( 64 - id_shift );
51 }
52
53 // helper function to choose bits for hash part of packed tuples
54 uint64_t getHashMask( uint64_t id_mask ) const
55 {
56 const uint64_t conn_mask = ( (uint64_t) 31 ) << 59;
57 return ~( conn_mask | id_mask );
58 }
59
60 // status labels such that IN < UNDECIDED < OUT
61 // there is no ordering within the IN set so all are marked 0,
62 // similarly all OUT are marked with max value
63 static constexpr uint64_t IN = std::numeric_limits<uint64_t>::max();
64 static constexpr uint64_t OUT = 0;
65
66 // Aggregate IDs are signed, where nonegative values are the
67 // assigned aggregate determined by this process.
68 // Negative values are used as semaphores for two cases,
69 // unaggregated points valid for assignment, and invalid
70 // points that are not to be aggregated at all
71 static constexpr int UNASSIGNED = -1;
72 static constexpr int INVALID = -2;
73};
74
75} // namespace AMP::Solver::AMG
76
77#endif
An concrete class for dealing with dense serial matrices.
Definition CSRMatrix.h:26
#define AMP_ASSERT(EXP)
Assert error.
int classifyVertices(std::shared_ptr< LinearAlgebra::CSRLocalMatrixData< Config > > A, const uint64_t num_gbl, typename Config::lidx_t *worklist, typename Config::lidx_t worklist_len, uint64_t *Tv, uint64_t *Tv_hat)
int assignLocalAggregates(std::shared_ptr< LinearAlgebra::Matrix > A, int *agg_ids) override
static constexpr int UNASSIGNED
MIS2Aggregator(const CoarsenSettings &settings)
uint64_t getHashMask(uint64_t id_mask) const
static constexpr uint64_t OUT
static constexpr uint64_t IN
uint64_t getIdMask(uint64_t num_global) const
int assignLocalAggregates(std::shared_ptr< LinearAlgebra::CSRMatrix< Config > > A, int *agg_ids)



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page