[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" |
---|
[568] | 15 | |
---|
| 16 | namespace xios |
---|
| 17 | { |
---|
| 18 | |
---|
| 19 | CClientServerMappingDistributed::CClientServerMappingDistributed(const boost::unordered_map<size_t,int>& globalIndexOfServer, |
---|
[585] | 20 | const MPI_Comm& clientIntraComm, bool isDataDistributed) |
---|
[829] | 21 | : CClientServerMapping(), ccDHT_(0) |
---|
[568] | 22 | { |
---|
[721] | 23 | ccDHT_ = new CClientClientDHTInt(globalIndexOfServer, |
---|
[835] | 24 | clientIntraComm); |
---|
[568] | 25 | } |
---|
| 26 | |
---|
| 27 | CClientServerMappingDistributed::~CClientServerMappingDistributed() |
---|
| 28 | { |
---|
[720] | 29 | if (0 != ccDHT_) delete ccDHT_; |
---|
[569] | 30 | } |
---|
[568] | 31 | |
---|
[569] | 32 | /*! |
---|
| 33 | Compute mapping global index of server which client sends to. |
---|
| 34 | \param [in] globalIndexOnClient global index client has |
---|
| 35 | */ |
---|
[584] | 36 | void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) |
---|
[568] | 37 | { |
---|
[721] | 38 | ccDHT_->computeIndexInfoMapping(globalIndexOnClient); |
---|
[860] | 39 | const CClientClientDHTInt::Index2VectorInfoTypeMap& infoIndexMap = (ccDHT_->getInfoIndexMap()); |
---|
| 40 | CClientClientDHTInt::Index2VectorInfoTypeMap::const_iterator itb = infoIndexMap.begin(), ite = infoIndexMap.end(), it; |
---|
[843] | 41 | std::vector<size_t> nbInfoIndex(ccDHT_->getNbClient(),0); |
---|
| 42 | |
---|
| 43 | for (it = itb; it != ite; ++it) |
---|
[568] | 44 | { |
---|
[860] | 45 | ++nbInfoIndex[it->second[0]]; |
---|
[568] | 46 | } |
---|
[843] | 47 | |
---|
| 48 | for (int idx = 0; idx < nbInfoIndex.size(); ++idx) |
---|
| 49 | { |
---|
| 50 | if (0 != nbInfoIndex[idx]) |
---|
| 51 | { |
---|
| 52 | indexGlobalOnServer_[idx].resize(nbInfoIndex[idx]); |
---|
| 53 | nbInfoIndex[idx] = 0; |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | for (it = itb; it != ite; ++it) |
---|
| 58 | { |
---|
[860] | 59 | indexGlobalOnServer_[it->second[0]][nbInfoIndex[it->second[0]]] = (it->first); |
---|
| 60 | ++nbInfoIndex[it->second[0]]; |
---|
[843] | 61 | } |
---|
[568] | 62 | } |
---|
| 63 | |
---|
| 64 | } |
---|