FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
sor_precond.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
8// includes, FEAT
10#include <kernel/solver/base.hpp>
11
12namespace FEAT
13{
14 namespace Solver
15 {
16 namespace Intern
17 {
18 int cuda_sor_apply(int m, double* y, const double* x, const double* csrVal, const int* csrColInd, int ncolors, double omega,
19 int* colored_row_ptr, int* rows_per_color, int* inverse_row_ptr);
20 template<int block_size_>
21 int cuda_sor_bcsr_apply(int m, double* y, const double* x, const double* csrVal, const int* csrColInd, int ncolors, double omega,
22 int* colored_row_ptr, int* rows_per_color, int* inverse_row_ptr);
23 void cuda_sor_done_symbolic(int* colored_row_ptr, int* rows_per_color, int* inverse_row_ptr);
24 void cuda_sor_init_symbolic(int m, int nnz, const double* csrVal, const int* csrRowPtr, const int* csrColInd, int& ncolors,
25 int*& colored_row_ptr, int*& rows_per_color, int*& inverse_row_ptr);
26 }
27
42 template<typename Matrix_>
44 {
45 public:
46 typedef typename Matrix_::DataType DataType;
47 typedef typename Matrix_::VectorTypeL VectorType;
48
49 virtual void set_omega(DataType omega) = 0;
50
51 virtual void init_symbolic() = 0;
52
53 virtual void done_symbolic() = 0;
54
55 virtual String name() const = 0;
56
57 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) = 0;
58
59 virtual ~SORPrecondBase() {}
60 }; // class SORPrecondBase
61
62 template<PreferredBackend backend_, typename Matrix_, typename Filter_>
64
77 template<typename Filter_, typename DT_, typename IT_>
79 public SORPrecondBase<typename LAFEM::SparseMatrixCSR<DT_, IT_>>
80 {
81 public:
83 typedef DT_ DataType;
84 typedef IT_ IndexType;
85 typedef Filter_ FilterType;
86 typedef typename MatrixType::VectorTypeL VectorType;
87
88 protected:
89 const MatrixType& _matrix;
90 const FilterType& _filter;
91 DataType _omega;
92
93 public:
107 explicit SORPrecondWithBackend(const MatrixType& matrix, const FilterType& filter, const DataType omega = DataType(1)) :
108 _matrix(matrix),
109 _filter(filter),
110 _omega(omega)
111 {
112 if (_matrix.num_cols() != _matrix.num_rows())
113 {
114 XABORTM("Matrix is not square!");
115 }
116 }
117
134 explicit SORPrecondWithBackend(const String& section_name, const PropertyMap* section,
135 const MatrixType& matrix, const FilterType& filter) :
136 _matrix(matrix),
137 _filter(filter),
138 _omega(1)
139 {
140 if (_matrix.num_cols() != _matrix.num_rows())
141 {
142 XABORTM("Matrix is not square!");
143 }
144
145 auto omega_p = section->query("omega");
146 if (omega_p.second && !omega_p.first.parse(this->_omega))
147 throw ParseError(section_name + ".omega", omega_p.first, "a positive float");
148 }
149
151 virtual String name() const override
152 {
153 return "SOR";
154 }
155
163 virtual void set_omega(DataType omega) override
164 {
165 XASSERT(omega > DataType(0));
166 _omega = omega;
167 }
168
169 virtual void init_symbolic() override
170 {
171 }
172
173 virtual void done_symbolic() override
174 {
175 }
176
177 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
178 {
179 XASSERTM(_matrix.num_rows() == vec_cor.size(), "matrix / vector size mismatch!");
180 XASSERTM(_matrix.num_rows() == vec_def.size(), "matrix / vector size mismatch!");
181
182 TimeStamp ts_start;
183
184 // copy in-vector to out-vector
185 vec_cor.copy(vec_def);
186
187 _apply_intern(_matrix, vec_cor, vec_def);
188
189 this->_filter.filter_cor(vec_cor);
190
191 TimeStamp ts_stop;
192 Statistics::add_time_precon(ts_stop.elapsed(ts_start));
193 Statistics::add_flops(_matrix.num_nzes() + 3 * vec_cor.size()); // 2 ops per matrix entry, but only on half of the matrix
194
195 return Status::success;
196 }
197
198 protected:
199 void _apply_intern(const LAFEM::SparseMatrixCSR<DataType, IndexType>& matrix, VectorType& vec_cor, const VectorType& vec_def)
200 {
201 // create pointers
202 Memory::TypedView<DataType> pout(vec_cor.elements_view_rw());
203 const Memory::TypedView<DataType> pin(vec_def.elements_view_r());
204 const Memory::TypedView<DataType> pval(matrix.val_view_r());
205 const Memory::TypedView<IndexType> pcol_idx(matrix.col_idx_view_r());
206 const Memory::TypedView<IndexType> prow_ptr(matrix.row_ptr_view_r());
207 const IndexType n = IndexType(matrix.num_rows());
208
209 // __forward-insertion__
210 // iteration over all rows
211 for (IndexType i(0); i < n; ++i)
212 {
213 IndexType col;
214 DataType d(0);
215 // iteration over all elements on the left side of the main-diagonal
216 for (col = prow_ptr[i]; pcol_idx[col] < i; ++col)
217 {
218 d += pval[col] * pout[pcol_idx[col]];
219 }
220 pout[i] = _omega * (pin[i] - d) / pval[col];
221 }
222 }
223 }; // class SORPrecondWithBackend<generic, SparseMatrixCSR>
224
225 template<typename Filter_, typename DT_, typename IT_, int block_height_, int block_width_>
226 class SORPrecondWithBackend<PreferredBackend::generic, LAFEM::SparseMatrixBCSR<DT_, IT_, block_height_, block_width_>, Filter_> :
227 public SORPrecondBase<typename LAFEM::SparseMatrixBCSR<DT_, IT_, block_height_, block_width_>>
228 {
229 static_assert(block_height_ == block_width_, "only square blocks are supported!");
230 public:
232 typedef Filter_ FilterType;
233 typedef typename MatrixType::VectorTypeL VectorType;
234 typedef typename MatrixType::DataType DataType;
235 typedef typename MatrixType::IndexType IndexType;
236
237 protected:
238 const MatrixType& _matrix;
239 const FilterType& _filter;
240 DataType _omega;
241
242 void _apply_intern(const MatrixType& matrix, VectorType& vec_cor, const VectorType& vec_def)
243 {
244 // create pointers
245 auto* pout(vec_cor.elements());
246 const auto* pin(vec_def.elements());
247 const auto* pval(matrix.val());
248 const IndexType* pcol_idx(matrix.col_idx());
249 const IndexType* prow_ptr(matrix.row_ptr());
250 const IndexType n((IndexType(matrix.num_rows())));
251 typename MatrixType::ValueType inverse;
252
253 // __forward-insertion__
254 // iteration over all rows
255
256 for (IndexType i(0); i < n; ++i)
257 {
258 IndexType col;
259 typename VectorType::ValueType d(0);
260
261 // iteration over all elements on the left side of the main-diagonal
262 for (col = prow_ptr[i]; pcol_idx[col] < i; ++col)
263 {
264 d += pval[col] * pout[pcol_idx[col]];
265 }
266 inverse.set_inverse(pval[col]);
267 pout[i] = _omega * inverse * (pin[i] - d);
268 }
269 }
270
271 public:
285 explicit SORPrecondWithBackend(const MatrixType& matrix, const FilterType& filter, const DataType omega = DataType(1)) :
286 _matrix(matrix),
287 _filter(filter),
288 _omega(omega)
289 {
290 if (_matrix.num_cols() != _matrix.num_rows())
291 {
292 XABORTM("Matrix is not square!");
293 }
294 }
295
312 explicit SORPrecondWithBackend(const String& /*section_name*/, const PropertyMap* section,
313 const MatrixType& matrix, const FilterType& filter) :
314 _matrix(matrix),
315 _filter(filter),
316 _omega(1)
317 {
318 if (_matrix.num_cols() != _matrix.num_rows())
319 {
320 XABORTM("Matrix is not square!");
321 }
322
323 // Check if we have set _krylov_vim
324 auto omega_p = section->query("omega");
325 if (omega_p.second)
326 {
327 set_omega(DataType(std::stod(omega_p.first)));
328 }
329 }
330
332 virtual String name() const override
333 {
334 return "SOR";
335 }
336
344 virtual void set_omega(DataType omega) override
345 {
346 XASSERT(omega > DataType(0));
347 _omega = omega;
348 }
349
350 virtual void init_symbolic() override
351 {
352 }
353
354 virtual void done_symbolic() override
355 {
356 }
357
358 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def)
359 {
360 XASSERTM(_matrix.num_rows() == vec_cor.size(), "matrix / vector size mismatch!");
361 XASSERTM(_matrix.num_rows() == vec_def.size(), "matrix / vector size mismatch!");
362
363 TimeStamp ts_start;
364
365 // copy in-vector to out-vector
366 vec_cor.copy(vec_def);
367
368 _apply_intern(_matrix, vec_cor, vec_def);
369
370 this->_filter.filter_cor(vec_cor);
371
372 TimeStamp ts_stop;
373 Statistics::add_time_precon(ts_stop.elapsed(ts_start));
374 Statistics::add_flops(_matrix.num_nzes_raw() + 3 * vec_cor.size_raw()); // 2 ops per matrix entry, but only on half of the matrix
375
376 return Status::success;
377 }
378 }; // class SORPrecondWithBackend<generic, SparseMatrixBCSR>
379
380#ifdef FEAT_HAVE_CUDA
397 template<typename Filter_>
398 class SORPrecondWithBackend<PreferredBackend::cuda, LAFEM::SparseMatrixCSR<double, unsigned int>, Filter_> :
399 public SORPrecondBase<LAFEM::SparseMatrixCSR<double, unsigned int>>
400 {
401 public:
402 typedef LAFEM::SparseMatrixCSR<double, unsigned int> MatrixType;
403 typedef Filter_ FilterType;
404 typedef typename MatrixType::VectorTypeL VectorType;
405 typedef typename MatrixType::DataType DataType;
406 typedef typename MatrixType::IndexType IndexType;
407
408 protected:
409 const MatrixType& _matrix;
410 const FilterType& _filter;
411 DataType _omega;
412 // row ptr permutation, sorted by color(each color sorted by amount of rows), start/end index per row
413 int* _colored_row_ptr;
414 // amount of rows per color (sorted by amount of rows)
415 int* _rows_per_color;
416 // mapping of idx to native row number
417 int* _inverse_row_ptr;
418 // number of colors
419 int _ncolors;
420
421 public:
435 explicit SORPrecondWithBackend(const MatrixType& matrix, const FilterType& filter, const DataType omega = DataType(1)) :
436 _matrix(matrix),
437 _filter(filter),
438 _omega(omega),
439 _colored_row_ptr(nullptr),
440 _rows_per_color(nullptr),
441 _inverse_row_ptr(nullptr),
442 _ncolors(0)
443 {
444 if (_matrix.num_cols() != _matrix.num_rows())
445 {
446 XABORTM("Matrix is not square!");
447 }
448 }
449
466 explicit SORPrecondWithBackend(const String& /*section_name*/, const PropertyMap* section,
467 const MatrixType& matrix, const FilterType& filter) :
468 _matrix(matrix),
469 _filter(filter),
470 _omega(1),
471 _colored_row_ptr(nullptr),
472 _rows_per_color(nullptr),
473 _inverse_row_ptr(nullptr),
474 _ncolors(0)
475 {
476 if (_matrix.num_cols() != _matrix.num_rows())
477 {
478 XABORTM("Matrix is not square!");
479 }
480
481 // Check if we have set _krylov_vim
482 auto omega_p = section->query("omega");
483 if (omega_p.second)
484 {
485 set_omega(DataType(std::stod(omega_p.first)));
486 }
487 }
488
490 virtual String name() const override
491 {
492 return "SOR";
493 }
494
502 virtual void set_omega(DataType omega) override
503 {
504 XASSERT(omega > DataType(0));
505 _omega = omega;
506 }
507
508 virtual void init_symbolic() override
509 {
510 Memory::TypedView<DataType> a = _matrix.val_view_r(Memory::Location::cuda);
511 // cast from 'unsigned int' to 'int'
512 Memory::TypedView<int> row_ptr(std::forward<Memory::View&&>(_matrix.row_ptr_view_r(Memory::Location::cuda)));
513 Memory::TypedView<int> col_idx(std::forward<Memory::View&&>(_matrix.col_idx_view_r(Memory::Location::cuda)));
514 Intern::cuda_sor_init_symbolic((int)_matrix.num_rows(), (int)_matrix.num_nzes(), a.get_r(), row_ptr.get_r(), col_idx.get_r(), _ncolors,
515 _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
516 }
517
518 virtual void done_symbolic() override
519 {
520 Intern::cuda_sor_done_symbolic(_colored_row_ptr, _rows_per_color, _inverse_row_ptr);
521 }
522
523 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
524 {
525 XASSERTM(_matrix.num_rows() == vec_cor.size(), "matrix / vector size mismatch!");
526 XASSERTM(_matrix.num_rows() == vec_def.size(), "matrix / vector size mismatch!");
527
528 TimeStamp ts_start;
529
530 int status = 0;
531
532 {
533 Memory::TypedView<DataType> vx = vec_cor.elements_view_w(Memory::Location::cuda);
534 const Memory::TypedView<DataType> vb = vec_def.elements_view_r(Memory::Location::cuda);
535 const Memory::TypedView<DataType> a = _matrix.val_view_r(Memory::Location::cuda);
536 // cast from 'unsigned int' to 'int'
537 Memory::TypedView<int> col_idx(std::forward<Memory::View&&>(_matrix.col_idx_view_r(Memory::Location::cuda)));
538
539 status = Intern::cuda_sor_apply((int)vec_cor.size(), vx.get_w(), vb.get_r(), a.get_r(), col_idx.get_r(), _ncolors, _omega, _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
540 }
541
542 this->_filter.filter_cor(vec_cor);
543
544 TimeStamp ts_stop;
545 Statistics::add_time_precon(ts_stop.elapsed(ts_start));
546 Statistics::add_flops(_matrix.num_nzes() + 3 * vec_cor.size()); // 2 ops per matrix entry, but only on half of the matrix
547
548 return (status == 0) ? Status::success : Status::aborted;
549 }
550 }; // class SORPrecondWithBackend<cuda, SparseMatrixCSR>
551
552 template<typename Filter_, int block_height_, int block_width_>
553 class SORPrecondWithBackend<PreferredBackend::cuda, LAFEM::SparseMatrixBCSR<double, unsigned int, block_height_, block_width_>, Filter_> :
554 public SORPrecondBase<typename LAFEM::SparseMatrixBCSR<double, unsigned int, block_height_, block_width_>>
555 {
556 static_assert(block_height_ == block_width_, "only square blocks are supported!");
557 public:
558 typedef LAFEM::SparseMatrixBCSR<double, unsigned int, block_height_, block_width_> MatrixType;
559 typedef Filter_ FilterType;
560 typedef typename MatrixType::VectorTypeL VectorType;
561 typedef typename MatrixType::DataType DataType;
562 typedef typename MatrixType::IndexType IndexType;
563
564 protected:
565 const MatrixType& _matrix;
566 const FilterType& _filter;
567 DataType _omega;
568 // row ptr permutation, sorted by color(each color sorted by amount of rows), start/end index per row
569 int* _colored_row_ptr;
570 // amount of rows per color (sorted by amount of rows)
571 int* _rows_per_color;
572 // mapping of idx to native row number
573 int* _inverse_row_ptr;
574 // number of colors
575 int _ncolors;
576
577 public:
591 explicit SORPrecondWithBackend(const MatrixType& matrix, const FilterType& filter, const DataType omega = DataType(1)) :
592 _matrix(matrix),
593 _filter(filter),
594 _omega(omega),
595 _colored_row_ptr(nullptr),
596 _rows_per_color(nullptr),
597 _inverse_row_ptr(nullptr),
598 _ncolors(0)
599 {
600 if (_matrix.num_cols() != _matrix.num_rows())
601 {
602 XABORTM("Matrix is not square!");
603 }
604 }
605
622 explicit SORPrecondWithBackend(const String& /*section_name*/, const PropertyMap* section,
623 const MatrixType& matrix, const FilterType& filter) :
624 _matrix(matrix),
625 _filter(filter),
626 _omega(1),
627 _colored_row_ptr(nullptr),
628 _rows_per_color(nullptr),
629 _inverse_row_ptr(nullptr),
630 _ncolors(0)
631 {
632 if (_matrix.num_cols() != _matrix.num_rows())
633 {
634 XABORTM("Matrix is not square!");
635 }
636
637 // Check if we have set _krylov_vim
638 auto omega_p = section->query("omega");
639 if (omega_p.second)
640 {
641 set_omega(DataType(std::stod(omega_p.first)));
642 }
643 }
644
646 virtual String name() const override
647 {
648 return "SOR";
649 }
650
658 virtual void set_omega(DataType omega) override
659 {
660 XASSERT(omega > DataType(0));
661 _omega = omega;
662 }
663
664 virtual void init_symbolic() override
665 {
666 Memory::TypedView<DataType> a = _matrix.val_view_raw_r(Memory::Location::cuda);
667 const Memory::TypedView<IndexType> row_ptr = _matrix.row_ptr_view_r(Memory::Location::cuda);
668 const Memory::TypedView<IndexType> col_idx = _matrix.col_idx_view_r(Memory::Location::cuda);
669
670 Intern::cuda_sor_init_symbolic((int)_matrix.num_rows(), (int)_matrix.num_nzes(), a.get_r(), row_ptr.get_r(), col_idx.get_r(), _ncolors,
671 _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
672 }
673
674 virtual void done_symbolic() override
675 {
676 Intern::cuda_sor_done_symbolic(_colored_row_ptr, _rows_per_color, _inverse_row_ptr);
677 }
678
679 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
680 {
681 XASSERTM(_matrix.num_rows() == vec_cor.size(), "matrix / vector size mismatch!");
682 XASSERTM(_matrix.num_rows() == vec_def.size(), "matrix / vector size mismatch!");
683
684 TimeStamp ts_start;
685
686 int status = 0;
687
688 {
689 Memory::TypedView<DataType> vx = vec_cor.elements_view_w(Memory::Location::cuda);
690 const Memory::TypedView<DataType> vb = vec_def.elements_view_r(Memory::Location::cuda);
691 const Memory::TypedView<DataType> a = _matrix.val_view_r(Memory::Location::cuda);
692 const Memory::TypedView<IndexType> col_idx = _matrix.col_idx_view_r(Memory::Location::cuda);
693
694 status = Intern::cuda_sor_bcsr_apply<block_height_>((int)vec_cor.size(), vx.get_w(), vb.get_r(), a.get_r(), col_idx.get_r(), _ncolors, _omega, _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
695 }
696
697 this->_filter.filter_cor(vec_cor);
698
699 TimeStamp ts_stop;
700 Statistics::add_time_precon(ts_stop.elapsed(ts_start));
701 Statistics::add_flops(_matrix.num_nzes_raw() + 3 * vec_cor.size_raw()); // 2 ops per matrix entry, but only on half of the matrix
702
703 return (status == 0) ? Status::success : Status::aborted;
704 }
705 }; // class SORPrecondWithBackend<cuda, SparseMatrixBCSR>
706#endif //FEAT_HAVE_CUDA
707
709 template<PreferredBackend backend_, typename Matrix_, typename Filter_>
711 public SORPrecondBase<Matrix_>
712 {
713 public:
714 template<typename DT_>
715 explicit SORPrecondWithBackend(const Matrix_&, const Filter_&, const DT_)
716 {
717 }
718
719 explicit SORPrecondWithBackend(const Matrix_&, const Filter_&)
720 {
721 }
722
723 explicit SORPrecondWithBackend(const String&, const PropertyMap*, const Matrix_&, const Filter_&)
724 {
725 }
726
727 virtual Status apply(typename Matrix_::VectorTypeL&, const typename Matrix_::VectorTypeL&) override
728 {
729 XABORTM("not implemented yet!");
730 }
731
732 virtual String name() const override
733 {
734 XABORTM("not implemented yet!");
735 }
736
737 virtual void init_symbolic() override
738 {
739 XABORTM("not implemented yet!");
740 }
741
742 virtual void done_symbolic() override
743 {
744 XABORTM("not implemented yet!");
745 }
746
747 virtual void set_omega(typename Matrix_::DataType /*omega*/) override
748 {
749 XABORTM("not implemented yet!");
750 }
751 };
752
765 template<typename Matrix_, typename Filter_>
766 class SORPrecond : public SolverBase<typename Matrix_::VectorTypeL>
767 {
768 private:
769 std::shared_ptr<SORPrecondBase<Matrix_>> _impl;
770
771 public:
772 typedef Matrix_ MatrixType;
773 typedef Filter_ FilterType;
774 typedef typename MatrixType::VectorTypeL VectorType;
775 typedef typename MatrixType::DataType DataType;
776
779
780 public:
797 SORPrecond(PreferredBackend backend, const MatrixType& matrix, const FilterType& filter, DataType omega = DataType(1))
798 {
799 if (backend == PreferredBackend::generic)
800 {
801 }
802 else //if(backend == PreferredBackend::cuda)
803 {
804 }
805
806 switch (backend)
807 {
809 _impl = std::make_shared<SORPrecondWithBackend<PreferredBackend::cuda, Matrix_, Filter_>>(matrix, filter, omega);
810 break;
813 default:
814 _impl = std::make_shared<SORPrecondWithBackend<PreferredBackend::generic, Matrix_, Filter_>>(matrix, filter, omega);
815 }
816 }
817
837 SORPrecond(const String& section_name, const PropertyMap* section, PreferredBackend backend, const MatrixType& matrix, const FilterType& filter, DataType omega = DataType(1)) :
838 BaseClass(section_name, section)
839 {
840 switch (backend)
841 {
843 _impl = std::make_shared<SORPrecondWithBackend<PreferredBackend::cuda, Matrix_, Filter_>>(section_name, section, matrix, filter, omega);
844 break;
847 default:
848 _impl = std::make_shared<SORPrecondWithBackend<PreferredBackend::generic, Matrix_, Filter_>>(section_name, section, matrix, filter, omega);
849 }
850 }
851
855 virtual ~SORPrecond()
856 {
857 }
858
860 virtual String name() const override
861 {
862 return _impl->name();
863 }
864
872 virtual void set_omega(DataType omega)
873 {
874 _impl->set_omega(omega);
875 }
876
877 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
878 {
879 return _impl->apply(vec_cor, vec_def);
880 }
881
882 virtual void init_symbolic() override
883 {
884 _impl->init_symbolic();
885 }
886
887 virtual void done_symbolic() override
888 {
889 _impl->done_symbolic();
890 }
891 }; // class SORPrecond
892
911 template<typename Matrix_, typename Filter_>
912 inline std::shared_ptr<SORPrecond<Matrix_, Filter_>> new_sor_precond(PreferredBackend backend,
913 const Matrix_& matrix, const Filter_& filter,
914 const typename Matrix_::DataType omega = typename Matrix_::DataType(1))
915 {
916 return std::make_shared<SORPrecond<Matrix_, Filter_>>(backend, matrix, filter, omega);
917 }
918
940 template<typename Matrix_, typename Filter_>
941 inline std::shared_ptr<SORPrecond<Matrix_, Filter_>> new_sor_precond(
942 const String& section_name, const PropertyMap* section, PreferredBackend backend,
943 const Matrix_& matrix, const Filter_& filter)
944 {
945 return std::make_shared<SORPrecond<Matrix_, Filter_>>(section_name, section, backend, matrix, filter);
946 }
947 } // namespace Solver
948} // namespace FEAT
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
#define XASSERT(expr)
Assertion macro definition.
Definition: assertion.hpp:262
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
FEAT Kernel base header.
CSR based blocked sparse matrix.
Index num_rows() const
Retrieve matrix row count.
Intern::BCSRVectorHelper< DT_, IT_, block_height_ >::VectorType VectorTypeL
Compatible L-vector type.
Index num_nzes_raw() const
Returns the scalar matrix nonzero element count.
Index num_cols() const
Retrieve matrix column count.
CSR based sparse matrix.
Index num_cols() const
Retrieve matrix column count.
Index num_rows() const
Retrieve matrix row count.
Index num_nzes() const
Retrieve non zero element count.
Class for parser related errors.
Definition: exception.hpp:132
A class organizing a tree of key-value pairs.
std::pair< String, bool > query(String key_path) const
Queries a value by its key path.
Inheritances inside sor_precond.hpp.
Definition: sor_precond.hpp:44
SOR preconditioner implementation.
virtual void set_omega(DataType omega)
Sets the damping parameter.
virtual void init_symbolic() override
Symbolic initialization method.
SolverBase< VectorType > BaseClass
Our base class.
SORPrecond(PreferredBackend backend, const MatrixType &matrix, const FilterType &filter, DataType omega=DataType(1))
Constructor.
virtual String name() const override
Returns the name of the solver.
SORPrecond(const String &section_name, const PropertyMap *section, PreferredBackend backend, const MatrixType &matrix, const FilterType &filter, DataType omega=DataType(1))
Constructor using a PropertyMap.
virtual ~SORPrecond()
Empty virtual destructor.
virtual void done_symbolic() override
Symbolic finalization method.
SORPrecondWithBackend(const String &section_name, const PropertyMap *section, const MatrixType &matrix, const FilterType &filter)
Constructor using a PropertyMap.
SORPrecondWithBackend(const MatrixType &matrix, const FilterType &filter, const DataType omega=DataType(1))
Constructor.
SORPrecondWithBackend(const String &, const PropertyMap *section, const MatrixType &matrix, const FilterType &filter)
Constructor using a PropertyMap.
SORPrecondWithBackend(const MatrixType &matrix, const FilterType &filter, const DataType omega=DataType(1))
Constructor.
Dummy class for not implemented specializations.
Polymorphic solver interface.
Definition: base.hpp:183
static void add_flops(Index flops)
Add an amount of flops to the global flop counter.
Definition: statistics.hpp:206
String class implementation.
Definition: string.hpp:47
Tiny Matrix class template.
CUDA_HOST_DEVICE Matrix & set_inverse(const Matrix< T_, m_, n_, sma_, sna_ > &a)
Sets this matrix to the inverse of another matrix.
Status
Solver status return codes enumeration.
Definition: base.hpp:47
@ success
solving successful (convergence criterion fulfilled)
@ aborted
premature abort (solver aborted due to internal errors or preconditioner failure)
std::shared_ptr< SORPrecond< Matrix_, Filter_ > > new_sor_precond(PreferredBackend backend, const Matrix_ &matrix, const Filter_ &filter, const typename Matrix_::DataType omega=typename Matrix_::DataType(1))
Creates a new SORPrecond solver object.
FEAT namespace.
Definition: adjactor.hpp:12
PreferredBackend
The backend that shall be used in all compute heavy calculations.
Definition: backend.hpp:18