Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsnRelaxedMemoryManager Class Reference

#include <PsnRelaxedMemoryManager.h>

Inheritance diagram for PsnRelaxedMemoryManager:

Inheritance graph
[legend]
Collaboration diagram for PsnRelaxedMemoryManager:

Collaboration graph
[legend]
List of all members.

Public Types

enum  PageState { Free, StepSync, LatencySync, Allocated }
 enumeration containing the different states a page can be in More...


Public Methods

 PsnRelaxedMemoryManager (void *startDsm, size_t sizeDsm, size_t pageSize, PsnUniqueCreator *creator, int queueSize)
 Constructeur :.

virtual ~PsnRelaxedMemoryManager ()
 Desctructeur.

virtual void sync ()
 Synchronise the memory managed by the PsnSharedMemoryManager.

virtual void strongSync ()
 Synchronise all of the managed memory now.

virtual void strongSynchronizeRegion (unsigned int startRegion, size_t sizeRegion)
 synchronise a subset of the managed memory now

virtual void synchronizeAfterLock (void *beginningAdress, long length)
 synchronize partially the memory as it was when the lock was last obtained

virtual void * mRelaxedMalloc (size_t size)
 allocate memory so it while be synced with latency simulation steps

virtual void mRelaxedFree (void *ptr, size_t size)
 free memory that was synced with latency simulation steps

virtual void * mSyncMalloc (size_t size)
 allocate memory so it while be synced at each simulation step

virtual void mSyncFree (void *ptr, size_t size)
 free memory that was synced at each simulation step

virtual void * allocateSizeRemembered (size_t size)
 redefinition of this malloc to delegate to the SharedFreeStoreMemoryManager

virtual void freeSizeRemembered (void *ptr)
 Accordingly, redefinition of this free.

virtual void * mmallocInPages (size_t size, unsigned int *initialOffsetForWrite, size_t *stepSize)
 Allocate a block at the same offset in numberOfPages pages.

virtual void mfreeInPages (void *ptr, size_t size)
 free a block at the same offset

virtual void * mmallocForOnce (size_t size)
 Allocate a block that oinly needs to be synced once.

virtual void mfreeForOnce (void *ptr, size_t size)
 free a block at the same offset

virtual void anticipateFreeStoreAllocation (int frame)
 prepare the memory manager for free store allocation which will be needed at frame if frame = -1, default mechanism is used (next frame)

virtual void syncStepSyncedMemory ()

Static Public Methods

int getWritableQueueIndex ()
 get the next queue index

int getNextSyncedQueueIndex ()
 get the next queue index

int getReadableQueueIndex ()
 get the current queue index


Protected Methods

virtual void * mLatencyMalloc (size_t size, list< PsnLatencySyncedSharedMemoryManager * > &memoryManagerList, int latency)
 common allocation member function for relaxedAlloc and SyncAlloc

virtual void mLatencyFree (void *ptr, size_t size, list< PsnLatencySyncedSharedMemoryManager * > &memoryManagerList)
 common deallocation membre function for relaxedFree and SyncFree

virtual void lock ()
 Proteger le Manager pour un accès en exclusion mutuelle.

virtual void unlock ()
 Lever l'exclusion mutuelle sur le memory manager.

virtual bool lockNeeded ()
 Is a lock needed ? before access to this shared memoryManager.

virtual void * getFromFree (size_t size)
 la zone de mémoire dans lesquels sont stockés les PsnMemoryElementDescriptor doit être vérouillée avant l'appel à cette fonction

virtual void addInFree (void *addr, size_t size)
 la zone de mémoire dans lesquels sont stockés les PsnMemoryElementDescriptor doit être vérouillée avant l'appel à cette fonction

virtual void syncSecondaryMemoryManagers ()
 call sync of all secondaryMemoryManagers


Protected Attributes

PsnLock_myLock
 Le verrou associé à la zone de mémoire.

PageState_pageState
 table containing the state of each page managed by this shared memory manager

bool * _myPage
 table containing containing a boolean indicating if the page is allocated locally

int * _whenSynced
 table containing the minor to which each page needs to be synchronized

int _numberOfManagedPages
 The number of pages managed.

int _firstFreePage
 the fisrt free page, as known localy

PsnUniqueCreator *const _myCreator
 The object that creates and destroys shared objects.

list< PsnSharedFreeStoreMemoryManager * > freeStoreManagers
 list of delegated FreeStoreManagers

list< PsnSharedArrayMemoryManager * > sharedArrayManagers
 list of delegated SharedArrayManagers

list< PsnLatencySyncedSharedMemoryManager * > stepSyncedMemoryManagers
 list of delegated SharedArrayManagers

list< PsnLatencySyncedSharedMemoryManager * > relaxedSyncedMemoryManagers
 list of delegated SharedArrayManagers

list< PsnOnceSyncedSharedMemoryManager * > onceSyncedMemoryManagers
 list of delegated OnceSyncedManagers

const int _queueSize
 the size of an outputQueue

int _frameForFreeStoreAllocation
unsigned long * oldSyncDate
 MomeDate and the end of initialisation.

bool _lockIsNeeded
 is a lock needed ?

long _timelost
 for profiling purposes :

timeval _dateReelleDebut
timeval _dateReelleFin

Static Protected Attributes

int _readableQueueIndex = 0
 the current outputQueue index being used (read)

int _writableQueueIndex = 0
 the current outputQueue index being used for write

int _nextSyncedQueueIndex = 0
 the next outputQueue index going to be synced


Friends

class PsnFramedMemoryManager
 any PsnFramedMemoryManager is allowed access to _whenSynced

class PsnLatencySyncedSharedMemoryManager
class PsnOnceSyncedSharedMemoryManager

Member Enumeration Documentation

enum PsnRelaxedMemoryManager::PageState
 

enumeration containing the different states a page can be in

Enumeration values:
Free 
StepSync 
LatencySync 
Allocated 

Definition at line 74 of file PsnRelaxedMemoryManager.h.

00074 { Free , StepSync , LatencySync , Allocated } ; 


Constructor & Destructor Documentation

PsnRelaxedMemoryManager::PsnRelaxedMemoryManager void *    startDsm,
size_t    sizeDsm,
size_t    pageSize,
PsnUniqueCreator   creator,
int    queueSize
 

Constructeur :.

Parameters:
sizeDsm size in number of bytes.

Definition at line 37 of file PsnRelaxedMemoryManager.cxx.

References _frameForFreeStoreAllocation, _lockIsNeeded, _myCreator, _myLock, _myPage, _nextSyncedQueueIndex, _numberOfManagedPages, _pageState, _queueSize, _readableQueueIndex, PsnSharedMemoryManager::_sizeDsm, PsnSharedMemoryManager::_startDsm, _timelost, _whenSynced, _writableQueueIndex, PsnLock::getLock(), PsnUniqueCreator::newPageStateTable(), PsnUniqueCreator::newWhenSyncedTable(), and oldSyncDate.

