Ignore:
Timestamp:
11/17/21 16:56:04 (3 years ago)
Author:
ymipsl
Message:

Improvment of one-sided protocol.
Windows are now created in the flight for each client-server connection.
YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_client.cpp

    r2258 r2259  
    1414  size_t CClientBuffer::maxRequestSize = 0; 
    1515 
    16   CClientBuffer::CClientBuffer(MPI_Comm interComm, vector<MPI_Win>& windows, int clientRank, int serverRank, StdSize bufferSize, StdSize estimatedMaxEventSize) 
     16  CClientBuffer::CClientBuffer(MPI_Comm interComm, int serverRank, StdSize bufferSize, StdSize estimatedMaxEventSize) 
    1717    : interComm(interComm) 
    1818    , clientRank_(0) 
     
    2525    , pending(false) 
    2626    , hasWindows(false)  
    27     , windows_(windows) 
    28   { 
    29     if (windows[0]==MPI_WIN_NULL && windows[1]==MPI_WIN_NULL) hasWindows=false ; 
    30     else hasWindows=true ; 
     27  { 
     28     /* 
     29      if (windows[0]==MPI_WIN_NULL && windows[1]==MPI_WIN_NULL) hasWindows=false ; 
     30      else hasWindows=true ; 
     31     */ 
    3132 
    3233      MPI_Alloc_mem(bufferSize+headerSize_, MPI_INFO_NULL, &bufferHeader[0]) ; 
     
    8687  MPI_Aint CClientBuffer::getWinAddress(int i) 
    8788  { 
    88      MPI_Aint address ; 
    89       
    90      if (hasWindows) MPI_Get_address(bufferHeader[i], &address) ; 
    91      else address=0 ; 
    92  
    93      return address ; 
    94   } 
     89    MPI_Aint address ; 
     90    MPI_Get_address(bufferHeader[i], &address) ; 
     91    return address ; 
     92  } 
     93 
     94  void CClientBuffer::attachWindows(vector<MPI_Win>& windows) 
     95  { 
     96    windows_=windows ; 
     97    if (windows_[0]==MPI_WIN_NULL && windows_[1]==MPI_WIN_NULL) hasWindows=false ; 
     98    else hasWindows=true ; 
     99 
     100    if (hasWindows) 
     101    {   
     102      MPI_Aint buffSize=bufferSize+headerSize_ ; 
     103      MPI_Win_attach(windows_[0], bufferHeader[0], buffSize) ; 
     104      MPI_Win_attach(windows_[1], bufferHeader[1], buffSize) ; 
     105     
     106      MPI_Group group ; 
     107      int groupSize,groupRank ; 
     108      MPI_Win_get_group(windows_[0], &group) ; 
     109      MPI_Group_size(group, &groupSize) ; 
     110      MPI_Group_rank(group, &groupRank) ; 
     111      if (groupRank!=clientRank_) ERROR("CClientBuffer::CClientBuffer",<< " ClientRank != groupRank "<<clientRank_<<" "<<groupRank); 
     112 
     113      MPI_Win_get_group(windows_[1], &group) ; 
     114      MPI_Group_size(group, &groupSize) ; 
     115      MPI_Group_rank(group, &groupRank) ; 
     116      if (groupRank!=clientRank_) ERROR("CClientBuffer::CClientBuffer",<< " ClientRank != groupRank "<<clientRank_<<" "<<groupRank); 
     117 
     118      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[0]) ; 
     119      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[1]) ; 
     120 
     121      MPI_Win_unlock(clientRank_, windows_[1]) ; 
     122      MPI_Win_unlock(clientRank_, windows_[0]) ; 
     123    }  
     124 
     125  } 
     126 
    95127 
    96128  CClientBuffer::~CClientBuffer() 
     
    217249    int flag; 
    218250     
    219     MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[0]) ; 
    220     MPI_Win_unlock(clientRank_, windows_[0]) ; 
    221  
    222     MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[1]) ; 
    223     MPI_Win_unlock(clientRank_, windows_[1]) ; 
    224  
     251    if (hasWindows) 
     252    {  
     253      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[0]) ; 
     254      MPI_Win_unlock(clientRank_, windows_[0]) ; 
     255 
     256      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, clientRank_, 0, windows_[1]) ; 
     257      MPI_Win_unlock(clientRank_, windows_[1]) ; 
     258    } 
     259     
    225260    if (pending) 
    226261    { 
Note: See TracChangeset for help on using the changeset viewer.