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

PsnSharedFreeStoreMemoryManager Class Reference

SHared memory manager who is aware of simulation steps SharedFreeStore memory managers have all their data localy allocated. More...

#include <PsnSharedFreeStoreMemoryManager.h>

Inheritance diagram for PsnSharedFreeStoreMemoryManager:

Inheritance graph
[legend]
Collaboration diagram for PsnSharedFreeStoreMemoryManager:

Collaboration graph
[legend]
List of all members.

Public Methods

 PsnSharedFreeStoreMemoryManager (size_t sizeDsm, size_t pageSize, size_t alignedSize, PsnRelaxedMemoryManager &memoryManager, int queueSize)
 Constructeur.

virtual ~PsnSharedFreeStoreMemoryManager ()
 Desctructeur.

virtual void * mmalloc (size_t size)
 allocate so the that the memory allocated gets synced at the next simulation step

virtual void mfree (void *ptr, size_t size)
 free memory allocated by the previous method

virtual void * mallocAvecMemoire (size_t size, int frame)
 allocate dynamicaly, for visibility at frame frame

virtual size_t getSize ()
 return the size of the sharedFreeStoreManager


Protected Attributes

PsnMemoryElementDescriptor ** _tabLibres
 the table of framed free mem lists */

size_t * _tabTailleLibre
 the table containing the free memory available for each frame


Detailed Description

SHared memory manager who is aware of simulation steps SharedFreeStore memory managers have all their data localy allocated.

Acess to them doesn't need protection unless the process is multithreaded.

Author:
David Margery
Version:
1.0

Definition at line 31 of file PsnSharedFreeStoreMemoryManager.h.


Constructor & Destructor Documentation

PsnSharedFreeStoreMemoryManager::PsnSharedFreeStoreMemoryManager size_t    sizeDsm,
size_t    pageSize,
size_t    alignedSize,
PsnRelaxedMemoryManager   memoryManager,
int    queueSize
 

Constructeur.

Definition at line 23 of file PsnSharedFreeStoreMemoryManager.cxx.

References PsnFramedMemoryManager::_blockSize, PsnSharedMemoryManager::_pageSize, PsnFramedMemoryManager::_queueSize, PsnSharedMemoryManager::_startDsm, _tabLibres, _tabTailleLibre, PsnMemoryElementDescriptor::base, PsnMemoryElementDescriptor::next, and PsnMemoryElementDescriptor::size.

00023                                                                                                                                                                             : 
00024    PsnFramedMemoryManager(sizeDsm,
00025                           pageSize, 
00026                           alignedSize, 
00027                           memoryManager, 
00028                           queueSize)
00029 {
00030    //cerr<<"gestion des adresses entre "<<(void *)_startDsm<<" et "<<(void *)(_startDsm+_sizeDsm)<<endl;
00031    _tabLibres = new PsnMemoryElementDescriptor * [ _queueSize ] ;
00032 
00033    _tabTailleLibre = new size_t [ _queueSize ] ;
00034    int * toto ;
00035    for (int i = 0 ; i < _queueSize ; i++ ) {
00036       _tabLibres [ i ] = new PsnMemoryElementDescriptor() ;
00037       _tabLibres [ i ]->base = i * _blockSize ;
00038       _tabLibres [ i ]->size = _blockSize ; 
00039       _tabLibres [ i ]->next = (unsigned int) NULL ;
00040       _tabTailleLibre [ i ] = _blockSize ;
00041       assert(_blockSize == _pageSize) ; //for rapid prototyping
00042       //write something on every page so that prefetch will work
00043       toto = (int *)(_startDsm + i * _pageSize) ;
00044       *toto = 0 ;
00045    }
00046 }

PsnSharedFreeStoreMemoryManager::~PsnSharedFreeStoreMemoryManager   [virtual]
 

Desctructeur.

Definition at line 48 of file PsnSharedFreeStoreMemoryManager.cxx.

References PsnFramedMemoryManager::_blockSize, PsnFramedMemoryManager::_queueSize, _tabLibres, and _tabTailleLibre.

00048                                                                    {
00049    for (int i = 0 ; i < _queueSize ; i++ ) {
00050       assert (_tabTailleLibre [ i ] == _blockSize) ;
00051       delete _tabLibres [ i ] ;
00052    }
00053    delete [] _tabLibres ;
00054    delete [] _tabTailleLibre ;
00055 }


Member Function Documentation

size_t PsnSharedFreeStoreMemoryManager::getSize   [virtual]
 

return the size of the sharedFreeStoreManager

Definition at line 58 of file PsnSharedFreeStoreMemoryManager.cxx.

References PsnSharedMemoryManager::_sizeDsm.

00058                                                 {
00059    return _sizeDsm ;
00060 }

void * PsnSharedFreeStoreMemoryManager::mallocAvecMemoire size_t    size,
int    frame
[virtual]
 

allocate dynamicaly, for visibility at frame frame

Definition at line 62 of file PsnSharedFreeStoreMemoryManager.cxx.

