diff --git a/benchmark/utils/generator.hpp b/benchmark/utils/generator.hpp index 25e8f6f81ce..6b173651aa3 100644 --- a/benchmark/utils/generator.hpp +++ b/benchmark/utils/generator.hpp @@ -223,9 +223,11 @@ struct DistributedDefaultSystemGenerator { const gko::matrix_data& data, json* spmv_case = nullptr) const { - auto part = gko::experimental::distributed:: - Partition::build_from_global_size_uniform( - exec, comm.size(), static_cast(data.size[0])); + auto part = gko::share( + gko::experimental::distributed::Partition:: + build_from_global_size_uniform( + exec, comm.size(), + static_cast(data.size[0]))); auto formats = split(format_name, '-'); if (formats.size() != 2) { throw std::runtime_error{"Invalid distributed format specifier " + diff --git a/reference/test/distributed/matrix_kernels.cpp b/reference/test/distributed/matrix_kernels.cpp index eb2473fbfda..302e16a2d6f 100644 --- a/reference/test/distributed/matrix_kernels.cpp +++ b/reference/test/distributed/matrix_kernels.cpp @@ -46,10 +46,7 @@ class Matrix : public ::testing::Test { local_values{ref}, non_local_row_idxs{ref}, non_local_col_idxs{ref}, - non_local_values{ref}, - gather_idxs{ref}, - recv_sizes{ref}, - non_local_to_global{ref} + non_local_values{ref} {} void validate( @@ -72,56 +69,50 @@ class Matrix : public ::testing::Test { std::tuple, std::initializer_list, std::initializer_list, std::initializer_list>> - non_local_entries, - std::initializer_list> - gather_idx_entries, - std::initializer_list> - recv_sizes_entries) + non_local_entries) { std::vector> ref_locals; - std::vector> + std::vector< + std::tuple, gko::array, + gko::array, gko::array>> ref_non_locals; - std::vector> ref_gather_idxs; - std::vector> ref_recv_sizes; auto input = gko::device_matrix_data{ ref, size, gko::array{ref, input_rows}, gko::array{ref, input_cols}, gko::array{ref, input_vals}}; - this->recv_sizes.resize_and_reset( - static_cast(row_partition->get_num_parts())); for (auto entry : local_entries) { ref_locals.emplace_back(ref, std::get<0>(entry), std::get<1>(entry), std::get<2>(entry), std::get<3>(entry)); } for (auto entry : non_local_entries) { - ref_non_locals.emplace_back(ref, std::get<0>(entry), - std::get<1>(entry), std::get<2>(entry), - std::get<3>(entry)); - } - for (auto entry : gather_idx_entries) { - ref_gather_idxs.emplace_back(ref, entry); - } - for (auto entry : recv_sizes_entries) { - ref_recv_sizes.emplace_back(ref, entry); + ref_non_locals.emplace_back( + std::get<0>(entry), + gko::array{ref, std::get<1>(entry)}, + gko::array{ref, std::get<2>(entry)}, + gko::array{ref, std::get<3>(entry)}); } for (comm_index_type part = 0; part < row_partition->get_num_parts(); ++part) { - gko::kernels::reference::distributed_matrix::build_local_nonlocal( - ref, input, row_partition.get(), col_partition.get(), part, - local_row_idxs, local_col_idxs, local_values, - non_local_row_idxs, non_local_col_idxs, non_local_values, - gather_idxs, recv_sizes, non_local_to_global); - - assert_device_matrix_data_equal(local_row_idxs, local_col_idxs, - local_values, ref_locals[part]); - assert_device_matrix_data_equal( - non_local_row_idxs, non_local_col_idxs, non_local_values, - ref_non_locals[part]); - GKO_ASSERT_ARRAY_EQ(gather_idxs, ref_gather_idxs[part]); - GKO_ASSERT_ARRAY_EQ(recv_sizes, ref_recv_sizes[part]); + gko::kernels::reference::distributed_matrix:: + separate_local_nonlocal( + ref, input, row_partition.get(), col_partition.get(), part, + local_row_idxs, local_col_idxs, local_values, + non_local_row_idxs, non_local_col_idxs, non_local_values); + + + auto local_arrays = ref_locals[part].empty_out(); + GKO_ASSERT_ARRAY_EQ(local_row_idxs, local_arrays.row_idxs); + GKO_ASSERT_ARRAY_EQ(local_col_idxs, local_arrays.col_idxs); + GKO_ASSERT_ARRAY_EQ(local_values, local_arrays.values); + GKO_ASSERT_ARRAY_EQ(non_local_row_idxs, + std::get<1>(ref_non_locals[part])); + GKO_ASSERT_ARRAY_EQ(non_local_col_idxs, + std::get<2>(ref_non_locals[part])); + GKO_ASSERT_ARRAY_EQ(non_local_values, + std::get<3>(ref_non_locals[part])); } } @@ -165,18 +156,15 @@ class Matrix : public ::testing::Test { gko::array local_col_idxs; gko::array local_values; gko::array non_local_row_idxs; - gko::array non_local_col_idxs; + gko::array non_local_col_idxs; gko::array non_local_values; - gko::array gather_idxs; - gko::array recv_sizes; - gko::array non_local_to_global; }; TYPED_TEST_SUITE(Matrix, gko::test::ValueLocalGlobalIndexTypes, TupleTypenameNameGenerator); -TYPED_TEST(Matrix, BuildsLocalNonLocalEmpty) +TYPED_TEST(Matrix, SeparateLocalNonLocalEmpty) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -194,12 +182,11 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalEmpty) std::make_tuple(gko::dim<2>{3, 3}, I{}, I{}, I{})}, {std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{}), std::make_tuple(gko::dim<2>{3, 0}, I{}, I{}, I{}), - std::make_tuple(gko::dim<2>{3, 0}, I{}, I{}, I{})}, - {{}, {}, {}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}); + std::make_tuple(gko::dim<2>{3, 0}, I{}, I{}, I{})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalSmall) +TYPED_TEST(Matrix, SeparateLocalNonLocalSmall) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -216,12 +203,11 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalSmall) {std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{0}, I{4}), std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{0}, I{1})}, {std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{0}, I{3}), - std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{0}, I{2})}, - {{0}, {0}}, {{0, 1}, {1, 0}}); + std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{1}, I{2})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalNoNonLocal) +TYPED_TEST(Matrix, SeparateLocalNonLocalNoNonLocal) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -243,12 +229,11 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalNoNonLocal) I{3, 4, 7})}, {std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{}), std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{}), - std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{})}, - {{}, {}, {}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}); + std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalNoLocal) +TYPED_TEST(Matrix, SeparateLocalNonLocalNoLocal) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -265,16 +250,15 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalNoLocal) {std::make_tuple(gko::dim<2>{2, 2}, I{}, I{}, I{}), std::make_tuple(gko::dim<2>{2, 2}, I{}, I{}, I{}), std::make_tuple(gko::dim<2>{2, 2}, I{}, I{}, I{})}, - {std::make_tuple(gko::dim<2>{2, 1}, I{1}, I{0}, I{6}), - std::make_tuple(gko::dim<2>{2, 3}, I{0, 0, 1}, I{2, 1, 0}, + {std::make_tuple(gko::dim<2>{2, 1}, I{1}, I{1}, I{6}), + std::make_tuple(gko::dim<2>{2, 3}, I{0, 0, 1}, I{1, 3, 2}, I{1, 2, 8}), - std::make_tuple(gko::dim<2>{2, 2}, I{0, 1}, I{1, 0}, - I{5, 7})}, - {{0}, {0, 1, 0}, {1, 1}}, {{0, 0, 1}, {2, 0, 1}, {1, 1, 0}}); + std::make_tuple(gko::dim<2>{2, 2}, I{0, 1}, I{5, 3}, + I{5, 7})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalMixed) +TYPED_TEST(Matrix, SeparateLocalNonLocalMixed) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -287,26 +271,26 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalMixed) this->validate( gko::dim<2>{6, 6}, partition, partition, + // clang-format on {0, 0, 0, 0, 1, 1, 1, 2, 3, 3, 4, 4, 5, 5}, {0, 1, 3, 5, 1, 4, 5, 3, 1, 2, 3, 4, 0, 2}, {11, 1, 2, 12, 13, 14, 5, 15, 6, 16, 7, 17, 18, 8}, - + // clang-format off {std::make_tuple(gko::dim<2>{2, 2}, I{0, 1}, I{1, 0}, I{15, 16}), std::make_tuple(gko::dim<2>{2, 2}, I{0, 0, 1}, I{0, 1, 0}, I{11, 12, 18}), std::make_tuple(gko::dim<2>{2, 2}, I{0, 0, 1}, I{0, 1, 1}, I{13, 14, 17})}, - {std::make_tuple(gko::dim<2>{2, 1}, I{1}, I{0}, I{6}), - std::make_tuple(gko::dim<2>{2, 3}, I{0, 0, 1}, I{2, 1, 0}, + {std::make_tuple(gko::dim<2>{2, 1}, I{1}, I{1}, I{6}), + std::make_tuple(gko::dim<2>{2, 3}, I{0, 0, 1}, I{1, 3, 2}, I{1, 2, 8}), - std::make_tuple(gko::dim<2>{2, 2}, I{0, 1}, I{1, 0}, - I{5, 7})}, - {{0}, {0, 1, 0}, {1, 1}}, {{0, 0, 1}, {2, 0, 1}, {1, 1, 0}}); + std::make_tuple(gko::dim<2>{2, 2}, I{0, 1}, I{5, 3}, + I{5, 7})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalEmptyWithColPartition) +TYPED_TEST(Matrix, SeparateLocalNonLocalEmptyWithColPartition) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -329,12 +313,11 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalEmptyWithColPartition) std::make_tuple(gko::dim<2>{3, 3}, I{}, I{}, I{})}, {std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{}), std::make_tuple(gko::dim<2>{3, 0}, I{}, I{}, I{}), - std::make_tuple(gko::dim<2>{3, 0}, I{}, I{}, I{})}, - {{}, {}, {}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}); + std::make_tuple(gko::dim<2>{3, 0}, I{}, I{}, I{})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalSmallWithColPartition) +TYPED_TEST(Matrix, SeparateLocalNonLocalSmallWithColPartition) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -354,12 +337,11 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalSmallWithColPartition) {1, 2, 3, 4}, {std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{0}, I{3}), std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{0}, I{2})}, - {std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{0}, I{4}), - std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{0}, I{1})}, - {{0}, {0}}, {{0, 1}, {1, 0}}); + {std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{1}, I{4}), + std::make_tuple(gko::dim<2>{1, 1}, I{0}, I{0}, I{1})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalNoNonLocalWithColPartition) +TYPED_TEST(Matrix, SeparateLocalNonLocalNoNonLocalWithColPartition) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -384,12 +366,11 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalNoNonLocalWithColPartition) I{4, 5, 6})}, {std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{}), std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{}), - std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{})}, - {{}, {}, {}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}); + std::make_tuple(gko::dim<2>{2, 0}, I{}, I{}, I{})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalNoLocalWithColPartition) +TYPED_TEST(Matrix, SeparateLocalNonLocalNoLocalWithColPartition) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -410,17 +391,16 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalNoLocalWithColPartition) {std::make_tuple(gko::dim<2>{2, 2}, I{}, I{}, I{}), std::make_tuple(gko::dim<2>{2, 2}, I{}, I{}, I{}), std::make_tuple(gko::dim<2>{2, 2}, I{}, I{}, I{})}, - {std::make_tuple(gko::dim<2>{2, 3}, I{0, 1, 0}, I{1, 2, 0}, + {std::make_tuple(gko::dim<2>{2, 3}, I{0, 1, 0}, I{2, 3, 5}, I{1, 2, 3}), std::make_tuple(gko::dim<2>{2, 2}, I{0, 1}, I{0, 1}, I{4, 5}), - std::make_tuple(gko::dim<2>{2, 2}, I{0, 0}, I{0, 1}, - I{6, 7})}, - {{1, 0, 1}, {0, 1}, {1, 0}}, {{0, 1, 2}, {2, 0, 0}, {1, 1, 0}}); + std::make_tuple(gko::dim<2>{2, 2}, I{0, 0}, I{1, 4}, + I{6, 7})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalMixedWithColPartition) +TYPED_TEST(Matrix, SeparateLocalNonLocalMixedWithColPartition) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -436,9 +416,11 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalMixedWithColPartition) this->ref, col_mapping, num_parts); this->validate(gko::dim<2>{6, 6}, partition, col_partition, + // clang-format off {2, 3, 3, 0, 5, 1, 4, 2, 3, 2, 0, 0, 1, 1, 4, 4}, - {0, 0, 1, 5, 4, 2, 2, 3, 2, 4, 1, 2, 4, 5, 0, 5}, + { 0, 0, 1, 5, 4, 2, 2, 3, 2, 4, 1, 2, 4, 5, 0, 5}, {11, 12, 13, 14, 15, 16, 17, 1, 2, 3, 4, 5, 6, 7, 8, 9}, + // clang-format on {std::make_tuple(gko::dim<2>{2, 2}, I{0, 1, 1}, I{0, 0, 1}, I{11, 12, 13}), std::make_tuple(gko::dim<2>{2, 2}, I{0, 1}, @@ -446,17 +428,15 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalMixedWithColPartition) std::make_tuple(gko::dim<2>{2, 2}, I{0, 1}, I{0, 0}, I{16, 17})}, {std::make_tuple(gko::dim<2>{2, 3}, I{0, 1, 0}, - I{2, 1, 0}, I{1, 2, 3}), + I{3, 2, 4}, I{1, 2, 3}), std::make_tuple(gko::dim<2>{2, 2}, I{0, 0}, - I{0, 1}, I{4, 5}), + I{1, 2}, I{4, 5}), std::make_tuple(gko::dim<2>{2, 3}, I{0, 0, 1, 1}, - I{1, 2, 0, 2}, I{6, 7, 8, 9})}, - {{0, 0, 1}, {1, 0}, {0, 0, 1}}, - {{0, 1, 2}, {1, 0, 1}, {1, 2, 0}}); + I{4, 5, 0, 5}, I{6, 7, 8, 9})}); } -TYPED_TEST(Matrix, BuildsLocalNonLocalNonSquare) +TYPED_TEST(Matrix, SeparateLocalNonLocalNonSquare) { using lit = typename TestFixture::local_index_type; using git = typename TestFixture::global_index_type; @@ -473,76 +453,22 @@ TYPED_TEST(Matrix, BuildsLocalNonLocalNonSquare) this->validate( gko::dim<2>{6, 4}, partition, col_partition, - {2, 3, 0, 1, 4, 3, 3, 0, 1, 4}, {0, 0, 3, 2, 1, 2, 3, 0, 3, 3}, + // clang-format off + {2, 3, 0, 1, 4, 3, 3, 0, 1, 4}, + {0, 0, 3, 2, 1, 2, 3, 0, 3, 3}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + // clang-format on {std::make_tuple(gko::dim<2>{2, 1}, I{0, 1}, I{0, 0}, I{1, 2}), std::make_tuple(gko::dim<2>{2, 1}, I{0}, I{0}, I{3}), std::make_tuple(gko::dim<2>{2, 2}, I{0, 1}, I{1, 0}, I{4, 5})}, - {std::make_tuple(gko::dim<2>{2, 2}, I{1, 1}, I{1, 0}, + {std::make_tuple(gko::dim<2>{2, 2}, I{1, 1}, I{2, 3}, I{6, 7}), std::make_tuple(gko::dim<2>{2, 1}, I{0}, I{0}, I{8}), - std::make_tuple(gko::dim<2>{2, 1}, I{0, 1}, I{0, 0}, - I{9, 10})}, - {{0, 1}, {0}, {0}}, {{0, 1, 1}, {1, 0, 0}, {0, 1, 0}}); + std::make_tuple(gko::dim<2>{2, 1}, I{0, 1}, I{3, 3}, + I{9, 10})}); } -TYPED_TEST(Matrix, BuildGhostMapContinuous) -{ - using value_type = typename TestFixture::value_type; - using local_index_type = typename TestFixture::local_index_type; - using global_index_type = typename TestFixture::global_index_type; - this->mapping = {this->ref, {0, 0, 0, 1, 1, 2, 2}}; - constexpr comm_index_type num_parts = 3; - auto partition = gko::experimental::distributed::Partition< - local_index_type, global_index_type>::build_from_mapping(this->ref, - this->mapping, - num_parts); - this->recv_sizes.resize_and_reset(num_parts + 1); - gko::array result[num_parts] = { - {this->ref, {3}}, {this->ref, {0, 6}}, {this->ref, {4}}}; - - for (int local_id = 0; local_id < num_parts; ++local_id) { - gko::kernels::reference::distributed_matrix::build_local_nonlocal( - this->ref, this->create_input_full_rank(), partition.get(), - partition.get(), local_id, this->local_row_idxs, - this->local_col_idxs, this->local_values, this->non_local_row_idxs, - this->non_local_col_idxs, this->non_local_values, this->gather_idxs, - this->recv_sizes, this->non_local_to_global); - - GKO_ASSERT_ARRAY_EQ(result[local_id], this->non_local_to_global); - } -} - -TYPED_TEST(Matrix, BuildGhostMapScattered) -{ - using value_type = typename TestFixture::value_type; - using local_index_type = typename TestFixture::local_index_type; - using global_index_type = typename TestFixture::global_index_type; - this->mapping = {this->ref, {0, 1, 2, 0, 1, 2, 0}}; - constexpr comm_index_type num_parts = 3; - auto partition = gko::experimental::distributed::Partition< - local_index_type, global_index_type>::build_from_mapping(this->ref, - this->mapping, - num_parts); - this->recv_sizes.resize_and_reset(num_parts + 1); - gko::array result[num_parts] = { - {this->ref, {5}}, - {this->ref, {6, 2}}, - {this->ref, {4}}}; // the columns are sorted by their part_id - - for (int local_id = 0; local_id < num_parts; ++local_id) { - gko::kernels::reference::distributed_matrix::build_local_nonlocal( - this->ref, this->create_input_full_rank(), partition.get(), - partition.get(), local_id, this->local_row_idxs, - this->local_col_idxs, this->local_values, this->non_local_row_idxs, - this->non_local_col_idxs, this->non_local_values, this->gather_idxs, - this->recv_sizes, this->non_local_to_global); - - GKO_ASSERT_ARRAY_EQ(result[local_id], this->non_local_to_global); - } -} - } // namespace diff --git a/test/distributed/matrix_kernels.cpp b/test/distributed/matrix_kernels.cpp index 8342898506d..5e3677db2f4 100644 --- a/test/distributed/matrix_kernels.cpp +++ b/test/distributed/matrix_kernels.cpp @@ -6,7 +6,6 @@ #include -#include #include @@ -15,8 +14,6 @@ #include #include -#include -#include #include "core/test/utils.hpp" @@ -35,7 +32,6 @@ class Matrix : public CommonTestFixture { 1, decltype(ValueLocalGlobalIndexType())>::type; using global_index_type = typename std::tuple_element< 2, decltype(ValueLocalGlobalIndexType())>::type; - using Mtx = gko::matrix::Csr; Matrix() : engine(42) {} @@ -65,34 +61,23 @@ class Matrix : public CommonTestFixture { gko::array d_local_col_idxs{exec}; gko::array d_local_values{exec}; gko::array non_local_row_idxs{ref}; - gko::array non_local_col_idxs{ref}; + gko::array non_local_col_idxs{ref}; gko::array non_local_values{ref}; gko::array d_non_local_row_idxs{exec}; - gko::array d_non_local_col_idxs{exec}; + gko::array d_non_local_col_idxs{exec}; gko::array d_non_local_values{exec}; - gko::array gather_idxs{ref}; - gko::array d_gather_idxs{exec}; - gko::array recv_sizes{ - ref, - static_cast(row_partition->get_num_parts())}; - gko::array d_recv_sizes{ - exec, - static_cast(row_partition->get_num_parts())}; - gko::array local_to_global_col{ref}; - gko::array d_local_to_global_col{exec}; - - gko::kernels::reference::distributed_matrix::build_local_nonlocal( - ref, input, row_partition.get(), col_partition.get(), part, - local_row_idxs, local_col_idxs, local_values, - non_local_row_idxs, non_local_col_idxs, non_local_values, - gather_idxs, recv_sizes, local_to_global_col); + + gko::kernels::reference::distributed_matrix:: + separate_local_nonlocal( + ref, input, row_partition.get(), col_partition.get(), part, + local_row_idxs, local_col_idxs, local_values, + non_local_row_idxs, non_local_col_idxs, non_local_values); gko::kernels::EXEC_NAMESPACE::distributed_matrix:: - build_local_nonlocal( + separate_local_nonlocal( exec, d_input, d_row_partition.get(), d_col_partition.get(), part, d_local_row_idxs, d_local_col_idxs, d_local_values, d_non_local_row_idxs, d_non_local_col_idxs, - d_non_local_values, d_gather_idxs, d_recv_sizes, - d_local_to_global_col); + d_non_local_values); GKO_ASSERT_ARRAY_EQ(local_row_idxs, d_local_row_idxs); GKO_ASSERT_ARRAY_EQ(local_col_idxs, d_local_col_idxs); @@ -100,9 +85,6 @@ class Matrix : public CommonTestFixture { GKO_ASSERT_ARRAY_EQ(non_local_row_idxs, d_non_local_row_idxs); GKO_ASSERT_ARRAY_EQ(non_local_col_idxs, d_non_local_col_idxs); GKO_ASSERT_ARRAY_EQ(non_local_values, d_non_local_values); - GKO_ASSERT_ARRAY_EQ(gather_idxs, d_gather_idxs); - GKO_ASSERT_ARRAY_EQ(recv_sizes, d_recv_sizes); - GKO_ASSERT_ARRAY_EQ(local_to_global_col, d_local_to_global_col); } } diff --git a/test/mpi/matrix.cpp b/test/mpi/matrix.cpp index 8f22c546185..aad699b541e 100644 --- a/test/mpi/matrix.cpp +++ b/test/mpi/matrix.cpp @@ -291,10 +291,10 @@ class Matrix : public CommonMpiTestFixture { gko::dim<2> size; - std::unique_ptr row_part; - std::unique_ptr col_part; - std::unique_ptr row_part_large; - std::unique_ptr col_part_large; + std::shared_ptr row_part; + std::shared_ptr col_part; + std::shared_ptr row_part_large; + std::shared_ptr col_part_large; std::unique_ptr dist_mat; std::unique_ptr dist_mat_large; diff --git a/test/mpi/preconditioner/schwarz.cpp b/test/mpi/preconditioner/schwarz.cpp index b4c77203bca..5c17254a970 100644 --- a/test/mpi/preconditioner/schwarz.cpp +++ b/test/mpi/preconditioner/schwarz.cpp @@ -87,7 +87,7 @@ class SchwarzPreconditioner : public CommonMpiTestFixture { exec, I{0, 2, 4, 8})); dist_mat = dist_mtx_type::create(exec, comm); - dist_mat->read_distributed(mat_input, row_part.get()); + dist_mat->read_distributed(mat_input, row_part); non_dist_mat = non_dist_matrix_type::create(exec); non_dist_mat->read(mat_input); diff --git a/test/mpi/solver/solver.cpp b/test/mpi/solver/solver.cpp index bb17207a556..52df7232e32 100644 --- a/test/mpi/solver/solver.cpp +++ b/test/mpi/solver/solver.cpp @@ -186,7 +186,7 @@ class Solver : public CommonMpiTestFixture { Solver() : rand_engine(15) {} - std::unique_ptr gen_part(int size, int num_active_parts) + std::shared_ptr gen_part(int size, int num_active_parts) { auto mapping = gko::test::generate_random_array< gko::experimental::distributed::comm_index_type>( @@ -195,12 +195,12 @@ class Solver : public CommonMpiTestFixture { gko::experimental::distributed::comm_index_type>( 0, num_active_parts - 1), rand_engine, ref); - return Part::build_from_mapping(ref, mapping, comm.size()); + return gko::share(Part::build_from_mapping(ref, mapping, comm.size())); } - std::shared_ptr gen_mtx(const Part* part, int num_rows, int num_cols, - int min_cols, int max_cols) + std::shared_ptr gen_mtx(std::shared_ptr part, int num_rows, + int num_cols, int min_cols, int max_cols) { auto data = gko::test::generate_random_matrix_data( @@ -224,8 +224,8 @@ class Solver : public CommonMpiTestFixture { template std::shared_ptr gen_in_vec( - const Part* part, const std::shared_ptr& solver, int nrhs, - int stride) + std::shared_ptr part, + const std::shared_ptr& solver, int nrhs, int stride) { auto global_size = gko::dim<2>{solver->get_size()[1], static_cast(nrhs)}; @@ -255,8 +255,8 @@ class Solver : public CommonMpiTestFixture { template std::shared_ptr gen_out_vec( - const Part* part, const std::shared_ptr& solver, int nrhs, - int stride) + std::shared_ptr part, + const std::shared_ptr& solver, int nrhs, int stride) { auto global_size = gko::dim<2>{solver->get_size()[0], static_cast(nrhs)}; @@ -312,7 +312,8 @@ class Solver : public CommonMpiTestFixture { } template - void forall_matrix_scenarios(const Part* part, TestFunction fn) + void forall_matrix_scenarios(std::shared_ptr part, + TestFunction fn) { auto guarded_fn = [&](auto mtx) { try { @@ -352,7 +353,7 @@ class Solver : public CommonMpiTestFixture { template - void forall_vector_scenarios(const Part* part, + void forall_vector_scenarios(std::shared_ptr part, const std::shared_ptr& solver, TestFunction fn) { @@ -483,10 +484,10 @@ TYPED_TEST_SUITE(Solver, SolverTypes, TypenameNameGenerator); TYPED_TEST(Solver, ApplyIsEquivalentToRef) { this->forall_partition_scenarios([&](auto part) { - this->forall_matrix_scenarios(part.get(), [&](auto mtx) { + this->forall_matrix_scenarios(part, [&](auto mtx) { this->forall_solver_scenarios(mtx, [&](auto solver) { this->forall_vector_scenarios( - part.get(), solver, [&](auto b, auto x) { + part, solver, [&](auto b, auto x) { solver->apply(b, x); this->assert_residual_near(mtx, x, b, this->tol(x)); @@ -500,10 +501,10 @@ TYPED_TEST(Solver, ApplyIsEquivalentToRef) TYPED_TEST(Solver, AdvancedApplyIsEquivalentToRef) { this->forall_partition_scenarios([&](auto part) { - this->forall_matrix_scenarios(part.get(), [&](auto mtx) { + this->forall_matrix_scenarios(part, [&](auto mtx) { this->forall_solver_scenarios(mtx, [&](auto solver) { this->forall_vector_scenarios( - part.get(), solver, [&](auto b, auto x) { + part, solver, [&](auto b, auto x) { auto alpha = this->gen_scalar(); auto beta = this->gen_scalar(); auto x_old = gko::share(gko::clone(x)); @@ -523,10 +524,10 @@ TYPED_TEST(Solver, MixedApplyIsEquivalentToRef) { using MixedVec = typename TestFixture::MixedVec; this->forall_partition_scenarios([&](auto part) { - this->forall_matrix_scenarios(part.get(), [&](auto mtx) { + this->forall_matrix_scenarios(part, [&](auto mtx) { this->forall_solver_scenarios(mtx, [&](auto solver) { this->template forall_vector_scenarios( - part.get(), solver, [&](auto b, auto x) { + part, solver, [&](auto b, auto x) { solver->apply(b, x); this->assert_residual_near(mtx, x, b, @@ -543,10 +544,10 @@ TYPED_TEST(Solver, MixedAdvancedApplyIsEquivalentToRef) using MixedVec = typename TestFixture::MixedVec; using MixedLocalVec = typename TestFixture::MixedLocalVec; this->forall_partition_scenarios([&](auto part) { - this->forall_matrix_scenarios(part.get(), [&](auto mtx) { + this->forall_matrix_scenarios(part, [&](auto mtx) { this->forall_solver_scenarios(mtx, [&](auto solver) { this->template forall_vector_scenarios( - part.get(), solver, [&](auto b, auto x) { + part, solver, [&](auto b, auto x) { auto alpha = this->template gen_scalar(); auto beta = this->template gen_scalar(); auto x_old = gko::share(gko::clone(x));