From: Wolfgang Bangerth Date: Sun, 29 May 2022 21:30:08 +0000 (-0600) Subject: Switch the answer-less CA algorithms to the empty type. X-Git-Tag: v9.4.0-rc1~109^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ad5f1eafc1c085275ddca5b8f0b6e6b914529b6;p=dealii.git Switch the answer-less CA algorithms to the empty type. --- diff --git a/include/deal.II/base/mpi_consensus_algorithms.h b/include/deal.II/base/mpi_consensus_algorithms.h index 2557e7f83b..ce6c84a42b 100644 --- a/include/deal.II/base/mpi_consensus_algorithms.h +++ b/include/deal.II/base/mpi_consensus_algorithms.h @@ -1177,29 +1177,27 @@ namespace Utilities { // TODO: For the moment, simply implement this special case by // forwarding to the other function with rewritten function - // objects and using a plain 'char' as answer type. This way, + // objects and using an empty type as answer type. This way, // we have the interface in place and can provide a more // efficient implementation later on. - return nbx( + using EmptyType = std::tuple<>; + + return nbx( targets, create_request, // answer_request: [&process_request](const unsigned int source_rank, - const RequestType &request) -> char { + const RequestType &request) -> EmptyType { process_request(source_rank, request); // Return something. What it is is arbitrary here, except that - // we will want to check what it is below in the process_answer(). - // We choose the smallest possible data type for the replies (a - // 'char'), but we can make ourselves feel more important by - // putting a whole " " into one char (sensible editor - // settings assumed). - return '\t'; + // we want it to be as small an object as possible. Using + // std::tuple<> is interpreted as an empty object that is packed + // down to a zero-length char array. + return {}; }, // process_answer: - [](const unsigned int /*target_rank */, const char &answer) { - (void)answer; - Assert(answer == '\t', ExcInternalError()); - }, + [](const unsigned int /*target_rank */, + const EmptyType & /*answer*/) {}, comm); } @@ -1231,29 +1229,27 @@ namespace Utilities { // TODO: For the moment, simply implement this special case by // forwarding to the other function with rewritten function - // objects and using a plain 'char' as answer type. This way, + // objects and using an empty type as answer type. This way, // we have the interface in place and can provide a more // efficient implementation later on. - return pex( + using EmptyType = std::tuple<>; + + return pex( targets, create_request, // answer_request: [&process_request](const unsigned int source_rank, - const RequestType &request) -> char { + const RequestType &request) -> EmptyType { process_request(source_rank, request); // Return something. What it is is arbitrary here, except that - // we will want to check what it is below in the process_answer(). - // We choose the smallest possible data type for the replies (a - // 'char'), but we can make ourselves feel more important by - // putting a whole " " into one char (sensible editor - // settings assumed). - return '\t'; + // we want it to be as small an object as possible. Using + // std::tuple<> is interpreted as an empty object that is packed + // down to a zero-length char array. + return {}; }, // process_answer: - [](const unsigned int /*target_rank */, const char &answer) { - (void)answer; - Assert(answer == '\t', ExcInternalError()); - }, + [](const unsigned int /*target_rank */, + const EmptyType & /*answer*/) {}, comm); } @@ -1287,29 +1283,27 @@ namespace Utilities { // TODO: For the moment, simply implement this special case by // forwarding to the other function with rewritten function - // objects and using a plain 'char' as answer type. This way, + // objects and using an empty type as answer type. This way, // we have the interface in place and can provide a more // efficient implementation later on. - return serial( + using EmptyType = std::tuple<>; + + return serial( targets, create_request, // answer_request: [&process_request](const unsigned int source_rank, - const RequestType &request) -> char { + const RequestType &request) -> EmptyType { process_request(source_rank, request); // Return something. What it is is arbitrary here, except that - // we will want to check what it is below in the process_answer(). - // We choose the smallest possible data type for the replies (a - // 'char'), but we can make ourselves feel more important by - // putting a whole " " into one char (sensible editor - // settings assumed). - return '\t'; + // we want it to be as small an object as possible. Using + // std::tuple<> is interpreted as an empty object that is packed + // down to a zero-length char array. + return {}; }, // process_answer: - [](const unsigned int /*target_rank */, const char &answer) { - (void)answer; - Assert(answer == '\t', ExcInternalError()); - }, + [](const unsigned int /*target_rank */, + const EmptyType & /*answer*/) {}, comm); } @@ -1343,29 +1337,27 @@ namespace Utilities { // TODO: For the moment, simply implement this special case by // forwarding to the other function with rewritten function - // objects and using a plain 'char' as answer type. This way, + // objects and using an empty type as answer type. This way, // we have the interface in place and can provide a more // efficient implementation later on. - return selector( + using EmptyType = std::tuple<>; + + return selector( targets, create_request, // answer_request: [&process_request](const unsigned int source_rank, - const RequestType &request) -> char { + const RequestType &request) -> EmptyType { process_request(source_rank, request); // Return something. What it is is arbitrary here, except that - // we will want to check what it is below in the process_answer(). - // We choose the smallest possible data type for the replies (a - // 'char'), but we can make ourselves feel more important by - // putting a whole " " into one char (sensible editor - // settings assumed). - return '\t'; + // we want it to be as small an object as possible. Using + // std::tuple<> is interpreted as an empty object that is packed + // down to a zero-length char array. + return {}; }, // process_answer: - [](const unsigned int /*target_rank */, const char &answer) { - (void)answer; - Assert(answer == '\t', ExcInternalError()); - }, + [](const unsigned int /*target_rank */, + const EmptyType & /*answer*/) {}, comm); }