Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce the size of partial shared malloc tests.
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / big_count_status.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2013 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7
8 #include <mpi.h>
9 #include <assert.h>
10 #include <stdio.h>
11
12 int test_count(MPI_Count count)
13 {
14     MPI_Status stat;
15     int cancelled, cancelled2;
16     MPI_Count bcount, bcount2;
17     int nerrs = 0;
18
19     bcount = count;
20     cancelled = 0;
21     MPI_Status_set_cancelled(&stat, cancelled);
22     MPI_Status_set_elements_x(&stat, MPI_BYTE, bcount);
23     MPI_Get_elements_x(&stat, MPI_BYTE, &bcount2);
24     MPI_Test_cancelled(&stat, &cancelled2);
25     if (bcount != bcount2) {
26         fprintf(stderr, "Count Error: expected %llx, got %llx\n",
27                 (long long int) bcount, (long long int) bcount2);
28         nerrs++;
29     }
30     if (cancelled != cancelled2) {
31         fprintf(stderr, "Cancelled Error: expected %d, got %d\n", cancelled, cancelled2);
32         nerrs++;
33     }
34     return nerrs;
35 }
36
37 int main(int argc, char **argv)
38 {
39     int nerrors = 0;
40
41     MPI_Init(&argc, &argv);
42     /* baseline: this tiny value should pose no problems */
43     nerrors += test_count(60);
44     /* one with no next-to-high-bits set */
45     nerrors += test_count(0x3654321f71234567);
46     /* masking after shift can help the count_high, but count_low is still
47      * wrong */
48     nerrors += test_count(0x7654321f71234567);
49     /* original problematic count reported by Artem Yalozo */
50     nerrors += test_count(0x7654321ff1234567);
51
52     if (nerrors != 0) {
53         fprintf(stderr, "found %d errors\n", nerrors);
54     }
55     else {
56         printf(" No Errors\n");
57     }
58     MPI_Finalize();
59     return 0;
60 }