Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / large_message.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2010 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <mpi.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "mpitest.h"
10
11 /* tests send/recv of a message > 2GB. count=270M, type=long long 
12    run with 3 processes to exercise both shared memory and TCP in Nemesis tests*/
13
14 int main(int argc, char *argv[]) 
15 {
16   int        ierr,i,size,rank;
17   int        cnt = 270000000;
18   MPI_Status status;
19   long long  *cols;
20   int errs = 0;
21
22
23   MTest_Init(&argc,&argv); 
24
25 /* need large memory */
26   if (sizeof(void *) < 8) {
27       MTest_Finalize(errs);
28       MPI_Finalize();
29       return 0;
30   }
31
32   ierr = MPI_Comm_size(MPI_COMM_WORLD,&size);
33   ierr = MPI_Comm_rank(MPI_COMM_WORLD,&rank);
34   if (size != 3) {
35     fprintf(stderr,"[%d] usage: mpiexec -n 3 %s\n",rank,argv[0]);
36     MPI_Abort(MPI_COMM_WORLD,1);
37   }
38
39   cols = malloc(cnt*sizeof(long long));
40   if (cols == NULL) {
41       printf("malloc of >2GB array failed\n");
42       errs++;
43       MTest_Finalize(errs);
44       MPI_Finalize();
45       return 0;
46   }
47
48   if (rank == 0) {
49     for (i=0; i<cnt; i++) cols[i] = i;
50     /* printf("[%d] sending...\n",rank);*/
51     ierr = MPI_Send(cols,cnt,MPI_LONG_LONG_INT,1,0,MPI_COMM_WORLD);
52     ierr = MPI_Send(cols,cnt,MPI_LONG_LONG_INT,2,0,MPI_COMM_WORLD);
53   } else {
54       /* printf("[%d] receiving...\n",rank); */
55     for (i=0; i<cnt; i++) cols[i] = -1;
56     ierr = MPI_Recv(cols,cnt,MPI_LONG_LONG_INT,0,0,MPI_COMM_WORLD,&status);
57     /* ierr = MPI_Get_count(&status,MPI_LONG_LONG_INT,&cnt);
58        Get_count still fails because status.count is not 64 bit */
59     for (i=0; i<cnt; i++) {
60         if (cols[i] != i) {
61             /*printf("Rank %d, cols[i]=%lld, should be %d\n", rank, cols[i], i);*/
62             errs++;
63         }
64     }
65   }
66   MTest_Finalize(errs);
67   MPI_Finalize();
68   return 0;
69 }