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