Changeset 2517 for XIOS3/trunk


Ignore:
Timestamp:
06/12/23 11:52:10 (13 months ago)
Author:
ymipsl
Message:

New way to manage locks in window manager. Windows is locked with MPI_Win_lock_all at creation (shared mode), and lock is manage by software way in the class (using MPI_swap_and_compare and MPI_Fetch_op). We get in this case a better control of lock, with controled latency between each attemp of lock.

YM

Location:
XIOS3/trunk/src/manager
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/trunk/src/manager/contexts_manager.cpp

    r2287 r2517  
    2727    MPI_Comm_rank(xiosComm_, &commRank) ; 
    2828    winNotify_ = new CWindowManager(xiosComm_, maxBufferSize_) ; 
     29    winNotify_->updateToExclusiveWindow(commRank, this, &CContextsManager::notificationsDumpOut) ; 
    2930    
    3031 
    3132    winContexts_ = new CWindowManager(xiosComm_, maxBufferSize_) ; 
    32     winContexts_->lockWindow(commRank,0) ; 
    33     winContexts_->updateToWindow(commRank, this, &CContextsManager::contextsDumpOut) ; 
    34     winContexts_->unlockWindow(commRank,0) ; 
    35  
     33    winContexts_->updateToExclusiveWindow(commRank, this, &CContextsManager::contextsDumpOut) ; 
     34   
    3635    MPI_Barrier(xiosComm_)  ;     
    3736  } 
     
    111110    winNotify_->lockWindowExclusive(rank) ; 
    112111    winNotify_->pushToLockedWindow(rank, this, &CContextsManager::notificationsDumpOut) ; 
    113     winNotify_->unlockWindow(rank) ; 
     112    winNotify_->unlockWindowExclusive(rank) ; 
    114113  } 
    115114 
     
    170169    int commRank ; 
    171170    MPI_Comm_rank(xiosComm_, &commRank) ; 
    172     winNotify_->lockWindowExclusive(commRank) ; 
    173     winNotify_->popFromLockedWindow(commRank, this, &CContextsManager::notificationsDumpIn) ; 
    174     winNotify_->unlockWindow(commRank) ; 
     171    winNotify_->popFromExclusiveWindow(commRank, this, &CContextsManager::notificationsDumpIn) ; 
    175172    if (notifyType_==NOTIFY_CREATE_CONTEXT) createServerContext() ; 
    176173    else if (notifyType_==NOTIFY_CREATE_INTERCOMM) createServerContextIntercomm() ; 
     
    215212    contexts_[fullContextId] = contextInfo ; 
    216213    winContexts_->updateToLockedWindow(managerGlobalLeader_, this, &CContextsManager::contextsDumpOut) ; 
    217     winContexts_->unlockWindow(managerGlobalLeader_) ; 
     214    winContexts_->unlockWindowExclusive(managerGlobalLeader_) ; 
    218215  } 
    219216 
     
    227224    { 
    228225 
    229       winContexts_->lockWindowShared(managerGlobalLeader_) ; 
    230       winContexts_->updateFromLockedWindow(managerGlobalLeader_, this, &CContextsManager::contextsDumpIn) ; 
    231       winContexts_->unlockWindow(managerGlobalLeader_) ; 
     226      winContexts_->updateFromSharedWindow(managerGlobalLeader_, this, &CContextsManager::contextsDumpIn) ; 
    232227 
    233228      auto it=contexts_.find(fullContextId) ; 
  • XIOS3/trunk/src/manager/coupler_manager.cpp

    r1878 r2517  
    2323    if (commRank==managerGlobalLeader_) 
    2424    { 
    25       winRegistredCoupling_->lockWindow(managerGlobalLeader_,0) ; 
    26       winRegistredCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ; 
    27       winRegistredCoupling_->unlockWindow(managerGlobalLeader_,0) ; 
    28  
    29       winNextCoupling_->lockWindow(managerGlobalLeader_,0) ; 
    30       winNextCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ; 
    31       winNextCoupling_->unlockWindow(managerGlobalLeader_,0) ; 
     25      winRegistredCoupling_->updateToExclusiveWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ; 
     26      winNextCoupling_->updateToExclusiveWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ; 
    3227    } 
    3328 
     
    4742    size_t key = strHash(getStrCoupling(srcCoupling,dstCoupling)) ; 
    4843     
    49     winRegistredCoupling_->lockWindow(managerGlobalLeader_,0) ; 
    50     winRegistredCoupling_->updateFromWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpIn) ; 
     44    winRegistredCoupling_->lockWindowExclusive(managerGlobalLeader_) ; 
     45    winRegistredCoupling_->updateFromLockedWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpIn) ; 
    5146    if (registredCoupling_.count(key)==1) 
    5247    { 
    5348      registredCoupling_.erase(key) ; 
    54       winRegistredCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ; 
    55       winNextCoupling_->lockWindow(managerGlobalLeader_,0) ; 
    56       winNextCoupling_->updateFromWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpIn) ; 
     49      winRegistredCoupling_->updateToLockedWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ; 
     50      winNextCoupling_->lockWindowExclusive(managerGlobalLeader_) ; 
     51      winNextCoupling_->updateFromLockedWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpIn) ; 
    5752      nextCoupling_.push_back(pair<size_t,int>(key,2)) ; 
    58       winNextCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ; 
    59       winNextCoupling_->unlockWindow(managerGlobalLeader_,0) ; 
     53      winNextCoupling_->updateToLockedWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ; 
     54      winNextCoupling_->unlockWindowExclusive(managerGlobalLeader_) ; 
    6055    } 
    6156    else  
    6257    { 
    6358      registredCoupling_.insert(key) ; 
    64       winRegistredCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ; 
     59      winRegistredCoupling_->updateToLockedWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ; 
    6560    } 
    66     winRegistredCoupling_->unlockWindow(managerGlobalLeader_,0) ; 
     61    winRegistredCoupling_->unlockWindowExclusive(managerGlobalLeader_) ; 
    6762  } 
    6863 
     
    7368    size_t key = strHash(getStrCoupling(srcCoupling,dstCoupling)) ; 
    7469 
    75     winNextCoupling_->lockWindow(managerGlobalLeader_,0) ; 
    76     winNextCoupling_->updateFromWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpIn) ; 
     70    winNextCoupling_->lockWindowExclusive(managerGlobalLeader_) ; 
     71    winNextCoupling_->updateFromLockedWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpIn) ; 
    7772    if (nextCoupling_.front().first==key) 
    7873    { 
     
    8075      if (nextCoupling_.front().second==1) nextCoupling_.pop_front() ; 
    8176      else nextCoupling_.front().second=1 ; 
    82       winNextCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ; 
     77      winNextCoupling_->updateToLockedWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ; 
    8378    } 
    8479    else ret=false ; 
    85     winNextCoupling_->unlockWindow(managerGlobalLeader_,0) ; 
     80    winNextCoupling_->unlockWindowExclusive(managerGlobalLeader_) ; 
    8681    return ret ; 
    8782  } 
  • XIOS3/trunk/src/manager/pool_ressource.cpp

    r2494 r2517  
    2727     
    2828    notifyType_=NOTIFY_NOTHING; 
    29     winNotify_->lockWindow(commRank,0) ; 
    30     winNotify_->updateToWindow(commRank, this, &CPoolRessource::notificationsDumpOut) ; 
    31     winNotify_->unlockWindow(commRank,0) ;        
     29    winNotify_->updateToExclusiveWindow(commRank, this, &CPoolRessource::notificationsDumpOut) ; 
    3230    MPI_Barrier(poolComm_) ; 
    3331  } 
     
    104102  void CPoolRessource::sendNotification(int rank) 
    105103  { 
    106     winNotify_->lockWindowExclusive(rank) ; 
    107     winNotify_->pushToLockedWindow(rank, this, &CPoolRessource::notificationsDumpOut) ; 
    108     winNotify_->unlockWindow(rank) ; 
     104    winNotify_->pushToExclusiveWindow(rank, this, &CPoolRessource::notificationsDumpOut) ; 
    109105  } 
    110106 
     
    113109    int commRank ; 
    114110    MPI_Comm_rank(poolComm_, &commRank) ; 
    115     winNotify_->lockWindowExclusive(commRank) ; 
    116     winNotify_->popFromLockedWindow(commRank, this, &CPoolRessource::notificationsDumpIn) ; 
    117     winNotify_->unlockWindow(commRank) ; 
     111    winNotify_->popFromExclusiveWindow(commRank, this, &CPoolRessource::notificationsDumpIn) ; 
    118112    if (notifyType_==NOTIFY_CREATE_SERVICE) createService() ; 
    119113    else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO) createServiceOnto() ; 
  • XIOS3/trunk/src/manager/ressources_manager.cpp

    r2458 r2517  
    4949    info(40)<<"CRessourcesManager::createPool : calling createPool : "<<poolId<<"  of size"<<size<<endl ; 
    5050    info(40)<<"send notification to leader : "<<serverLeader_<<endl ; 
    51     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    52     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    53     winRessources_->unlockWindow(managerGlobalLeader_,0) ;     
    54     
     51    winRessources_->updateFromExclusiveWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
     52     
    5553    notifyType_=NOTIFY_CREATE_POOL ; 
    5654    notifyCreatePool_=make_tuple(poolId, size) ; 
     
    6159  void CRessourcesManager::finalize(void) 
    6260  { 
    63     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    64     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    65     winRessources_->unlockWindow(managerGlobalLeader_,0) ;     
     61    winRessources_->updateFromExclusiveWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    6662    
    6763    if (serverLeader_!=-1) 
     
    7773    winNotify_->lockWindowExclusive(rank) ; 
    7874    winNotify_->pushToLockedWindow(rank, this, &CRessourcesManager::notificationsDumpOut) ; 
    79     winNotify_->unlockWindow(rank) ; 
     75    winNotify_->unlockWindowExclusive(rank) ; 
    8076  } 
    8177 
     
    139135    CTimer::get("CRessourcesManager::checkNotifications pop").suspend(); 
    140136    CTimer::get("CRessourcesManager::checkNotifications unlock").resume(); 
    141     winNotify_->unlockWindow(commRank) ; 
     137    winNotify_->unlockWindowExclusive(commRank) ; 
    142138    CTimer::get("CRessourcesManager::checkNotifications unlock").suspend(); 
    143139    if (notifyType_==NOTIFY_CREATE_POOL) createPool() ; 
     
    196192  void CRessourcesManager::registerServerLeader(int serverLeaderRank) 
    197193  { 
    198     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    199     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
     194    winRessources_->lockWindowExclusive(managerGlobalLeader_) ; 
     195    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    200196    serverLeader_ = serverLeaderRank ; 
    201     winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
    202     winRessources_->unlockWindow(managerGlobalLeader_,0) ;     
     197    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
     198    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ;     
    203199  } 
    204200   
    205201  void CRessourcesManager::registerRessourcesSize(int size) 
    206202  { 
    207     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    208     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
     203    winRessources_->lockWindowExclusive(managerGlobalLeader_) ; 
     204    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    209205    ressourcesSize_ = size ; 
    210206    freeRessourcesSize_ = size ; 
    211     winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
    212     winRessources_->unlockWindow(managerGlobalLeader_,0) ;     
     207    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
     208    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ;     
    213209  } 
    214210 
     
    216212  void CRessourcesManager::registerPoolClient(const string& poolId, int size, int leader) 
    217213  { 
    218     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    219     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
     214    winRessources_->lockWindowExclusive(managerGlobalLeader_) ; 
     215    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    220216    pools_[poolId] = make_tuple(size, size, leader) ; 
    221     winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
    222     winRessources_->unlockWindow(managerGlobalLeader_,0) ;     
     217    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
     218    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ;     
    223219  } 
    224220 
    225221  void CRessourcesManager::registerPoolServer(const string& poolId, int size, int leader) 
    226222  { 
    227     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    228     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
     223    winRessources_->lockWindowExclusive(managerGlobalLeader_) ; 
     224    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    229225    pools_[poolId] = make_tuple(size, size, leader) ; 
    230226    freeRessourcesSize_-=size ; 
    231     winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
    232     winRessources_->unlockWindow(managerGlobalLeader_,0) ;     
     227    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
     228    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ;     
    233229  } 
    234230 
    235231  bool CRessourcesManager::getPoolInfo(const string& poolId, int& size, int& freeSize, int& leader) 
    236232  { 
    237     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    238     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    239     winRessources_->unlockWindow(managerGlobalLeader_,0) ; 
     233    winRessources_->updateFromSharedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    240234 
    241235    auto it=pools_.find(poolId) ; 
     
    254248    bool ret ; 
    255249 
    256     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    257     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
     250    winRessources_->lockWindowExclusive(managerGlobalLeader_) ; 
     251    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    258252    
    259253 
     
    266260      ret=true ; 
    267261    } 
    268     winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
    269     winRessources_->unlockWindow(managerGlobalLeader_,0) ;  
     262    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ; 
     263    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ;  
    270264 
    271265    return ret ;    
     
    274268  int CRessourcesManager::getRessourcesSize(void) 
    275269  { 
    276     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    277     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    278     winRessources_->unlockWindow(managerGlobalLeader_,0) ; 
    279  
     270    winRessources_->updateFromSharedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
     271     
    280272    return ressourcesSize_ ; 
    281273  } 
     
    283275  int CRessourcesManager::getFreeRessourcesSize(void) 
    284276  { 
    285     winRessources_->lockWindow(managerGlobalLeader_,0) ; 
    286     winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    287     winRessources_->unlockWindow(managerGlobalLeader_,0) ; 
     277    winRessources_->updateFromSharedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ; 
    288278 
    289279    return freeRessourcesSize_ ; 
  • XIOS3/trunk/src/manager/server_context.cpp

    r2274 r2517  
    160160  void CServerContext::sendNotification(int rank) 
    161161  { 
    162     winNotify_->lockWindowExclusive(rank) ; 
    163     winNotify_->pushToLockedWindow(rank, this, &CServerContext::notificationsDumpOut) ; 
    164     winNotify_->unlockWindow(rank) ; 
     162    winNotify_->pushToExclusiveWindow(rank, this, &CServerContext::notificationsDumpOut) ; 
    165163  } 
    166164 
     
    201199        int commRank ; 
    202200        MPI_Comm_rank(contextComm_, &commRank) ; 
    203         winNotify_->lockWindowExclusive(commRank) ; 
    204         winNotify_->popFromLockedWindow(commRank, this, &CServerContext::notificationsDumpIn) ; 
    205         winNotify_->unlockWindow(commRank) ; 
    206        
     201        winNotify_->popFromExclusiveWindow(commRank, this, &CServerContext::notificationsDumpIn) ; 
     202        
    207203        if (notifyInType_!= NOTIFY_NOTHING) 
    208204        { 
  • XIOS3/trunk/src/manager/servers_ressource.cpp

    r2458 r2517  
    8181  void CServersRessource::sendNotification(int rank) 
    8282  { 
    83     winNotify_->lockWindow(rank,0) ; 
    84     winNotify_->pushToWindow(rank, this, &CServersRessource::notificationsDumpOut) ; 
    85     winNotify_->unlockWindow(rank,0) ; 
     83    winNotify_->pushToExclusiveWindow(rank, this, &CServersRessource::notificationsDumpOut) ; 
    8684  } 
    8785 
     
    146144    int commRank ; 
    147145    MPI_Comm_rank(serverComm_, &commRank) ; 
    148     winNotify_->lockWindow(commRank,0) ; 
    149     winNotify_->popFromWindow(commRank, this, &CServersRessource::notificationsDumpIn) ; 
    150     winNotify_->unlockWindow(commRank,0) ; 
     146    winNotify_->popFromExclusiveWindow(commRank, this, &CServersRessource::notificationsDumpIn) ; 
    151147    if (notifyInType_==NOTIFY_CREATE_POOL) createPool() ; 
    152148    else if (notifyInType_==NOTIFY_FINALIZE) finalizeSignal() ; 
  • XIOS3/trunk/src/manager/services.cpp

    r2486 r2517  
    2727     
    2828    winNotify_ = new CWindowManager(serviceComm_, maxBufferSize_) ; 
    29     winNotify_->lockWindow(localRank,0) ; 
    30     winNotify_->updateToWindow(localRank, this, &CService::createContextDumpOut) ; 
    31     winNotify_->unlockWindow(localRank,0) ; 
     29    winNotify_->updateToExclusiveWindow(localRank, this, &CService::createContextDumpOut) ; 
    3230    MPI_Barrier(serviceComm_) ; 
    3331    if (localRank==localLeader_)  
     
    7472  void CService::createContextNotify(int rank, const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) 
    7573  { 
    76     winNotify_->lockWindow(rank,0) ; 
    77     winNotify_->updateFromWindow(rank, this, &CService::createContextDumpIn) ; 
     74    winNotify_->lockWindowExclusive(rank) ; 
     75    winNotify_->updateFromLockedWindow(rank, this, &CService::createContextDumpIn) ; 
    7876    notifications_.push_back(std::make_tuple(poolId, serviceId, partitionId, contextId)) ; 
    79     winNotify_->updateToWindow(rank, this, &CService::createContextDumpOut) ;   
    80     winNotify_->unlockWindow(rank,0) ;    
     77    winNotify_->updateToLockedWindow(rank, this, &CService::createContextDumpOut) ;   
     78    winNotify_->unlockWindowExclusive(rank) ;    
    8179  } 
    8280 
     
    143141  void CService::sendNotification(int rank) 
    144142  { 
    145     winNotify_->lockWindowExclusive(rank) ; 
    146     winNotify_->pushToLockedWindow(rank, this, &CService::notificationsDumpOut) ; 
    147     winNotify_->unlockWindow(rank) ; 
     143    winNotify_->pushToExclusiveWindow(rank, this, &CService::notificationsDumpOut) ; 
    148144  } 
    149145 
     
    187183        int commRank ; 
    188184        MPI_Comm_rank(serviceComm_, &commRank) ; 
    189         winNotify_->lockWindowExclusive(commRank) ; 
    190         winNotify_->popFromLockedWindow(commRank, this, &CService::notificationsDumpIn) ; 
    191         winNotify_->unlockWindow(commRank) ; 
    192        
     185        winNotify_->popFromExclusiveWindow(commRank, this, &CService::notificationsDumpIn) ; 
     186         
    193187        if (notifyInType_!= NOTIFY_NOTHING) 
    194188        { 
     
    227221    int commRank ; 
    228222    MPI_Comm_rank(serviceComm_, &commRank) ; 
    229     winNotify_->lockWindow(commRank,0) ; 
    230     winNotify_->updateFromWindow(commRank, this, &CService::createContextDumpIn) ; 
     223    winNotify_->lockWindowExclusive(commRank) ; 
     224    winNotify_->updateFromLockedWindow(commRank, this, &CService::createContextDumpIn) ; 
    231225     
    232226    if (!notifications_.empty()) 
     
    235229      createNewContext(get<0>(info), get<1>(info), get<2>(info), get<3>(info)) ; 
    236230      notifications_.pop_front() ; 
    237       winNotify_->updateToWindow(commRank, this, &CService::createContextDumpOut) ;      
    238     } 
    239     winNotify_->unlockWindow(commRank,0) ; 
     231      winNotify_->updateToLockedWindow(commRank, this, &CService::createContextDumpOut) ;      
     232    } 
     233    winNotify_->unlockWindowExclusive(commRank) ; 
    240234  } 
    241235 
  • XIOS3/trunk/src/manager/services_manager.cpp

    r2507 r2517  
    3131    MPI_Comm_rank(xiosComm_, &commRank) ; 
    3232    winNotify_ = new CWindowManager(xiosComm_, maxBufferSize_) ; 
    33     winNotify_->lockWindow(commRank,0) ; 
    34     winNotify_->updateToWindow(commRank, this, &CServicesManager::notificationsDumpOut) ; 
    35     winNotify_->unlockWindow(commRank,0) ; 
     33    winNotify_->updateToExclusiveWindow(commRank, this, &CServicesManager::notificationsDumpOut) ; 
    3634 
    3735    winServices_ = new CWindowManager(xiosComm_, maxBufferSize_) ; 
    38     winServices_->lockWindow(commRank,0) ; 
    39     winServices_->updateToWindow(commRank, this, &CServicesManager::servicesDumpOut) ; 
    40     winServices_->unlockWindow(commRank,0) ; 
    41  
     36    winServices_->updateToExclusiveWindow(commRank, this, &CServicesManager::servicesDumpOut) ; 
     37    
    4238    MPI_Barrier(xiosComm_)  ;     
    4339  } 
     
    121117  void CServicesManager::sendNotification(int rank) 
    122118  { 
    123     winNotify_->lockWindowExclusive(rank) ; 
    124     winNotify_->pushToLockedWindow(rank, this, &CServicesManager::notificationsDumpOut) ; 
    125     winNotify_->unlockWindow(rank) ; 
     119    winNotify_->pushToExclusiveWindow(rank, this, &CServicesManager::notificationsDumpOut) ; 
    126120  } 
    127121 
     
    147141    int commRank ; 
    148142    MPI_Comm_rank(xiosComm_, &commRank) ; 
    149     winNotify_->lockWindowExclusive(commRank) ; 
    150     winNotify_->popFromLockedWindow(commRank, this, &CServicesManager::notificationsDumpIn) ; 
    151     winNotify_->unlockWindow(commRank) ; 
     143    winNotify_->popFromExclusiveWindow(commRank, this, &CServicesManager::notificationsDumpIn) ; 
    152144    if (notifyType_==NOTIFY_CREATE_SERVICE) createService() ; 
    153145    else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO) createServiceOnto() ; 
     
    253245    services_[std::tuple<std::string, std::string,int>(poolId,serviceId,partitionId)]=std::make_tuple(type,size,nbPartitions,leader) ; 
    254246    winServices_->updateToLockedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpOut) ; 
    255     winServices_->unlockWindow(managerGlobalLeader_) ; 
     247    winServices_->unlockWindowExclusive(managerGlobalLeader_) ; 
    256248 
    257249  } 
     
    260252                                        int& size, int& nbPartitions, int& leader, bool wait) 
    261253  { 
    262     winServices_->lockWindowShared(managerGlobalLeader_) ; 
    263     winServices_->updateFromLockedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpIn) ; 
    264     winServices_->unlockWindow(managerGlobalLeader_) ; 
     254    winServices_->updateFromSharedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpIn) ; 
    265255     
    266256    if (wait) waitServiceRegistration(poolId, serviceId, partitionId) ; 
     
    303293  bool CServicesManager::hasService(const std::string& poolId, const std::string& serviceId, const int& partitionId) 
    304294  { 
    305     winServices_->lockWindowShared(managerGlobalLeader_) ; 
    306     winServices_->updateFromLockedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpIn) ; 
    307     winServices_->unlockWindow(managerGlobalLeader_) ; 
     295    winServices_->updateFromSharedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpIn) ; 
    308296    auto it=services_.find(std::tuple<std::string, std::string, int>(poolId, serviceId, partitionId)) ; 
    309297    if ( it == services_.end()) return false ; 
  • XIOS3/trunk/src/manager/window_manager.cpp

    r1761 r2517  
    77{ 
    88   
    9    
     9    const MPI_Aint CWindowManager::OFFSET_LOCK ; 
     10    const int CWindowManager::SIZE_LOCK ; 
     11    const MPI_Aint CWindowManager::OFFSET_BUFFER_SIZE ; 
     12    const int CWindowManager::SIZE_BUFFER_SIZE ; 
     13    const MPI_Aint CWindowManager::OFFSET_BUFFER; 
     14    const int CWindowManager::WINDOWS_LOCKED ; 
    1015} 
    1116 
  • XIOS3/trunk/src/manager/window_manager.hpp

    r2263 r2517  
    77#include "buffer_out.hpp" 
    88#include "message.hpp" 
     9#include "window_base.hpp" 
    910 
    1011namespace xios 
     
    1213 
    1314 
    14   class CWindowManager 
     15  class CWindowManager : public CWindowBase  
    1516  { 
    1617 
    1718    private : 
    18     const MPI_Aint OFFSET_LOCK=0 ; 
    19     const int SIZE_LOCK=sizeof(int) ; 
    20     const MPI_Aint OFFSET_BUFFER_SIZE=OFFSET_LOCK+SIZE_LOCK ; 
    21     const int SIZE_BUFFER_SIZE=sizeof(size_t) ; 
    22     const MPI_Aint OFFSET_BUFFER=OFFSET_BUFFER_SIZE+SIZE_BUFFER_SIZE ; 
    23     const int WINDOWS_LOCKED=-1 ; 
     19    static const MPI_Aint OFFSET_LOCK=0 ; 
     20    static const int SIZE_LOCK=sizeof(int) ; 
     21    static const MPI_Aint OFFSET_BUFFER_SIZE=OFFSET_LOCK+SIZE_LOCK ; 
     22    static const int SIZE_BUFFER_SIZE=sizeof(size_t) ; 
     23    static const MPI_Aint OFFSET_BUFFER=OFFSET_BUFFER_SIZE+SIZE_BUFFER_SIZE ; 
     24    static const int WINDOWS_LOCKED=-1 ; 
    2425 
    2526    MPI_Win window_ ; 
     
    3031    public : 
    3132 
    32     CWindowManager(MPI_Comm winComm, size_t bufferSize) 
    33     { 
    34       const MPI_Aint windowSize=bufferSize+OFFSET_BUFFER ; 
    35       MPI_Win_allocate(windowSize, 1, MPI_INFO_NULL, winComm, &winBuffer_, &window_) ; 
     33    CWindowManager(MPI_Comm winComm, size_t bufferSize) : CWindowBase(winComm, bufferSize + OFFSET_BUFFER_SIZE) 
     34    { 
    3635      int lock=0 ; 
    3736      size_t size=0 ; 
    3837      int commRank ; 
    3938      MPI_Comm_rank(winComm, &commRank) ; 
    40       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, commRank, 0, window_) ; 
    41       MPI_Put(&lock, SIZE_LOCK, MPI_CHAR, commRank, OFFSET_LOCK, SIZE_LOCK, MPI_CHAR, window_) ; 
    42       MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, commRank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    43       MPI_Win_unlock(commRank, window_) ; 
     39      lockExclusive(commRank) ; 
     40      put(&lock, SIZE_LOCK, MPI_CHAR, commRank, OFFSET_LOCK, SIZE_LOCK, MPI_CHAR) ; 
     41      put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, commRank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ; 
     42      unlockExclusive(commRank) ; 
    4443      MPI_Barrier(winComm) ; 
    4544    } 
     
    6362        int flag ; 
    6463        MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE); 
    65         MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    66         MPI_Compare_and_swap(&WINDOWS_LOCKED, &state, &lock, MPI_INT, rank, OFFSET_LOCK, window_) ; 
    67         MPI_Win_unlock(rank, window_) ; 
     64        compareAndSwap(&WINDOWS_LOCKED, &state, &lock, MPI_INT, rank, OFFSET_LOCK) ; 
     65        flush(rank) ; 
    6866        lastTime=MPI_Wtime() ; 
    6967      } while (lock!=state) ; 
     
    9088        int flag ; 
    9189        MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE); 
    92         MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    93         MPI_Compare_and_swap(&WINDOWS_LOCKED, &state, &lock, MPI_INT, rank, OFFSET_LOCK, window_) ; 
    94         MPI_Win_unlock(rank, window_) ; 
     90        lockExclusive(rank) ; 
     91        compareAndSwap(&WINDOWS_LOCKED, &state, &lock, MPI_INT, rank, OFFSET_LOCK) ; 
     92        unlockExclusive(rank) ; 
    9593        lastTime=MPI_Wtime() ; 
    9694      } while (lock!=state) ; 
     
    9997    void lockWindowExclusive(int rank) 
    10098    { 
    101       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
     99      lockExclusive(rank) ; 
    102100    } 
    103101 
    104102    void lockWindowShared(int rank) 
    105103    { 
    106       MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ; 
    107     } 
    108  
     104      lockShared(rank) ; 
     105    } 
     106 
     107    void unlockWindowExclusive(int rank) 
     108    { 
     109      unlockExclusive(rank) ; 
     110    } 
     111 
     112    void unlockWindowShared(int rank) 
     113    { 
     114      unlockShared(rank) ; 
     115    } 
     116 
     117    void lockWindow(int rank) 
     118    { 
     119      lockWindowExclusive(rank) ; 
     120    } 
     121     
    109122    void unlockWindow(int rank) 
    110123    { 
    111       MPI_Win_unlock(rank, window_) ; 
     124      unlockWindowExclusive(rank) ; 
    112125    } 
    113126 
    114127    void flushWindow(int rank) 
    115128    { 
    116       MPI_Win_flush(rank, window_) ; 
     129      flush(rank) ; 
    117130    } 
    118131 
     
    120133    { 
    121134      int lock ; 
    122       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    123       MPI_Compare_and_swap(&state, &WINDOWS_LOCKED, &lock, MPI_INT, rank, OFFSET_LOCK, window_) ; 
    124       MPI_Win_unlock(rank, window_) ; 
     135      compareAndSwap(&state, &WINDOWS_LOCKED, &lock, MPI_INT, rank, OFFSET_LOCK) ; 
     136      flush(rank) ; 
    125137    } 
    126138     
    127139    template< class T > 
    128140    void updateToWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
     141    { 
     142      updateToExclusiveWindow(rank, object, dumpOut) ; 
     143    } 
     144 
     145    template< class T > 
     146    void updateToExclusiveWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
     147    { 
     148      lockExclusive(rank) ; 
     149      updateToLockedWindow(rank, object, dumpOut) ; 
     150      unlockExclusive(rank) ; 
     151     } 
     152 
     153    template< class T > 
     154    void updateTosharedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
     155    { 
     156      lockShared(rank) ; 
     157      updateToLockedWindow(rank, object, dumpOut) ; 
     158      unlockShared(rank) ; 
     159    } 
     160 
     161    template< class T > 
     162    void updateToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    129163    { 
    130164      CBufferOut buffer ; 
    131165      (object->*dumpOut)(buffer) ; 
    132166      size_t size=buffer.count() ; 
    133       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    134       MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    135       MPI_Put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    136       MPI_Win_unlock(rank, window_) ; 
    137     } 
    138  
    139     template< class T > 
    140     void updateToExclusiveWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    141     { 
    142       CBufferOut buffer ; 
    143       (object->*dumpOut)(buffer) ; 
    144       size_t size=buffer.count() ; 
    145       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    146       MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    147       MPI_Put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    148       MPI_Win_unlock(rank, window_) ; 
    149     } 
    150  
    151     template< class T > 
    152     void updateTosharedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    153     { 
    154       CBufferOut buffer ; 
    155       (object->*dumpOut)(buffer) ; 
    156       size_t size=buffer.count() ; 
    157       MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ; 
    158       MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    159       MPI_Put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    160       MPI_Win_unlock(rank, window_) ; 
    161     } 
    162  
    163     template< class T > 
    164     void updateToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    165     { 
    166       CBufferOut buffer ; 
    167       (object->*dumpOut)(buffer) ; 
    168       size_t size=buffer.count() ; 
    169 //      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    170       MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    171       MPI_Put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    172       MPI_Win_flush(rank, window_) ; 
    173 //      MPI_Win_unlock(rank, window_) ; 
     167 
     168      put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ; 
     169      put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR) ; 
     170      flush(rank) ; 
    174171    } 
    175172 
     
    177174    void updateFromWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
    178175    { 
    179       size_t size ; 
    180       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    181       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    182       MPI_Win_flush(rank,window_) ; 
     176      updateFromExclusiveWindow(rank,object, dumpIn) ; 
     177    } 
     178 
     179    template< typename T > 
     180    void updateFromExclusiveWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
     181    { 
     182      size_t size ; 
     183      lockExclusive(rank) ; 
     184      updateFromLockedWindow(rank,object, dumpIn) ; 
     185      unlockExclusive(rank) ; 
     186    } 
     187 
     188    template< typename T > 
     189    void updateFromSharedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
     190    { 
     191      size_t size ; 
     192      lockShared(rank) ; 
     193      updateFromLockedWindow(rank,object, dumpIn) ; 
     194      unlockShared(rank) ; 
     195    } 
     196 
     197    template< typename T > 
     198    void updateFromLockedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
     199    { 
     200      size_t size ; 
     201 
     202      get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ; 
     203      flush(rank) ; 
    183204      CBufferIn buffer(size) ; 
    184       MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    185       MPI_Win_unlock(rank, window_) ; 
     205      get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR) ; 
     206      flush(rank) ; 
     207 
    186208      (object->*dumpIn)(buffer) ; 
    187209    } 
    188210 
    189     template< typename T > 
    190     void updateFromExclusiveWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
    191     { 
    192       size_t size ; 
    193       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    194       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    195       MPI_Win_flush(rank,window_) ; 
    196       CBufferIn buffer(size) ; 
    197       MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    198       MPI_Win_unlock(rank, window_) ; 
    199       (object->*dumpIn)(buffer) ; 
    200     } 
    201  
    202     template< typename T > 
    203     void updateFromSharedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
    204     { 
    205       size_t size ; 
    206       MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ; 
    207       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    208       MPI_Win_flush(rank,window_) ; 
    209       CBufferIn buffer(size) ; 
    210       MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    211       MPI_Win_unlock(rank, window_) ; 
    212       (object->*dumpIn)(buffer) ; 
    213     } 
    214  
    215     template< typename T > 
    216     void updateFromLockedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
    217     { 
    218       size_t size ; 
    219 //      MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ; 
    220       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    221       MPI_Win_flush(rank,window_) ; 
    222       CBufferIn buffer(size) ; 
    223       MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    224 //      MPI_Win_unlock(rank, window_) ; 
    225       MPI_Win_flush(rank, window_) ; 
    226       (object->*dumpIn)(buffer) ; 
    227     } 
    228211 
    229212 
     
    231214    void pushToWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    232215    { 
    233       size_t size ; 
    234       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    235       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    236       MPI_Win_flush(rank,window_) ; 
     216      pushToExclusiveWindow(rank, object, dumpOut) ; 
     217    } 
     218 
     219    template< class T > 
     220    void pushToExclusiveWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
     221    { 
     222      lockExclusive(rank) ; 
     223      pushToLockedWindow(rank, object, dumpOut) ; 
     224      unlockExclusive(rank) ; 
     225    } 
     226 
     227    template< class T > 
     228    void pushToSharedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
     229    { 
     230      lockShared(rank) ; 
     231      pushToLockedWindow(rank, object, dumpOut) ; 
     232      unlockShared(rank) ; 
     233    } 
     234 
     235    template< class T > 
     236    void pushToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
     237    { 
     238      size_t size ; 
     239      get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ; 
     240      flush(rank) ; 
    237241      CBufferOut buffer ; 
    238242      (object->*dumpOut)(buffer) ; 
    239243      size_t bufferSize=buffer.count() ; 
    240244      size_t newSize = size + bufferSize; 
    241       MPI_Put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    242       MPI_Put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR, window_) ; 
    243       MPI_Win_unlock(rank, window_) ; 
    244     } 
    245  
    246     template< class T > 
    247     void pushToExclusiveWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    248     { 
    249       size_t size ; 
    250       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    251       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    252       MPI_Win_flush(rank,window_) ; 
    253       CBufferOut buffer ; 
    254       (object->*dumpOut)(buffer) ; 
    255       size_t bufferSize=buffer.count() ; 
    256       size_t newSize = size + bufferSize; 
    257       MPI_Put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    258       MPI_Put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR, window_) ; 
    259       MPI_Win_unlock(rank, window_) ; 
    260     } 
    261  
    262     template< class T > 
    263     void pushToSharedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    264     { 
    265       size_t size ; 
    266       MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ; 
    267       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    268       MPI_Win_flush(rank,window_) ; 
    269       CBufferOut buffer ; 
    270       (object->*dumpOut)(buffer) ; 
    271       size_t bufferSize=buffer.count() ; 
    272       size_t newSize = size + bufferSize; 
    273       MPI_Put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    274       MPI_Put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR, window_) ; 
    275       MPI_Win_unlock(rank, window_) ; 
    276     } 
    277  
    278     template< class T > 
    279     void pushToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    280     { 
    281       size_t size ; 
    282       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    283       MPI_Win_flush(rank,window_) ; 
    284       CBufferOut buffer ; 
    285       (object->*dumpOut)(buffer) ; 
    286       size_t bufferSize=buffer.count() ; 
    287       size_t newSize = size + bufferSize; 
    288       MPI_Put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    289       MPI_Put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR, window_) ; 
    290       MPI_Win_flush(rank, window_) ; 
    291     } 
     245      put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ; 
     246      put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR) ; 
     247      flush(rank) ; 
     248    } 
     249 
     250 
    292251 
    293252    template< typename T > 
    294253    void popFromWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
    295254    { 
    296       size_t size ; 
    297       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    298       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    299       MPI_Win_flush(rank,window_) ; 
     255      popFromExclusiveWindow(rank,object, dumpIn) ;  
     256    } 
     257 
     258    template< typename T > 
     259    void popFromExclusiveWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
     260    { 
     261      lockExclusive(rank) ; 
     262      popFromLockedWindow(rank,object, dumpIn) ;  
     263      unlockExclusive(rank) ; 
     264       
     265    } 
     266 
     267    template< typename T > 
     268    void popFromSharedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
     269    { 
     270      lockShared(rank) ; 
     271      popFromLockedWindow(rank,object, dumpIn) ;  
     272      unlockShared(rank) ; 
     273    } 
     274 
     275    template< typename T > 
     276    void popFromLockedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
     277    { 
     278      size_t size ; 
     279      get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ; 
     280      flush(rank) ; 
    300281      CBufferIn buffer(size) ; 
    301       MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    302       MPI_Win_flush(rank,window_) ; 
     282      get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR) ; 
     283      flush(rank) ; 
    303284      (object->*dumpIn)(buffer) ; 
    304285       
    305286      size=buffer.remain() ; 
    306       MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    307       MPI_Put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR, window_) ; 
    308       MPI_Win_unlock(rank, window_) ; 
    309        
    310     } 
    311  
    312     template< typename T > 
    313     void popFromExclusiveWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
    314     { 
    315       size_t size ; 
    316       MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ; 
    317       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    318       MPI_Win_flush(rank,window_) ; 
    319       CBufferIn buffer(size) ; 
    320       MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    321       MPI_Win_flush(rank,window_) ; 
    322       (object->*dumpIn)(buffer) ; 
    323        
    324       size=buffer.remain() ; 
    325       MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    326       MPI_Put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR, window_) ; 
    327       MPI_Win_unlock(rank, window_) ; 
    328        
    329     } 
    330  
    331     template< typename T > 
    332     void popFromSharedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
    333     { 
    334       size_t size ; 
    335       MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ; 
    336       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    337       MPI_Win_flush(rank,window_) ; 
    338       CBufferIn buffer(size) ; 
    339       MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    340       MPI_Win_flush(rank,window_) ; 
    341       (object->*dumpIn)(buffer) ; 
    342        
    343       size=buffer.remain() ; 
    344       MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    345       MPI_Put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR, window_) ; 
    346       MPI_Win_unlock(rank, window_) ; 
    347        
    348     } 
    349  
    350     template< typename T > 
    351     void popFromLockedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
    352     { 
    353       size_t size ; 
    354       MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    355       MPI_Win_flush(rank,window_) ; 
    356       CBufferIn buffer(size) ; 
    357       MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
    358       MPI_Win_flush(rank,window_) ; 
    359       (object->*dumpIn)(buffer) ; 
    360        
    361       size=buffer.remain() ; 
    362       MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    363       MPI_Put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR, window_) ; 
    364       MPI_Win_flush(rank, window_) ; 
     287      put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ; 
     288      put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR) ; 
     289      flush(rank) ; 
    365290    } 
    366291 
    367292    ~CWindowManager() 
    368293    { 
    369       MPI_Win_free(&window_) ; 
    370294    } 
    371295  } ; 
Note: See TracChangeset for help on using the changeset viewer.