History

merge

ericvh committed 16 years ago

Commit f68939a2 parents 6083349 da88d0b5 files · +67 −34Browse files

Unified · Split

5 files
  1. sys/src/cmd/rompi/mkfile +1 −0
  2. sys/src/cmd/rompi/reduce.c +17 −5
  3. sys/src/cmd/rompi/rompi.c +18 −17
  4. sys/src/cmd/rompi/stupidreduce.c +29 −10
  5. sys/src/cmd/rompi/torus.c +2 −2
sys/src/cmd/rompi/mkfile+1−0
@@ -13,6 +13,7 @@ DIRS=\ · 12 unmodified lines
1313 OTHEROFILES=\
1414 torus.$O\
1515 rompi.$O\
16+ support.$O\
1617
1718 HFILES=mpi.h
1819
sys/src/cmd/rompi/reduce.c+17−5
@@ -5,6 +5,7 @@ · 4 unmodified lines
55 #include "mpi.h"
66
77 /* tested may 17 2010 and works */
8+u64int tbget(void);
89 extern int torusdebug, rompidebug;
910 extern int x, y, z, xsize, ysize, zsize;
1011 int xyztorank(int x, int y, int z);
@@ -16,20 +17,31 @@ main(int argc, char **argv) · 5 unmodified lines
1617 {
1718 int node, nproc;
1819 unsigned int sum[1], nsum[1];
20+ int i;
21+ vlong startnsec, stopnsec;
22+ int iter = 100;
1923
2024 MPI_Init(&argc,&argv);
2125 MPI_Comm_rank(MPI_COMM_WORLD, &node);
2226 MPI_Comm_size(MPI_COMM_WORLD, &nproc);
2327
24− print("%lld Hello World from Node %d of %d\n", nsec(),node, nproc);
25−
26− sum[0] = node;
28+ print("%lld Hello World from Node %d of %d\n", tbget(),node, nproc);
2729
2830 if (0 && node)
2931 rompidebug |= 4;
30− MPI_Reduce (sum, nsum, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
32+ for (i = 0; i < iter; i++){
33+ if (i == 1)
34+ startnsec = tbget();
35+ sum[0] = node;
36+ MPI_Reduce (sum, nsum, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
37+// if (! node)
38+// print("%d\n", i);
39+ }
40+ stopnsec = tbget();
3141
32− print("%lld Node %d (%d, %d, %d) computes sum as %d and MPI says sum is %d\n", nsec(), node, x, y, z, ((nproc-1)*nproc)/2, nsum[0]);
42+ print("%lld Node %d (%d, %d, %d) computes sum as %d and MPI says sum is %d\n", tbget(), node, x, y, z, ((nproc-1)*nproc)/2, nsum[0]);
43+ if (! node)
44+ print("%lld nsec for %d iterations\n", stopnsec-startnsec, iter);
3345 print("%lld %d: Finalize\n", nsec(), node);
3446 MPI_Finalize();
3547 }
sys/src/cmd/rompi/rompi.c+18−17
@@ -40,6 +40,7 @@ void torusinit(int *pmyproc, const int pnprocs); · 39 unmodified lines
4040 void ranktoxyz(int rank, int *x, int *y, int *z);
4141 int xyztorank(int x, int y, int z);
4242 extern int x, y, z, xsize, ysize, zsize;
43+u64int tbget(void);
4344
4445 void
4546 buf_add(struct bufpacket *new)
@@ -282,7 +283,7 @@ int reduce_end ( void *buf, int num, MPI_Datatype datatype, int /*root*/, · 236 unmodified lines
282283 torustag[TAGtag] = reducetag;
283284 torustag[TAGsource] = myproc;
284285
285− if(rompidebug&4) print("%lld reduce_end: %d(%d, %d, %d)\n", nsec(), myproc, x, y, z);
286+ if(rompidebug&4) print("%lld reduce_end: %d(%d, %d, %d)\n", tbget(), myproc, x, y, z);
286287 if (myproc) {
287288 /* who we get it from depends on who we are. */
288289 /* this shows some bad design. We compute x,y,z, turn it into rank,
@@ -298,9 +299,9 @@ int reduce_end ( void *buf, int num, MPI_Datatype datatype, int /*root*/, · 9 unmodified lines
298299 else if (x)
299300 fromz = fromy = fromx = 0;
300301 fromrank = xyztorank(fromx, fromy, fromz);
301− if(rompidebug&4) print("%lld reduce_end: %d(%d,%d,%d): wait from (%d, %d, %d)\n", nsec(), myproc, x, y, z, fromx, fromy, fromz);
302+ if(rompidebug&4) print("%lld reduce_end: %d(%d,%d,%d): wait from (%d, %d, %d)\n", tbget(), myproc, x, y, z, fromx, fromy, fromz);
302303 MPI_Recv(buf, 1, MPI_INT, fromrank, reducetag, MPI_COMM_WORLD, status);
303− if(rompidebug&4) print("%lld reduce_end: %d: Got from %d\n", nsec(), myproc, fromrank);
304+ if(rompidebug&4) print("%lld reduce_end: %d: Got from %d\n", tbget(), myproc, fromrank);
304305 }
305306
306307 /* OK, we got it, we just need to do one send to our "axis" (of evil?) */
@@ -311,24 +312,24 @@ int reduce_end ( void *buf, int num, MPI_Datatype datatype, int /*root*/, · 4 unmodified lines
311312 */
312313 if (z) {
313314 } else if (y) {
314− if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", nsec(), myproc, x, y, z, x, y, zsize-1);
315+ if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", tbget(), myproc, x, y, z, x, y, zsize-1);
315316 torustag[TAGsource] = myproc;
316317 torussend(buf, count, x, y, zsize-1, 1, torustag, sizeof(torustag));
317318 }
318319 else if (x) {
319320 /* send down BOTH our y and z axis */
320321 torustag[TAGsource] = myproc;
321− if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", nsec(), myproc, x, y, z, x, ysize-1, 0);
322+ if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", tbget(), myproc, x, y, z, x, ysize-1, 0);
322323 torussend(buf, count, x, ysize-1, 0, 1, torustag, sizeof(torustag));
323− if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", nsec(), myproc, x, y, z, x, y, zsize-1);
324+ if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", tbget(), myproc, x, y, z, x, y, zsize-1);
324325 torussend(buf, count, x, y, zsize-1, 1, torustag, sizeof(torustag));
325326 } else {
326327 /* send down x, y, z */
327− if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", nsec(), myproc, x, y, z, xsize-1, 0, 0);
328+ if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", tbget(), myproc, x, y, z, xsize-1, 0, 0);
328329 torussend(buf, count, xsize-1, 0, 0, 1, torustag, sizeof(torustag));
329− if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", nsec(), myproc, x, y, z, x, ysize-1, 0);
330+ if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", tbget(), myproc, x, y, z, x, ysize-1, 0);
330331 torussend(buf, count, x, ysize-1, 0, 1, torustag, sizeof(torustag));
331− if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", nsec(), myproc, x, y, z, x, y, zsize-1);
332+ if(rompidebug&4) print("%lld reduce_end %d(%d, %d, %d): send to (%d, %d, %d)\n", tbget(), myproc, x, y, z, x, y, zsize-1);
332333 torussend(buf, count, x, y, zsize-1, 1, torustag, sizeof(torustag));
333334 }
334335
@@ -344,7 +345,7 @@ opsum(void *dst, void *src, int) · 9 unmodified lines
344345 int *is = src;
345346 int *id = dst;
346347 int tmp = *is;
347− if (rompidebug & 4) print("%lld %d(%d,%d,%d): SUM %d+%d=%d\n", nsec(), myproc, x,y,z,*id, *is, *id+tmp);
348+ if (rompidebug & 4) print("%lld %d(%d,%d,%d): SUM %d+%d=%d\n", tbget(), myproc, x,y,z,*id, *is, *id+tmp);
348349 *id += tmp;
349350 return *id;
350351 }
@@ -397,7 +398,7 @@ int MPI_Reduce ( void *sendbuf, void *recvbuf, int count, · 46 unmodified lines
397398 if (z) {
398399 torank = xyztorank(x,y,0);
399400 if (rompidebug&4)
400− print("%lld %d:(%d,%d,%d) sends %d to %d\n", nsec(), myproc, x, y, z, myproc, torank);
401+ print("%lld %d:(%d,%d,%d) sends %d to %d\n", tbget(), myproc, x, y, z, myproc, torank);
401402 MPI_Send(tmp, 1, datatype, torank, 1, comm);
402403 } else {
403404 /* gather up all our z >0 data */
@@ -407,14 +408,14 @@ int MPI_Reduce ( void *sendbuf, void *recvbuf, int count, · 3 unmodified lines
407408 op(tmp, recvbuf, count);
408409 }
409410 if (rompidebug&4)
410− print("%lld AFTER Z: %d(%d, %d, %d): %d\n", nsec(), myproc, x, y, z, sum[0]);
411+ print("%lld AFTER Z: %d(%d, %d, %d): %d\n", tbget(), myproc, x, y, z, sum[0]);
411412
412413 /* y? y o y? */
413414 if (y) {
414415 torank = xyztorank(x,0,0);
415416 /* send to our parent */
416417 if (rompidebug&4)
417− print("%lld %d:(%d,%d,%d) sends %d to %d\n", nsec(), myproc, x, y, z, sum[0], torank);
418+ print("%lld %d:(%d,%d,%d) sends %d to %d\n", tbget(), myproc, x, y, z, sum[0], torank);
418419 MPI_Send(tmp, 1, datatype, torank, 1, comm);
419420 } else {
420421 /* This is the vector along the X axis. All myprocs, including (0,0,0), gather up along
@@ -429,11 +430,11 @@ int MPI_Reduce ( void *sendbuf, void *recvbuf, int count, · 8 unmodified lines
429430 op(tmp, recvbuf, count);
430431 }
431432 if (rompidebug&4)
432− print("%lld %d:(%d,%d,%d) gets %d accum %d\n", nsec(), myproc, x, y, z, nsum[0], sum[0]);
433+ print("%lld %d:(%d,%d,%d) gets %d accum %d\n", tbget(), myproc, x, y, z, nsum[0], sum[0]);
433434 if (x) {
434435 /* send to our parent */
435436 if (rompidebug&4)
436− print("%lld %d:(%d,%d,%d) sends %d to %d\n", nsec(), myproc, x, y, z, sum[0], torank);
437+ print("%lld %d:(%d,%d,%d) sends %d to %d\n", tbget(), myproc, x, y, z, sum[0], torank);
437438 MPI_Send(tmp, 1, datatype, torank, 1, comm);
438439 } else {
439440 /* sum contains the sum from our y axis above */
@@ -441,7 +442,7 @@ int MPI_Reduce ( void *sendbuf, void *recvbuf, int count, · 1 unmodified line
441442 MPI_Recv(recvbuf, 1, datatype, i, 1, comm, &status);
442443 op(tmp, recvbuf, count);
443444 if (rompidebug&4)
444− print("%lld %d:(%d,%d,%d) recv %d to %d\n", nsec(), myproc, x, y, z, sum[0], i);
445+ print("%lld %d:(%d,%d,%d) recv %d to %d\n", tbget(), myproc, x, y, z, sum[0], i);
445446 }
446447 }
447448 }
@@ -450,7 +451,7 @@ int MPI_Reduce ( void *sendbuf, void *recvbuf, int count, · 2 unmodified lines
450451 if (! myproc){
451452 memmove(recvbuf, tmp, nbytes);
452453 if (rompidebug&4)
453− print("%lld reduce: %d(%d,%d,%d): gather done, send SUM %d\n", nsec(), myproc, x, y, z, sum[0]);
454+ print("%lld reduce: %d(%d,%d,%d): gather done, send SUM %d\n", tbget(), myproc, x, y, z, sum[0]);
454455 }
455456
456457 return reduce_end (recvbuf, count, datatype, root, comm, &status);
sys/src/cmd/rompi/stupidreduce.c+29−10
@@ -6,21 +6,14 @@ · 5 unmodified lines
66
77 /* tested may 17 2010 and works */
88 extern int torusdebug;
9+u64int tbget(void);
10+int node, nproc;
911
1012 void
11−main(int argc, char **argv)
13+stupidreduce(unsigned int *sum)
1214 {
13− int node, nproc;
14− unsigned int sum[1];
1515 MPI_Status status;
1616 int i;
17−
18− MPI_Init(&argc,&argv);
19− MPI_Comm_rank(MPI_COMM_WORLD, &node);
20− MPI_Comm_size(MPI_COMM_WORLD, &nproc);
21−
22− print("Hello World from Node %d of %d\n",node, nproc);
23−
2417 if (node) {
2518 sum[0] = node;
2619 MPI_Send(sum, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
@@ -36,7 +29,33 @@ main(int argc, char **argv) · 9 unmodified lines
3629 MPI_Send(sum, 1, MPI_INT, i, 1, MPI_COMM_WORLD);
3730 }
3831 }
32+}
33+
34+void
35+main(int argc, char **argv)
36+{
37+ unsigned int sum[1];
38+ int i;
39+ vlong startnsec, stopnsec;
40+ int iter = 100;
41+
42+ MPI_Init(&argc,&argv);
43+ MPI_Comm_rank(MPI_COMM_WORLD, &node);
44+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
45+
46+ print("Hello World from Node %d of %d\n",node, nproc);
47+
48+ for(i = 0; i < iter; i++){
49+ if (i == 1)
50+ startnsec = tbget();
51+ sum[0] = node;
52+ stupidreduce(sum);
53+ }
54+ stopnsec = tbget();
55+
3956 print("%d: Finalize\n", node);
57+ if (! node)
58+ print("%lld nsec for %d iterations\n", stopnsec-startnsec, iter-1);
4059 MPI_Finalize();
4160 print("Node %d computes sum as %d and MPI says sum is %d\n", node, ((nproc-1)*nproc)/2, sum[0]);
4261 }
sys/src/cmd/rompi/torus.c+2−2
@@ -205,11 +205,11 @@ void torusinit(int *pmyproc, const int numprocs) · 204 unmodified lines
205205 z = d[Z];
206206
207207 *pmyproc = (z << (lx + ly)) + (y << lx) + x;
208− /*
208+
209209 print( "%d/%d %d/%d %d/%d\n", x, xsize, y, ysize, z, zsize);
210210 print( "numprocs %d \n", numprocs);
211211 print("%d/%d %d/%d %d/%d\n", lx, xbits, ly, ybits, lz, zbits);
212− */
212+
213213 /* make some tables. Mapping is done as it is to maximally distributed broadcast traffic */
214214 xyz = calloc(numprocs, sizeof(*xyz));
215215 if (!xyz)