Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
added simple usage message to smpirun and removed nonworking sample
authormarkls <markls@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 28 Feb 2008 08:18:17 +0000 (08:18 +0000)
committermarkls <markls@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 28 Feb 2008 08:18:17 +0000 (08:18 +0000)
programs.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5249 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/smpi/sample/allreduce.c [deleted file]
src/smpi/sample/alltoall.c [deleted file]
src/smpi/sample/matrix.c [deleted file]
src/smpi/smpirun.in

diff --git a/src/smpi/sample/allreduce.c b/src/smpi/sample/allreduce.c
deleted file mode 100644 (file)
index 1f8cd88..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <mpi.h>
-
-int main(int argc, char *argv[]) {
-  int rank, size;
-  int i;
-  int *sendbuf, *recvbuf;
-  MPI_Init(&argc, &argv);
-  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-  MPI_Comm_size(MPI_COMM_WORLD, &size);
-  sendbuf = malloc(sizeof(int) * size);
-  recvbuf = malloc(sizeof(int) * size);
-  for (i = 0; i < size; i++) {
-    sendbuf[i] = 0;
-    recvbuf[i] = 0;
-  }
-  sendbuf[rank] = rank + 1;
-  MPI_Allreduce(sendbuf, recvbuf, size, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
-  printf("node %d has: ", rank);
-  for (i = 0; i < size; i++) {
-    printf("%d ", recvbuf[i]);
-  }
-  printf("\n");
-  free(sendbuf);
-  free(recvbuf);
-  MPI_Finalize();
-  return 0;
-}
diff --git a/src/smpi/sample/alltoall.c b/src/smpi/sample/alltoall.c
deleted file mode 100644 (file)
index c11a6dd..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-#include "mpi.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS 0
-#define EXIT_FAILURE 1
-#endif
-
-// sandler says, compile with mpicc -v alltoalldemo.c
-// run with mpirun -np 3 a.out -m 5
-
-int main( int argc, char *argv[] )
-{
-    int rank, size;
-    int chunk = 128;
-    int i;
-     int j; // added by sandler
-    int *sb;
-    int *rb;
-    int status, gstatus;
-
-    MPI_Init(&argc,&argv);
-    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
-    MPI_Comm_size(MPI_COMM_WORLD,&size);
-     if (rank==0) {
-        printf("size: %d\n", size);
-    }
-    for ( i=1 ; i < argc ; ++i ) {
-        if ( argv[i][0] != '-' ) {
-                // added by sandler
-                fprintf(stderr, "Unrecognized option %s\n", argv[i]);fflush(stderr);
-            continue;
-            }
-        switch(argv[i][1]) {
-            case 'm':
-                chunk = atoi(argv[++i]);
-                     if (rank==0) {
-                        printf("chunk: %d\n", chunk);
-                    }
-                break;
-            default:
-                fprintf(stderr, "Unrecognized argument %s\n", argv[i]);fflush(stderr);
-                MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
-        }
-    }
-    sb = (int *)malloc(size*chunk*sizeof(int));
-    if ( !sb ) {
-        perror( "can't allocate send buffer" );fflush(stderr);
-        MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
-    }
-    rb = (int *)malloc(size*chunk*sizeof(int));
-    if ( !rb ) {
-        perror( "can't allocate recv buffer");fflush(stderr);
-        free(sb);
-        MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
-    }
-     
-     
-     /* original deino.net:
-    for ( i=0 ; i < size*chunk ; ++i ) {
-        sb[i] = sb[i] = rank + 1;
-        rb[i] = 0;
-    }
-    */
-        // written by sandler
-        
-        if (rank==0) printf("note in the following:\n"
-        "if you were to compare the sending buffer and the receiving buffer on the SAME processor, \n"
-        "you might think that the values were getting wiped out.  However, each row IS going somewhere. \n"
-        "The 0th row of processor 0 goes to the 0th row of processor 0\n"
-        "The 1st row of processor 0 goes to the 0th row of processor 1.  (Go look at rb for processor 1!)\n"
-        "\n"
-        "Too bad the values don't come out in a deterministic order. That's life!\n"
-        "\n"
-        "Now look at the receiving buffer for processor 0.\n"
-        "The 0th row is from processor 0 (itself).\n"
-        "The 1st row on processor 0 is from the 0th row on processor 1. (Go look at the sb of processor 1!)\n"
-        "\n"
-        "Apparently this is the intended behavior.\n"
-        "\n"
-        "Note that each row is always moved as one chunk, unchangeable.\n"
-        "\n"
-        "TODO: draw a diagram\n"
-        );
-        
-        for (i=0; i<size; i++) {
-            for (j=0; j<chunk; j++) {
-                int offset = i*chunk + j; // note the multiplier is chunk, not size
-
-                sb[offset] = rank*100 + i*10 + j;
-                rb[offset] = -1;
-            }
-        }
-    
-    
-        // this clearly shows what is NOT indended to be done, in that the rb on a processor is the same as the sb on the processor 
-        // in this intialization: on processor 0, only the 0th row gets normal values.
-        // on processor 1, only the 1st row gets normal values.
-        // when you look the rb, it looks like nothing happened.  this is because, say, for processor 1, the 1st row got sent to itself.
-        /*
-        for (i=0; i<size; i++) {
-            for (j=0; j<chunk; j++) {
-                int offset = i*chunk + j; // note the multiplier is chunk, not size
-                
-                if (i==rank) 
-                    sb[offset] = rank*100 + i*10 + j;
-                else 
-                    sb[offset] = 999;
-                    
-                rb[i*chunk + j] = 999;
-            }
-        }
-    */
-        
-        // this does printgrid("sb", rank, size, chunk, sb);
-        //added by sandler
-        printf("[processor %d] To send:\n", rank);
-        for (i=0; i<size; i++) {
-            for (j=0; j<chunk; j++) {
-                // note the multiplier is chunk, not size
-                printf("%03d ", sb[i*chunk+j]);       
-            }
-            printf("\n");
-        }
-        printf("\n");
-
-/*
-        // for another variation, could send out a bunch of characters, like
-        p r o c e s s o r 0 r o w 0
-        p r o c e s s o r 0 r o w 1
-        p r o c e s s o r 0 r o w 2
-        
-        then you'd get back
-        
-        p r o c e s s o r 0 r o w 0
-        p r o c e s s o r 1 r o w 0
-        p r o c e s s o r 2 r o w 0
-*/      
-        
-
-    status = MPI_Alltoall(sb, chunk, MPI_INT, rb, chunk, MPI_INT, MPI_COMM_WORLD);
-
-        // this does printgrid("rb", rank, size, chunk, rb);
-        // added by sandler
-        printf("[processor %d] Received:\n", rank);
-        for (i=0; i<size; i++) {
-            for (j=0; j<chunk; j++) {
-                printf("%03d ", rb[i*chunk+j]);       
-            }
-            printf("\n");
-        }
-        printf("\n");
-
-
-    MPI_Allreduce( &status, &gstatus, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
-    if (rank == 0) {
-        if (gstatus != 0) {
-            printf("all_to_all returned %d\n",gstatus);fflush(stdout);
-        }
-
-        
-   }
-
-
-
-    free(sb);
-    free(rb);
-    MPI_Finalize();
-    return(EXIT_SUCCESS);
-}
diff --git a/src/smpi/sample/matrix.c b/src/smpi/sample/matrix.c
deleted file mode 100644 (file)
index 4e10a8e..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Mark Stillwell
- * ICS691: High Performance Computing
- * Fall 2006
- * Homework 3, Exercise 2, Step 1
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <libgen.h>
-#include <mpi.h>
-
-#define ITERATIONS         10
-#define STEPS              1
-#define STEP_SIZE          0
-
-#define USAGE_ERROR        1
-#define MALLOC_ERROR       2
-#define GETTIMEOFDAY_ERROR 3
-
-void * checked_malloc(int rank, const char * varname, size_t size) {
-  void * ptr;
-  ptr = malloc(size);
-  if (NULL == ptr) {
-    printf("node %d could not malloc memory for %s.\n", rank, varname);
-    MPI_Abort(MPI_COMM_WORLD, MALLOC_ERROR);
-    exit(MALLOC_ERROR);
-  }
-  return ptr;
-}
-
-int main(int argc, char* argv[]) {
-
-  // timing/system variables
-  int iteration, iterations = ITERATIONS;
-  int step, steps = STEPS, step_size = STEP_SIZE;
-  long usecs, total_usecs;
-  struct timeval *start_time, *stop_time;
-  char *program;
-
-  // mpi/communications variables
-  int rank;
-  int row, col;
-  MPI_Comm row_comm, col_comm;
-
-  // algorithm variables
-  int N_start, N, P;
-  int *A, *A_t, *B, *C, *D, *a, *b, *abuf, *bbuf;
-  int n, i, j, k, I, J;
-
-  MPI_Init(&argc, &argv);
-
-  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-
-  if (0 == rank) {
-    int size;
-    MPI_Comm_size(MPI_COMM_WORLD, &size);
-
-    program = basename(argv[0]);
-
-    // root node parses cmdline args
-    /*
-    if (3 > argc || !isdigit(*argv[1]) || !isdigit(*argv[2])) {
-      printf("usage:\n%s <N> <P> [<iterations>]\n", program);
-      MPI_Abort(MPI_COMM_WORLD, USAGE_ERROR);
-      exit(USAGE_ERROR);
-    }
-    */
-
-    //N_start = atoi(argv[1]);
-    //P = atoi(argv[2]);
-    N_start = 100;
-    P = 2;
-
-    /*
-    if (4 <= argc && isdigit(*argv[3])) {
-      iterations = atoi(argv[3]);
-    }
-
-    if (5 <= argc && isdigit(*argv[4])) {
-      steps = atoi(argv[4]);
-    }
-
-    if (6 <= argc && isdigit(*argv[5])) {
-      step_size = atoi(argv[5]);
-    }
-    */
-
-    if (P*P != size) {
-      printf("P^2 must equal size.\n");
-      MPI_Abort(MPI_COMM_WORLD, USAGE_ERROR);
-      exit(USAGE_ERROR);
-    }
-
-    start_time = (struct timeval *)checked_malloc(rank, "start_time", sizeof(struct timeval));
-    stop_time  = (struct timeval *)checked_malloc(rank, "stop_time",  sizeof(struct timeval));
-
-  }
-
-  // send command line parameters except N, since it can vary
-  MPI_Bcast(&P, 1, MPI_INT, 0, MPI_COMM_WORLD);
-  MPI_Bcast(&iterations, 1, MPI_INT, 0, MPI_COMM_WORLD);
-  MPI_Bcast(&steps, 1, MPI_INT, 0, MPI_COMM_WORLD);
-  MPI_Bcast(&step_size, 1, MPI_INT, 0, MPI_COMM_WORLD);
-
-  row = rank / P;
-  col = rank % P;
-
-  // create row/column communicators
-  MPI_Comm_split(MPI_COMM_WORLD, row, col, &row_comm);
-  MPI_Comm_split(MPI_COMM_WORLD, col, row, &col_comm);
-
-  for (step = 0; step < steps; step++) {
-
-    total_usecs = 0;
-
-    if (0 == rank) {
-      N = N_start + step * step_size;
-      if ((N/P)*P != N) {
-        printf("P must divide N and %d does not divide %d.\n", P, N);
-        N = -1;
-      }
-    }
-
-    MPI_Bcast(&N, 1, MPI_INT, 0, MPI_COMM_WORLD);
-
-    // if root passes N = -1, skip this round
-    if (-1 == N) continue;
-
-    n = N / P;
-
-    // initialize matrix components
-    A   = (int *)checked_malloc(rank, "A",   n*n*sizeof(int));
-    A_t = (int *)checked_malloc(rank, "A_t", n*n*sizeof(int));
-    B   = (int *)checked_malloc(rank, "B",   n*n*sizeof(int));
-    C   = (int *)checked_malloc(rank, "C",   n*n*sizeof(int));
-    D   = (int *)checked_malloc(rank, "D",   n*n*sizeof(int));
-
-    for (i = 0; i < n; i++) {
-      for (j = 0; j < n; j++) {
-
-        I = n*row+i;
-        J = n*col+j;
-
-        A[n*i+j] = I+J;
-        B[n*i+j] = I;
-
-        // d is the check matrix
-        D[n*i+j] = 0;
-        for (k = 0; k < N; k++) {
-          // A[I,k] = I+k
-          // B[k,J] = k
-          D[n*i+j] += (I+k) * k;
-        }
-
-      }
-    }
-
-    // buffers
-    abuf = (int *)checked_malloc(rank, "abuf", n*sizeof(int));
-    bbuf = (int *)checked_malloc(rank, "bbuf", n*sizeof(int));
-
-    for (iteration = 0; iteration < iterations; iteration++) {
-
-      for (i = 0; i < n*n; i++) {
-        C[i] = 0;
-      }
-
-      // node zero sets start time
-      if (0 == rank && -1 == gettimeofday(start_time, NULL)) {
-        printf("couldn't set start_time on node 0!\n");
-        MPI_Abort(MPI_COMM_WORLD, GETTIMEOFDAY_ERROR);
-        exit(GETTIMEOFDAY_ERROR);
-      }
-
-      // populate transpose of A
-      for (i = 0; i < n; i++) {
-        for (j = 0; j < n; j++) {
-          A_t[n*i+j] = A[n*j+i];
-        }
-      }
-
-      // perform calculations
-      for (k = 0; k < N; k++) {
-
-        if (k/n == col) {
-          a = A_t + n*(k%n);
-        } else {
-          a = abuf;
-        }
-
-        if (k/n == row) {
-          b = B + n*(k%n);
-        } else {
-          b = bbuf;
-        }
-
-        MPI_Bcast(a, n, MPI_INT, k/n, row_comm);
-        MPI_Bcast(b, n, MPI_INT, k/n, col_comm);
-
-        for (i = 0; i < n; i++) {
-          for (j = 0; j < n; j++) {
-            C[n*i+j] += a[i] * b[j];
-          }
-        }
-
-      } // for k
-
-      // node zero sets stop time
-      if (0 == rank && -1 == gettimeofday(stop_time, NULL)) {
-        printf("couldn't set stop_time on node 0!\n");
-        MPI_Abort(MPI_COMM_WORLD, GETTIMEOFDAY_ERROR);
-        exit(GETTIMEOFDAY_ERROR);
-      }
-
-      // check calculation
-      for (i = 0; i < n*n && C[i] == D[i]; i++);
-      j = (n*n == i);
-      MPI_Reduce(&j, &k, 1, MPI_INT, MPI_LAND, 0, MPI_COMM_WORLD);
-
-      // node zero prints stats
-      if (0 == rank) {
-        usecs = (stop_time->tv_sec*1000000+stop_time->tv_usec) - (start_time->tv_sec*1000000+start_time->tv_usec);
-        printf("prog: %s, N: %d, P: %d, procs: %d, time: %d us, check: %d\n", program, N, P, P*P, usecs, k);
-        total_usecs += usecs;
-      }
-
-    }
-
-    // node 0 prints final stats
-    if (0 == rank) {
-      printf("prog: %s, N: %d, P: %d, procs: %d, iterations: %d, avg. time: %d us\n",
-          program, N, P, P*P, iterations, total_usecs / iterations);
-    }
-
-    // free data structures
-    free(A);
-    free(A_t);
-    free(B);
-    free(C);
-    free(D);
-    free(abuf);
-    free(bbuf);
-
-  }
-
-  if (0 == rank) {
-    free(start_time);
-    free(stop_time);
-  }
-
-  MPI_Finalize();
-
-  return 0;
-}
index e18b271..5211e87 100755 (executable)
@@ -27,6 +27,12 @@ while true; do
       NETWORK_LATENCY="$2"
       shift 2
     ;;
       NETWORK_LATENCY="$2"
       shift 2
     ;;
+   "-help")
+      echo "usage:"
+      echo "$0 [-np <numprocs>] [-bandwidth <bytes/sec>] [-latency <secs>] program [program-options]"
+      echo
+      exit
+   ;;
     *)
       break
     ;;
     *)
       break
     ;;