00041                                                                 : 
00042    PsnSharedMemoryManager(startDsm, sizeDsm, pageSize, 1),
00043    _numberOfManagedPages( sizeDsm / pageSize ),
00044    _firstFreePage(0) ,
00045    _myCreator ( creator ) ,
00046    _queueSize ( queueSize )
00047 {
00048 #ifdef _MOME
00049    _readableQueueIndex = queueSize - 2  ; //because création at initialisation time.
00050    _nextSyncedQueueIndex = 0 ;
00051    _writableQueueIndex  = 0 ;
00052 
00053    MomeConsistencyOfRegion (startDsm,
00054                             sizeDsm,
00055                             MomeStrongConsistency,
00056                             MomeRegionBlockingProtocol,
00057                             0);
00058 
00059    cerr<<"Relaxing consistency"<<endl;
00060 
00061    MomeConsistencyOfRegion (startDsm,
00062                             sizeDsm,
00063                             MomeRelaxedConsistency,
00064                             MomeRegionBlockingProtocol,
00065                             0);
00066    _myLock= new PsnLock();
00067    
00068    cerr<<"PsnRelaxedMemoryManager::PsnRelaxedMemoryManager obtenu le numero de verrou "<<_myLock->getLock()<<endl; 
00069 
00070    _pageState = _myCreator->newPageStateTable ( _numberOfManagedPages ) ;
00071 
00072    _whenSynced = _myCreator->newWhenSyncedTable( _numberOfManagedPages ) ;
00073    
00074    _myPage = new bool [_numberOfManagedPages] ;
00075    
00076    for (int i = 0 ; i<_numberOfManagedPages ; i++ ) {
00077       _myPage[i] = false ;
00078    }
00079 //     MomeConsistencyOfRegion((void*) _whenSynced,
00080 //                         sizeof(int[_numberOfManagedPages]),
00081 //                         MomeRelaxedConsistency,
00082 //                         MomeRegionBlockingProtocol,
00083 //                         0);
00084 
00085 #ifdef _DEBUGPAGEFAULTS
00086    MomeSetRegionAttributes ((void *)_startDsm,
00087                             (long)_sizeDsm,
00088                             MomeTraceTransitions);
00089 #endif
00090 
00091    _frameForFreeStoreAllocation = -1;
00092 
00093    oldSyncDate = new MomeTpDate [ _queueSize ] ;
00094 
00095    _lockIsNeeded = false ;
00096 
00097    _timelost = 0 ;
00098 #endif
00099 }

PsnRelaxedMemoryManager::~PsnRelaxedMemoryManager   [virtual]
 

Desctructeur.

Definition at line 101 of file PsnRelaxedMemoryManager.cxx.

References _myCreator, _myPage, _numberOfManagedPages, _timelost, PsnUniqueCreator::deletePageStateTable(), PsnUniqueCreator::deleteWhenSyncedTable(), and oldSyncDate.

00101                                                   {
00102 #ifdef _MOME
00103 
00104 #ifdef _PROFILE
00105    cerr<<"Time lost to calls for synchronisation : "<<_timelost<<endl;
00106 #endif
00107 
00108    _myCreator->deletePageStateTable ( _numberOfManagedPages ) ; 
00109 
00110    _myCreator->deleteWhenSyncedTable ( _numberOfManagedPages ) ; 
00111    
00112    delete [] oldSyncDate ;
00113    delete [] _myPage ;
00114 #endif
00115 }


Member Function Documentation

void PsnRelaxedMemoryManager::addInFree void *    addr,
size_t    size
[protected, virtual]
 

la zone de mémoire dans lesquels sont stockés les PsnMemoryElementDescriptor doit être vérouillée avant l'appel à cette fonction

Parameters:
addr : address of the memory to be freed
size : size asked for when memory was allocated

Implements PsnSharedMemoryManager.

Definition at line 536 of file PsnRelaxedMemoryManager.cxx.

References _firstFreePage, PsnSharedMemoryManager::_pageSize, _pageState, and Free.

00536                                                                 {
00537 #ifdef _MOME
00538    assert (((unsigned int) addr) % _pageSize == 0) ;
00539 
00540    int firstPageNumber = ((unsigned int) addr) / _pageSize ;
00541 
00542    for (int i = firstPageNumber ; i < firstPageNumber+size ; i++ ) {
00543 
00544       _pageState [ i ] = Free ;
00545 
00546    }
00547    
00548    if (firstPageNumber < _firstFreePage) _firstFreePage = firstPageNumber ;
00549 #endif   
00550 }

void * PsnRelaxedMemoryManager::allocateSizeRemembered size_t    size [virtual]
 

redefinition of this malloc to delegate to the SharedFreeStoreMemoryManager

Reimplemented from PsnSharedMemoryManager.

Definition at line 127 of file PsnRelaxedMemoryManager.cxx.

References _frameForFreeStoreAllocation, PsnSharedMemoryManager::_pageSize, _queueSize, _writableQueueIndex, list< PsnSharedFreeStoreMemoryManager * >::begin(), list< PsnSharedFreeStoreMemoryManager * >::end(), freeStoreManagers, PsnSharedMemoryManager::lockIfNeeded(), PsnSharedFreeStoreMemoryManager::mallocAvecMemoire(), list< PsnSharedFreeStoreMemoryManager * >::push_front(), and PsnSharedMemoryManager::unlockIfNeeded().

00127                                                                    {
00128 
00129    void * resul = NULL ;
00130 
00131 #ifdef _MOME
00132 
00133 #ifdef _DEBUGALLOCATIONMOME
00134    cerr<<"PsnRelaxedMemoryManager::allocateSizeRemembered "<<size;
00135 #endif   
00136    HeapStackTop standardAllocationContext(0) ;
00137 
00138    int whichFrame ;
00139 
00140    if (_frameForFreeStoreAllocation == -1) {
00141       //cerr<<"PsnRelaxedMemoryManager::allocateSizeRemembered : using default next frame"<<endl;
00142       whichFrame = _writableQueueIndex ;
00143    }
00144    else {
00145       whichFrame = _frameForFreeStoreAllocation ;
00146    }
00147 
00148 
00149    size_t currentSizeOfFreeStoreManagers = _queueSize * _pageSize ;
00150 
00151    list < PsnSharedFreeStoreMemoryManager * >::iterator i(freeStoreManagers.begin() ) ;
00152 
00153    while( resul == NULL && i != freeStoreManagers.end() ) {
00154 
00155       try {
00156          //currentSizeOfFreeStoreManagers = (*i)->getSize();
00157          resul = (*i)->mallocAvecMemoire(size, whichFrame ) ;
00158       }
00159       catch (PsNoMemoryAvailableException & e) {
00160          resul = NULL ;
00161       }
00162       resul = (*i)->mallocAvecMemoire(size, whichFrame ) ;
00163       
00164       i++ ;
00165 
00166    }
00167    if (resul == NULL) { //create a new sharedFreeStoreManager
00168       
00169       if (_queueSize * size > currentSizeOfFreeStoreManagers) currentSizeOfFreeStoreManagers = ( (_queueSize * size) / _pageSize + 1 ) * _pageSize;
00170 #ifdef _DEBUGALLOCATIONMOME
00171       cerr<<"creation d'un nouveau PsnSharedFreeStoreMemoryManager"<<endl;
00172 #endif
00173       lockIfNeeded () ;
00174 
00175       PsnSharedFreeStoreMemoryManager * newManager = 
00176          new PsnSharedFreeStoreMemoryManager(currentSizeOfFreeStoreManagers,
00177                                              _pageSize,
00178                                              4,
00179                                              *this,
00180                                              _queueSize) ;
00181 
00182       unlockIfNeeded() ;
00183 
00184       freeStoreManagers.push_front ( newManager ) ;
00185 
00186       resul = newManager->mallocAvecMemoire( size, whichFrame ) ; //if this fails, an exception is raised
00187    }
00188 #ifdef _DEBUGALLOCATIONMOME
00189    cerr<<" "<<resul<<endl;
00190 #endif
00191 #endif
00192    return resul ;
00193 }

void PsnRelaxedMemoryManager::anticipateFreeStoreAllocation int    frame [virtual]
 

prepare the memory manager for free store allocation which will be needed at frame if frame = -1, default mechanism is used (next frame)

Definition at line 118 of file PsnRelaxedMemoryManager.cxx.

References _frameForFreeStoreAllocation.

00118                                                                      {
00119 #ifdef _MOME
00120    //cerr<<"PsnRelaxedMemoryManager::anticipateFreeStoreAllocation("<<frame<<")"<<endl;
00121    _frameForFreeStoreAllocation=frame ;
00122 #endif
00123 }

void PsnRelaxedMemoryManager::freeSizeRemembered void *    ptr [virtual]
 

Accordingly, redefinition of this free.

