Skip to content

Commit 73ab495

Browse files
committed
Address PR review suggestions
1 parent bd8d4cd commit 73ab495

6 files changed

Lines changed: 20 additions & 28 deletions

File tree

core/config/config_helper.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum class LinOpFactoryType : int {
4242
Bicg,
4343
Bicgstab,
4444
Fcg,
45+
PipeCg,
4546
Cgs,
4647
Ir,
4748
Idr,

core/config/registry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ configuration_map generate_config_map()
2323
{"solver::Bicg", parse<LinOpFactoryType::Bicg>},
2424
{"solver::Bicgstab", parse<LinOpFactoryType::Bicgstab>},
2525
{"solver::Fcg", parse<LinOpFactoryType::Fcg>},
26+
{"solver::PipeCg", parse<LinOpFactoryType::PipeCg>},
2627
{"solver::Cgs", parse<LinOpFactoryType::Cgs>},
2728
{"solver::Ir", parse<LinOpFactoryType::Ir>},
2829
{"solver::Idr", parse<LinOpFactoryType::Idr>},

core/config/solver_config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <ginkgo/core/solver/ir.hpp>
2222
#include <ginkgo/core/solver/minres.hpp>
2323
#include <ginkgo/core/solver/multigrid.hpp>
24+
#include <ginkgo/core/solver/pipe_cg.hpp>
2425
#include <ginkgo/core/solver/triangular.hpp>
2526

2627
#include "core/config/config_helper.hpp"
@@ -43,6 +44,7 @@ GKO_PARSE_VALUE_TYPE(Gcr, gko::solver::Gcr);
4344
GKO_PARSE_VALUE_TYPE(Gmres, gko::solver::Gmres);
4445
GKO_PARSE_VALUE_TYPE_BASE(CbGmres, gko::solver::CbGmres);
4546
GKO_PARSE_VALUE_TYPE(Minres, gko::solver::Minres);
47+
GKO_PARSE_VALUE_TYPE(PipeCg, gko::solver::PipeCg);
4648
GKO_PARSE_VALUE_AND_INDEX_TYPE(Direct, gko::experimental::solver::Direct);
4749
GKO_PARSE_VALUE_AND_INDEX_TYPE(LowerTrs, gko::solver::LowerTrs);
4850
GKO_PARSE_VALUE_AND_INDEX_TYPE(UpperTrs, gko::solver::UpperTrs);

core/test/config/solver.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <ginkgo/core/solver/idr.hpp>
2323
#include <ginkgo/core/solver/ir.hpp>
2424
#include <ginkgo/core/solver/minres.hpp>
25+
#include <ginkgo/core/solver/pipe_cg.hpp>
2526
#include <ginkgo/core/solver/triangular.hpp>
2627
#include <ginkgo/core/stop/iteration.hpp>
2728

@@ -127,6 +128,15 @@ struct Fcg
127128
};
128129

129130

