| 1322 | } |
| 1323 | |
| 1324 | void assertAllNodesAgreeThat(bool valid, string msg, tokenSubs vars, const char* func) { |
| 1325 | |
| 1326 | // avoid communication if validation not enabled anyway |
| 1327 | if (!global_isValidationEnabled) |
| 1328 | return; |
| 1329 | |
| 1330 | // this function seeks consensus among distributed nodes before validation, |
| 1331 | // to ensure all nodes fail together (and ergo all validly finalize MPI) |
| 1332 | // when performing validation that may be non-uniform between nodes. For |
| 1333 | // example, mallocs may succeed on one node but fail on another due to |
| 1334 | // inhomogeneous loads. |
| 1335 | if (comm_isInit()) |
| 1336 | valid = comm_isTrueOnAllNodes(valid); |
| 1337 | |
| 1338 | // prepare error message only if validation will fail |
| 1339 | if (!valid) |
| 1340 | if (!vars.empty()) |
| 1341 | msg = getStringWithSubstitutedVars(msg, vars); |
| 1342 | |
| 1343 | // commenting out the top if-statement above (preserving the bottom one) |
| 1344 | // is convenient during development, since it ensures that even validation |
| 1345 | // which passed has a correctly formatted error message, else errors. |
| 1346 | |
| 1347 | assertThat(valid, msg, func); |
| 1348 | } |
| 1349 | void assertAllNodesAgreeThat(bool valid, string msg, const char* func) { |
| 1350 | |
| 1351 | assertAllNodesAgreeThat(valid, msg, {}, func); |
no test coverage detected