Loading...
Searching...
No Matches
StructuredOptions.hpp
Go to the documentation of this file.
1/*
2 * STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
3 * Regents of the University of California, through Lawrence Berkeley
4 * National Laboratory (subject to receipt of any required approvals
5 * from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * If you have questions about your rights to use or distribute this
8 * software, please contact Berkeley Lab's Technology Transfer
9 * Department at TTD@lbl.gov.
10 *
11 * NOTICE. This software is owned by the U.S. Department of Energy. As
12 * such, the U.S. Government has been granted for itself and others
13 * acting on its behalf a paid-up, nonexclusive, irrevocable,
14 * worldwide license in the Software to reproduce, prepare derivative
15 * works, and perform publicly and display publicly. Beginning five
16 * (5) years after the date permission to assert copyright is obtained
17 * from the U.S. Department of Energy, and subject to any subsequent
18 * five (5) year renewals, the U.S. Government is granted for itself
19 * and others acting on its behalf a paid-up, nonexclusive,
20 * irrevocable, worldwide license in the Software to reproduce,
21 * prepare derivative works, distribute copies to the public, perform
22 * publicly and display publicly, and to permit others to do so.
23 *
24 * Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
25 * (Lawrence Berkeley National Lab, Computational Research
26 * Division).
27 */
32#ifndef STRUCTURED_OPTIONS_HPP
33#define STRUCTURED_OPTIONS_HPP
34
35#include <string>
36#include <cassert>
37
38#include "dense/BLASLAPACKWrapper.hpp"
39
40namespace strumpack {
41 namespace structured {
42
43 template<typename real_t> inline real_t default_structured_rel_tol() {
44 return real_t(1e-4);
45 }
46 template<typename real_t> inline real_t default_structured_abs_tol() {
47 return real_t(1e-10);
48 }
49 template<> inline float default_structured_rel_tol() {
50 return 1e-2;
51 }
52 template<> inline float default_structured_abs_tol() {
53 return 1e-5;
54 }
55
60 enum class Type : int
61 {
62 HSS = 0,
64 BLR,
66 HODLR,
69 HODBF,
73 BUTTERFLY,
76 LR,
79 LOSSY,
81 };
82
83 inline std::string get_name(Type a) {
84 switch (a) {
85 case Type::HSS: return "HSS";
86 case Type::BLR: return "BLR";
87 case Type::HODLR: return "HODLR";
88 case Type::HODBF: return "HODBF";
89 case Type::BUTTERFLY: return "BUTTERFLY";
90 case Type::LR: return "LR";
91 case Type::LOSSY: return "LOSSY";
92 case Type::LOSSLESS: return "LOSSLESS";
93 default: return "unknown";
94 }
95 }
96
106 template<typename scalar_t> class StructuredOptions {
107 using real_t = typename RealType<scalar_t>::value_type;
108
109 public:
111 StructuredOptions(Type type) : type_(type) {}
112
113 virtual ~StructuredOptions() {}
114
115 void set_rel_tol(real_t rel_tol) {
116 // assert(rel_tol <= real_t(1.) && rel_tol >= real_t(0.));
117 rel_tol_ = rel_tol;
118 }
119 void set_abs_tol(real_t abs_tol) {
120 // assert(abs_tol >= real_t(0.));
121 abs_tol_ = abs_tol;
122 }
123 void set_leaf_size(int leaf_size) {
124 assert(leaf_size_ > 0);
125 leaf_size_ = leaf_size;
126 }
127 void set_pivot_threshold(real_t thresh) {
128 pivot_ = thresh;
129 }
130 void set_max_rank(int max_rank) {
131 assert(max_rank > 0);
132 max_rank_ = max_rank;
133 }
134 void set_type(Type a) {
135 type_ = a;
136 }
137 void set_verbose(bool verbose) {
138 verbose_ = verbose;
139 }
140
141 real_t rel_tol() const { return rel_tol_; }
142 real_t abs_tol() const { return abs_tol_; }
143 real_t pivot_threshold() const { return pivot_; }
144 int leaf_size() const { return leaf_size_; }
145 int max_rank() const { return max_rank_; }
146 Type type() const { return type_; }
147 bool verbose() const { return verbose_; }
148 bool use_gpu_aware_mpi() const { return use_gpu_aware_mpi_; }
149 virtual void set_from_command_line(int argc, const char* const* cargv);
150
151 virtual void describe_options() const;
152
153 protected:
154 Type type_ = Type::BLR;
155 real_t rel_tol_ = default_structured_rel_tol<real_t>();
156 real_t abs_tol_ = default_structured_abs_tol<real_t>();
157 real_t pivot_ = -1.;
158 int leaf_size_ = 128;
159 int max_rank_ = 5000;
160 bool verbose_ = true;
161 bool use_gpu_aware_mpi_ = std::getenv("STRUMPACK_GPU_AWARE_MPI");
162 };
163
164 } // end namespace structured
165} // end namespace strumpack
166
167
168#endif // STRUCTURED_OPTIONS_HPP
Class containing several options for the StructuredMatrix code and data-structures.
Definition StructuredOptions.hpp:106
Type
Definition StructuredOptions.hpp:61
Definition StrumpackOptions.hpp:44
std::string get_name(ReorderingStrategy method)