source: XIOS/dev/branch_openmp/src/client_server_mapping_distributed.cpp @ 1328

Last change on this file since 1328 was 1328, checked in by yushan, 6 years ago

dev_omp

File size: 2.1 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 <boost/functional/hash.hpp>
13#include "utils.hpp"
14#include "mpi_tag.hpp"
15#include "context.hpp"
16#include "context_client.hpp"
17using namespace ep_lib;
18
19namespace xios
20{
21
22CClientServerMappingDistributed::CClientServerMappingDistributed(const boost::unordered_map<size_t,int>& globalIndexOfServer,
23                                                                 const MPI_Comm& clientIntraComm, bool isDataDistributed)
24  : CClientServerMapping(), ccDHT_(0)
25{
26  ccDHT_ = new CClientClientDHTInt(globalIndexOfServer,
27                                   clientIntraComm);
28}
29
30CClientServerMappingDistributed::~CClientServerMappingDistributed()
31{
32  if (0 != ccDHT_) delete ccDHT_;
33}
34
35/*!
36   Compute mapping global index of server which client sends to.
37   \param [in] globalIndexOnClient global index client has
38*/
39void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient)
40{
41  CContext* context=CContext::getCurrent() ;
42  CContextClient* client=context->client ;
43  int nbServer=client->serverSize;
44
45  ccDHT_->computeIndexInfoMapping(globalIndexOnClient);
46  const CClientClientDHTInt::Index2VectorInfoTypeMap& infoIndexMap = (ccDHT_->getInfoIndexMap());
47  CClientClientDHTInt::Index2VectorInfoTypeMap::const_iterator itb = infoIndexMap.begin(), ite = infoIndexMap.end(), it;
48  std::vector<size_t> nbInfoIndex(std::max(ccDHT_->getNbClient(),nbServer),0);
49
50  for (it = itb; it != ite; ++it)
51  {
52    ++nbInfoIndex[it->second[0]];
53  }
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  {
66    indexGlobalOnServer_[it->second[0]][nbInfoIndex[it->second[0]]] = (it->first);
67    ++nbInfoIndex[it->second[0]];
68  }
69}
70
71}
Note: See TracBrowser for help on using the repository browser.