1 /* Copyright 2007,2008,2010,2011,2014 IPB, Universite de Bordeaux, INRIA & CNRS
2 **
3 ** This file is part of the Scotch software package for static mapping,
4 ** graph partitioning and sparse matrix ordering.
5 **
6 ** This software is governed by the CeCILL-C license under French law
7 ** and abiding by the rules of distribution of free software. You can
8 ** use, modify and/or redistribute the software under the terms of the
9 ** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
10 ** URL: "http://www.cecill.info".
11 **
12 ** As a counterpart to the access to the source code and rights to copy,
13 ** modify and redistribute granted by the license, users are provided
14 ** only with a limited warranty and the software's author, the holder of
15 ** the economic rights, and the successive licensors have only limited
16 ** liability.
17 **
18 ** In this respect, the user's attention is drawn to the risks associated
19 ** with loading, using, modifying and/or developing or reproducing the
20 ** software by the user in light of its specific status of free software,
21 ** that may mean that it is complicated to manipulate, and that also
22 ** therefore means that it is reserved for developers and experienced
23 ** professionals having in-depth computer knowledge. Users are therefore
24 ** encouraged to load and test the software's suitability as regards
25 ** their requirements in conditions enabling the security of their
26 ** systems and/or data to be ensured and, more generally, to use and
27 ** operate it in the same conditions as regards security.
28 **
29 ** The fact that you are presently reading this means that you have had
30 ** knowledge of the CeCILL-C license and that you accept its terms.
31 */
32 /************************************************************/
33 /**                                                        **/
34 /**   NAME       : bdgraph.h                               **/
35 /**                                                        **/
36 /**   AUTHOR     : Jun-Ho HER (v6.0)                       **/
37 /**                Francois PELLEGRINI                     **/
38 /**                                                        **/
39 /**   FUNCTION   : This module contains the data declara-  **/
40 /**                tions for distributed edge bipartition- **/
41 /**                ing routines.                           **/
42 /**                                                        **/
43 /**   DATES      : # Version 5.1  : from : 10 sep 2007     **/
44 /**                                 to   : 14 apr 2011     **/
45 /**                # Version 6.0  : from : 11 sep 2011     **/
46 /**                                 to   : 31 aug 2014     **/
47 /**                                                        **/
48 /************************************************************/
49 
50 /*
51 **  The type and structure definitions.
52 */
53 
54 /*+ Graph option flags. +*/
55 
56 #define BDGRAPHFREEFRON             (DGRAPHBITSNOTUSED) /* Free part array               */
57 #define BDGRAPHFREEPART             (DGRAPHBITSNOTUSED << 1) /* Free frontier array      */
58 #define BDGRAPHFREEVEEX             (DGRAPHBITSNOTUSED << 2) /* Free external gain array */
59 
60 /*+ Active graph structure. +*/
61 
62 typedef struct Bdgraph_ {
63   Dgraph                    s;                    /*+ Distributed source graph                           +*/
64   Gnum *                    veexloctax;           /*+ Local vertex external gain array if moved to 1     +*/
65   Gnum                      veexglbsum;           /*+ Global sum of veexloctax array cells               +*/
66   GraphPart *               partgsttax;           /*+ Based local part array: 0,1: part                  +*/
67   Gnum *                    fronloctab;           /*+ Array of local frontier vertex numbers             +*/
68   Gnum                      fronlocnbr;           /*+ Number of local frontier vertices                  +*/
69   Gnum                      fronglbnbr;           /*+ Number of global frontier vertices                 +*/
70   Gnum                      complocload0;         /*+ Local load of part 0                               +*/
71   Gnum                      compglbload0;         /*+ Global load of part 0                              +*/
72   Gnum                      compglbload0min;      /*+ Minimum allowed load in part 0 (strategy variable) +*/
73   Gnum                      compglbload0max;      /*+ Maximum allowed load in part 0 (strategy variable) +*/
74   Gnum                      compglbload0avg;      /*+ Global average load of part 0                      +*/
75   Gnum                      compglbload0dlt;      /*+ Load difference from the average                   +*/
76   Gnum                      complocsize0;         /*+ Number of local vertices in part 0                 +*/
77   Gnum                      compglbsize0;         /*+ Number of global vertices in part 0                +*/
78   Gnum                      commglbload;          /*+ Global communication load                          +*/
79   Gnum                      commglbgainextn;      /*+ Global external gain if all swapped                +*/
80   Gnum                      commglbloadextn0;     /*+ Global communication load if all moved to part 0   +*/
81   Gnum                      commglbgainextn0;     /*+ Global external gain if all swapped from part 0    +*/
82   double                    bbalglbval;           /*+ Bipartitioning imbalance ratio (strategy variable) +*/
83   Anum                      domndist;             /*+ Distance between subdomains                        +*/
84   Anum                      domnwght[2];          /*+ Weights for each subdomain                         +*/
85   INT                       levlnum;              /*+ Graph coarsening level                             +*/
86 } Bdgraph;
87 
88 /*+ The distributed save graph structure. +*/
89 
90 typedef struct BdgraphStore_ {
91   Gnum                      fronlocnbr;           /*+ Number of local frontier vertices   +*/
92   Gnum                      fronglbnbr;           /*+ Number of frontier vertices         +*/
93   Gnum                      complocload0;         /*+ Local load in part 0                +*/
94   Gnum                      compglbload0;         /*+ Load in part 0                      +*/
95   Gnum                      compglbload0dlt;      /*+ Difference from the average         +*/
96   Gnum                      complocsize0;         /*+ Number of local vertices in part 0  +*/
97   Gnum                      compglbsize0;         /*+ Number of global vertices in part 0 +*/
98   Gnum                      commglbload;
99   Gnum                      commglbgainextn;
100   byte *                    datatab;              /*+ Variable-sized data array           +*/
101 } BdgraphStore;
102 
103 /*
104 **  The function prototypes.
105 */
106 
107 #ifndef BDGRAPH
108 #define static
109 #endif
110 
111 #ifdef DMAPPING_H
112 int                         bdgraphInit         (Bdgraph * const, const Dgraph * const, const Dgraph * const, const Arch * const, const ArchDom[]);
113 #endif /* DMAPPING_H */
114 void                        bdgraphInit2        (Bdgraph * const, const Anum, const Anum, const Anum);
115 #ifdef DMAPPING_H
116 int                         bdgraphInit3        (Bdgraph * const, const Dgraph * const, const Dmapping * const, const ArchDom[]);
117 #endif /* DMAPPING_H */
118 void                        bdgraphExit         (Bdgraph * restrict const);
119 void                        bdgraphFree         (Bdgraph * restrict const);
120 void                        bdgraphZero         (Bdgraph * restrict const);
121 int                         bdgraphCheck        (const Bdgraph * restrict const);
122 #ifdef BGRAPH_H
123 int                         bdgraphGatherAll    (const Bdgraph * restrict const, Bgraph * restrict);
124 #endif /* BGRAPH_H */
125 
126 int                         bdgraphStoreInit    (const Bdgraph * const, BdgraphStore * const);
127 void                        bdgraphStoreExit    (BdgraphStore * const);
128 void                        bdgraphStoreSave    (const Bdgraph * const , BdgraphStore * const);
129 void                        bdgraphStoreUpdt    (Bdgraph * const, const BdgraphStore * const);
130 
131 #undef static
132