2 |
|
#include <stdlib.h> |
3 |
|
#include <stdio.h> |
4 |
|
#include <string.h> |
5 |
+ |
#define __mpiBASSEVENT |
6 |
|
#include "mpiInterface.h" |
7 |
|
|
8 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
< |
mpiEventInit() |
14 |
> |
void mpiEventInit(void) |
15 |
|
{ |
16 |
< |
int blockCounts[4] = {1,3,4,120} |
16 |
> |
int blockCounts[4] = {1,3,4,120}; |
17 |
|
MPI_Aint dspls[4]; |
18 |
|
MPI_Datatype types[4]; |
19 |
|
mBEvent protoEvent; |
20 |
|
|
21 |
|
int i; |
22 |
|
|
23 |
< |
MPI_Address(&protoEvent.type, dspls[0]); |
24 |
< |
MPI_Address(&protoEvent.d1, dspls[1]); |
25 |
< |
MPI_Address(&protoEvent.i1, dspls[2]); |
26 |
< |
MPI_Address(&protoEvent.cArray, dspls[3]); |
23 |
> |
MPI_Address(&protoEvent.type, &dspls[0]); |
24 |
> |
MPI_Address(&protoEvent.d1, &dspls[1]); |
25 |
> |
MPI_Address(&protoEvent.i1, &dspls[2]); |
26 |
> |
MPI_Address(&protoEvent.cArray, &dspls[3]); |
27 |
|
|
28 |
|
|
29 |
|
types[0] = MPI_INT; |
39 |
|
} |
40 |
|
|
41 |
|
|
42 |
< |
throwMPIEvent(event* the_event) |
42 |
> |
void throwMPIEvent(event* the_event) |
43 |
|
{ |
44 |
< |
mBEvent mpiBEventContainer; |
44 |
> |
mBEvent mpiEventContainer; |
45 |
|
int mpiStatus; |
46 |
|
int mpiError; |
47 |
|
|
51 |
|
mpiError = MPI_Bcast(&mpiStatus,1,MPI_INT,0,MPI_COMM_WORLD); |
52 |
|
if (mpiError != MPI_SUCCESS){ |
53 |
|
mpiError = MPI_Finalize(); |
54 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
54 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
55 |
|
exit (0); |
56 |
|
} |
57 |
|
|
59 |
|
switch (the_event->event_type){ |
60 |
|
case MOLECULE: |
61 |
|
mpiEventContainer.type = mpiMOLECULE; |
62 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
62 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
63 |
|
break; |
64 |
|
|
65 |
|
case ATOM: |
66 |
|
mpiEventContainer.type = mpiATOM; |
67 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
67 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
68 |
|
break; |
69 |
|
|
70 |
|
case BOND: |
71 |
|
mpiEventContainer.type = mpiBOND; |
72 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
72 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
73 |
|
break; |
74 |
|
|
75 |
|
case BEND: |
76 |
|
mpiEventContainer.type = mpiBEND; |
77 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
77 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
78 |
|
break; |
79 |
|
|
80 |
|
case TORSION: |
81 |
|
mpiEventContainer.type = mpiTORSION; |
82 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
82 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
83 |
|
break; |
84 |
|
|
85 |
|
case COMPONENT: |
86 |
|
mpiEventContainer.type = mpiCOMPONENT; |
87 |
< |
mpiEventContainer.i1 = the_event->evt.block_index; // pack block index into first int |
87 |
> |
mpiEventContainer.i1 = the_event->evt.blk_index; // pack block index into first int |
88 |
|
break; |
89 |
|
|
90 |
|
case POSITION: |
118 |
|
switch (the_event->evt.asmt.asmt_type){ |
119 |
|
case STRING: |
120 |
|
mpiEventContainer.type = mpiASSIGNMENT_s; |
121 |
< |
strcpy(mpiEventContainer.cArray,the_event->evt.asmt.sval); |
121 |
> |
strcpy(mpiEventContainer.cArray,the_event->evt.asmt.rhs.sval); |
122 |
|
break; |
123 |
|
|
124 |
|
case INT: |
125 |
|
mpiEventContainer.type = mpiASSIGNMENT_i; |
126 |
< |
mpiEventContainer.i1 = the_event->evt.asmt.ival; |
126 |
> |
mpiEventContainer.i1 = the_event->evt.asmt.rhs.ival; |
127 |
|
break; |
128 |
|
|
129 |
|
case DOUBLE: |
130 |
|
mpiEventContainer.type = mpiASSIGNMENT_d; |
131 |
< |
mpiEventContainer.d1 = the_event->evt.asmt.dval; |
131 |
> |
mpiEventContainer.d1 = the_event->evt.asmt.rhs.dval; |
132 |
|
break; |
133 |
|
} |
134 |
|
break; |
143 |
|
|
144 |
|
if (mpiError != MPI_SUCCESS){ |
145 |
|
mpiError = MPI_Finalize(); |
146 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
146 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
147 |
|
exit (0); |
148 |
|
} |
149 |
|
} |
151 |
|
|
152 |
|
|
153 |
|
// Everybody but node 0 runs this |
154 |
< |
mpiEventLoop() |
154 |
> |
void mpiEventLoop(void) |
155 |
|
{ |
156 |
|
int mpiError; |
157 |
|
int mpiContinue; |
159 |
|
mpiError = MPI_Bcast(&mpiContinue,1,MPI_INT,0,MPI_COMM_WORLD); |
160 |
|
if (mpiError != MPI_SUCCESS){ |
161 |
|
mpiError = MPI_Finalize(); |
162 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
162 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
163 |
|
exit (0); |
164 |
|
} |
165 |
|
|
171 |
|
mpiError = MPI_Bcast(&mpiContinue,1,MPI_INT,0,MPI_COMM_WORLD); |
172 |
|
if (mpiError != MPI_SUCCESS){ |
173 |
|
mpiError = MPI_Finalize(); |
174 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
174 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
175 |
|
exit (0); |
176 |
|
} |
177 |
|
} |
178 |
|
|
179 |
|
if (mpiContinue == MPI_INTERFACE_ABORT){ |
180 |
|
mpiError = MPI_Finalize(); |
181 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
181 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
182 |
|
exit (0); |
183 |
|
} |
184 |
|
} |
185 |
|
|
186 |
< |
mpiCatchEvent() |
186 |
> |
void mpiCatchEvent(void) |
187 |
|
{ |
188 |
|
event the_event; |
189 |
< |
mBEvent mpiBEventContainer; |
189 |
> |
mBEvent mpiEventContainer; |
190 |
|
int mpiError; |
191 |
|
|
192 |
|
|
194 |
|
|
195 |
|
if (mpiError != MPI_SUCCESS){ |
196 |
|
mpiError = MPI_Finalize(); |
197 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
197 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
198 |
|
exit (0); |
199 |
|
} |
200 |
|
|
202 |
|
switch (mpiEventContainer.type){ |
203 |
|
case mpiMOLECULE: |
204 |
|
the_event.event_type = MOLECULE; |
205 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
205 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
206 |
|
break; |
207 |
|
|
208 |
|
case mpiATOM: |
209 |
|
the_event.event_type = ATOM; |
210 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
210 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
211 |
|
break; |
212 |
|
|
213 |
|
case mpiBOND: |
214 |
|
the_event.event_type = BOND; |
215 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
215 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
216 |
|
break; |
217 |
|
|
218 |
|
case mpiBEND: |
219 |
|
the_event.event_type = BEND; |
220 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
220 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
221 |
|
break; |
222 |
|
|
223 |
|
case mpiTORSION: |
224 |
|
the_event.event_type = TORSION; |
225 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
225 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
226 |
|
break; |
227 |
|
|
228 |
|
case mpiCOMPONENT: |
229 |
|
the_event.event_type = COMPONENT; |
230 |
< |
the_event.evt.block_index = mpiEventContainer.i1; |
230 |
> |
the_event.evt.blk_index = mpiEventContainer.i1; |
231 |
|
break; |
232 |
|
|
233 |
|
|
261 |
|
case mpiASSIGNMENT_s: |
262 |
|
the_event.event_type = ASSIGNMENT; |
263 |
|
the_event.evt.asmt.asmt_type = STRING; |
264 |
< |
strcpy(the_event.evt.asmt.sval,mpiEventContainer.cArray); |
264 |
> |
strcpy(the_event.evt.asmt.rhs.sval,mpiEventContainer.cArray); |
265 |
|
break; |
266 |
|
|
267 |
|
case mpiASSIGNMENT_i: |
268 |
|
the_event.event_type = ASSIGNMENT; |
269 |
|
the_event.evt.asmt.asmt_type = INT; |
270 |
< |
the_event.evt.asmt.ival = mpiEventContainer.i1; |
270 |
> |
the_event.evt.asmt.rhs.ival = mpiEventContainer.i1; |
271 |
|
break; |
272 |
|
|
273 |
|
case mpiASSIGNMENT_d: |
274 |
|
the_event.event_type = ASSIGNMENT; |
275 |
|
the_event.evt.asmt.asmt_type = DOUBLE; |
276 |
< |
the_event.evt.asmt.dval = mpiEventContainer.d1; |
276 |
> |
the_event.evt.asmt.rhs.dval = mpiEventContainer.d1; |
277 |
|
break; |
278 |
|
|
279 |
|
case mpiBLOCK_END: |
283 |
|
|
284 |
|
|
285 |
|
if (!event_handler(&the_event)){ |
286 |
< |
sprintf(stderr,"MPI event handling error => %s\n",the_event.err_msg); |
286 |
> |
fprintf(stderr,"MPI event handling error => %s\n",the_event.err_msg); |
287 |
|
mpiError = MPI_Finalize(); |
288 |
< |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(); |
288 |
> |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
289 |
|
exit (0); |
290 |
|
} |
291 |
|
} |
292 |
+ |
|
293 |
+ |
|
294 |
+ |
void mpiInterfaceExit(void){ |
295 |
+ |
int mpiError; |
296 |
+ |
int mpiStatus = MPI_INTERFACE_ABORT; |
297 |
+ |
|
298 |
+ |
mpiError = MPI_Bcast(&mpiStatus,1,MPI_INT,0,MPI_COMM_WORLD); |
299 |
+ |
if (mpiError != MPI_SUCCESS){ |
300 |
+ |
mpiError = MPI_Finalize(); |
301 |
+ |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
302 |
+ |
exit (0); |
303 |
+ |
} |
304 |
+ |
|
305 |
+ |
mpiError = MPI_Finalize(); |
306 |
+ |
if (mpiError != MPI_SUCCESS) mpiError = MPI_Abort(MPI_COMM_WORLD,0); |
307 |
+ |
exit (0); |
308 |
+ |
|
309 |
+ |
} |