Reimplemented from PsnSharedMemoryManager.

Definition at line 195 of file PsnRelaxedMemoryManager.cxx.

References list< PsnSharedFreeStoreMemoryManager * >::begin(), list< PsnSharedFreeStoreMemoryManager * >::end(), and freeStoreManagers.

00195                                                              {
00196 #ifdef _MOME
00197 #ifdef _DEBUGALLOCATIONMOME
00198    cerr<<"PsnRelaxedMemoryManager::freeSizeRemembered "<<ptr<<endl;
00199 #endif
00200    list < PsnSharedFreeStoreMemoryManager * >::iterator i(freeStoreManagers.begin() ) ;
00201 
00202    while( i != freeStoreManagers.end() ) {
00203   
00204       if ( (*i)->inAdressSpace ( ptr ) ) {
00205          
00206          (*i)->freeSizeRemembered( ptr ) ;
00207          
00208          i = freeStoreManagers.end() ;
00209          
00210       }
00211       else {
00212          i++ ;
00213       }
00214    }
00215 #endif
00216 }

void * PsnRelaxedMemoryManager::getFromFree size_t    size [protected, virtual]
 

la zone de mémoire dans lesquels sont stockés les PsnMemoryElementDescriptor doit être vérouillée avant l'appel à cette fonction

Parameters:
size : size of memory to allocate
Returns:
: address of a memory zone of at least size.

Implements PsnSharedMemoryManager.

Definition at line 552 of file PsnRelaxedMemoryManager.cxx.

References _firstFreePage, _lockIsNeeded, _myPage, _numberOfManagedPages, PsnSharedMemoryManager::_pageSize, _pageState, PsnSharedMemoryManager::_startDsm, Allocated, Free, PsnSharedMemoryManager::localAddressToGlobal(), PsnSharedMemoryManager::lockIfNeeded(), and PsnSharedMemoryManager::unlockIfNeeded().

00552                                                        {
00553 #ifdef _MOME
00554    HeapStackTop classicAllocationContext(0);
00555 
00556    _lockIsNeeded = true ;
00557 
00558    bool found = true ;
00559 
00560    int startOfCurrentZone ; 
00561 
00562    int currentPageNumber ;
00563 
00564    int numberOfFreePagesFound = 0 ; 
00565 
00566    lockIfNeeded() ;
00567 
00568    try {
00569       while ( _pageState[ _firstFreePage ] != Free ) {
00570          ++ _firstFreePage ;
00571       }
00572       startOfCurrentZone  = _firstFreePage ;
00573       currentPageNumber = startOfCurrentZone ;
00574 
00575       while ( ! found ) { 
00576          assert(_pageState[ currentPageNumber ] == Free) ;
00577          while ( ( _pageState[ currentPageNumber + numberOfFreePagesFound ] == Free) && 
00578                  numberOfFreePagesFound < size ) {
00579 
00580             ++numberOfFreePagesFound ; 
00581 
00582             if (numberOfFreePagesFound > _numberOfManagedPages ) {
00583                unlockIfNeeded() ;
00584                _lockIsNeeded = false ;
00585                throw PsNoMemoryAvailableException("PsnRelaxedMemoryManager::getFromFree", size);
00586             }
00587          }
00588          if (numberOfFreePagesFound == size ) {
00589             found = true ;
00590          }
00591          else {//look for the next free page 
00592             startOfCurrentZone =  currentPageNumber + numberOfFreePagesFound ;
00593             while ( _pageState[ startOfCurrentZone ] != Free ) {
00594                ++ startOfCurrentZone ;
00595                if ( startOfCurrentZone > _numberOfManagedPages ) {
00596                   unlockIfNeeded() ;
00597                   _lockIsNeeded = false ;
00598                   throw PsNoMemoryAvailableException("PsnRelaxedMemoryManager::getFromFree", size);
00599                }
00600             }  
00601             currentPageNumber = startOfCurrentZone ;
00602          }
00603       }
00604    }
00605    catch (PsNoMemoryAvailableException & exceptionHandeld) {
00606       //retry, after reinitialisation of _firstFreePage
00607       if (_firstFreePage != 0 ) {
00608          _firstFreePage = 0 ;
00609          return getFromFree(size) ;
00610       }
00611       else throw ;
00612    }
00613    //mark the allocated pages as allocated and migrate the corresponding page manager
00614    for (int i = startOfCurrentZone ; i < startOfCurrentZone + size ; i++) {
00615       _myPage [i] = true ;
00616       _pageState[ i ] = Allocated ;
00617       MomeManageAtAddress( (void *) (i * _pageSize + _startDsm), MomeMe ) ;
00618       MomeSetPageAttributes( (void *) (i * _pageSize + _startDsm), MomeOneWriter ) ;
00619 #ifdef _DEBUGALLOCATIONPAGES
00620       cerr<<"page "<<i<<" allocated"<<endl;
00621 #endif
00622    }
00623    _firstFreePage = startOfCurrentZone + size ;
00624    unlockIfNeeded() ;
00625    _lockIsNeeded = false ;
00626    return localAddressToGlobal (_pageSize * startOfCurrentZone) ;
00627 #else
00628    return 0 ;
00629 #endif
00630 }

int PsnRelaxedMemoryManager::getNextSyncedQueueIndex   [inline, static]
 

get the next queue index

Definition at line 120 of file PsnRelaxedMemoryManager.h.

References _nextSyncedQueueIndex.

00120                                                 {
00121       return _nextSyncedQueueIndex ;
00122    }

int PsnRelaxedMemoryManager::getReadableQueueIndex   [inline, static]
 

get the current queue index

Definition at line 125 of file PsnRelaxedMemoryManager.h.

References _readableQueueIndex.

Referenced by PsnMomeReaderFifo< Type >::findFirstValid(), PsnMomeReaderFifo< Type >::getNumberOfPresentValues(), PsnMomeReaderFifo< Type >::printDebuggingInformation(), and PsnMomeFifo< Type >::PsnMomeFifo().

00125                                               {
00126       return _readableQueueIndex ;
00127    }

int PsnRelaxedMemoryManager::getWritableQueueIndex   [inline, static]
 

get the next queue index

Definition at line 115 of file PsnRelaxedMemoryManager.h.

References _writableQueueIndex.

Referenced by PsnMomeWriterFifo< Type >::getNextPlaceHolder(), PsnMomeWriterFifo< Type >::set(), PsnMomeWriterFifo< Type >::setInPlace(), and PsnFramedMemoryManager::sync().

00115                                               {
00116       return _writableQueueIndex ;
00117    }

void PsnRelaxedMemoryManager::lock   [protected, virtual]
 

Proteger le Manager pour un accès en exclusion mutuelle.

Après le verrou, on est sur de disposer de la version de la mémoire géree au moins aussi récente que celle disponible sur n'importe quelle processeur après unlock si on fait un synchronizeAfterLock sur la zone de donnée voulue..

Implements PsnSharedMemoryManager.

Definition at line 637 of file PsnRelaxedMemoryManager.cxx.

References _myLock, and PsnLock::getLock().

00637                                    {
00638 #ifdef _MOME
00639 #ifdef _DEBUGLOCK
00640    cerr<<(int)_myLock->getLock();
00641 #endif
00642    //sleep(10) ;
00643    MomeMutexLock(_myLock->getLock()); 
00644 #endif
00645 }

bool PsnRelaxedMemoryManager::lockNeeded   [protected, virtual]
 

Is a lock needed ? before access to this shared memoryManager.

Implements PsnSharedMemoryManager.

Definition at line 656 of file PsnRelaxedMemoryManager.cxx.

00656                                          {
00657    //cerr<<"+";
00658    return true ;
00659    //return _lockIsNeeded ;
00660 }

void PsnRelaxedMemoryManager::mfreeForOnce void *    ptr,
size_t    size
[virtual]
 

free a block at the same offset

Definition at line 507 of file PsnRelaxedMemoryManager.cxx.

