00001 00002 /* Allows for the storage and reuse of memory blocks for event messages and 00003 checkpointing. */ 00004 00005 #ifndef MEMPOOL_H 00006 #define MEMPOOL_H 00007 #include "mempool.decl.h" 00008 00009 extern CkGroupID MemPoolID; // global readonly to access pool anywhere 00010 00011 // Basic single pool of same-size memory blocks 00012 class Pool 00013 { 00014 public: 00015 int numBlocks, blockSize; 00016 void *memPool[MAX_POOL_SIZE]; 00017 Pool *next, *prev; 00018 Pool() : numBlocks(0),blockSize(0),next(NULL), prev(NULL){ } 00019 }; 00020 00021 // Set of memory pools for various size blocks; 1 MemoryPool per PE 00022 class MemoryPool : public Group { 00023 private: 00024 Pool *memPools; // the Pools 00025 Pool *lastLook; // last pool looked at 00026 public: 00028 MemoryPool() :memPools(NULL),lastLook(NULL){ 00029 #ifdef VERBOSE_DEBUG 00030 CkPrintf("[%d] constructing MemoryPool\n",CkMyPe()); 00031 #endif 00032 } 00033 MemoryPool(CkMigrateMessage *msg) : Group(msg) { } 00034 void pup(PUP::er &p) { } 00036 int CheckPool(int sz); 00038 /* Assumes a block of the appropriate size exists! */ 00039 void *GetBlock(int sz); 00041 /* Assumes there is space in the pool for the block! */ 00042 void PutBlock(int sz, void *blk); 00043 }; 00044 00045 #endif