Fix direct calls to SDAG entry methods
[namd.git] / src / PmeSolver.ci
1 module PmeSolver {
2
3   message PmeStartMsg;
4
5   message PmeRunMsg;
6
7   message PmeDoneMsg;
8
9   group PmePencilXYZMap : CkArrayMap {
10     entry PmePencilXYZMap(int pe);
11   };
12
13   group PmePencilXMap : CkArrayMap {
14     entry PmePencilXMap(int ia, int ib, int width, std::vector<int> pes);
15   };
16
17   group PmePencilXYMap : CkArrayMap {
18     entry PmePencilXYMap(std::vector<int> pes);
19   };
20
21   array[1D] PmePencilXYZ {
22     entry PmePencilXYZ();
23     entry void chargeGridReady(PmeRunMsg *msg);
24     entry void skip();
25     entry void start(PmeStartMsg *pmeStartMsg) {
26       serial "initFFT" {
27         initFFT(pmeStartMsg); 
28         delete pmeStartMsg;
29       }
30       while (true) {
31         when chargeGridReady(PmeRunMsg *msg) serial "forwardFFT" {
32           doEnergy = msg->doEnergy;
33           doVirial = msg->doVirial;
34           lattice = msg->lattice;
35           numStrayAtoms = msg->numStrayAtoms;
36           delete msg;
37           forwardFFT();
38         }
39         serial "forwardDone" { forwardDone(); }
40         serial "backwardFFT" { backwardFFT(); }
41         serial "backwardDone" { backwardDone(); }
42       }
43     };
44   };
45
46   message PmeBlockMsg {
47     float2 data[];
48   };
49
50   array[3D] PmePencilXY {
51     entry PmePencilXY();
52     entry void startDoneCallback();
53     entry void chargeGridReady(PmeRunMsg *msg);
54     entry void recvBlock(PmeBlockMsg *msg);
55     entry void start(PmeStartMsg *pmeStartMsg) {
56       serial "initFFT" {
57         initFFT(pmeStartMsg); 
58         delete pmeStartMsg;
59         start(CkCallback(CkIndex_PmePencilXY::startDoneCallback(), thisProxy[thisIndex]));
60       }
61       when startDoneCallback() serial {}
62       while (true) {
63         when chargeGridReady(PmeRunMsg *msg) serial "forwardFFT" {
64           doEnergy = msg->doEnergy;
65           doVirial = msg->doVirial;
66           lattice = msg->lattice;
67           numStrayAtoms = msg->numStrayAtoms;
68           delete msg;
69           forwardFFT();
70           forwardDone();
71         }
72         // ------------------------
73         // Goes into z-pencil here
74         // ------------------------
75         for (imsg=0;imsg < pmeGrid.xBlocks;++imsg) {
76           when recvBlock(PmeBlockMsg *msg) serial "recvDataFromZ" {
77             recvDataFromZ(msg);
78           }
79         }
80         serial "backwardFFT" {
81           backwardFFT();
82           backwardDone();
83         }
84       }
85     };
86   };
87
88   array[3D] PmePencilX {
89     entry PmePencilX();
90     entry void startDoneCallback();
91     entry void chargeGridReady(PmeRunMsg *msg);
92     entry void recvBlock(PmeBlockMsg *msg);
93     entry void start(PmeStartMsg *pmeStartMsg) {
94       serial "initFFT" {
95         initFFT(pmeStartMsg); 
96         delete pmeStartMsg;
97         start(CkCallback(CkIndex_PmePencilX::startDoneCallback(), thisProxy[thisIndex]));
98       }
99       when startDoneCallback() serial {}
100       while (true) {
101         when chargeGridReady(PmeRunMsg *msg) serial "forwardFFT" {
102           doEnergy = msg->doEnergy;
103           doVirial = msg->doVirial;
104           lattice = msg->lattice;
105           numStrayAtoms = msg->numStrayAtoms;
106           delete msg;
107           forwardFFT();
108           forwardDone();
109         }
110         // ------------------------
111         // Goes into y-pencil here
112         // ------------------------
113         for (imsg=0;imsg < pmeGrid.xBlocks;++imsg) {
114           when recvBlock(PmeBlockMsg *msg) serial "recvDataFromY" {
115             recvDataFromY(msg);
116           }
117         }
118         serial "backwardFFT" {
119           backwardFFT();
120           backwardDone();
121         }
122       }
123     };
124   };
125
126   array[3D] PmePencilY {
127     entry PmePencilY();
128     entry void startDoneCallback();
129     entry void recvBlock(PmeBlockMsg *msg);
130     entry void start(PmeStartMsg *pmeStartMsg) {
131       serial "initFFT" {
132         initFFT(pmeStartMsg); 
133         delete pmeStartMsg;
134         start(CkCallback(CkIndex_PmePencilY::startDoneCallback(), thisProxy[thisIndex]));
135       }
136       when startDoneCallback() serial {}
137       while (true) {
138         for (imsg=0;imsg < pmeGrid.yBlocks;++imsg) {
139           when recvBlock(PmeBlockMsg *msg) serial "recvDataFromX" {
140             doEnergy = msg->doEnergy;
141             doVirial = msg->doVirial;
142             lattice  = msg->lattice;
143             numStrayAtoms += msg->numStrayAtoms;
144             recvDataFromX(msg);
145           }
146         }
147         serial "forwardFFT" {
148           forwardFFT();
149           forwardDone();
150           numStrayAtoms = 0;
151         }
152         // ------------------------
153         // Goes into z-pencil here
154         // ------------------------
155         for (imsg=0;imsg < pmeGrid.yBlocks;++imsg) {
156           when recvBlock(PmeBlockMsg *msg) serial "recvDataFromZ" {
157             recvDataFromZ(msg);
158           }
159         }
160         serial "backwardFFT" {
161           backwardFFT();
162           backwardDone();
163         }
164       }
165     };
166   };
167
168   array[3D] PmePencilZ {
169     entry PmePencilZ();
170     entry void startDoneCallback();
171     entry void recvBlock(PmeBlockMsg *msg);
172     entry void skip();
173     entry void start(PmeStartMsg *pmeStartMsg) {
174       serial "initFFT" {
175         initFFT(pmeStartMsg); 
176         delete pmeStartMsg;
177         start(CkCallback(CkIndex_PmePencilZ::startDoneCallback(), thisProxy[thisIndex]));
178       }
179       when startDoneCallback() serial {}
180       while (true) {
181         for (imsg=0;imsg < pmeGrid.zBlocks;++imsg) {
182           when recvBlock(PmeBlockMsg *msg) serial "recvDataFromY" {
183             doEnergy = msg->doEnergy;
184             doVirial = msg->doVirial;
185             lattice  = msg->lattice;
186             numStrayAtoms += msg->numStrayAtoms;
187             recvDataFromY(msg);
188           }
189         }
190         serial "forwardFFT" {
191           forwardFFT();
192           forwardDone();
193         }
194         serial "backwardFFT" { backwardFFT(); }
195         serial "backwardDone" { backwardDone(); }
196       }
197     };
198   };
199
200 };