References list< PsnOnceSyncedSharedMemoryManager * >::begin(), list< PsnOnceSyncedSharedMemoryManager * >::end(), and onceSyncedMemoryManagers.

Referenced by PsnMomeArray< T >::operator delete().

00508                                                         {
00509 #ifdef _MOME
00510 
00511    HeapStackTop standardAllocationContext(0) ;
00512    
00513    list < PsnOnceSyncedSharedMemoryManager * >::iterator i(onceSyncedMemoryManagers.begin() ) ;
00514    
00515    while( i != onceSyncedMemoryManagers.end() ) {
00516   
00517       if ( (*i)->inAdressSpace ( ptr ) ) {
00518 #ifdef _DEBUGMFREE
00519          cerr<<"PsnRelaxedMemoryManager::mLatencyFree : iutilisation de mfree"<<endl;
00520 #endif
00521          (*i)->mfree( ptr , size ) ;
00522 #ifdef _DEBUGMFREE
00523          cerr<<"done"<<endl;
00524 #endif
00525          i = onceSyncedMemoryManagers.end() ;
00526          
00527       }
00528       else {
00529          i++ ;
00530       }
00531    }   
00532 #endif
00533 }

void PsnRelaxedMemoryManager::mfreeInPages void *    ptr,
size_t    size
[virtual]
 

free a block at the same offset

Definition at line 284 of file PsnRelaxedMemoryManager.cxx.

References list< PsnSharedArrayMemoryManager * >::begin(), list< PsnSharedArrayMemoryManager * >::end(), and sharedArrayManagers.

Referenced by PsnMomeArray< T >::~PsnMomeArray().

00284                                                                   {
00285 #ifdef _MOME
00286    
00287    list < PsnSharedArrayMemoryManager * >::iterator i(sharedArrayManagers.begin() ) ;
00288    
00289    while( i != sharedArrayManagers.end() ) {
00290   
00291       if ( (*i)->inAdressSpace ( ptr ) ) {
00292 #ifdef _DEBUGMFREE
00293          cerr<<"PsnRelaxedMemoryManager::mfreeInPages : utilisation de mfree ";
00294 #endif   
00295          (*i)->mfree( ptr , size ) ;
00296 #ifdef _DEBUGMFREE
00297          cerr<<"done"<<endl;
00298 #endif   
00299          
00300          i = sharedArrayManagers.end() ;
00301          
00302       }
00303       else {
00304          i++ ;
00305       }
00306    }
00307 #endif
00308 }

void PsnRelaxedMemoryManager::mLatencyFree void *    ptr,
size_t    size,
list< PsnLatencySyncedSharedMemoryManager * > &    memoryManagerList
[protected, virtual]
 

common deallocation membre function for relaxedFree and SyncFree

Definition at line 413 of file PsnRelaxedMemoryManager.cxx.

References list< T, Alloc >::begin(), and list< T, Alloc >::end().

Referenced by mRelaxedFree(), and mSyncFree().

00415                                                                                                             {
00416 
00417 #ifdef _MOME
00418    HeapStackTop standardAllocationContext(0) ;
00419    
00420    list < PsnLatencySyncedSharedMemoryManager * >::iterator i(memoryManagerList.begin() ) ;
00421    
00422    while( i != memoryManagerList.end() ) {
00423   
00424       if ( (*i)->inAdressSpace ( ptr ) ) {
00425 #ifdef _DEBUGMFREE
00426          cerr<<"PsnRelaxedMemoryManager::mLatencyFree : iutilisation de mfree"<<endl;
00427 #endif
00428          (*i)->mfree( ptr , size ) ;
00429 #ifdef _DEBUGMFREE
00430          cerr<<"done"<<endl;
00431 #endif
00432          i = memoryManagerList.end() ;
00433          
00434       }
00435       else {
00436          i++ ;
00437       }
00438    }   
00439 #endif
00440 }

void * PsnRelaxedMemoryManager::mLatencyMalloc size_t    size,
list< PsnLatencySyncedSharedMemoryManager * > &    memoryManagerList,
int    latency
[protected, virtual]
 

common allocation member function for relaxedAlloc and SyncAlloc

Definition at line 340 of file PsnRelaxedMemoryManager.cxx.

References PsnSharedMemoryManager::_pageSize, _queueSize, list< T, Alloc >::begin(), list< T, Alloc >::end(), HeapStackTop::globalMemoryManagerKey, PsnSharedMemoryManager::lockIfNeeded(), PsnSharedMemoryManager::mmalloc(), PsnLatencySyncedSharedMemoryManager, list< T, Alloc >::push_front(), and PsnSharedMemoryManager::unlockIfNeeded().

Referenced by mRelaxedMalloc(), and mSyncMalloc().

00342                                                             {
00343 
00344    void * resul = NULL ;
00345    
00346 #ifdef _MOME
00347 
00348 #ifdef _DEBUGALLOCATIONMOME
00349    cerr<<"PsnRelaxedMemoryManager::mLatencyMalloc "<<&memoryManagerList<<endl;
00350 #endif
00351    HeapStackTop standardAllocationContext(0) ;
00352 
00353    
00354    list < PsnLatencySyncedSharedMemoryManager * >::iterator i( memoryManagerList.begin() ) ;
00355 
00356    while( resul == NULL && i != memoryManagerList.end() ) {
00357       
00358       try {
00359 
00360          (*i)->lockIfNeeded () ;
00361 
00362          resul = (*i)->mmalloc(size) ;
00363 
00364          (*i)->unlockIfNeeded () ;
00365 
00366       }
00367       catch (PsNoMemoryAvailableException & e) {
00368 
00369          (*i)->unlockIfNeeded () ;
00370 
00371          resul = NULL ;
00372 
00373       }
00374       i++ ;
00375    }
00376 
00377    if (i == memoryManagerList.end()) { //create a new StoreManager
00378 
00379 #ifdef _DEBUGALLOCATIONPAGES
00380       cerr<<"creation d'un nouveau PsnLatencySyncedSharedMemoryManager "<<latency<<endl;    
00381 #endif
00382 
00383       lockIfNeeded() ;
00384 
00385       PsnLatencySyncedSharedMemoryManager * newManager = 
00386          new PsnLatencySyncedSharedMemoryManager((size / _pageSize + 1)*_pageSize,
00387                                                  _pageSize,
00388                                                  4,
00389                                                  *this,
00390                                                  _queueSize,
00391                                                  latency) ;
00392 
00393       unlockIfNeeded() ;
00394 #ifdef _DEBUGALLOCATIONPAGES
00395       cerr<<"Un nouveau PsnLatencySyncedSharedMemoryManager est créé "<<latency<<endl;    
00396 #endif
00397       newManager->lockIfNeeded() ;
00398 
00399       resul = newManager->mmalloc( size ) ; //if this fails, an exception is raised
00400 
00401       newManager->unlockIfNeeded() ;
00402 
00403       assert( pthread_getspecific(HeapStackTop::globalMemoryManagerKey) == NULL );
00404 
00405       memoryManagerList.push_front ( newManager ) ;
00406    }   
00407 #endif
00408    return resul ;
00409 }

void * PsnRelaxedMemoryManager::mmallocForOnce size_t    size [virtual]
 

Allocate a block that oinly needs to be synced once.

Definition at line 443 of file PsnRelaxedMemoryManager.cxx.

References PsnSharedMemoryManager::_pageSize, _queueSize, list< PsnOnceSyncedSharedMemoryManager * >::begin(), list< PsnOnceSyncedSharedMemoryManager * >::end(), HeapStackTop::globalMemoryManagerKey, PsnSharedMemoryManager::lockIfNeeded(), PsnSharedMemoryManager::mmalloc(), onceSyncedMemoryManagers, PsnOnceSyncedSharedMemoryManager, list< PsnOnceSyncedSharedMemoryManager * >::push_front(), and PsnSharedMemoryManager::unlockIfNeeded().

