|
6 | 6 | *
|
7 | 7 | * @author Tyson Jones
|
8 | 8 | * @author Jakub Adamski (sped-up large comm by asynch messages)
|
| 9 | + * @author Oliver Brown (patched max-message inference, consulted on AR and MPICH support) |
9 | 10 | * @author Ania (Anna) Brown (developed QuEST v1 logic)
|
10 | 11 | */
|
11 | 12 |
|
|
26 | 27 |
|
27 | 28 | #include <vector>
|
28 | 29 | #include <array>
|
| 30 | +#include <algorithm> |
29 | 31 |
|
30 | 32 | using std::vector;
|
31 | 33 |
|
@@ -132,15 +134,24 @@ int getMaxNumMessages() {
|
132 | 134 | // the max supported tag value constrains the total number of messages
|
133 | 135 | // we can send in a round of communication, since we uniquely tag
|
134 | 136 | // each message in a round such that we do not rely upon message-order
|
135 |
| - // gaurantees and ergo can safely support UCX adaptive routing (AR) |
136 |
| - int maxNumMsgs, isAttribSet; |
| 137 | + // gaurantees and ergo can safely support UCX adaptive routing (AR). |
| 138 | + // The MPI standard necessitates the max tag is always at least... |
| 139 | + int minTagUpperBound = 32767; |
137 | 140 |
|
138 |
| - MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &maxNumMsgs, &isAttribSet); |
| 141 | + // but we pedantically consult MPI in case we ever need to send MORE (smaller?) |
| 142 | + // messages. Beware the max is obtained via a void pointer and might be unset... |
| 143 | + void* tagUpperBoundPtr; |
| 144 | + int isAttribSet; |
| 145 | + MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &tagUpperBoundPtr, &isAttribSet); |
139 | 146 |
|
| 147 | + // if something went wrong with obtaining the tag bound, return the safe minimum |
140 | 148 | if (!isAttribSet)
|
141 |
| - error_commTagUpperBoundNotSet(); |
| 149 | + return minTagUpperBound; |
142 | 150 |
|
143 |
| - return maxNumMsgs; |
| 151 | + // otherwise return whichever is bigger of the found bound and the minimum |
| 152 | + // (which is really just hiding an error; it should ALWAYS be that UB>=min) |
| 153 | + int tagUpperBound = *(int*) tagUpperBoundPtr; |
| 154 | + return std::max({minTagUpperBound, tagUpperBound}); |
144 | 155 |
|
145 | 156 | #else
|
146 | 157 | error_commButEnvNotDistributed();
|
|
0 commit comments