Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
711f2d6bf9dee260a2d0b803a3a8b718e275f950
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / manylmt.c
1 /*
2  *  (C) 2016 by Argonne National Laboratory.
3  *      See COPYRIGHT in top-level directory.
4  *
5  *  Portions of this code were written by Intel Corporation.
6  *  Copyright (C) 2011-2016 Intel Corporation.  Intel provides this material
7  *  to Argonne National Laboratory subject to Software Grant and Corporate
8  *  Contributor License Agreement dated February 8, 2012.
9  *
10  *
11  *  This program checks if MPICH can correctly handle
12  *  many outstanding large message transfers
13  *
14  */
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <memory.h>
19 #include <mpi.h>
20
21 #define N_TRY 32
22 #define BLKSIZE (10*1024*1024)
23
24 int main(int argc, char *argv[])
25 {
26     int size, rank;
27     int dest;
28     int i;
29     char *buff;
30     MPI_Request reqs[N_TRY];
31
32     MPI_Init(&argc, &argv);
33
34     buff = malloc(N_TRY * BLKSIZE);
35     memset(buff, -1, N_TRY * BLKSIZE);
36
37     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
38     MPI_Comm_size(MPI_COMM_WORLD, &size);
39
40     dest = size - 1;
41
42     if (rank == 0) {
43         for (i = 0; i < N_TRY; i++)
44             MPI_Isend(buff + BLKSIZE*i, BLKSIZE, MPI_BYTE, dest, 0, MPI_COMM_WORLD, &reqs[i]);
45         MPI_Waitall(N_TRY, reqs, MPI_STATUSES_IGNORE);
46     }
47     else if (rank == dest) {
48         for (i = 0; i < N_TRY; i++)
49             MPI_Irecv(buff + BLKSIZE*i, BLKSIZE, MPI_BYTE, 0, 0, MPI_COMM_WORLD, &reqs[i]);
50         MPI_Waitall(N_TRY, reqs, MPI_STATUSES_IGNORE);
51     }
52
53     free(buff);
54
55     if (rank == 0)
56         puts(" No Errors");
57
58     MPI_Finalize();
59
60     return 0;
61 }