source: XIOS3/trunk/src/transport/context_server.cpp @ 2547

Last change on this file since 2547 was 2547, checked in by ymipsl, 9 months ago

Major update :

  • New method to lock and unlock one-sided windows (window_dynamic) to avoid network overhead
  • Introducing multithreading on server sided to manage more efficiently dead-lock occuring (similar to co-routine which will be available and implemented in futur c++ standard), based on c++ threads
  • Suprression of old "attached mode" which is replaced by online writer and reder filters

YM

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#include "context_server.hpp"
2#include "buffer_in.hpp"
3#include "type.hpp"
4#include "context.hpp"
5#include "object_template.hpp"
6#include "group_template.hpp"
7#include "attribute_template.hpp"
8#include "domain.hpp"
9#include "field.hpp"
10#include "file.hpp"
11#include "grid.hpp"
12#include "mpi.hpp"
13#include "tracer.hpp"
14#include "timer.hpp"
15#include "cxios.hpp"
16#include "event_scheduler.hpp"
17#include "server.hpp"
18#include "servers_ressource.hpp"
19#include "pool_ressource.hpp"
20#include "services.hpp"
21#include "contexts_manager.hpp"
22#include "timeline_events.hpp"
23#include "one_sided_context_server.hpp"
24#include "legacy_context_server.hpp"
25
26
27
28#include <boost/functional/hash.hpp>
29#include <random>
30#include <chrono>
31
32
33namespace xios
34{
35  using namespace std ;
36
37  CContextServer::CContextServer(CContext* parent,MPI_Comm intraComm_,MPI_Comm interComm_) 
38    : associatedClient_(nullptr)
39  {
40    context=parent;
41    intraComm=intraComm_;
42    MPI_Comm_size(intraComm,&intraCommSize);
43    MPI_Comm_rank(intraComm,&intraCommRank);
44
45    interComm=interComm_;
46    MPI_Comm_remote_size(interComm,&clientSize_);
47   
48    SRegisterContextInfo contextInfo ;
49    CXios::getContextsManager()->getContextInfo(context->getId(), contextInfo, intraComm) ;
50    eventScheduler_=CXios::getPoolRessource()->getService(contextInfo.serviceId,contextInfo.partitionId)->getEventScheduler() ;
51
52    // generate unique hash for server
53    auto time=chrono::system_clock::now().time_since_epoch().count() ;
54    std::default_random_engine rd(time); // not reproducible from a run to another
55    std::uniform_int_distribution<size_t> dist;
56    hashId=dist(rd) ;
57    MPI_Bcast(&hashId,1,MPI_SIZE_T,0,intraComm) ; // Bcast to all server of the context
58     
59  }
60
61  template<>
62  CContextServer* CContextServer::getNew<CContextServer::generic>(CContext* parent,MPI_Comm intraComm,MPI_Comm interComm) 
63  { 
64    string defaultProtocol = CXios::getin<string>("transport_protocol", "default") ;
65    if (defaultProtocol=="one_sided") return new COneSidedContextServer(parent, intraComm, interComm) ;
66    else if  (defaultProtocol=="legacy") return new CLegacyContextServer(parent, intraComm, interComm) ;
67    else if  (defaultProtocol=="default") return new CLegacyContextServer(parent, intraComm, interComm) ;
68    else ERROR("CContextServer* CContextServer::getNew<CContextServer::generic>(CContext* parent,MPI_Comm intraComm,MPI_Comm interComm)",
69              <<"Protocol name <"<<defaultProtocol<<"> is undefined,  must be <default>, <one_sided> or <legacy>" ) ;     
70  }
71
72  template<>
73  CContextServer* CContextServer::getNew<CContextServer::oneSided>(CContext* parent,MPI_Comm intraComm,MPI_Comm interComm) 
74  { 
75    return new COneSidedContextServer(parent, intraComm, interComm) ; 
76  }
77
78  template<>
79  CContextServer* CContextServer::getNew<CContextServer::legacy>(CContext* parent,MPI_Comm intraComm,MPI_Comm interComm) 
80  { 
81    return new COneSidedContextServer(parent, intraComm, interComm) ; 
82  }
83
84}
Note: See TracBrowser for help on using the repository browser.