References PsnFramedMemoryManager::_currentWritableIndex, and PsnSharedMemoryManager::allocateSizeRemembered().

Referenced by PsnRelaxedMemoryManager::allocateSizeRemembered().

00062                                                                                 {
00063    int oldCurrentWritableIndex = _currentWritableIndex ;
00064    _currentWritableIndex = frame ;
00065    void * resul=PsnFramedMemoryManager::allocateSizeRemembered(size);
00066    _currentWritableIndex = oldCurrentWritableIndex ;
00067    return resul;
00068 }

void PsnSharedFreeStoreMemoryManager::mfree void *    ptr,
size_t    size
[virtual]
 

free memory allocated by the previous method

find out in which block this memory element is allocated

add in the correct list

change freeSize

manage sync

Reimplemented from PsnSharedMemoryManager.

Definition at line 92 of file PsnSharedFreeStoreMemoryManager.cxx.

References PsnFramedMemoryManager::_blockSize, PsnFramedMemoryManager::_queueSize, _tabLibres, _tabTailleLibre, PsnSecondarySharedMemoryManager::addInThisFree(), PsnSharedMemoryManager::alignedSize(), PsnSharedMemoryManager::inAdressSpace(), and PsnFramedMemoryManager::removeBlockFromSync().

00092                                                                      {
00093    assert( inAdressSpace(ptr) ) ;
00094 
00095    size_t allocatedSize=alignedSize(size);
00096    //cerr<<"PsnSharedFreeStoreMemoryManager::mfree a "<<ptr<<" "<<allocatedSize<<endl;
00098    unsigned int offsetInMemory = globalAddressToLocal ( ptr ) ;
00099    unsigned int blockNumber = offsetInMemory / _blockSize ;
00100 
00101    //unsigned int offsetInBlock = offsetInMemory - blockNumber * _blockSize ;
00102 
00103    //assert ( offsetInBlock < _blockSize ) ;
00104    assert ( blockNumber < _queueSize ) ;
00105 
00107    addInThisFree( & _tabLibres [ blockNumber ] , offsetInMemory , allocatedSize ) ;
00108 
00110    _tabTailleLibre [ blockNumber ] -= allocatedSize ;
00111    
00113    if (_tabTailleLibre [ blockNumber ] == 0 ) {
00114       cerr<<"PsnSharedFreeStoreMemoryManager::mfree "<<blockNumber<<" removed from sync"<<endl;
00115       removeBlockFromSync ( blockNumber ) ;
00116    }
00117    
00118 }

void * PsnSharedFreeStoreMemoryManager::mmalloc size_t    size [virtual]
 

allocate so the that the memory allocated gets synced at the next simulation step

Returns:
NULL if allocaation is not possible, address of block of size bytes otherwise

Reimplemented from PsnSharedMemoryManager.

Definition at line 71 of file PsnSharedFreeStoreMemoryManager.cxx.

References PsnFramedMemoryManager::_blockSize, PsnFramedMemoryManager::_currentWritableIndex, _tabLibres, _tabTailleLibre, PsnFramedMemoryManager::addBlockInSync(), PsnSharedMemoryManager::alignedSize(), and PsnSecondarySharedMemoryManager::getFromThisFree().

00071                                                             {
00072 
00073    void * resul ;
00074    size_t allocatedSize=alignedSize(size);
00075    //cerr<<"PsnSharedFreeStoreMemoryManager::mmalloc "<<allocatedSize<<" "<<_tabTailleLibre[ nextQueueIndex ]<<endl;
00076    if (allocatedSize <= _tabTailleLibre[ _currentWritableIndex ]) {
00077       resul = getFromThisFree( & (_tabLibres [ _currentWritableIndex ]) , allocatedSize) ;
00078       if ( resul != NULL ) {
00079          if ( _tabTailleLibre [ _currentWritableIndex ] == _blockSize ) {
00080             addBlockInSync( _currentWritableIndex ); 
00081          }
00082          _tabTailleLibre [ _currentWritableIndex ] -= allocatedSize ;
00083       }
00084    }
00085    else {
00086       resul = NULL ;
00087    }
00088    //cerr<<"Block alloué à : "<<resul<<", debut de la memoire gérée : "<<(void *)_startDsm<<", page relative "<<_currentWritableIndex<<endl;
00089    return resul ;
00090 }


Member Data Documentation

PsnMemoryElementDescriptor* * PsnSharedFreeStoreMemoryManager::_tabLibres [protected]
 

the table of framed free mem lists */

Definition at line 63 of file PsnSharedFreeStoreMemoryManager.h.

Referenced by mfree(), mmalloc(), PsnSharedFreeStoreMemoryManager(), and ~PsnSharedFreeStoreMemoryManager().

size_t* PsnSharedFreeStoreMemoryManager::_tabTailleLibre [protected]
 

the table containing the free memory available for each frame

Definition at line 66 of file PsnSharedFreeStoreMemoryManager.h.

Referenced by mfree(), mmalloc(), PsnSharedFreeStoreMemoryManager(), and ~PsnSharedFreeStoreMemoryManager().


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

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

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