Changeset 2263 for XIOS/dev


Ignore:
Timestamp:
11/19/21 18:27:19 (3 years ago)
Author:
ymipsl
Message:

Fix memory problem.
YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/manager/window_manager.hpp

    r2260 r2263  
    138138 
    139139    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 > 
    140164    void updateToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    141165    { 
     
    146170      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    147171      MPI_Put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
     172      MPI_Win_flush(rank, window_) ; 
    148173//      MPI_Win_unlock(rank, window_) ; 
    149174    } 
     
    154179      size_t size ; 
    155180      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_) ; 
     183      CBufferIn buffer(size) ; 
     184      MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ; 
     185      MPI_Win_unlock(rank, window_) ; 
     186      (object->*dumpIn)(buffer) ; 
     187    } 
     188 
     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_) ; 
    156207      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    157208      MPI_Win_flush(rank,window_) ; 
     
    194245 
    195246    template< class T > 
    196     void pushToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) ) 
    197     { 
    198       size_t size ; 
     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_) ; 
    199251      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    200252      MPI_Win_flush(rank,window_) ; 
     
    205257      MPI_Put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    206258      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_) ; 
    207291    } 
    208292 
     
    227311 
    228312    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 > 
    229351    void popFromLockedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) )  
    230352    { 
     
    240362      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ; 
    241363      MPI_Put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR, window_) ; 
     364      MPI_Win_flush(rank, window_) ; 
    242365    } 
    243366 
Note: See TracChangeset for help on using the changeset viewer.