Skip to content

Commit

Permalink
[pgm] review updates:
Browse files Browse the repository at this point in the history
- documentation
- refactor

Co-authored-by: Fritz Goebel <fritz.goebel@tum.de>
Co-authored-by: Yu-Hsiang M. Tsai <yhmtsai@gmail.com>u
  • Loading branch information
MarcelKoch and fritzgoebel committed Feb 18, 2025
1 parent 0d1acb1 commit f8cb0e8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions core/distributed/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,15 @@ Matrix<ValueType, LocalIndexType, GlobalIndexType>::create(
array<comm_index_type> part_ids(exec->get_master(), comm.size());
std::iota(part_ids.get_data(), part_ids.get_data() + part_ids.get_size(),
0);
auto uniform_partition =
auto contiguous_partition =
share(build_partition_from_local_size<LocalIndexType, GlobalIndexType>(
exec, comm, local_linop->get_size()[0]));
array<global_index_type> global_recv_gather_idxs(
exec, recv_gather_idxs.get_size());
for (int rank = 0; rank < comm.size(); ++rank) {
if (recv_sizes[rank] > 0) {
auto map = index_map<LocalIndexType, GlobalIndexType>(
exec, uniform_partition, rank, array<GlobalIndexType>{exec});
exec, contiguous_partition, rank, array<GlobalIndexType>{exec});
auto local_view = make_array_view(
exec, recv_sizes[rank],
recv_gather_idxs.get_data() + recv_offsets[rank]);
Expand All @@ -258,7 +258,7 @@ Matrix<ValueType, LocalIndexType, GlobalIndexType>::create(
return Matrix::create(
exec, comm,
index_map<LocalIndexType, GlobalIndexType>(
exec, uniform_partition, comm.rank(), global_recv_gather_idxs),
exec, contiguous_partition, comm.rank(), global_recv_gather_idxs),
std::move(local_linop), std::move(non_local_linop));
}

Expand Down
8 changes: 4 additions & 4 deletions core/multigrid/pgm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ array<GlobalIndexType> Pgm<ValueType, IndexType>::communicate_non_local_agg(
// local indices to global
experimental::distributed::index_map<IndexType, GlobalIndexType> imap(
exec, coarse_partition, comm.rank(), array<GlobalIndexType>{exec});
auto seng_global_agg = imap.map_to_global(
auto send_global_agg = imap.map_to_global(
send_agg, experimental::distributed::index_space::local);

array<GlobalIndexType> non_local_agg(exec, total_recv_size);
Expand All @@ -293,13 +293,13 @@ array<GlobalIndexType> Pgm<ValueType, IndexType>::communicate_non_local_agg(
host_recv_buffer.resize_and_reset(total_recv_size);
host_send_buffer.resize_and_reset(total_send_size);
exec->get_master()->copy_from(exec, total_send_size,
seng_global_agg.get_data(),
send_global_agg.get_data(),
host_send_buffer.get_data());
}
auto type = experimental::mpi::type_impl<GlobalIndexType>::get_type();

const auto send_ptr = use_host_buffer ? host_send_buffer.get_const_data()
: seng_global_agg.get_const_data();
: send_global_agg.get_const_data();
auto recv_ptr = use_host_buffer ? host_recv_buffer.get_data()
: non_local_agg.get_data();
exec->synchronize();
Expand Down Expand Up @@ -396,7 +396,7 @@ void Pgm<ValueType, IndexType>::generate()
// the coarse partition will have only one range per part
// and only one part per rank.
// The global indices are ordered block-wise by rank, i.e. rank
// 1 owns [0, ..., N_1), rank 2 [N_1, ..., N_2), ...
// 0 owns [0, ..., N_1), rank 1 [N_1, ..., N_2), ...
auto coarse_local_size =
static_cast<int64>(std::get<1>(result)->get_size()[0]);
auto coarse_partition = gko::share(
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/multigrid/pgm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Pgm : public EnableLinOp<Pgm<ValueType, IndexType>>,
* @param local_agg the local aggregate indices
*
* @return the aggregates for non-local columns. The aggregated indices are
* in the new global indexing
* in the new global indexing for the coarse matrix
*/
template <typename GlobalIndexType>
array<GlobalIndexType> communicate_non_local_agg(
Expand Down
1 change: 1 addition & 0 deletions test/mpi/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ TYPED_TEST(MatrixCreation, BuildFromExistingData)
GKO_ASSERT_MTX_NEAR(y->get_local_vector(), result[rank], 0);
}


#endif


Expand Down

0 comments on commit f8cb0e8

Please sign in to comment.