Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Free memory.
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / huge_anysrc.c
1 /*
2  *  (C) 2017 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-2017 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  *  This program checks if MPICH can correctly handle many outstanding large
11  *  message transfers which use wildcard receives.
12  *
13  */
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <memory.h>
18 #include <mpi.h>
19
20 #define N_TRY 16
21 #define BLKSIZE (10*1024*1024)
22
23 int main(int argc, char *argv[])
24 {
25     int size, rank;
26     int dest;
27     int i;
28     char *buff;
29     MPI_Request reqs[N_TRY];
30
31     MPI_Init(&argc, &argv);
32
33     buff = malloc(N_TRY * BLKSIZE);
34     memset(buff, -1, N_TRY * BLKSIZE);
35
36     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
37     MPI_Comm_size(MPI_COMM_WORLD, &size);
38
39     dest = size - 1;
40
41     if (rank == 0) {
42         for (i = 0; i < N_TRY; i++)
43             MPI_Isend(buff + BLKSIZE*i, BLKSIZE, MPI_BYTE, dest, 0, MPI_COMM_WORLD, &reqs[i]);
44         MPI_Waitall(N_TRY, reqs, MPI_STATUSES_IGNORE);
45     }
46     else if (rank == dest) {
47         for (i = 0; i < N_TRY; i++)
48             MPI_Irecv(buff + BLKSIZE*i, BLKSIZE, MPI_BYTE, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &reqs[i]);
49         MPI_Waitall(N_TRY, reqs, MPI_STATUSES_IGNORE);
50     }
51
52     free(buff);
53
54     if (rank == 0)
55         puts(" No Errors");
56
57     MPI_Finalize();
58
59     return 0;
60 }