-
Notifications
You must be signed in to change notification settings - Fork 100
Add diag sorting to Schwarz precond w/ l1 smoother #1939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
129e312
001d582
cee911d
00aef87
c3c01fc
900829a
7a12250
49c0aba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,7 @@ GSYMS | |
| GTAGS | ||
| GPATH | ||
| .gitignore | ||
| .cache | ||
|
|
||
| ### OS | ||
| # temporary and backup files | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| #include "core/test/utils.hpp" | ||
| #include "core/test/utils/matrix_generator.hpp" | ||
| #include "core/utils/matrix_utils.hpp" | ||
| #include "ginkgo/core/base/math.hpp" | ||
| #include "test/utils/mpi/common_fixture.hpp" | ||
|
|
||
|
|
||
|
|
@@ -145,7 +146,9 @@ class SchwarzPreconditioner : public CommonMpiTestFixture { | |
|
|
||
| void assert_equal_to_non_distributed_vector( | ||
| std::shared_ptr<dist_vec_type> dist_vec, | ||
| std::shared_ptr<local_vec_type> local_vec) | ||
| std::shared_ptr<local_vec_type> local_vec, | ||
| gko::remove_complex<value_type> mult = | ||
| gko::one<gko::remove_complex<value_type>>()) | ||
| { | ||
| auto host_row_part = row_part->clone(ref); | ||
| auto l_dist_vec = dist_vec->get_local_vector(); | ||
|
|
@@ -156,7 +159,8 @@ class SchwarzPreconditioner : public CommonMpiTestFixture { | |
| local_vec->get_const_values() + | ||
| host_row_part->get_range_bounds()[comm.rank()]), | ||
| l_dist_vec->get_size()[1]); | ||
| GKO_ASSERT_MTX_NEAR(l_dist_vec, vec_view.get(), r<value_type>::value); | ||
| GKO_ASSERT_MTX_NEAR(l_dist_vec, vec_view.get(), | ||
| mult * r<value_type>::value); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -381,3 +385,51 @@ TYPED_TEST(SchwarzPreconditioner, CanApplyPreconditionerWithL1Smoother) | |
| this->assert_equal_to_non_distributed_vector(this->dist_x, | ||
| this->non_dist_x); | ||
| } | ||
|
|
||
|
|
||
| TYPED_TEST(SchwarzPreconditioner, CanApplyPreconditionedSolverWithL1Smoother) | ||
| { | ||
| using value_type = typename TestFixture::value_type; | ||
| using csr = typename TestFixture::local_matrix_type; | ||
| using cg = typename TestFixture::solver_type; | ||
| using prec = typename TestFixture::dist_prec_type; | ||
| using local_matrix_type = typename TestFixture::local_matrix_type; | ||
| constexpr double tolerance = 1e-20; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tolerance should adapt with valuetype. you can get it by |
||
| auto iter_stop = gko::share( | ||
| gko::stop::Iteration::build().with_max_iters(200u).on(this->exec)); | ||
| auto tol_stop = gko::share( | ||
| gko::stop::ResidualNorm<value_type>::build() | ||
| .with_reduction_factor( | ||
| static_cast<gko::remove_complex<value_type>>(tolerance)) | ||
| .on(this->exec)); | ||
| auto non_dist_diag_with_l1 = | ||
| gko::share(gko::matrix::Diagonal<value_type>::create( | ||
| this->exec, 8u, | ||
| gko::array<value_type>(this->exec, {2, 3, 3, 3, 3, 2, 2, 2}))); | ||
| this->dist_solver_factory = | ||
| cg::build() | ||
| .with_preconditioner( | ||
| prec::build() | ||
| .with_local_solver(this->local_solver_factory) | ||
| .with_l1_smoother(true) | ||
| .on(this->exec)) | ||
| .with_criteria(iter_stop, tol_stop) | ||
| .on(this->exec); | ||
| auto dist_solver = this->dist_solver_factory->generate(this->dist_mat); | ||
| this->non_dist_solver_factory = | ||
| cg::build() | ||
| .with_generated_preconditioner(this->local_solver_factory->generate( | ||
| gko::copy_and_convert_to<local_matrix_type>( | ||
| this->exec, non_dist_diag_with_l1))) | ||
|
Comment on lines
+421
to
+423
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not the same matrix. |
||
| .with_criteria(iter_stop, tol_stop) | ||
| .on(this->exec); | ||
| auto non_dist_solver = | ||
| this->non_dist_solver_factory->generate(this->non_dist_mat); | ||
|
|
||
| dist_solver->apply(this->dist_b.get(), this->dist_x.get()); | ||
| non_dist_solver->apply(this->non_dist_b.get(), this->non_dist_x.get()); | ||
|
|
||
| this->assert_equal_to_non_distributed_vector( | ||
| this->dist_x, this->non_dist_x, | ||
| 2); // mult = 2 is needed for the gko::half to work | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.