1 /*
2  * Copyright (C) by Argonne National Laboratory
3  *     See COPYRIGHT in top-level directory
4  */
5 
6 #include "../adio/include/adio.h"
7 #include "../adio/include/adio_extern.h"
8 #include "mpi.h"
9 
main(int argc,char ** argv)10 int main(int argc, char **argv)
11 {
12     int i;
13     ADIO_File fd;
14     ADIO_Offset min_st_offset, max_end_offset;
15     int rank;
16     int nprocs_for_coll;
17     int lb;
18     MPI_Count size, extent;
19 
20     MPI_Init(&argc, &argv);
21     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22 
23     if (argc != 4) {
24         if (!rank)
25             printf("Usage: file_realms_test <number of aggregators> <lower bound> <upper bound>\n"
26                    "    simulates file_realm calculation\n");
27         MPI_Finalize();
28         return 1;
29     }
30 
31     nprocs_for_coll = atoi(argv[1]);
32 
33     min_st_offset = atoi(argv[2]);
34     max_end_offset = atoi(argv[3]);
35 
36     if (max_end_offset < min_st_offset) {
37         if (!rank)
38             printf("end offset %lld is less then start offset %lld\n",
39                    max_end_offset, min_st_offset);
40         MPI_Finalize();
41         return 1;
42     }
43 
44     printf("min_st_offset = %lld\nmax_end_offset = %lld\n", min_st_offset, max_end_offset);
45 
46     fd = (ADIO_File) ADIOI_Malloc(sizeof(struct ADIOI_FileD));
47     fd->hints = (ADIOI_Hints *)
48         ADIOI_Malloc(sizeof(struct ADIOI_Hints_struct));
49     fd->hints->cb_nodes = nprocs_for_coll;
50     ADIOI_Calc_file_realms(fd, min_st_offset, max_end_offset);
51 
52     for (i = 0; i < nprocs_for_coll; i++) {
53         printf("file_realm_st_offs[%d] = %lld\n", i, fd->file_realm_st_offs[i]);
54     }
55     for (i = 0; i < nprocs_for_coll; i++) {
56         MPI_Type_size_x(fd->file_realm_types[i], &size);
57         printf("file_realm [%d] size = %d\n", i, size);
58     }
59     for (i = 0; i < nprocs_for_coll; i++) {
60         MPI_Type_get_extent(fd->file_realm_types[i], &lb, &extent);
61         printf("file_realm [%d] extent = %d\n", i, extent);
62     }
63 
64     for (i = 0; i < nprocs_for_coll; i++)
65         MPI_Type_free(&fd->file_realm_types[i]);
66     ADIOI_Free(fd->file_realm_st_offs);
67     ADIOI_Free(fd->file_realm_types);
68     ADIOI_Free(fd->hints);
69     ADIOI_Free(fd);
70 
71     MPI_Finalize();
72 
73     return 0;
74 }
75