HSSOptions.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  */
33 #ifndef HSS_OPTIONS_HPP
34 #define HSS_OPTIONS_HPP
35 
38 
39 namespace strumpack {
40 
42  namespace HSS {
43 
51  template<typename real_t> inline real_t default_HSS_rel_tol() {
52  return real_t(1e-2);
53  }
59  template<typename real_t> inline real_t default_HSS_abs_tol() {
60  return real_t(1e-8);
61  }
62 
70  template<> inline float default_HSS_rel_tol() {
71  return 1e-1;
72  }
78  template<> inline float default_HSS_abs_tol() {
79  return 1e-5;
80  }
81 
87  enum class CompressionAlgorithm {
88  ORIGINAL,
91  STABLE,
98  };
99 
106 
107 
117  template<typename scalar_t> class HSSOptions
118  : public structured::StructuredOptions<scalar_t> {
119 
120  public:
121 
126  using real_t = typename RealType<scalar_t>::value_type;
127 
128  HSSOptions() :
129  structured::StructuredOptions<scalar_t>(structured::Type::HSS) {
130  set_defaults();
131  }
132 
134  : structured::StructuredOptions<scalar_t>(sopts) {
135  this->type_ = structured::Type::HSS;
136  }
137 
143  void set_d0(int d0) { assert(d0 > 0); d0_ = d0; }
144 
152  void set_dd(int dd) { assert(dd > 0); dd_ = dd; }
153 
158  void set_p(int p) { assert(p >= 0); p_ = p; }
159 
165  random_engine_ = random_engine;
166  }
167 
174  random_distribution_ = random_distribution;
175  }
176 
184  compress_algo_ = a;
185  }
186 
194  clustering_algo_ = a;
195  }
196 
203  void set_approximate_neighbors(int neighbors) {
204  approximate_neighbors_ = neighbors;
205  }
206 
215  void set_ann_iterations(int iters) {
216  assert(iters > 0);
217  ann_iterations_ = iters;
218  }
219 
225  user_defined_random_ = user_defined_random;
226  }
227 
234  sync_ = sync;
235  }
236 
241  void set_log_ranks(bool log_ranks) { log_ranks_ = log_ranks; }
242 
243 
253  int d0() const { return d0_; }
254 
263  int dd() const { return dd_; }
264 
270  int p() const { return p_; }
271 
277  random::RandomEngine random_engine() const { return random_engine_; }
278 
286  return random_distribution_;
287  }
288 
295  return compress_algo_;
296  }
297 
305  return clustering_algo_;
306  }
307 
314  int approximate_neighbors() const {
315  return approximate_neighbors_;
316  }
317 
326  int ann_iterations() const { return ann_iterations_; }
327 
336  bool user_defined_random() const { return user_defined_random_; }
337 
345  bool synchronized_compression() const { return sync_; }
346 
355  bool log_ranks() const { return log_ranks_; }
356 
365  void set_from_command_line(int argc, const char* const* cargv) override;
366 
371  void describe_options() const override;
372 
373  private:
374  int d0_ = 128;
375  int dd_ = 64;
376  int p_ = 10;
377  random::RandomEngine random_engine_ =
379  random::RandomDistribution random_distribution_ =
381  bool user_defined_random_ = false;
382  bool log_ranks_ = false;
384  bool sync_ = false;
386  int approximate_neighbors_ = 64;
387  int ann_iterations_ = 5;
388 
389  void set_defaults() {
390  this->type_ = structured::Type::HSS;
391  this->rel_tol_ = default_HSS_rel_tol<real_t>();
392  this->abs_tol_ = default_HSS_abs_tol<real_t>();
393  this->leaf_size_ = 512;
394  this->max_rank_ = 50000;
395  }
396  };
397 
398  } // end namespace HSS
399 } // end namespace strumpack
400 
401 
402 #endif // HSS_OPTIONS_HPP
Main include file for the different clustering/ordering codes. These ordering codes can be used to de...
Contains the class definition for StructuredOptions, as well as some routines to get default options,...
Class containing several options for the HSS code and data-structures.
Definition: HSSOptions.hpp:118
void set_synchronized_compression(bool sync)
Definition: HSSOptions.hpp:233
void set_approximate_neighbors(int neighbors)
Definition: HSSOptions.hpp:203
void set_random_engine(random::RandomEngine random_engine)
Definition: HSSOptions.hpp:164
void set_dd(int dd)
Definition: HSSOptions.hpp:152
void describe_options() const override
void set_d0(int d0)
Definition: HSSOptions.hpp:143
int p() const
Definition: HSSOptions.hpp:270
random::RandomDistribution random_distribution() const
Definition: HSSOptions.hpp:285
int ann_iterations() const
Definition: HSSOptions.hpp:326
int dd() const
Definition: HSSOptions.hpp:263
void set_ann_iterations(int iters)
Definition: HSSOptions.hpp:215
bool synchronized_compression() const
Definition: HSSOptions.hpp:345
bool user_defined_random() const
Definition: HSSOptions.hpp:336
random::RandomEngine random_engine() const
Definition: HSSOptions.hpp:277
int approximate_neighbors() const
Definition: HSSOptions.hpp:314
void set_p(int p)
Definition: HSSOptions.hpp:158
void set_log_ranks(bool log_ranks)
Definition: HSSOptions.hpp:241
int d0() const
Definition: HSSOptions.hpp:253
ClusteringAlgorithm clustering_algorithm() const
Definition: HSSOptions.hpp:304
CompressionAlgorithm compression_algorithm() const
Definition: HSSOptions.hpp:294
void set_compression_algorithm(CompressionAlgorithm a)
Definition: HSSOptions.hpp:183
void set_random_distribution(random::RandomDistribution random_distribution)
Definition: HSSOptions.hpp:173
void set_clustering_algorithm(ClusteringAlgorithm a)
Definition: HSSOptions.hpp:193
bool log_ranks() const
Definition: HSSOptions.hpp:355
void set_from_command_line(int argc, const char *const *cargv) override
void set_user_defined_random(bool user_defined_random)
Definition: HSSOptions.hpp:224
Class containing several options for the StructuredMatrix code and data-structures.
Definition: StructuredOptions.hpp:106
CompressionAlgorithm
Definition: HSSOptions.hpp:87
real_t default_HSS_abs_tol()
Definition: HSSOptions.hpp:59
real_t default_HSS_rel_tol()
Definition: HSSOptions.hpp:51
std::string get_name(CompressionAlgorithm a)
RandomEngine
Random number engine.
Definition: RandomWrapper.hpp:52
RandomDistribution
Definition: RandomWrapper.hpp:74
Type
Definition: StructuredOptions.hpp:61
Definition: StrumpackOptions.hpp:42
ClusteringAlgorithm
Definition: Clustering.hpp:51