FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
richardson_apply_helper.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
9#include <kernel/util/memory_arbiter.hpp>
10#include <kernel/util/dist.hpp>
11#include <kernel/solver/base.hpp>
12
13#include <array>
14#include <vector>
15
16namespace FEAT::Solver::RichardsonHelper
17{
18 // All matrix/vector/mirror data is passed as Memory::Arbiter objects; the device driver acquires
19 // the cuda views it needs itself, instead of receiving pre-resolved raw device pointers. This
20 // mirrors the design of FEAT::Solver::CSRHelper used by the fused AmaVankaGMRES driver, but keeps
21 // the meta-block (k x l) BCSR structure intact instead of flattening it into a single scalar CSR.
22
35 template<typename DT_, typename IT_>
36 struct MetaBlock
37 {
38 const Memory::Arbiter* val = nullptr;
39 const Memory::Arbiter* row = nullptr;
40 const Memory::Arbiter* col = nullptr;
43 void* workspace = nullptr;
44 int block_height = 0;
45 int block_width = 0;
46 Index num_rows = 0;
47 Index num_cols = 0;
48 Index num_nnz = 0;
49
50 bool empty() const { return (val == nullptr) || (num_nnz == Index(0)); }
51 };
52
60 template<typename DT_, typename IT_, int NR_, int NC_>
62 {
63 static constexpr int num_row_blocks = NR_;
64 static constexpr int num_col_blocks = NC_;
65 std::array<MetaBlock<DT_, IT_>, std::size_t(NR_) * std::size_t(NC_)> blocks;
66
67 MetaBlock<DT_, IT_>& at(int r, int c) { return blocks[std::size_t(r) * std::size_t(NC_) + std::size_t(c)]; }
68 const MetaBlock<DT_, IT_>& at(int r, int c) const { return blocks[std::size_t(r) * std::size_t(NC_) + std::size_t(c)]; }
69 };
70
73 {
74 int block_size = 1;
77
78 Index size_raw() const { return num_entries * Index(block_size); }
79 };
80
83 template<typename DT_, typename IT_>
85 {
86 const Memory::Arbiter* val = nullptr;
87 const Memory::Arbiter* ind = nullptr;
88 Index used_elements = 0;
89 };
90
100 template<typename DT_, typename IT_>
102 {
104 std::vector<const Memory::Arbiter*> mirror_idx;
106 std::vector<Index> mirror_size;
108 std::vector<int> ranks;
110 const Memory::Arbiter* freqs = nullptr;
111 Dist::Comm* comm = nullptr;
112
113 bool empty() const { return ranks.empty(); }
114 };
115
121 template<typename DT_, typename IT_, int NC_>
123 {
129 std::array<UnitFilterInfo<DT_, IT_>, std::size_t(NC_)> def_filters;
131 std::array<MetaVectorInfo, std::size_t(NC_)> components;
133 std::array<GateWrapper<DT_, IT_>, std::size_t(NC_)> gates;
134
136 std::array<Memory::Arbiter*, std::size_t(NC_)> vec_sol;
138 std::array<const Memory::Arbiter*, std::size_t(NC_)> vec_rhs;
140 std::array<Memory::Arbiter*, std::size_t(NC_)> vec_def;
142 std::array<Memory::Arbiter*, std::size_t(NC_)> vec_cor;
143
144 DT_ omega = DT_(1);
145 Index min_iter = 0;
146 Index max_iter = 0;
147 bool always_use_parallel_kernel = false;
148 };
149
150 template<typename DT_>
152 {
153 DT_ def_norm = DT_(0);
154 DT_ def_init = DT_(0);
155 Index num_iter = 0;
156 };
157} // namespace FEAT::Solver::RichardsonHelper
FEAT Kernel base header.
Communicator class.
Definition: dist.hpp:1657
Memory arbiter class.
std::uint64_t Index
Index data type.
Per-meta-row (per-component) gate for the hand-rolled synchronization.
const Memory::Arbiter * freqs
this component's frequency array (type-1 -> type-0 weighting for sync_1)
std::vector< const Memory::Arbiter * > mirror_idx
per-neighbor shared-node (scalar) mirror index arrays
std::vector< Index > mirror_size
per-neighbor number of shared nodes (mirror indices)
std::vector< int > ranks
neighbor ranks (empty => empty gate)
A single (k x l) BCSR meta-block, referenced by its data arbiters.
A whole meta matrix as a constexpr NR_ x NC_ grid of (possibly empty) BCSR blocks.
Layout of one meta-vector component (velocity => block_size == dim, pressure => 1).
Index num_entries
number of blocks (nodes); the raw scalar length is num_entries * block_size
Everything the fused Richardson driver needs for one apply.
std::array< const Memory::Arbiter *, std::size_t(NC_)> vec_rhs
per-component element arbiters of the right-hand-side vector (read-only)
std::array< Memory::Arbiter *, std::size_t(NC_)> vec_cor
per-component element arbiters of the correction scratch vector
std::array< Memory::Arbiter *, std::size_t(NC_)> vec_def
per-component element arbiters of the defect scratch vector
MetaMatrix< DT_, IT_, NC_, NC_ > mat_sys
system matrix A (structure-agnostic; empty cells skipped)
std::array< MetaVectorInfo, std::size_t(NC_)> components
per-component layout (block size + node count)
std::array< GateWrapper< DT_, IT_ >, std::size_t(NC_)> gates
one gate per meta row (some may be empty)
std::array< UnitFilterInfo< DT_, IT_ >, std::size_t(NC_)> def_filters
one defect/correction unit filter per component
std::array< Memory::Arbiter *, std::size_t(NC_)> vec_sol
per-component element arbiters of the solution vector (read-write, iterated in place)
MetaMatrix< DT_, IT_, NC_, NC_ > mat_vanka
AmaVanka approximate-inverse matrix V.
Flat unit-filter (defect/correction) info for a single meta component (phase 1: only UnitFilter / Uni...