Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce the size of partial shared malloc tests.
[simgrid.git] / teshsuite / smpi / mpich3-test / rma / large-acc-flush_local.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2015 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6
7 /* This code tests the case when origin process issues 10 ACC
8  * operations for each data size to the target process, and each
9  * operation is followed by a MPI_Win_flush_local. */
10
11 /* FIXME: we should merge this into a comprehensive test for RMA
12  * operations + MPI_Win_flush_local. */
13
14 #include "mpi.h"
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <time.h>
18
19 #define MIN_DATA_SIZE (262144)
20 #define MAX_DATA_SIZE (8 * 262144)
21 #define OPS_NUM 10
22 #define LOOP 500
23
24 int main(int argc, char *argv[])
25 {
26     int rank, nproc, i, j;
27     MPI_Win win;
28     int *tar_buf = NULL;
29     int *orig_buf = NULL;
30     int data_size;
31
32     MPI_Init(&argc, &argv);
33
34     MPI_Comm_size(MPI_COMM_WORLD, &nproc);
35     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
36
37     MPI_Alloc_mem(MAX_DATA_SIZE, MPI_INFO_NULL, &orig_buf);
38     MPI_Alloc_mem(MAX_DATA_SIZE, MPI_INFO_NULL, &tar_buf);
39
40     /* run this test for LOOP times */
41
42     for (j = 0; j < LOOP; j++) {
43
44         MPI_Win_create(tar_buf, MAX_DATA_SIZE, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
45
46         MPI_Win_lock_all(0, win);
47
48         if (rank != 0) {
49             for (data_size = MIN_DATA_SIZE; data_size <= MAX_DATA_SIZE; data_size *= 2) {
50                 for (i = 0; i < OPS_NUM; i++) {
51                     MPI_Accumulate(orig_buf, data_size, MPI_BYTE,
52                                    0, 0, data_size, MPI_BYTE, MPI_SUM, win);
53                     MPI_Win_flush_local(0, win);
54                 }
55                 MPI_Win_flush(0, win);
56             }
57         }
58
59         MPI_Win_unlock_all(win);
60
61         MPI_Win_free(&win);
62     }
63
64     if (rank == 0)
65         printf(" No Errors\n");
66
67     MPI_Free_mem(orig_buf);
68     MPI_Free_mem(tar_buf);
69
70     MPI_Finalize();
71
72     return 0;
73 }