131+
struct PipeCg : SolverConfigTest<gko::solver::PipeCg<float>,
132+
gko::solver::PipeCg<double>> {
133+
static pnode::map_type setup_base()
134+
{
135+
return {{"type", pnode{"solver::PipeCg"}}};
136+
}
137+
};
138+
139+
130140
struct Bicg
131141
: SolverConfigTest<gko::solver::Bicg<float>, gko::solver::Bicg<double>> {
132142
static pnode::map_type setup_base()
@@ -513,9 +523,9 @@ class Solver : public ::testing::Test {
513523

514524

515525
using SolverTypes =
516-
::testing::Types<::Cg, ::Fcg, ::Cgs, ::Bicg, ::Bicgstab, ::Ir, ::Idr, ::Gcr,
517-
::Gmres, ::CbGmres, ::Minres, ::Direct, ::LowerTrs,
518-
::UpperTrs>;
526+
::testing::Types<::Cg, ::Fcg, ::Cgs, ::PipeCg, ::Bicg, ::Bicgstab, ::Ir,
527+
::Idr, ::Gcr, ::Gmres, ::CbGmres, ::Minres, ::Direct,
528+
::LowerTrs, ::UpperTrs>;
519529

520530

521531
TYPED_TEST_SUITE(Solver, SolverTypes, TypenameNameGenerator);

core/test/solver/pipe_cg.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
#include "core/test/utils.hpp"
1717

1818

19-
namespace {
20-
21-
2219
template <typename T>
2320
class PipeCg : public ::testing::Test {
2421
protected:
@@ -267,6 +264,3 @@ TYPED_TEST(PipeCg, PassExplicitFactory)
267264
ASSERT_EQ(factory->get_parameters().criteria.front(), stop_factory);
268265
ASSERT_EQ(factory->get_parameters().preconditioner, precond_factory);
269266
}
270-
271-
272-
} // namespace

reference/test/solver/pipe_cg_kernels.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
#include "core/test/utils.hpp"
1919

20-
21-
namespace {
22-
23-
2420
template <typename T>
2521
class PipeCg : public ::testing::Test {
2622
protected:
@@ -173,12 +169,10 @@ TYPED_TEST(PipeCg, KernelStep1)
173169
this->small_r->fill(2);
174170
this->small_z->fill(3);
175171
this->small_w->fill(4);
176-
177172
this->small_p->fill(4);
178173
this->small_q->fill(3);
179174
this->small_f->fill(2);
180175
this->small_g->fill(1);
181-
182176
this->small_rho->at(0) = 2;
183177
this->small_rho->at(1) = 3;
184178
this->small_beta->at(0) = 8;
@@ -204,12 +198,10 @@ TYPED_TEST(PipeCg, KernelStep1DivByZero)
204198
this->small_r->fill(2);
205199
this->small_z->fill(3);
206200
this->small_w->fill(4);
207-
208201
this->small_p->fill(4);
209202
this->small_q->fill(3);
210203
this->small_f->fill(2);
211204
this->small_g->fill(1);
212-
213205
this->small_rho->fill(1);
214206
this->small_beta->fill(0);
215207

@@ -232,12 +224,10 @@ TYPED_TEST(PipeCg, KernelStep2)
232224
this->small_w->fill(2);
233225
this->small_m->fill(3);
234226
this->small_n->fill(4);
235-
236227
this->small_p->fill(4);
237228
this->small_q->fill(3);
238229
this->small_f->fill(2);
239230
this->small_g->fill(1);
240-
241231
this->small_rho->at(0) = -2;
242232
this->small_rho->at(1) = 3;
243233
this->small_prev_rho->at(0) = 4;
@@ -246,7 +236,6 @@ TYPED_TEST(PipeCg, KernelStep2)
246236
this->small_beta->at(1) = 3;
247237
this->small_delta->at(0) = 5;
248238
this->small_delta->at(1) = 6;
249-
250239
this->small_stop.get_data()[1] = this->stopped;
251240

252241
gko::kernels::reference::pipe_cg::step_2(
@@ -270,12 +259,10 @@ TYPED_TEST(PipeCg, KernelStep2DivByZero)
270259
this->small_w->fill(2);
271260
this->small_m->fill(3);
272261
this->small_n->fill(4);
273-
274262
this->small_p->fill(4);
275263
this->small_q->fill(3);
276264
this->small_f->fill(2);
277265
this->small_g->fill(1);
278-
279266
this->small_rho->at(0) = -2;
280267
this->small_rho->at(1) = 3;
281268
this->small_prev_rho->fill(0);
@@ -301,16 +288,15 @@ TYPED_TEST(PipeCg, KernelStep2DivByZero)
301288

302289
TYPED_TEST(PipeCg, KernelStep2BetaZero)
303290
{
291+
using value_type = typename TestFixture::value_type;
304292
this->small_z->fill(1);
305293
this->small_w->fill(1);
306294
this->small_m->fill(1);
307295
this->small_n->fill(1);
308-
309296
this->small_p->fill(1);
310297
this->small_q->fill(1);
311298
this->small_f->fill(1);
312299
this->small_g->fill(1);
313-
314300
this->small_rho->at(0) = 3;
315301
this->small_rho->at(1) = 3;
316302
this->small_prev_rho->at(0) = 3;
@@ -319,7 +305,6 @@ TYPED_TEST(PipeCg, KernelStep2BetaZero)
319305
this->small_beta->at(1) = 4;
320306
this->small_delta->at(0) = 2;
321307
this->small_delta->at(1) = 1;
322-
323308
this->small_stop.get_data()[0].reset();
324309
this->small_stop.get_data()[1].reset();
325310

@@ -331,6 +316,8 @@ TYPED_TEST(PipeCg, KernelStep2BetaZero)
331316
this->small_delta.get(), &this->small_stop);
332317

333318
GKO_ASSERT_MTX_NEAR(this->small_beta, this->small_delta, 0);
319+
GKO_ASSERT_MTX_NEAR(this->small_p, l({{2.0, 1.5}, {2.0, 1.5}}),
320+
r<value_type>::value);
334321
}
335322

336323

@@ -689,6 +676,3 @@ TYPED_TEST(PipeCg, SolvesConjTransposedBigDenseSystem)
689676
GKO_ASSERT_MTX_NEAR(x, l({81.0, 55.0, 45.0, 5.0, 85.0, -10.0}),
690677
r<value_type>::value * 5 * 1e4);
691678
}
692-
693-
694-
} // namespace

0 commit comments

Comments
 (0)