New version of communication library with learning capabilities. Learning and dynamic...
[charm.git] / src / ck-com / RingMulticastStrategy.h
1 #ifndef RING_MULTICAST_STRATEGY
2 #define RING_MULTICAST_STRATEGY
3
4 #include "DirectMulticastStrategy.h"
5
6 class RingMulticastHashObject{
7  public:
8     CkVec<CkArrayIndexMax> indices;
9     int nextPE;
10 };
11
12
13 class RingMulticastStrategy: public DirectMulticastStrategy {
14     
15     int nextPE;
16     
17     void commonRingInit();
18     int isEndOfRing(int next_pe, int src_pe);
19     RingMulticastHashObject *getHashObject(int pe, int id);
20     RingMulticastHashObject *createHashObject(int nelements, 
21                                               CkArrayIndexMax *elements);
22     void initSectionID(CkSectionID *sid);
23
24  public:
25     
26     //Group constructor
27     RingMulticastStrategy(int ndestpes, int *destpelist);
28     
29     //Array constructor
30     RingMulticastStrategy(CkArrayID dest_id);    
31     RingMulticastStrategy(CkArrayID src, CkArrayID dest);    
32     RingMulticastStrategy(CkMigrateMessage *m) {}
33
34     //Destructor
35     ~RingMulticastStrategy() { 
36         
37         CkHashtableIterator *ht_iterator = sec_ht.iterator();
38         ht_iterator->seekStart();
39         while(ht_iterator->hasNext()){
40             void **data;
41             data = (void **)ht_iterator->next();        
42             RingMulticastHashObject *robj = 
43                 (RingMulticastHashObject*)(* data);
44
45             *data = NULL;
46             if(robj)
47                 delete robj;
48         }
49
50         sec_ht.empty();
51     }
52     
53     void insertMessage(CharmMessageHolder *msg);
54     void doneInserting();
55     void handleMulticastMessage(void *msg);
56     
57     void pup(PUP::er &p);    
58     void beginProcessing(int nelements);
59     
60     PUPable_decl(RingMulticastStrategy);
61 };
62 #endif
63