1 /*============================================================================
2  * Unit test for some FVM global numbering issues;
3  *============================================================================*/
4 
5 /*
6   This file is part of Code_Saturne, a general-purpose CFD tool.
7 
8   Copyright (C) 1998-2021 EDF S.A.
9 
10   This program is free software; you can redistribute it and/or modify it under
11   the terms of the GNU General Public License as published by the Free Software
12   Foundation; either version 2 of the License, or (at your option) any later
13   version.
14 
15   This program is distributed in the hope that it will be useful, but WITHOUT
16   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18   details.
19 
20   You should have received a copy of the GNU General Public License along with
21   this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
22   Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24 
25 /*----------------------------------------------------------------------------*/
26 
27 #include "cs_defs.h"
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 
33 #include <bft_error.h>
34 #include <bft_printf.h>
35 
36 #include "cs_block_dist.h"
37 
38 /*---------------------------------------------------------------------------*/
39 
40 /*---------------------------------------------------------------------------*/
41 
42 int
main(int argc,char * argv[])43 main (int argc, char *argv[])
44 {
45   CS_UNUSED(argc);
46   CS_UNUSED(argv);
47 
48   int i, j;
49   int rank_id[] = {0, 1024, 2048, 4095};
50   int n_ranks = 4096;
51   cs_gnum_t n_g_ents[] = {500, 1100000000, 2200000000,5400000000};
52 
53   cs_block_dist_info_t bi;
54 
55   for (i = 0; i < 4; i++) {
56 
57     int64_t g_ent_id = 0;
58     int l_rank_id = 0;
59 
60     bft_printf("\ntest for n_g_ents = %llu\n",
61                (unsigned long long)(n_g_ents[i]));
62     for (j = 0; j < 4; j++) {
63       bi = cs_block_dist_compute_sizes(rank_id[j],
64                                        n_ranks,
65                                        0,
66                                        1024*1024,
67                                        n_g_ents[i]);
68       bft_printf("%d/%d [%llu %llu] block step %d, block size %d\n",
69                  rank_id[j], n_ranks, (unsigned long long)(bi.gnum_range[0]),
70                  (unsigned long long)(bi.gnum_range[1]),
71                  (int)(bi.rank_step), (int)(bi.block_size));
72     }
73 
74     g_ent_id = n_g_ents[i] - 1;
75     l_rank_id = g_ent_id/bi.block_size * bi.rank_step;
76     bft_printf("\nrank id for ent_id = %llu: %d\n",
77                (unsigned long long)g_ent_id, l_rank_id);
78   }
79 
80   exit(EXIT_SUCCESS);
81 }
82