[569] | 1 | /*! |
---|
| 2 | \file client_server_mapping.hpp |
---|
| 3 | \author Ha NGUYEN |
---|
| 4 | \since 27 Feb 2015 |
---|
[829] | 5 | \date 16 Mars 2016 |
---|
[569] | 6 | |
---|
| 7 | \brief Mapping between index client and server. |
---|
| 8 | Clients pre-calculate all information of server distribution. |
---|
| 9 | */ |
---|
[568] | 10 | #include "client_server_mapping_distributed.hpp" |
---|
| 11 | #include <limits> |
---|
| 12 | #include <boost/functional/hash.hpp> |
---|
[584] | 13 | #include "utils.hpp" |
---|
[720] | 14 | #include "mpi_tag.hpp" |
---|
[906] | 15 | #include "context.hpp" |
---|
| 16 | #include "context_client.hpp" |
---|
[1646] | 17 | #ifdef _usingEP |
---|
[1601] | 18 | using namespace ep_lib; |
---|
[1646] | 19 | #endif |
---|
[568] | 20 | |
---|
| 21 | namespace xios |
---|
| 22 | { |
---|
| 23 | |
---|
[1542] | 24 | CClientServerMappingDistributed::CClientServerMappingDistributed(const std::unordered_map<size_t,int>& globalIndexOfServer, |
---|
[585] | 25 | const MPI_Comm& clientIntraComm, bool isDataDistributed) |
---|
[829] | 26 | : CClientServerMapping(), ccDHT_(0) |
---|
[568] | 27 | { |
---|
[721] | 28 | ccDHT_ = new CClientClientDHTInt(globalIndexOfServer, |
---|
[835] | 29 | clientIntraComm); |
---|
[568] | 30 | } |
---|
| 31 | |
---|
| 32 | CClientServerMappingDistributed::~CClientServerMappingDistributed() |
---|
| 33 | { |
---|
[720] | 34 | if (0 != ccDHT_) delete ccDHT_; |
---|
[569] | 35 | } |
---|
[568] | 36 | |
---|
[569] | 37 | /*! |
---|
| 38 | Compute mapping global index of server which client sends to. |
---|
| 39 | \param [in] globalIndexOnClient global index client has |
---|
[1336] | 40 | \param [in] nbServer size of server's intracomm |
---|
[569] | 41 | */ |
---|
[1336] | 42 | void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, int nbServer) |
---|
[568] | 43 | { |
---|
[906] | 44 | |
---|
[721] | 45 | ccDHT_->computeIndexInfoMapping(globalIndexOnClient); |
---|
[860] | 46 | const CClientClientDHTInt::Index2VectorInfoTypeMap& infoIndexMap = (ccDHT_->getInfoIndexMap()); |
---|
| 47 | CClientClientDHTInt::Index2VectorInfoTypeMap::const_iterator itb = infoIndexMap.begin(), ite = infoIndexMap.end(), it; |
---|
[907] | 48 | std::vector<size_t> nbInfoIndex(std::max(ccDHT_->getNbClient(),nbServer),0); |
---|
[843] | 49 | |
---|
| 50 | for (it = itb; it != ite; ++it) |
---|
[568] | 51 | { |
---|
[860] | 52 | ++nbInfoIndex[it->second[0]]; |
---|
[568] | 53 | } |
---|
[843] | 54 | |
---|
| 55 | for (int idx = 0; idx < nbInfoIndex.size(); ++idx) |
---|
| 56 | { |
---|
| 57 | if (0 != nbInfoIndex[idx]) |
---|
| 58 | { |
---|
| 59 | indexGlobalOnServer_[idx].resize(nbInfoIndex[idx]); |
---|
| 60 | nbInfoIndex[idx] = 0; |
---|
| 61 | } |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | for (it = itb; it != ite; ++it) |
---|
| 65 | { |
---|
[860] | 66 | indexGlobalOnServer_[it->second[0]][nbInfoIndex[it->second[0]]] = (it->first); |
---|
| 67 | ++nbInfoIndex[it->second[0]]; |
---|
[843] | 68 | } |
---|
[568] | 69 | } |
---|
| 70 | |
---|
| 71 | } |
---|