Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / huge_dupcomm.c
1 /*
2  *  (C) 2018 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-2018 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 huge message sends
11  *  over multiple different communicators simultaneously
12  *
13  */
14
15 #include <mpi.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18
19 #include "mpitest.h"
20
21 #define COUNT (4*1024*1024)
22 #define NCOMMS 4
23
24 int main(int argc, char *argv[])
25 {
26     int *buff;
27     int size, rank;
28     int i;
29     MPI_Comm comms[NCOMMS];
30     MPI_Request reqs[NCOMMS];
31
32     MTest_Init(&argc, &argv);
33
34     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
35     MPI_Comm_size(MPI_COMM_WORLD, &size);
36
37     if (size != 2) {
38         fprintf(stderr, "Launch with two processes\n");
39         MPI_Abort(MPI_COMM_WORLD, 1);
40     }
41
42     buff = malloc(COUNT * NCOMMS * sizeof(int));
43
44     for (i = 0; i < NCOMMS; i++)
45         MPI_Comm_dup(MPI_COMM_WORLD, &comms[i]);
46
47     for (i = 0; i < NCOMMS; i++) {
48         if (rank == 0)
49             MPI_Isend(buff + COUNT * i, COUNT, MPI_INT, 1 /* dest */ , 0 /* tag */ , comms[i],
50                       &reqs[i]);
51         else
52             MPI_Irecv(buff + COUNT * i, COUNT, MPI_INT, 0 /* src */ , 0 /* tag */ , comms[i],
53                       &reqs[i]);
54     }
55     MPI_Waitall(NCOMMS, reqs, MPI_STATUSES_IGNORE);
56
57     for (i = 0; i < NCOMMS; i++)
58         MPI_Comm_free(&comms[i]);
59
60     free(buff);
61
62     MTest_Finalize(0);
63
64     return 0;
65 }