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
Introduce free functions for consensus algorithms. #13414
Conversation
Any thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be enough to have a single function Utilities::MPI::ConsensusAlgorithms::run()
, which wraps the class Utilities::MPI::ConsensusAlgorithms::Selector
(the function should simplify the usage; multiple options just make it complicated). But I guess the reason for having the functions nbx()
, pex()
, selector()
is that you want to move in a follow-up PR the content of the classes there. At least this is how I interpret the comment:
introduce global functions that replace ConsensusAlgorithms::*::run().
As stated elsewhere I don't think it is a good idea to get rid of the classes.
I don't actually have much of an opinion on what to do with the classes. I had in mind to ask what people want to do with them. There are currently only two uses of the My main motivation for making these free functions instead of classes is so I can provide overloads. As mentioned in #13084, a substantial number of places where we currently use the consensus algorithm interface don't send an answer back for each request -- or, to be more clear, they send an empty vector. In other words, they really just do what
the interface where no answer is required would be
One could have achieved the same by providing specializations of the existing classes, for example for the case Either way, I'm happy to discuss future steps separately. I think this patch is a step forward by itself. |
How should we proceed here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be fine to have both classes (to encapsulate additional information where it is needed between the calls of different functions) and the free functions proposed here.
I would like to keep these classes, since I see those as the place for future developments, like supporting multihop versions. I regard the free functions only as a way to improve the usability, which important - particularly for the user. |
I'm ok with keeping the classes. Are there objections to the patch as-is then? |
// Implementation of the functions in this namespace. | ||
|
||
template <typename T1, typename T2> | ||
std::vector<unsigned int> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these be inline?
std::vector<unsigned int> | |
inline std::vector<unsigned int> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't technically need the inline
statement as these are templated functions and thus automatically inline
(i.e., not causing duplicate symbols during linking if they get included from multiple compilations units). But we tend to write inline
in most occurrences. (But I would not stop the PR from this minor style issue, it has waited for long already.)
This addresses #13358. It introduces free functions for the consensus algorithms and uses them in all of the places where we currently use the
run()
functions that get their information through a number ofstd::function
arguments.I took the liberty to move the main parts of the documentation from the base class to the namespace everything is in. The new functions and the old classes now refer to this main documentation place.
/rebuild