source: XIOS3/trunk/src/distribution/client_server_mapping_distributed.cpp @ 2634

Last change on this file since 2634 was 2629, checked in by jderouillat, 4 months ago

Delete boost dependencies, the few features used are replaced by functions stored in extern/boost_extraction

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1/*!
2   \file client_server_mapping.hpp
3   \author Ha NGUYEN
4   \since 27 Feb 2015
5   \date 16 Mars 2016
6
7   \brief Mapping between index client and server.
8   Clients pre-calculate all information of server distribution.
9 */
10#include "client_server_mapping_distributed.hpp"
11#include <limits>
12#include "utils.hpp"
13#include "mpi_tag.hpp"
14#include "context.hpp"
15#include "context_client.hpp"
16
17namespace xios
18{
19
20CClientServerMappingDistributed::CClientServerMappingDistributed(const std::unordered_map<size_t,int>& globalIndexOfServer,
21                                                                 const MPI_Comm& clientIntraComm, bool isDataDistributed)
22  : CClientServerMapping(), ccDHT_(0)
23{
24  ccDHT_ = new CClientClientDHTInt(globalIndexOfServer,
25                                   clientIntraComm);
26}
27
28CClientServerMappingDistributed::~CClientServerMappingDistributed()
29{
30  if (0 != ccDHT_) delete ccDHT_;
31}
32
33/*!
34   Compute mapping global index of server which client sends to.
35   \param [in] globalIndexOnClient global index client has
36   \param [in] nbServer size of server's intracomm
37*/
38void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, int nbServer)
39{
40
41  ccDHT_->computeIndexInfoMapping(globalIndexOnClient);
42  const CClientClientDHTInt::Index2VectorInfoTypeMap& infoIndexMap = (ccDHT_->getInfoIndexMap());
43  CClientClientDHTInt::Index2VectorInfoTypeMap::const_iterator itb = infoIndexMap.begin(), ite = infoIndexMap.end(), it;
44  std::vector<size_t> nbInfoIndex(std::max(ccDHT_->getNbClient(),nbServer),0);
45
46  for (it = itb; it != ite; ++it)
47  {
48    ++nbInfoIndex[it->second[0]];
49  }
50
51  for (int idx = 0; idx < nbInfoIndex.size(); ++idx)
52  {
53    if (0 != nbInfoIndex[idx])
54    {
55      indexGlobalOnServer_[idx].resize(nbInfoIndex[idx]);
56      nbInfoIndex[idx] = 0;
57    }
58  }
59
60  for (it = itb; it != ite; ++it)
61  {
62    indexGlobalOnServer_[it->second[0]][nbInfoIndex[it->second[0]]] = (it->first);
63    ++nbInfoIndex[it->second[0]];
64  }
65}
66
67}
Note: See TracBrowser for help on using the repository browser.