Referenced by PsnMomeArray< T >::operator new().

00443                                                           {
00444    void * resul = NULL ;
00445 #ifdef _MOME
00446 
00447 #ifdef _DEBUGALLOCATIONMOME
00448    cerr<<"PsnRelaxedMemoryManager::mmallocForOnce"<<endl;
00449 #endif
00450    HeapStackTop standardAllocationContext(0) ;
00451 
00452    
00453    list < PsnOnceSyncedSharedMemoryManager * >::iterator i( onceSyncedMemoryManagers.begin() ) ;
00454 
00455    while( resul == NULL && i != onceSyncedMemoryManagers.end() ) {
00456       
00457       try {
00458          (*i)->lockIfNeeded () ;
00459 
00460          resul = (*i)->mmalloc(size) ;
00461 
00462          (*i)->unlockIfNeeded () ;
00463 
00464       }
00465       catch (PsNoMemoryAvailableException & e) {
00466          (*i)->unlockIfNeeded () ;
00467 
00468          resul = NULL ;
00469       }
00470       
00471       i++ ;
00472 
00473    }
00474 
00475    if (resul == NULL) { //create a new StoreManager
00476 
00477 #ifdef _DEBUGALLOCATIONPAGES
00478       cerr<<"creation d'un nouveau PsnOnceSyncedSharedMemoryManager "<<endl;    
00479 #endif
00480       lockIfNeeded () ;
00481       PsnOnceSyncedSharedMemoryManager * newManager = 
00482          new PsnOnceSyncedSharedMemoryManager((size / _pageSize + 1)*_pageSize,
00483                                               _pageSize,
00484                                               4,
00485                                               *this,
00486                                               _queueSize) ;
00487       unlockIfNeeded () ;
00488 #ifdef _DEBUGALLOCATIONPAGES
00489       cerr<<"Un nouveau PsnOnceSyncedSharedMemoryManager est créé "<<endl;    
00490 #endif
00491       
00492       newManager-> lockIfNeeded() ;
00493 
00494       resul = newManager->mmalloc( size ) ; //if this fails, an exception is raised
00495 
00496       newManager->unlockIfNeeded () ;
00497 
00498       assert( pthread_getspecific(HeapStackTop::globalMemoryManagerKey) == NULL );
00499 
00500       onceSyncedMemoryManagers.push_front( newManager ) ;
00501    }   
00502 #endif
00503    return resul ;
00504 }

void * PsnRelaxedMemoryManager::mmallocInPages size_t    size,
unsigned int *    initialOffsetForWrite,
size_t *    stepSize
[virtual]
 

Allocate a block at the same offset in numberOfPages pages.

Definition at line 218 of file PsnRelaxedMemoryManager.cxx.

References PsnSharedMemoryManager::_pageSize, _queueSize, _writableQueueIndex, list< PsnSharedArrayMemoryManager * >::begin(), list< PsnSharedArrayMemoryManager * >::end(), PsnSharedArrayMemoryManager::getStepSize(), PsnSharedMemoryManager::lockIfNeeded(), PsnSharedArrayMemoryManager::mmalloc(), list< PsnSharedArrayMemoryManager * >::push_front(), sharedArrayManagers, and PsnSharedMemoryManager::unlockIfNeeded().

00218                                                                                                                    {
00219    void * resul = NULL ;
00220 #ifdef _MOME
00221    HeapStackTop standardAllocationContext(0) ;
00222 
00223    * initialOffsetForWrite = _writableQueueIndex ;
00224 
00225    
00226    list < PsnSharedArrayMemoryManager * >::iterator i(sharedArrayManagers.begin() ) ;
00227 
00228    while( resul == NULL && i != sharedArrayManagers.end() ) {
00229       
00230       try {
00231 
00232          *stepSize = (*i)->getStepSize() ;
00233 
00234          (*i)->lockIfNeeded () ;
00235 
00236          resul = (*i)->mmalloc(size) ;
00237 
00238          (*i)->unlockIfNeeded () ;
00239 
00240       }
00241       catch (PsNoMemoryAvailableException & e) {
00242          (*i)->unlockIfNeeded () ;
00243 
00244          resul = NULL ;
00245       }
00246       
00247       i++ ;
00248       
00249    }
00250    if (resul == NULL) { //create a new sharedFreeStoreManager
00251       
00252 #ifdef _DEBUGALLOCATIONMOME
00253       cerr<<"creation d'un nouveau PsnSharedArrayMemoryManager"<<endl;
00254 #endif
00255       
00256       lockIfNeeded () ;
00257 
00258       PsnSharedArrayMemoryManager * newManager = 
00259          new PsnSharedArrayMemoryManager((size / _pageSize + 1) * _pageSize,
00260                                          _pageSize,
00261                                          4,
00262                                          *this,
00263                                          _queueSize) ;
00264       
00265       unlockIfNeeded () ;
00266       
00267       newManager-> lockIfNeeded() ;
00268 
00269       resul = newManager->mmalloc( size ) ; //if this fails, an exception is raised
00270 
00271       newManager-> unlockIfNeeded() ;
00272 
00273       *stepSize = newManager->getStepSize() ;
00274       sharedArrayManagers.push_front( newManager ) ;
00275    }   
00276 #ifdef _DEBUGALLOCATIONMOME
00277    cerr<<"PsnRelaxedMemoryManager::mmallocInPages "<<resul<<endl;
00278 #endif
00279 #endif
00280    return resul ;
00281 }

void PsnRelaxedMemoryManager::mRelaxedFree void *    ptr,
size_t    size
[virtual]
 

free memory that was synced with latency simulation steps

Definition at line 319 of file PsnRelaxedMemoryManager.cxx.

References mLatencyFree(), and relaxedSyncedMemoryManagers.

00319                                                                    {
00320 #ifdef _MOME
00321    mLatencyFree(ptr, size, relaxedSyncedMemoryManagers) ;
00322 #endif
00323 }

void * PsnRelaxedMemoryManager::mRelaxedMalloc size_t    size [virtual]
 

allocate memory so it while be synced with latency simulation steps

Definition at line 311 of file PsnRelaxedMemoryManager.cxx.

References mLatencyMalloc(), and relaxedSyncedMemoryManagers.

00311                                                            {
00312 #ifdef _MOME
00313    return mLatencyMalloc(size, relaxedSyncedMemoryManagers, 1) ;
00314 #else
00315    return NULL ;
00316 #endif
00317 }

void PsnRelaxedMemoryManager::mSyncFree void *    ptr,
size_t    size
[virtual]
 

free memory that was synced at each simulation step

Definition at line 334 of file PsnRelaxedMemoryManager.cxx.

References mLatencyFree(), and stepSyncedMemoryManagers.

00334                                                                 {
00335 #ifdef _MOME
00336    mLatencyFree(ptr, size, stepSyncedMemoryManagers);
00337 #endif
00338 }

void * PsnRelaxedMemoryManager::mSyncMalloc size_t    size [virtual]
 

allocate memory so it while be synced at each simulation step

Definition at line 326 of file PsnRelaxedMemoryManager.cxx.

References mLatencyMalloc(), and stepSyncedMemoryManagers.

00326                                                         {
00327 #ifdef _MOME
00328    return mLatencyMalloc(size, stepSyncedMemoryManagers, 0) ;
00329 #else
00330    return 0 ;
00331 #endif
00332 }

void PsnRelaxedMemoryManager::strongSync   [virtual]
 

Synchronise all of the managed memory now.

Definition at line 860 of file PsnRelaxedMemoryManager.cxx.

References _numberOfManagedPages, PsnSharedMemoryManager::_pageSize, _pageState, _queueSize, Free, PsnSharedMemoryManager::localAddressToGlobal(), oldSyncDate, and syncSecondaryMemoryManagers().

Referenced by PsMomeController::init().

