00001 // File: evmpool.h 00002 // EventMsgPool: facility for reusing event messages 00003 // Last Modified: 5.29.01 by Terry L. Wilmarth 00004 00005 #ifndef EVMPOOL_H 00006 #define EVMPOOL_H 00007 #include "evmpool.decl.h" 00008 00009 extern CkGroupID EvmPoolID; // global readonly to access pool anywhere 00010 //extern int MapSizeToIdx(int size); 00011 00012 // Message to initialize EventMsgPool 00013 class PoolInitMsg : public CMessage_PoolInitMsg { 00014 public: 00015 int numPools; 00016 }; 00017 00018 // Basic single pool of same-size messages 00019 class Pool 00020 { 00021 public: 00022 int numMsgs; 00023 void *msgPool[MAX_POOL_SIZE]; 00024 Pool() { numMsgs = 0; } 00025 }; 00026 00027 // Set of message pools for various size messages; 1 EventMsgPool per PE 00028 class EventMsgPool : public Group { 00029 private: 00030 int numPools; // corresponds to number of message sizes 00031 Pool *msgPools; // the Pools 00032 public: 00033 EventMsgPool(PoolInitMsg *m) { // initialize and allocate number of pools 00034 numPools = m->numPools; 00035 CkFreeMsg(m); 00036 msgPools = new Pool[numPools]; 00037 for (int i=0; i<numPools; i++) 00038 msgPools[i].numMsgs = 0; 00039 } 00040 EventMsgPool(CkMigrateMessage *) { }; 00041 int CheckPool(int idx); // returns number of messages in pool idx 00042 void *GetEventMsg(int idx); // returns a message from pool idx 00043 void PutEventMsg(int idx, void *msg); // puts a message in pool idx 00044 }; 00045 00046 #endif