Skip to content
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

Replace std::vector<RequestType> by RequestType in consensus algorithms. Same for AnswerType. #13722

Merged
merged 3 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions include/deal.II/base/mpi_compute_index_owner_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ namespace Utilities
*/
class DictionaryPayLoad
: public ConsensusAlgorithms::Process<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>
std::vector<
std::pair<types::global_dof_index, types::global_dof_index>>,
std::vector<unsigned int>>
Comment on lines -80 to +82
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, the CA algorithms took as template arguments the element types of vectors. Now they just take the overall type as template argument, which means that it is now a vector-of-something.

{
public:
/**
Expand Down Expand Up @@ -282,8 +283,9 @@ namespace Utilities
*/
class ConsensusAlgorithmsPayload
: public ConsensusAlgorithms::Process<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>
std::vector<
std::pair<types::global_dof_index, types::global_dof_index>>,
std::vector<unsigned int>>
{
public:
/**
Expand Down
332 changes: 144 additions & 188 deletions include/deal.II/base/mpi_consensus_algorithms.h

Large diffs are not rendered by default.

223 changes: 99 additions & 124 deletions include/deal.II/base/mpi_consensus_algorithms.templates.h

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions include/deal.II/fe/fe_tools_extrapolate.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -1177,11 +1177,13 @@ namespace FETools
Assert(answer.size() == 0, ExcInternalError());
};

Utilities::MPI::ConsensusAlgorithms::selector<char, char>(destinations,
create_request,
answer_request,
read_answer,
communicator);
Utilities::MPI::ConsensusAlgorithms::selector<std::vector<char>,
std::vector<char>>(
destinations,
create_request,
answer_request,
read_answer,
communicator);
}


Expand Down
10 changes: 6 additions & 4 deletions include/deal.II/lac/affine_constraints.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ namespace internal
true);

Utilities::MPI::ConsensusAlgorithms::Selector<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>(constrained_indices_process, mpi_communicator)
std::vector<std::pair<types::global_dof_index, types::global_dof_index>>,
std::vector<unsigned int>>(constrained_indices_process, mpi_communicator)
.run();

// step 2: collect all locally owned constraints
Expand Down Expand Up @@ -388,8 +388,10 @@ namespace internal
true);

Utilities::MPI::ConsensusAlgorithms::Selector<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>(locally_relevant_dofs_process, mpi_communicator)
std::vector<
std::pair<types::global_dof_index, types::global_dof_index>>,
std::vector<unsigned int>>(locally_relevant_dofs_process,
mpi_communicator)
.run();

const auto locally_relevant_dofs_by_ranks =
Expand Down
15 changes: 8 additions & 7 deletions include/deal.II/matrix_free/matrix_free.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -2170,13 +2170,14 @@ MatrixFree<dim, Number, VectorizedArrayType>::initialize_indices(
}
};

Utilities::MPI::ConsensusAlgorithms::
Selector<dealii::types::global_dof_index, unsigned int>()
.run(targets,
create_request,
answer_request,
process_answer,
communicator_sm);
Utilities::MPI::ConsensusAlgorithms::Selector<
std::vector<dealii::types::global_dof_index>,
std::vector<unsigned int>>()
.run(targets,
create_request,
answer_request,
process_answer,
communicator_sm);

return cells;
}();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,9 @@ namespace internal
false);

Utilities::MPI::ConsensusAlgorithms::Selector<
std::pair<types::global_cell_index, types::global_cell_index>,
unsigned int>
std::vector<
std::pair<types::global_cell_index, types::global_cell_index>>,
std::vector<unsigned int>>
consensus_algorithm(process, communicator);
consensus_algorithm.run();
}
Expand All @@ -593,8 +594,9 @@ namespace internal
true);

Utilities::MPI::ConsensusAlgorithms::Selector<
std::pair<types::global_cell_index, types::global_cell_index>,
unsigned int>
std::vector<
std::pair<types::global_cell_index, types::global_cell_index>>,
std::vector<unsigned int>>
consensus_algorithm(process, communicator);
consensus_algorithm.run();

Expand Down Expand Up @@ -3086,8 +3088,9 @@ MGTwoLevelTransfer<dim, LinearAlgebra::distributed::Vector<Number>>::reinit(
false);

Utilities::MPI::ConsensusAlgorithms::Selector<
std::pair<types::global_cell_index, types::global_cell_index>,
unsigned int>
std::vector<
std::pair<types::global_cell_index, types::global_cell_index>>,
std::vector<unsigned int>>
consensus_algorithm(process, communicator);
consensus_algorithm.run();

Expand Down
9 changes: 5 additions & 4 deletions source/base/mpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ namespace Utilities
if (Utilities::MPI::min((my_destinations_are_unique ? 1 : 0), mpi_comm) ==
1)
{
return ConsensusAlgorithms::nbx<char, char>(
return ConsensusAlgorithms::nbx<std::vector<char>, std::vector<char>>(
destinations, {}, {}, {}, mpi_comm);
}

Expand Down Expand Up @@ -477,7 +477,7 @@ namespace Utilities
if (Utilities::MPI::min((my_destinations_are_unique ? 1 : 0), mpi_comm) ==
1)
{
return ConsensusAlgorithms::nbx<char, char>(
return ConsensusAlgorithms::nbx<std::vector<char>, std::vector<char>>(
destinations, {}, {}, {}, mpi_comm)
.size();
}
Expand Down Expand Up @@ -1098,8 +1098,9 @@ namespace Utilities
// partition (i.e. in the dictionary). This process returns the actual
// owner of the index.
ConsensusAlgorithms::Selector<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>
std::vector<
std::pair<types::global_dof_index, types::global_dof_index>>,
std::vector<unsigned int>>
consensus_algorithm(process, comm);
consensus_algorithm.run();

Expand Down
5 changes: 3 additions & 2 deletions source/base/mpi_compute_index_owner_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,9 @@ namespace Utilities
actually_owning_rank_list);

ConsensusAlgorithms::Selector<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>
std::vector<
std::pair<types::global_dof_index, types::global_dof_index>>,
std::vector<unsigned int>>
consensus_algo(temp, comm);
consensus_algo.run();
}
Expand Down
85 changes: 49 additions & 36 deletions source/base/mpi_consensus_algorithms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

#include <deal.II/base/mpi_consensus_algorithms.templates.h>

#include <boost/serialization/utility.hpp>


DEAL_II_NAMESPACE_OPEN

namespace Utilities
Expand All @@ -23,68 +26,78 @@ namespace Utilities
{
namespace ConsensusAlgorithms
{
template class Process<unsigned int, unsigned int>;
template class Process<std::vector<unsigned int>,
std::vector<unsigned int>>;

template class Interface<unsigned int, unsigned int>;
template class Interface<std::vector<unsigned int>,
std::vector<unsigned int>>;

template class NBX<unsigned int, unsigned int>;
template class NBX<std::vector<unsigned int>, std::vector<unsigned int>>;

template class PEX<unsigned int, unsigned int>;
template class PEX<std::vector<unsigned int>, std::vector<unsigned int>>;

template class Serial<unsigned int, unsigned int>;
template class Serial<std::vector<unsigned int>,
std::vector<unsigned int>>;

template class Selector<unsigned int, unsigned int>;
template class Selector<std::vector<unsigned int>,
std::vector<unsigned int>>;


template class Process<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>;
template class Process<std::vector<std::pair<types::global_dof_index,
types::global_dof_index>>,
std::vector<unsigned int>>;

template class Interface<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>;
template class Interface<std::vector<std::pair<types::global_dof_index,
types::global_dof_index>>,
std::vector<unsigned int>>;

template class Selector<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>;
template class Selector<std::vector<std::pair<types::global_dof_index,
types::global_dof_index>>,
std::vector<unsigned int>>;

template class NBX<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>;
template class NBX<std::vector<std::pair<types::global_dof_index,
types::global_dof_index>>,
std::vector<unsigned int>>;

template class Serial<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>;
template class Serial<std::vector<std::pair<types::global_dof_index,
types::global_dof_index>>,
std::vector<unsigned int>>;

template class PEX<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>;
template class PEX<std::vector<std::pair<types::global_dof_index,
types::global_dof_index>>,
std::vector<unsigned int>>;

#ifdef DEAL_II_WITH_64BIT_INDICES
template class Process<types::global_dof_index, unsigned int>;
template class Process<std::vector<types::global_dof_index>,
std::vector<unsigned int>>;

template class Interface<types::global_dof_index, unsigned int>;
template class Interface<std::vector<types::global_dof_index>,
std::vector<unsigned int>>;

template class NBX<types::global_dof_index, unsigned int>;
template class NBX<std::vector<types::global_dof_index>,
std::vector<unsigned int>>;

template class Serial<types::global_dof_index, unsigned int>;
template class Serial<std::vector<types::global_dof_index>,
std::vector<unsigned int>>;

template class PEX<types::global_dof_index, unsigned int>;
template class PEX<std::vector<types::global_dof_index>,
std::vector<unsigned int>>;

template class Selector<types::global_dof_index, unsigned int>;
template class Selector<std::vector<types::global_dof_index>,
std::vector<unsigned int>>;
#endif

template class Process<char, char>;
template class Process<std::vector<char>, std::vector<char>>;

template class Interface<char, char>;
template class Interface<std::vector<char>, std::vector<char>>;

template class NBX<char, char>;
template class NBX<std::vector<char>, std::vector<char>>;

template class PEX<char, char>;
template class PEX<std::vector<char>, std::vector<char>>;

template class Serial<char, char>;
template class Serial<std::vector<char>, std::vector<char>>;

template class Selector<char, char>;
template class Selector<std::vector<char>, std::vector<char>>;

} // namespace ConsensusAlgorithms
} // end of namespace MPI
Expand Down
5 changes: 3 additions & 2 deletions source/base/mpi_noncontiguous_partitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ namespace Utilities
true);

Utilities::MPI::ConsensusAlgorithms::Selector<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>
std::vector<
std::pair<types::global_dof_index, types::global_dof_index>>,
std::vector<unsigned int>>
consensus_algorithm(process, communicator);
consensus_algorithm.run();

Expand Down
5 changes: 3 additions & 2 deletions source/base/partitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ namespace Utilities
// in the static partition (i.e. in the dictionary). This process
// returns the actual owner of the index.
ConsensusAlgorithms::Selector<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>
std::vector<
std::pair<types::global_dof_index, types::global_dof_index>>,
std::vector<unsigned int>>
consensus_algorithm(process, communicator);
consensus_algorithm.run();

Expand Down
5 changes: 3 additions & 2 deletions source/distributed/repartitioning_policy_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ namespace RepartitioningPolicyTools
false);

Utilities::MPI::ConsensusAlgorithms::Selector<
std::pair<types::global_cell_index, types::global_cell_index>,
unsigned int>
std::vector<
std::pair<types::global_cell_index, types::global_cell_index>>,
std::vector<unsigned int>>
consensus_algorithm(process, communicator);
consensus_algorithm.run();
}
Expand Down
3 changes: 2 additions & 1 deletion source/grid/grid_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6080,7 +6080,8 @@ namespace GridTools
}
};

Utilities::MPI::ConsensusAlgorithms::selector<char, char>(
Utilities::MPI::ConsensusAlgorithms::selector<std::vector<char>,
std::vector<char>>(
potential_owners_ranks,
create_request,
answer_request,
Expand Down
12 changes: 6 additions & 6 deletions source/grid/tria_description.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ namespace TriangulationDescription
};


dealii::Utilities::MPI::ConsensusAlgorithms::selector<char, char>(
relevant_processes,
create_request,
answer_request,
process_answer,
comm);
dealii::Utilities::MPI::ConsensusAlgorithms::
selector<std::vector<char>, std::vector<char>>(relevant_processes,
create_request,
answer_request,
process_answer,
comm);
}

/**
Expand Down
7 changes: 5 additions & 2 deletions source/matrix_free/vector_data_exchange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#ifdef DEAL_II_WITH_64BIT_INDICES
# include <deal.II/base/mpi_consensus_algorithms.templates.h>

# include <boost/serialization/utility.hpp>
#endif

#include <map>
Expand Down Expand Up @@ -441,8 +443,9 @@ namespace internal
/*track_index_requests = */ true);

Utilities::MPI::ConsensusAlgorithms::Selector<
std::pair<types::global_dof_index, types::global_dof_index>,
unsigned int>
std::vector<
std::pair<types::global_dof_index, types::global_dof_index>>,
std::vector<unsigned int>>
consensus_algorithm(process, comm);
consensus_algorithm.run();

Expand Down
5 changes: 3 additions & 2 deletions source/multigrid/mg_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1823,8 +1823,9 @@ namespace MGTools
false);

Utilities::MPI::ConsensusAlgorithms::Selector<
std::pair<types::global_cell_index, types::global_cell_index>,
unsigned int>
std::vector<
std::pair<types::global_cell_index, types::global_cell_index>>,
std::vector<unsigned int>>
consensus_algorithm;
consensus_algorithm.run(process, communicator);

Expand Down