00860                                          {
00861 #ifdef _MOME
00862 #ifdef _DEBUGSYNC
00863    cerr<<"PsnRelaxedMemoryManager::strongSync()"<<endl;
00864 #endif
00865    syncSecondaryMemoryManagers() ;
00866    MomeBarrier();
00867 
00868 //     MomeSynchronizeRegion((void*) _whenSynced,
00869 //                       sizeof(int[_numberOfManagedPages]),
00870 //                       MomeBarrierSynchronization,
00871 //                       0,
00872 //                       MomeBlockingProtocol,
00873 //                       0);
00874 
00875    for (int i=0 ; i<_numberOfManagedPages ; i++) {
00876       if (_pageState [ i ] != Free) {
00877          MomeSynchronizeRegion(localAddressToGlobal ( i * _pageSize ),
00878                                (long)_pageSize,
00879                                MomeBarrierSynchronization,
00880                                0,
00881                                MomeSignallingProtocol,
00882                                0);
00883          
00884       }
00885    }
00886    MomeWaitOnCounter( 0 );
00887    MomeBarrier();
00888    for ( int i = 0 ; i < _queueSize ; i++ ) {
00889       oldSyncDate [ i ] = MomeInternalDate () ;
00890    }
00891 #ifdef _DEBUGSYNC 
00892    cerr<<"PsnRelaxedMemoryManager::strongSync() done"<<endl;
00893 #endif
00894 #endif
00895 }

void PsnRelaxedMemoryManager::strongSynchronizeRegion unsigned int    startRegion,
size_t    sizeRegion
[virtual]
 

synchronise a subset of the managed memory now

Definition at line 897 of file PsnRelaxedMemoryManager.cxx.

References PsnSharedMemoryManager::localAddressToGlobal().

Referenced by PsMomeController::init(), and PsnMomeArray< T >::resync().

00897                                                                                            {
00898 #ifdef _MOME
00899    MomeSynchronizeRegion(localAddressToGlobal(startRegion),
00900                          size,
00901                          MomeBarrierSynchronization,
00902                          0,
00903                          MomeNonBlockingProtocol,
00904                          0);
00905 #endif
00906 }

void PsnRelaxedMemoryManager::sync   [virtual]
 

Synchronise the memory managed by the PsnSharedMemoryManager.

Implements PsnSharedMemoryManager.

Definition at line 688 of file PsnRelaxedMemoryManager.cxx.

References _dateReelleDebut, _dateReelleFin, _myPage, _nextSyncedQueueIndex, PsnSharedMemoryManager::_pageSize, _pageState, _queueSize, _readableQueueIndex, _timelost, _whenSynced, _writableQueueIndex, Allocated, Free, PsnSharedMemoryManager::localAddressToGlobal(), StepSync, and syncSecondaryMemoryManagers().

Referenced by PsMomeController::computeNextSimulationStep().

00688                                    {
00689 #ifdef _MOME
00690    //cerr<<"PsnRelaxedMemoryManager::sync****************************"<<endl;
00691    void * where;
00692 #ifdef _PROFILE
00693    gettimeofday(&_dateReelleDebut, NULL);
00694 #endif
00695    syncSecondaryMemoryManagers() ;
00696    MomeBarrier();
00697 
00698    int syncedQueueIndex = _nextSyncedQueueIndex ;
00699    _nextSyncedQueueIndex = (_nextSyncedQueueIndex + 1) % _queueSize;
00700    _readableQueueIndex = (_readableQueueIndex + 1) % _queueSize;
00701    _writableQueueIndex = (_writableQueueIndex + 1) % _queueSize;
00702    //oldSyncDate [ _nextSyncedQueueIndex ] = MomeInternalDate() ;
00703 #ifdef _DEBUGSYNC
00704    cerr<<"Free : "<<Free<<" StepSync : "<<StepSync<<endl;
00705    cerr<<_whenSynced<<endl;
00706 #endif
00707 #ifdef _DEBUGPAGEFAULTS
00708    for (int i=0 ; i<350 ; i++) { //replace 300 by _numberOfManagedPages
00709       switch ( _pageState [ i ] ) {
00710       case Allocated : 
00711          if (_myPage[ i ]) {
00712             if (_whenSynced [i] == _writableQueueIndex) {
00713                where = localAddressToGlobal(i*_pageSize) ;
00714                cerr<<"On va écrire la page : "<<i + 4096<<endl;
00715             }
00716          }
00717          else 
00718             if (_whenSynced [i] == syncedQueueIndex) {
00719                where = localAddressToGlobal(i*_pageSize) ;
00720                cerr<<"Page "<<i + 4096<<" Prefetched pour la lecture"<<endl;
00721          }
00722          break ;
00723       default :
00724          break;
00725       }
00726 
00727    }
00728 #endif
00729    for (int i=0 ; i<350 ; i++) { //replace 300 by _numberOfManagedPages
00730 #ifdef _DEBUGSYNC
00731       //cerr<<"etat de la page "<<i<<" : "<<_pageState [ i ]<<endl;
00732 #endif
00733       switch ( _pageState [ i ] ) {
00734 //      case Free : break ; //nothing to to
00735 //      case StepSync : 
00736 //  #ifdef _DEBUGSYNC
00737 //       cerr<<"Page "<<i<<" a synchroniser"<<endl;
00738 //  #endif
00739 //       where = localAddressToGlobal( i * _pageSize) ;
00740 //  #ifdef _DEBUGSYNC
00741 //       cerr<<"adresse a synchronisée : "<<where<<endl;
00742 //  #endif
00743 //  #ifdef _DEBUGPAGEFAULTS
00744 //       //cerr<<"Page "<<i<<" StepSynced"<<endl;
00745 //  #endif
00746 //       MomeSynchronizeRegion(where,
00747 //                             _pageSize,
00748 //                             MomeBarrierSynchronization,
00749 //                             0,
00750 //                             MomeSignallingProtocol,
00751 //                             0);
00752          
00753 //       if (!_myPage[i]) { 
00754 //          MomePrefetchRegion(where,
00755 //                             _pageSize,
00756 //                             MomePrefetchRead,
00757 //                             MomeNonBlockingProtocol,
00758 //                             0) ;
00759 //       }
00760 //  #ifdef _DEBUGSYNC
00761 //       cerr<<"adresse synchronisée."<<endl;
00762 //  #endif
00763 //       break ;
00764 //        case LatencySync : 
00765 //       where = localAddressToGlobal(i*_pageSize) ;
00766 //  #ifdef _DEBUGPAGEFAULTS
00767 //       //cout<<"Page "<<i + 4096<<" LatencySynced"<<endl;
00768 //  #endif
00769 //       MomeSynchronizeRegion(where,
00770 //                             _pageSize,
00771 //                             MomeDateSynchronization,
00772 //                             oldSyncDate[syncedQueueIndex],
00773 //                             MomeSignallingProtocol,
00774 //                             0);
00775 //       MomePrefetchRegion(where,
00776 //                          _pageSize,
00777 //                          MomePrefetchRead,
00778 //                          MomeNonBlockingProtocol,
00779 //                          0) ;
00780 //       break;
00781       case Allocated : 
00782 #ifdef _DEBUGSYNC
00783          cerr<<"Page "<<i<<" allouée"
00784              <<" et à synchroniser au pas "<<_whenSynced [i]
00785              <<". On est à "<<_currentQueueIndex
00786              <<endl;
00787 #endif
00788          if (_myPage[ i ]) {
00789             if (_whenSynced [i] == _writableQueueIndex) {
00790                where = localAddressToGlobal(i*_pageSize) ;
00791 #ifdef _DEBUGSYNC
00792                //           cerr<<"adresse synchronisée : "<<where<<" "<<_pageSize<<endl;
00793 #endif
00794 //             MomeSynchronizeRegion(where,
00795 //                                   _pageSize,
00796 //                                   MomeBarrierSynchronization,
00797 //                                   0, //oldSyncDate[oldQueueIndex],
00798 //                                   MomeNonBlockingProtocol,
00799 //                                   0);
00800                MomePrefetchRegion(where,
00801                                   _pageSize,
00802                                   MomePrefetchWrite,
00803                                   MomeNonBlockingProtocol,
00804                                   0) ;
00805             }
00806          }
00807          else 
00808             if (_whenSynced [i] == syncedQueueIndex) {
00809                where = localAddressToGlobal(i*_pageSize) ;
00810 #ifdef _DEBUGPAGEFAULTS
00811                //           MomeSetRegionAttributes ((void *)where,
00812                //                                    (long)_pageSize,
00813                //                                    MomeTraceTransitions);
00814 #endif
00815                //           if (_myPage[i] ) {
00816                //cout<<"Page "<<i + 4096<<" Prefetched ("<<where<<") en écriture"<<endl;
00817                //              MomePrefetchRegion(where,
00818                //                                 _pageSize,
00819                //                                 MomePrefetchWrite,
00820                //                                 MomeNonBlockingProtocol,
00821                //                                 0) ;
00822                //           }
00823                //           else 
00824                MomeSynchronizeRegion(where,
00825                                      _pageSize,
00826                                      MomeBarrierSynchronization,
00827                                      0, //oldSyncDate[syncedQueueIndex],
00828                                      MomeNonBlockingProtocol,
00829                                      0);
00830                MomePrefetchRegion(where,
00831                                   _pageSize,
00832                                   MomePrefetchRead,
00833                                   MomeNonBlockingProtocol,
00834                                   0) ;
00835          }
00836          break ;
00837       default :
00838 //       cerr<<"Pb de cohérance"<<endl;
00839 //       sleep (1) ;
00840          break;
00841       }
00842    }
00843 #ifdef _DEBUGSYNC
00844    cerr<<"Avant attente"<<endl;
00845 #endif
00846    MomeWaitOnCounter( 0 );
00847 #ifdef _PROFILE
00848    gettimeofday(&_dateReelleFin, NULL);
00849    if (_dateReelleFin.tv_usec - _dateReelleDebut.tv_usec<0 ) {
00850       _timelost += _dateReelleFin.tv_usec - _dateReelleDebut.tv_usec + 1000000 ;
00851    }
00852    else {
00853       _timelost += _dateReelleFin.tv_usec - _dateReelleDebut.tv_usec ;
00854    }
00855 #endif
00856    //cerr<<"Demande de synchronisation traitée"<<endl;
00857 #endif
00858 }

