Skip to content

Commit 9ecdcf1

Browse files
yhmtsaiMarcelKoch
andcommitted
rename l1 to aggregate_l1 and update parse
Co-authored-by: Marcel Koch <[email protected]>
1 parent df3c982 commit 9ecdcf1

File tree

6 files changed

+52
-32
lines changed

6 files changed

+52
-32
lines changed

core/preconditioner/jacobi.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ Jacobi<ValueType, IndexType>::parse(const config::pnode& config,
8989
params.with_accuracy(
9090
gko::config::get_value<remove_complex<ValueType>>(obj));
9191
}
92-
92+
if (auto& obj = config.get("aggregate_l1")) {
93+
params.with_aggregate_l1(gko::config::get_value<bool>(obj));
94+
}
9395
return params;
9496
}
9597

@@ -331,7 +333,7 @@ void Jacobi<ValueType, IndexType>::generate(const LinOp* system_matrix,
331333
const auto exec = this->get_executor();
332334
if (parameters_.max_block_size == 1) {
333335
std::shared_ptr<LinOp> diag = nullptr;
334-
if (this->get_parameters().l1) {
336+
if (this->get_parameters().aggregate_l1) {
335337
auto csr_mtx = convert_to_with_sorting<const csr_type>(
336338
exec, system_matrix, skip_sorting);
337339
auto diagonal = share(csr_mtx->extract_diagonal());
@@ -360,7 +362,7 @@ void Jacobi<ValueType, IndexType>::generate(const LinOp* system_matrix,
360362
if (parameters_.block_pointers.get_data() == nullptr) {
361363
this->detect_blocks(csr_mtx.get());
362364
}
363-
if (this->get_parameters().l1) {
365+
if (this->get_parameters().aggregate_l1) {
364366
// It should be sorted in the convert_to_with_sorting
365367
// We only use it to generate the inversed block, so we do not need
366368
// to rebuild srow

core/test/config/preconditioner.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ struct Jacobi
277277
config_map["accuracy"] = pnode{1e-2};
278278
param.with_accuracy(
279279
gko::remove_complex<typename changed_type::value_type>{1e-2});
280+
config_map["aggregate_l1"] = pnode{true};
281+
param.with_aggregate_l1(true);
280282
}
281283

282284
template <bool from_reg, typename AnswerType>
@@ -291,6 +293,7 @@ struct Jacobi
291293
ASSERT_EQ(res_param.max_block_stride, ans_param.max_block_stride);
292294
ASSERT_EQ(res_param.skip_sorting, ans_param.skip_sorting);
293295
GKO_ASSERT_ARRAY_EQ(res_param.block_pointers, ans_param.block_pointers);
296+
ASSERT_EQ(res_param.aggregate_l1, ans_param.aggregate_l1);
294297

295298
ASSERT_EQ(res_so.is_block_wise, ans_so.is_block_wise);
296299
ASSERT_EQ(res_so.of_all_blocks, ans_so.of_all_blocks);

core/test/preconditioner/jacobi.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ TYPED_TEST(JacobiFactory, CanSetL1)
120120
{
121121
using Bj = typename TestFixture::Bj;
122122
auto bj_factory =
123-
Bj::build().with_max_block_size(3u).with_l1(true).on(this->exec);
123+
Bj::build().with_max_block_size(3u).with_aggregate_l1(true).on(
124+
this->exec);
124125

125-
EXPECT_TRUE(bj_factory->get_parameters().l1);
126+
EXPECT_TRUE(bj_factory->get_parameters().aggregate_l1);
126127
}
127128

128129

include/ginkgo/core/preconditioner/jacobi.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,12 @@ class Jacobi : public EnableLinOp<Jacobi<ValueType, IndexType>>,
372372
nullptr);
373373

374374
/**
375-
* Use L1 Jacboi.
375+
* Use L1 Jacboi, which is introduced in the paper A. H. Baker et al.
376+
* "Multigrid smoothers for ultraparallel computing."
376377
* If it is true, it generates the preconditioner on A + Diag(sum_{k in
377378
* off diagonal block of i} A_ik) not A.
378379
*/
379-
bool GKO_FACTORY_PARAMETER_SCALAR(l1, false);
380+
bool GKO_FACTORY_PARAMETER_SCALAR(aggregate_l1, false);
380381

381382
private:
382383
// See documentation of storage_optimization parameter for details about

reference/test/preconditioner/jacobi_kernels.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ TYPED_TEST(Jacobi, L1BlockJaocbiConvertsToDense)
11821182
auto bj_factory = Bj::build()
11831183
.with_max_block_size(3u)
11841184
.with_block_pointers(this->block_pointers)
1185-
.with_l1(true)
1185+
.with_aggregate_l1(true)
11861186
.on(this->exec);
11871187
// after L1 modification, it will be the same as the matrix in other tests
11881188
/* test matrix:
@@ -1229,7 +1229,7 @@ TYPED_TEST(Jacobi, L1BlockJaocbiConvertsToDenseWithAdaptivePrecision)
12291229
// make sure group size is 1
12301230
.with_block_pointers(this->block_pointers)
12311231
.with_storage_optimization(this->block_precisions)
1232-
.with_l1(true)
1232+
.with_aggregate_l1(true)
12331233
.on(this->exec);
12341234
// after L1 modification, it will be the same as the matrix in other tests
12351235
/* test matrix:

test/preconditioner/jacobi_kernels.cpp

+36-23
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class Jacobi : public CommonTestFixture {
3030
std::initializer_list<gko::precision_reduction> block_precisions,
3131
std::initializer_list<double> condition_numbers,
3232
gko::uint32 max_block_size, int min_nnz, int max_nnz, int num_rhs = 1,
33-
double accuracy = 0.1, bool skip_sorting = true, bool l1 = false)
33+
double accuracy = 0.1, bool skip_sorting = true,
34+
bool aggregate_l1 = false)
3435
{
3536
std::default_random_engine engine(42);
3637
const auto dim = *(end(block_pointers) - 1);
@@ -61,13 +62,13 @@ class Jacobi : public CommonTestFixture {
6162
.with_max_block_stride(gko::uint32(exec->get_warp_size()))
6263
#endif
6364
.with_skip_sorting(skip_sorting)
64-
.with_l1(l1)
65+
.with_aggregate_l1(aggregate_l1)
6566
.on(ref);
6667
d_bj_factory = Bj::build()
6768
.with_max_block_size(max_block_size)
6869
.with_block_pointers(block_ptrs)
6970
.with_skip_sorting(skip_sorting)
70-
.with_l1(l1)
71+
.with_aggregate_l1(aggregate_l1)
7172
.on(exec);
7273
} else {
7374
bj_factory =
@@ -80,15 +81,15 @@ class Jacobi : public CommonTestFixture {
8081
.with_storage_optimization(block_prec)
8182
.with_accuracy(accuracy)
8283
.with_skip_sorting(skip_sorting)
83-
.with_l1(l1)
84+
.with_aggregate_l1(aggregate_l1)
8485
.on(ref);
8586
d_bj_factory = Bj::build()
8687
.with_max_block_size(max_block_size)
8788
.with_block_pointers(block_ptrs)
8889
.with_storage_optimization(block_prec)
8990
.with_accuracy(accuracy)
9091
.with_skip_sorting(skip_sorting)
91-
.with_l1(l1)
92+
.with_aggregate_l1(aggregate_l1)
9293
.on(exec);
9394
}
9495
b = gko::test::generate_random_matrix<Vec>(
@@ -268,12 +269,16 @@ TEST_F(Jacobi, ScalarInLargeMatrixEquivalentToRef)
268269
mtx->read(data::diag({550, 550},
269270
{{1.0, 1.0, 0.0}, {1.0, 1.0, 0.0}, {1.0, 0.0, 1.0}}));
270271

271-
auto bj =
272-
Bj::build().with_max_block_size(1u).with_l1(true).on(ref)->generate(
273-
mtx);
274-
auto d_bj =
275-
Bj::build().with_max_block_size(1u).with_l1(true).on(exec)->generate(
276-
mtx);
272+
auto bj = Bj::build()
273+
.with_max_block_size(1u)
274+
.with_aggregate_l1(true)
275+
.on(ref)
276+
->generate(mtx);
277+
auto d_bj = Bj::build()
278+
.with_max_block_size(1u)
279+
.with_aggregate_l1(true)
280+
.on(exec)
281+
->generate(mtx);
277282

278283
GKO_ASSERT_MTX_NEAR(gko::as<Bj>(d_bj.get()), gko::as<Bj>(bj.get()), 1e-13);
279284
}
@@ -297,12 +302,16 @@ TEST_F(Jacobi, BlockL1InLargeMatrixEquivalentToRef)
297302
{1.0, 0.0, 1.0, 1.0, 0.0},
298303
{1.0, 0.0, 1.0, 0.0, 0.0}}});
299304

300-
auto bj =
301-
Bj::build().with_max_block_size(3u).with_l1(true).on(ref)->generate(
302-
mtx);
303-
auto d_bj =
304-
Bj::build().with_max_block_size(3u).with_l1(true).on(exec)->generate(
305-
mtx);
305+
auto bj = Bj::build()
306+
.with_max_block_size(3u)
307+
.with_aggregate_l1(true)
308+
.on(ref)
309+
->generate(mtx);
310+
auto d_bj = Bj::build()
311+
.with_max_block_size(3u)
312+
.with_aggregate_l1(true)
313+
.on(exec)
314+
->generate(mtx);
306315

307316
GKO_ASSERT_MTX_NEAR(gko::as<Bj>(d_bj.get()), gko::as<Bj>(bj.get()), 1e-13);
308317
}
@@ -531,12 +540,16 @@ TEST_F(Jacobi, ScalarL1ApplyEquivalentToRef)
531540
d_smtx->copy_from(smtx);
532541
d_sb->copy_from(sb);
533542

534-
auto sj =
535-
Bj::build().with_max_block_size(1u).with_l1(true).on(ref)->generate(
536-
smtx);
537-
auto d_sj =
538-
Bj::build().with_max_block_size(1u).with_l1(true).on(exec)->generate(
539-
d_smtx);
543+
auto sj = Bj::build()
544+
.with_max_block_size(1u)
545+
.with_aggregate_l1(true)
546+
.on(ref)
547+
->generate(smtx);
548+
auto d_sj = Bj::build()
549+
.with_max_block_size(1u)
550+
.with_aggregate_l1(true)
551+
.on(exec)
552+
->generate(d_smtx);
540553

541554
sj->apply(sb, sx);
542555
d_sj->apply(d_sb, d_sx);

0 commit comments

Comments
 (0)