8 struct { /* none */ } p1
;
9 struct { int created
; int processed
; } p2
;
10 struct { /* none */ } p3
;
11 struct { int dirty
; } p4
;
15 int getPhase(void) { return phase
; }
16 void setPhase(int p
) { phase
= p
; }
17 CkCallback
getCb(void) { CkAssert(phase
==0); return cb
; }
18 void setCb(CkCallback cb_
) { CkAssert(phase
==0); cb
= cb_
; }
19 int getCreated(void) { CkAssert(phase
==1); return u
.p2
.created
; }
20 void setCreated(int c
) { CkAssert(phase
==1); u
.p2
.created
= c
; }
21 int getProcessed(void) { CkAssert(phase
==1); return u
.p2
.processed
; }
22 void setProcessed(int p
) { CkAssert(phase
==1); u
.p2
.processed
= p
; }
23 int getDirty(void) { CkAssert(phase
==2); return u
.p4
.dirty
; }
24 void setDirty(int d
) { CkAssert(phase
==2); u
.p4
.dirty
= d
; }
29 int flag
; // 0: create 1: process
37 QdCallback(int e
, CkChareID c
) : cb(e
, c
) {}
38 QdCallback(CkCallback cb_
) : cb(cb_
) {}
39 // void send(void) { CkSendMsg(ep,CkAllocMsg(0,0,0),&cid); }
41 // pretending pe 0 in blue gene mode, switch back after the call.
42 #if CMK_CONDS_USE_SPECIAL_CODE
43 int old
= CmiSwitchToPE(0);
46 #if CMK_CONDS_USE_SPECIAL_CODE
56 int mCreated
, mProcessed
;
57 int cCreated
, cProcessed
;
65 QdState():stage(0),mCreated(0),mProcessed(0),nReported(0) {
66 cCreated
= 0; cProcessed
= 0; cDirty
= 0;
68 callbacks
= new PtrQ();
70 nChildren
= CmiNumSpanTreeChildren(CmiMyPe());
71 parent
= CmiSpanTreeParent(CmiMyPe());
73 children
= new int[nChildren
];
75 CmiSpanTreeChildren(CmiMyPe(), children
);
77 /* CmiPrintf("[%d] n:%d parent:%d - %d %d %d %d %d %d.\n", CmiMyPe(), nChildren, parent, nChildren?children[0]:-1, nChildren?children[1]:-1, nChildren?children[2]:-1, nChildren?children[3]:-1, nChildren?children[4]:-1, nChildren?children[5]:-1); */
79 void propagate(QdMsg
*msg
) {
80 envelope
*env
= UsrToEnv((void *)msg
);
81 CmiSetHandler(env
, _qdHandlerIdx
);
82 for(int i
=0; i
<nChildren
; i
++) {
84 CmiSyncSendFn(children
[i
], env
->getTotalsize(), (char *)env
);
86 CmiSyncSend(children
[i
], env
->getTotalsize(), (char *)env
);
90 int getParent(void) { return parent
; }
91 QdCallback
*deq(void) { return (QdCallback
*) callbacks
->deq(); }
92 void enq(QdCallback
*c
) { callbacks
->enq((void *) c
); }
93 void create(int n
=1) {
99 void sendCount(int flag
, int count
); // send msg to rank 0 for counting
100 void process(int n
=1) {
102 #if CMK_IMMEDIATE_MSG
106 int getCreated(void) { return mCreated
; }
107 int getProcessed(void) { return mProcessed
; }
108 int getCCreated(void) { return cCreated
; }
109 int getCProcessed(void) { return cProcessed
; }
110 void subtreeCreate(int c
) { cCreated
+= c
; }
111 void subtreeProcess(int p
) { cProcessed
+= p
; }
112 int getStage(void) { return stage
; }
113 void setStage(int p
) { stage
= p
; }
114 void reported(void) { nReported
++; }
115 int allReported(void) {return nReported
==(nChildren
+1);}
116 void reset(void) { nReported
=0; cCreated
=0; cProcessed
=0; cDirty
=0; }
117 void markProcessed(void) { oProcessed
= mProcessed
; }
118 int isDirty(void) { return ((mProcessed
> oProcessed
) || cDirty
); }
119 void subtreeSetDirty(int d
) { cDirty
= cDirty
|| d
; }
121 stage
= mCreated
= mProcessed
= nReported
= 0;
122 cCreated
= 0; cProcessed
= 0; cDirty
= 0;
127 extern void _qdHandler(envelope
*);
128 extern void _qdCommHandler(envelope
*);
129 CpvExtern(QdState
*, _qd
);