void PsnRelaxedMemoryManager::synchronizeAfterLock void *    beginningAdress,
long    length
[virtual]
 

synchronize partially the memory as it was when the lock was last obtained

Parameters:
beginningAdress address of the part of memory to partially synchronize
length size (in number of pages) of the chunk of memory to synchronize

Implements PsnSharedMemoryManager.

Definition at line 908 of file PsnRelaxedMemoryManager.cxx.

References _myLock, and PsnLock::getLock().

Referenced by PsMomeOutput< Type >::PsMomeOutput().

00908                                                                                      {
00909 #ifdef _MOME
00910    MomeSynchronizeRegion(beginningAdress,
00911                          length,
00912                          MomeLockSynchronization,
00913                          _myLock->getLock(),
00914                          MomeNonBlockingProtocol,
00915                          0);
00916 #endif
00917 }

void PsnRelaxedMemoryManager::syncSecondaryMemoryManagers   [protected, virtual]
 

call sync of all secondaryMemoryManagers

Definition at line 919 of file PsnRelaxedMemoryManager.cxx.

References list< PsnOnceSyncedSharedMemoryManager * >::begin(), list< PsnLatencySyncedSharedMemoryManager * >::begin(), list< PsnSharedArrayMemoryManager * >::begin(), list< PsnSharedFreeStoreMemoryManager * >::begin(), list< PsnOnceSyncedSharedMemoryManager * >::end(), list< PsnLatencySyncedSharedMemoryManager * >::end(), list< PsnSharedArrayMemoryManager * >::end(), list< PsnSharedFreeStoreMemoryManager * >::end(), freeStoreManagers, onceSyncedMemoryManagers, relaxedSyncedMemoryManagers, sharedArrayManagers, and stepSyncedMemoryManagers.

Referenced by strongSync(), and sync().

00919                                                           {
00920 #ifdef _MOME
00921 #ifdef _DEBUGSYNC
00922    cerr<<"PsnRelaxedMemoryManager::syncSecondaryMemoryManagers()"<<endl;
00923 #endif
00924    list < PsnSharedFreeStoreMemoryManager * >::iterator i(freeStoreManagers.begin() ) ;
00925    while( i != freeStoreManagers.end() ) {
00926       (*i)->sync();
00927       i++ ;
00928    }
00929 #ifdef _DEBUGSYNC
00930    cerr<<"Free store synced"<<endl;
00931 #endif
00932    list < PsnSharedArrayMemoryManager * >::iterator j(sharedArrayManagers.begin() ) ;
00933    while( j != sharedArrayManagers.end() ) {
00934       (*j)->sync() ;
00935       j++ ;
00936    }
00937 #ifdef _DEBUGSYNC
00938    cerr<<"Shared Array synced"<<endl;
00939 #endif
00940    list < PsnLatencySyncedSharedMemoryManager * >::iterator k(stepSyncedMemoryManagers.begin() ) ;
00941    while ( k != stepSyncedMemoryManagers.end() ) {
00942       (*k)->sync() ;
00943       k++ ;
00944    }
00945 #ifdef _DEBUGSYNC
00946    cerr<<"Latency synced"<<endl;
00947 #endif
00948    k = relaxedSyncedMemoryManagers.begin() ;
00949    while ( k != relaxedSyncedMemoryManagers.end() ) {
00950       (*k)->sync() ;
00951       k++ ;
00952    }
00953 #ifdef _DEBUGSYNC
00954    cerr<<"relaxed synced"<<endl;
00955 #endif
00956    list < PsnOnceSyncedSharedMemoryManager * >::iterator l(onceSyncedMemoryManagers.begin() ) ;
00957    while( l != onceSyncedMemoryManagers.end() ) {
00958       (*l)->sync();
00959       l++ ;
00960    }
00961 #ifdef _DEBUGSYNC
00962    cerr<<"Once synced"<<endl;
00963 #endif
00964    //MomeWaitOnCounter (0) ;
00965 #ifdef _DEBUGSYNC
00966    cerr<<"PsnRelaxedMemoryManager::syncSecondaryMemoryManagers() done"<<endl;
00967 #endif
00968 #endif
00969 }

void PsnRelaxedMemoryManager::syncStepSyncedMemory   [virtual]
 

Definition at line 662 of file PsnRelaxedMemoryManager.cxx.

References _myPage, _numberOfManagedPages, PsnSharedMemoryManager::_pageSize, _pageState, PsnSharedMemoryManager::localAddressToGlobal(), and StepSync.

Referenced by PsMomeOutput< Type >::get().

00662                                                    {
00663 #ifdef _MOME
00664    void * where;
00665    for (int i=0 ; i<_numberOfManagedPages ; i++) {  
00666       if (_pageState [ i ] == StepSync ) {
00667          where = localAddressToGlobal( i * _pageSize) ;
00668          MomeSynchronizeRegion(where,
00669                                _pageSize,
00670                                MomeBarrierSynchronization,
00671                                0,
00672                                MomeSignallingProtocol,
00673                                0);
00674          
00675          if (!_myPage[i]) { 
00676             MomePrefetchRegion(where,
00677                                _pageSize,
00678                                MomePrefetchRead,
00679                                MomeNonBlockingProtocol,
00680                                0) ;
00681          }
00682       }
00683    }
00684 #endif
00685 }

void PsnRelaxedMemoryManager::unlock   [protected, virtual]
 

