#include "MPIUtil.h"
#include "ThirdPartyHeadersBegin.h"
#include <algorithm>
#include "ThirdPartyHeadersEnd.h"
using namespace tecplot::___3933; namespace { bool containsOneOfEachRank(std::vector<int32_t> const& ranks) { std::vector<bool> rankIsPresent(ranks.size(), false); for (size_t i = 0; i < ranks.size(); ++i) if (rankIsPresent[ranks[i]]) return false; else rankIsPresent[ranks[i]] = true; return true; } } namespace tecplot { namespace teciompi { bool everyRankAppearsOnce(MPI_Comm comm, std::vector<int32_t> const& ranks) { REQUIRE(!ranks.empty()); int32_t commSize; MPI_Comm_size(comm, &commSize); if (static_cast<int32_t>(ranks.size()) != commSize) return false; return containsOneOfEachRank(ranks); } bool everyRankOwnsOnePartition(MPI_Comm comm, ___37& ___36, ___4636 zone) { REQUIRE(0 <= zone && ___36.___4638(zone + 1)); int32_t commSize; MPI_Comm_size(comm, &commSize); if (static_cast<___4636>(commSize) != ___36.zoneGetNumPartitions(zone + 1)) return false; std::vector<int32_t> owners; owners.reserve(___36.zoneGetNumPartitions(zone + 1)); for (int32_t i = 1; i <= ___36.zoneGetNumPartitions(zone + 1); ++i) owners.push_back(___36.zonePartitionGetOwnerProcess(zone + 1, i)); return containsOneOfEachRank(owners); } void gatherScatterPartitionFileLocs(___1393& finalFileLoc, ___1393& localPartitionFileLoc, ___37 &___36, ___4636 const zone, int32_t localProcess, uint64_t localPartitionFileSize, int32_t mainProcess, MPI_Comm comm) { REQUIRE(0 <= zone && ___36.___4638(zone + 1)); REQUIRE(0 <= localProcess); REQUIRE(0 <= mainProcess); int32_t numPartitions = ___36.zoneGetNumPartitions(zone + 1); std::vector<uint64_t> rankFileSizes; rankFileSizes.resize(numPartitions, 0); rankFileSizes[localProcess] = localPartitionFileSize; MPI_Gather(&localPartitionFileSize, 1, MPI_UINT64_T, &rankFileSizes[0], 1, MPI_UINT64_T, mainProcess, comm); std::vector<uint64_t> rankFileLocations; rankFileLocations.resize(numPartitions); for (___4636 ___2977 = 0; ___2977 < numPartitions; ++___2977) { int32_t partitionOwner = ___36.zonePartitionGetOwnerProcess(zone + 1, ___2977 + 1); rankFileLocations[partitionOwner] = finalFileLoc; finalFileLoc += rankFileSizes[partitionOwner]; } MPI_Scatter(&rankFileLocations[0], 1, MPI_UINT64_T, &localPartitionFileLoc, 1, MPI_UINT64_T, mainProcess, comm); } }}
