virtual ~Interface() = default;
/**
- * Run consensus algorithm.
+ * Run consensus algorithm and return the requesting processes.
*/
- virtual void
+ virtual std::vector<unsigned int>
run() = 0;
protected:
/**
* @copydoc Interface::run()
*/
- virtual void
+ virtual std::vector<unsigned int>
run() override;
private:
MPI_Request barrier_request;
#endif
-#ifdef DEBUG
/**
* List of processes who have made a request to this process.
*/
std::set<unsigned int> requesting_processes;
-#endif
/**
* Check if all request answers have been received by this rank.
/**
* @copydoc Interface::run()
*/
- virtual void
+ virtual std::vector<unsigned int>
run() override;
private:
*/
std::vector<MPI_Request> requests_answers;
#endif
+ /**
+ * List of processes who have made a request to this process.
+ */
+ std::set<unsigned int> requesting_processes;
/**
* The ith request message from another rank has been received: process
/**
* @copydoc Interface::run()
*/
- virtual void
+ virtual std::vector<unsigned int>
run() override;
};
*
* @note The function call is delegated to another ConsensusAlgorithms::Interface implementation.
*/
- virtual void
+ virtual std::vector<unsigned int>
run() override;
private:
template <typename T1, typename T2>
- void
+ std::vector<unsigned int>
NBX<T1, T2>::run()
{
static CollectiveMutex mutex;
// 5) process the answer to all requests
clean_up_and_end_communication();
+
+ return std::vector<unsigned int>(requesting_processes.begin(),
+ requesting_processes.end());
+ ;
}
// get rank of requesting process
const auto other_rank = status.MPI_SOURCE;
-# ifdef DEBUG
Assert(requesting_processes.find(other_rank) ==
requesting_processes.end(),
ExcMessage("Process is requesting a second time!"));
requesting_processes.insert(other_rank);
-# endif
std::vector<T1> buffer_recv;
// get size of incoming message
template <typename T1, typename T2>
- void
+ std::vector<unsigned int>
PEX<T1, T2>::run()
{
static CollectiveMutex mutex;
// 3) process answers
clean_up_and_end_communication();
+
+ return std::vector<unsigned int>(requesting_processes.begin(),
+ requesting_processes.end());
}
// get rank of incoming message
const auto other_rank = status.MPI_SOURCE;
+ Assert(requesting_processes.find(other_rank) ==
+ requesting_processes.end(),
+ ExcMessage("Process is requesting a second time!"));
+ requesting_processes.insert(other_rank);
+
std::vector<T1> buffer_recv;
// get size of incoming message
template <typename T1, typename T2>
- void
+ std::vector<unsigned int>
Serial<T1, T2>::run()
{
const auto targets = this->process.compute_targets();
- if (targets.size() == 0)
- return; // nothing to do
+ if (targets.size() != 0)
+ {
+ AssertDimension(targets[0], 0);
- AssertDimension(targets[0], 0);
+ std::vector<T1> send_buffer;
+ std::vector<T2> recv_buffer;
+ std::vector<T2> request_buffer;
- std::vector<T1> send_buffer;
- std::vector<T2> recv_buffer;
- std::vector<T2> request_buffer;
+ this->process.create_request(0, send_buffer);
+ this->process.prepare_buffer_for_answer(0, recv_buffer);
+ this->process.answer_request(0, send_buffer, request_buffer);
+ recv_buffer = request_buffer;
+ this->process.read_answer(0, recv_buffer);
+ }
- this->process.create_request(0, send_buffer);
- this->process.prepare_buffer_for_answer(0, recv_buffer);
- this->process.answer_request(0, send_buffer, request_buffer);
- recv_buffer = request_buffer;
- this->process.read_answer(0, recv_buffer);
+ return targets; // nothing to do
}
template <typename T1, typename T2>
- void
+ std::vector<unsigned int>
Selector<T1, T2>::run()
{
- consensus_algo->run();
+ return consensus_algo->run();
}