Lever l'exclusion mutuelle sur le memory manager.

Implements PsnSharedMemoryManager.

Definition at line 647 of file PsnRelaxedMemoryManager.cxx.

References _myLock, and PsnLock::getLock().

00647                                      {
00648 #ifdef _MOME
00649 #ifdef _DEBUGLOCK
00650    cerr<<(int)_myLock->getLock();
00651 #endif
00652    MomeMutexUnLock(_myLock->getLock());
00653 #endif
00654 }


Friends And Related Function Documentation

friend class PsnFramedMemoryManager [friend]
 

any PsnFramedMemoryManager is allowed access to _whenSynced

Definition at line 174 of file PsnRelaxedMemoryManager.h.

friend class PsnLatencySyncedSharedMemoryManager [friend]
 

Definition at line 175 of file PsnRelaxedMemoryManager.h.

Referenced by mLatencyMalloc().

friend class PsnOnceSyncedSharedMemoryManager [friend]
 

Definition at line 176 of file PsnRelaxedMemoryManager.h.

Referenced by mmallocForOnce().


Member Data Documentation

timeval PsnRelaxedMemoryManager::_dateReelleDebut [protected]
 

Definition at line 232 of file PsnRelaxedMemoryManager.h.

Referenced by sync().

timeval PsnRelaxedMemoryManager::_dateReelleFin [protected]
 

Definition at line 233 of file PsnRelaxedMemoryManager.h.

Referenced by sync().

int PsnRelaxedMemoryManager::_firstFreePage [protected]
 

the fisrt free page, as known localy

Definition at line 181 of file PsnRelaxedMemoryManager.h.

Referenced by addInFree(), and getFromFree().

int PsnRelaxedMemoryManager::_frameForFreeStoreAllocation [protected]
 

Definition at line 222 of file PsnRelaxedMemoryManager.h.

Referenced by allocateSizeRemembered(), anticipateFreeStoreAllocation(), and PsnRelaxedMemoryManager().

bool PsnRelaxedMemoryManager::_lockIsNeeded [protected]
 

is a lock needed ?

Definition at line 228 of file PsnRelaxedMemoryManager.h.

Referenced by getFromFree(), and PsnRelaxedMemoryManager().

PsnUniqueCreator* const PsnRelaxedMemoryManager::_myCreator [protected]
 

The object that creates and destroys shared objects.

Definition at line 184 of file PsnRelaxedMemoryManager.h.

Referenced by PsnRelaxedMemoryManager(), and ~PsnRelaxedMemoryManager().

PsnLock* PsnRelaxedMemoryManager::_myLock [protected]
 

Le verrou associé à la zone de mémoire.

Definition at line 162 of file PsnRelaxedMemoryManager.h.

Referenced by lock(), PsnRelaxedMemoryManager(), synchronizeAfterLock(), and unlock().

bool* PsnRelaxedMemoryManager::_myPage [protected]
 

table containing containing a boolean indicating if the page is allocated locally

Definition at line 168 of file PsnRelaxedMemoryManager.h.

Referenced by getFromFree(), PsnRelaxedMemoryManager(), sync(), syncStepSyncedMemory(), and ~PsnRelaxedMemoryManager().

int PsnRelaxedMemoryManager::_nextSyncedQueueIndex = 0 [static, protected]
 

the next outputQueue index going to be synced

Definition at line 34 of file PsnRelaxedMemoryManager.cxx.

Referenced by getNextSyncedQueueIndex(), PsnRelaxedMemoryManager(), and sync().

int PsnRelaxedMemoryManager::_numberOfManagedPages [protected]
 

The number of pages managed.

Definition at line 178 of file PsnRelaxedMemoryManager.h.

Referenced by getFromFree(), PsnRelaxedMemoryManager(), strongSync(), syncStepSyncedMemory(), and ~PsnRelaxedMemoryManager().

PageState* PsnRelaxedMemoryManager::_pageState [protected]
 

table containing the state of each page managed by this shared memory manager

Definition at line 165 of file PsnRelaxedMemoryManager.h.

Referenced by addInFree(), getFromFree(), PsnRelaxedMemoryManager(), strongSync(), sync(), and syncStepSyncedMemory().

const int PsnRelaxedMemoryManager::_queueSize [protected]
 

the size of an outputQueue

Definition at line 211 of file PsnRelaxedMemoryManager.h.

Referenced by allocateSizeRemembered(), mLatencyMalloc(), mmallocForOnce(), mmallocInPages(), PsnRelaxedMemoryManager(), strongSync(), and sync().

int PsnRelaxedMemoryManager::_readableQueueIndex = 0 [static, protected]
 

the current outputQueue index being used (read)

Definition at line 32 of file PsnRelaxedMemoryManager.cxx.

Referenced by getReadableQueueIndex(), PsnRelaxedMemoryManager(), and sync().

long PsnRelaxedMemoryManager::_timelost [protected]
 

for profiling purposes :

Definition at line 231 of file PsnRelaxedMemoryManager.h.

Referenced by PsnRelaxedMemoryManager(), sync(), and ~PsnRelaxedMemoryManager().

int* PsnRelaxedMemoryManager::_whenSynced [protected]
 

table containing the minor to which each page needs to be synchronized

Definition at line 171 of file PsnRelaxedMemoryManager.h.

Referenced by PsnRelaxedMemoryManager(), sync(), and PsnFramedMemoryManager::sync().

int PsnRelaxedMemoryManager::_writableQueueIndex = 0 [static, protected]
 

the current outputQueue index being used for write

Definition at line 33 of file PsnRelaxedMemoryManager.cxx.

Referenced by allocateSizeRemembered(), getWritableQueueIndex(), mmallocInPages(), PsnRelaxedMemoryManager(), and sync().

list< PsnSharedFreeStoreMemoryManager * > PsnRelaxedMemoryManager::freeStoreManagers [protected]
 

list of delegated FreeStoreManagers

Definition at line 187 of file PsnRelaxedMemoryManager.h.

Referenced by allocateSizeRemembered(), freeSizeRemembered(), and syncSecondaryMemoryManagers().

unsigned long* PsnRelaxedMemoryManager::oldSyncDate [protected]
 

MomeDate and the end of initialisation.

Definition at line 225 of file PsnRelaxedMemoryManager.h.

Referenced by PsnRelaxedMemoryManager(), strongSync(), and ~PsnRelaxedMemoryManager().

list< PsnOnceSyncedSharedMemoryManager * > PsnRelaxedMemoryManager::onceSyncedMemoryManagers [protected]
 

list of delegated OnceSyncedManagers

Definition at line 199 of file PsnRelaxedMemoryManager.h.

Referenced by mfreeForOnce(), mmallocForOnce(), and syncSecondaryMemoryManagers().

list< PsnLatencySyncedSharedMemoryManager * > PsnRelaxedMemoryManager::relaxedSyncedMemoryManagers [protected]
 

list of delegated SharedArrayManagers

Definition at line 196 of file PsnRelaxedMemoryManager.h.

Referenced by mRelaxedFree(), mRelaxedMalloc(), and syncSecondaryMemoryManagers().

list< PsnSharedArrayMemoryManager * > PsnRelaxedMemoryManager::sharedArrayManagers [protected]
 

list of delegated SharedArrayManagers

Definition at line 190 of file PsnRelaxedMemoryManager.h.

Referenced by mfreeInPages(), mmallocInPages(), and syncSecondaryMemoryManagers().

list< PsnLatencySyncedSharedMemoryManager * > PsnRelaxedMemoryManager::stepSyncedMemoryManagers [protected]
 

list of delegated SharedArrayManagers

Definition at line 193 of file PsnRelaxedMemoryManager.h.

Referenced by mSyncFree(), mSyncMalloc(), and syncSecondaryMemoryManagers().


The documentation for this class was generated from the following files:
logo OpenMask

Documentation generated on Mon Nov 25 15:26:24 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001