doc: Add serial to list of ci file reserved words
[charm.git] / src / ck-com / ComlibArrayListener.C
1 ///**
2 //   @addtogroup CharmComlib
3 //*/
4 ///*@{*/
5 //
6 ///** @file */
7 //
8 ////#include "charm++.h"
9 ////#include "envelope.h"
10 ////#include "ckhashtable.h"
11 //#include "ComlibArrayListener.h"
12 //#include "ComlibManager.h"
13 //
14 ///*
15 //ComlibArrayListener::ComlibArrayListener () 
16 //    : CkArrayListener(0){ //Carry 1 int for the sid, not used yet
17 //    nElements = 0;
18 //    ht = new CkHashtableT<CkArrayIndex, CkArrayIndex *>;
19 //    //    CkPrintf("Creating Array Listener\n");
20 //}
21 //*/
22 //
23 //ComlibArrayListener::ComlibArrayListener(CkArrayID &id) : CkArrayListener(0) {
24 //  setupFinished = 0;
25 //  thisArrayID = id;
26 //  ComlibPrintf("[%d] Creating ComlibArrayListener for array %d\n",CkMyPe(),((CkGroupID)id).idx);
27 //}
28 //
29 //ComlibArrayListener::ComlibArrayListener (CkMigrateMessage *m)
30 //    :CkArrayListener(m) {
31 //  /*
32 //    nElements = 0;
33 //    ht = new CkHashtableT<CkArrayIndex, CkArrayIndex *>;
34 //  */
35 //}
36 //
37 //void ComlibArrayListener::pup(PUP::er &p) {
38 //  ComlibPrintf("[%d] ComlibArrayListener pupping for %s, why?!?\n",CkMyPe(),
39 //               p.isPacking()?"packing":(p.isUnpacking()?"unpacking":"sizing"));
40 //}
41 //
42 //void ComlibArrayListener::ckEndInserting() {
43 //      CkAssert(0);
44 //      CkAssert(setupFinished==0);
45 //
46 //      ComlibPrintf("[%d] ComlibArrayListener::ckEndInserting\n",CkMyPe());
47 //      CProxy_ComlibManager cgproxy(CkpvAccess(cmgrID));
48 //      for (int i=0; i<userIDs.size(); ++i) {
49 //              cgproxy[0].bracketedFinishSetup(userIDs[i]);
50 //      }
51 //
52 //      setupFinished = 1;
53 //  
54 //}
55 //
56 //void ComlibArrayListener::ckElementCreating(ArrayElement *elt){
57 //  ComlibPrintf("[%d] ComlibArrayListener::ckElementCreating\n",CkMyPe());
58 //  for (int i=0; i<users.size(); ++i) {
59 //    users[i]->newElement(thisArrayID, elt->ckGetArrayIndex());
60 //  }
61 //  //addElement(elt, CmiFalse);
62 //    //CkPrintf("[%d] Element Created\n", CkMyPe());
63 //}
64 ///*
65 //void ComlibArrayListener::ckElementDied(ArrayElement *elt){
66 //    deleteElement(elt, CmiFalse);
67 //}
68 //
69 //void ComlibArrayListener::ckElementLeaving(ArrayElement *elt){
70 //    deleteElement(elt, CmiTrue);
71 //}
72 //
73 //CmiBool ComlibArrayListener::ckElementArriving(ArrayElement *elt){
74 //    addElement(elt, CmiTrue);
75 //    return CmiTrue;
76 //}
77 //
78 //void ComlibArrayListener::addElement(ArrayElement *elt, 
79 //                                     CmiBool migration_flag){
80 //    if(nElements == 0)
81 //        thisArrayID = elt->ckGetArrayID();
82 //
83 //    ht->put(elt->thisIndexMax) = &(elt->thisIndexMax);
84 //    //elt->thisIndexMax.print();
85 //    nElements ++;
86 //
87 //    if(!migration_flag) {
88 //        for(int count = 0; count < strategyList.length(); count++){
89 //            CharmStrategy *strategy = (CharmStrategy *)
90 //                strategyList[count]->strategy;
91 //            if(isRegistered(elt, strategy)) {
92 //                strategyList[count]->numElements ++;
93 //            }
94 //        }   
95 //    }
96 //}
97 //
98 //void ComlibArrayListener::deleteElement(ArrayElement *elt, 
99 //                                        CmiBool migration_flag){
100 //    ht->remove(elt->thisIndexMax);
101 //    nElements --;
102 //    
103 //    if(!migration_flag) {
104 //        for(int count = 0; count < strategyList.length(); count++){
105 //            CharmStrategy *strategy = (CharmStrategy *)
106 //                strategyList[count]->strategy;
107 //            if(isRegistered(elt, strategy)) {
108 //                strategyList[count]->numElements --;
109 //            }
110 //        }   
111 //    }
112 //}
113 //
114 //int ComlibArrayListener::isRegistered(ArrayElement *elt, 
115 //                                      CharmStrategy *strat){
116 //    CkArrayIndex idx = elt->thisIndexMax;
117 //
118 //    CkArrayID st_aid;
119 //    int st_nelements;
120 //    CkArrayIndex *st_elem;
121 //    strat->ainfo.getSourceArray(st_aid, st_elem, st_nelements);
122 //
123 //    if(st_nelements < 0)
124 //        CkAbort("Not an Array Strategy\n");
125 //    
126 //    if(st_nelements == 0)
127 //        return 1;   
128 //
129 //    for(int count = 0; count < st_nelements; count ++)
130 //        if(st_elem[count].compare(idx))
131 //            return 1;
132 //
133 //    return 0;
134 //}
135 // 
136 ////Assumes strategy is already present in the strategy table   
137 //void ComlibArrayListener::registerStrategy(StrategyTableEntry *stable_entry) {
138 //    strategyList.insertAtEnd(stable_entry);
139 //
140 //    CharmStrategy *strat = (CharmStrategy *) stable_entry->strategy;
141 //
142 //    CkArrayID st_aid;
143 //    int st_nelements;
144 //    CkArrayIndex *st_elem;
145 //    strat->ainfo.getSourceArray(st_aid, st_elem, st_nelements);
146 //
147 //    if(st_nelements == 0) {//All elements of array in strategy
148 //        stable_entry->numElements += nElements;
149 //
150 ////         CkHashtableIterator *ht_iterator = ht->iterator();
151 ////         ht_iterator->seekStart();
152 ////         while(ht_iterator->hasNext()){
153 ////             CkArrayIndex *idx;
154 ////             ht_iterator->next((void **)&idx);
155 ////             stable_entry->strategy->insertLocalIndex(*idx);       
156 ////         }
157 //
158 //    }
159 //    else if (st_nelements > 0){ //Only some elements belong to strategy
160 //        for(int count = 0; count < st_nelements; count ++)
161 //            if(ht->get(st_elem[count]) != NULL) {
162 //                stable_entry->numElements ++;
163 //            }
164 //    }
165 //    else 
166 //        CkAbort("NOT an Array Strategy\n");
167 //
168 //}
169 //
170 //void ComlibArrayListener::getLocalIndices(CkVec<CkArrayIndex> &vec){
171 //    
172 //    CkHashtableIterator *ht_iterator = ht->iterator();
173 //    ht_iterator->seekStart();
174 //    while(ht_iterator->hasNext()){
175 //        CkArrayIndex *idx;
176 //        ht_iterator->next((void **)&idx);
177 //        vec.insertAtEnd(*idx);       
178 //    }
179 //}
180 //*/
181 //
182 ///*@}*/