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
39namespace 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
88 ORIGINAL,
91 STABLE,
98 };
99
106
112 enum class CompressionSketch {
113 GAUSSIAN,
115 SJLT
119 };
120
127
128 enum class SJLTAlgo {
129 CHUNK,
131 PERM
133 };
134
140 std::string get_name(SJLTAlgo a);
141
151 template<typename scalar_t> class HSSOptions
152 : public structured::StructuredOptions<scalar_t> {
153
154 public:
155
160 using real_t = typename RealType<scalar_t>::value_type;
161
162 HSSOptions() :
163 structured::StructuredOptions<scalar_t>(structured::Type::HSS) {
164 set_defaults();
165 }
166
168 : structured::StructuredOptions<scalar_t>(sopts) {
169 this->type_ = structured::Type::HSS;
170 }
171
177 void set_d0(int d0) { assert(d0 > 0); d0_ = d0; }
178
186 void set_dd(int dd) { assert(dd > 0); dd_ = dd; }
187
192 void set_p(int p) { assert(p >= 0); p_ = p; }
193
198 void set_nnz0(int nnz0) { assert(nnz0 > 0); nnz0_ = nnz0; }
199
204 void set_nnz(int nnz) { assert(nnz > 0); nnz_ = nnz; }
205
211 random_engine_ = random_engine;
212 }
213
220 random_distribution_ = random_distribution;
221 }
222
230 compress_algo_ = a;
231 }
232
239 compress_sketch_ = a;
240 }
241
248 sjlt_algo_ = a;
249 }
250
251
259 clustering_algo_ = a;
260 }
261
268 void set_approximate_neighbors(int neighbors) {
269 approximate_neighbors_ = neighbors;
270 }
271
280 void set_ann_iterations(int iters) {
281 assert(iters > 0);
282 ann_iterations_ = iters;
283 }
284
290 user_defined_random_ = user_defined_random;
291 }
292
299 sync_ = sync;
300 }
301
306 void set_log_ranks(bool log_ranks) { log_ranks_ = log_ranks; }
307
308
318 int d0() const { return d0_; }
319
327 int nnz0() const { return nnz0_; }
328
337 int nnz() const { return nnz_; }
338
347 int dd() const { return dd_; }
348
354 int p() const { return p_; }
355
361 random::RandomEngine random_engine() const { return random_engine_; }
362
370 return random_distribution_;
371 }
372
379 return compress_algo_;
380 }
381
382 CompressionSketch compression_sketch() const {
383 return compress_sketch_;
384 }
385
386 SJLTAlgo SJLT_algo() const{
387 return sjlt_algo_;
388 }
396 return clustering_algo_;
397 }
398
406 return approximate_neighbors_;
407 }
408
417 int ann_iterations() const { return ann_iterations_; }
418
427 bool user_defined_random() const { return user_defined_random_; }
428
436 bool synchronized_compression() const { return sync_; }
437
446 bool log_ranks() const { return log_ranks_; }
447
456 void set_from_command_line(int argc, const char* const* cargv) override;
457
462 void describe_options() const override;
463
464 private:
465 int d0_ = 128;
466 int dd_ = 64;
467 int nnz0_ = 4;
468 int nnz_ = 4;
469 int p_ = 10;
470 random::RandomEngine random_engine_ =
472 random::RandomDistribution random_distribution_ =
474 bool user_defined_random_ = false;
475 bool log_ranks_ = false;
478 SJLTAlgo sjlt_algo_ = SJLTAlgo::CHUNK;
479 bool sync_ = false;
481 int approximate_neighbors_ = 64;
482 int ann_iterations_ = 5;
483
484 void set_defaults() {
485 this->type_ = structured::Type::HSS;
486 this->rel_tol_ = default_HSS_rel_tol<real_t>();
487 this->abs_tol_ = default_HSS_abs_tol<real_t>();
488 this->leaf_size_ = 512;
489 this->max_rank_ = 50000;
490 }
491 };
492
493 } // end namespace HSS
494} // end namespace strumpack
495
496
497#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:152
void set_synchronized_compression(bool sync)
Definition: HSSOptions.hpp:298
void set_approximate_neighbors(int neighbors)
Definition: HSSOptions.hpp:268
void set_random_engine(random::RandomEngine random_engine)
Definition: HSSOptions.hpp:210
void set_dd(int dd)
Definition: HSSOptions.hpp:186
void describe_options() const override
void set_d0(int d0)
Definition: HSSOptions.hpp:177
void set_nnz0(int nnz0)
Definition: HSSOptions.hpp:198
int p() const
Definition: HSSOptions.hpp:354
random::RandomDistribution random_distribution() const
Definition: HSSOptions.hpp:369
void set_nnz(int nnz)
Definition: HSSOptions.hpp:204
int ann_iterations() const
Definition: HSSOptions.hpp:417
int nnz0() const
Definition: HSSOptions.hpp:327
int dd() const
Definition: HSSOptions.hpp:347
void set_ann_iterations(int iters)
Definition: HSSOptions.hpp:280
bool synchronized_compression() const
Definition: HSSOptions.hpp:436
void set_compression_sketch(CompressionSketch a)
Definition: HSSOptions.hpp:238
bool user_defined_random() const
Definition: HSSOptions.hpp:427
random::RandomEngine random_engine() const
Definition: HSSOptions.hpp:361
int approximate_neighbors() const
Definition: HSSOptions.hpp:405
void set_p(int p)
Definition: HSSOptions.hpp:192
void set_log_ranks(bool log_ranks)
Definition: HSSOptions.hpp:306
int d0() const
Definition: HSSOptions.hpp:318
ClusteringAlgorithm clustering_algorithm() const
Definition: HSSOptions.hpp:395
CompressionAlgorithm compression_algorithm() const
Definition: HSSOptions.hpp:378
void set_compression_algorithm(CompressionAlgorithm a)
Definition: HSSOptions.hpp:229
void set_random_distribution(random::RandomDistribution random_distribution)
Definition: HSSOptions.hpp:219
void set_clustering_algorithm(ClusteringAlgorithm a)
Definition: HSSOptions.hpp:258
bool log_ranks() const
Definition: HSSOptions.hpp:446
int nnz() const
Definition: HSSOptions.hpp:337
void set_from_command_line(int argc, const char *const *cargv) override
void set_user_defined_random(bool user_defined_random)
Definition: HSSOptions.hpp:289
void set_SJLT_algo(SJLTAlgo a)
Definition: HSSOptions.hpp:247
Class containing several options for the StructuredMatrix code and data-structures.
Definition: StructuredOptions.hpp:106
CompressionSketch
Definition: HSSOptions.hpp:112
CompressionAlgorithm
Definition: HSSOptions.hpp:87
SJLTAlgo
Definition: HSSOptions.hpp:128
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:43
ClusteringAlgorithm
Definition: Clustering.hpp:51