1 /* 2 * Copyright 1997, Regents of the University of Minnesota 3 * 4 * struct.h 5 * 6 * This file contains data structures for ILU routines. 7 * 8 * Started 9/26/95 9 * George 10 * 11 */ 12 13 #ifndef _LIBMETIS_STRUCT_H_ 14 #define _LIBMETIS_STRUCT_H_ 15 16 17 18 /*************************************************************************/ 19 /*! This data structure stores cut-based k-way refinement info about an 20 adjacent subdomain for a given vertex. */ 21 /*************************************************************************/ 22 typedef struct cnbr_t { 23 idx_t pid; /*!< The partition ID */ 24 idx_t ed; /*!< The sum of the weights of the adjacent edges 25 that are incident on pid */ 26 } cnbr_t; 27 28 29 /*************************************************************************/ 30 /*! The following data structure stores holds information on degrees for k-way 31 partition */ 32 /*************************************************************************/ 33 typedef struct ckrinfo_t { 34 idx_t id; /*!< The internal degree of a vertex (sum of weights) */ 35 idx_t ed; /*!< The total external degree of a vertex */ 36 idx_t nnbrs; /*!< The number of neighboring subdomains */ 37 idx_t inbr; /*!< The index in the cnbr_t array where the nnbrs list 38 of neighbors is stored */ 39 } ckrinfo_t; 40 41 42 /*************************************************************************/ 43 /*! This data structure stores volume-based k-way refinement info about an 44 adjacent subdomain for a given vertex. */ 45 /*************************************************************************/ 46 typedef struct vnbr_t { 47 idx_t pid; /*!< The partition ID */ 48 idx_t ned; /*!< The number of the adjacent edges 49 that are incident on pid */ 50 idx_t gv; /*!< The gain in volume achieved by moving the 51 vertex to pid */ 52 } vnbr_t; 53 54 55 /*************************************************************************/ 56 /*! The following data structure holds information on degrees for k-way 57 vol-based partition */ 58 /*************************************************************************/ 59 typedef struct vkrinfo_t { 60 idx_t nid; /*!< The internal degree of a vertex (count of edges) */ 61 idx_t ned; /*!< The total external degree of a vertex (count of edges) */ 62 idx_t gv; /*!< The volume gain of moving that vertex */ 63 idx_t nnbrs; /*!< The number of neighboring subdomains */ 64 idx_t inbr; /*!< The index in the vnbr_t array where the nnbrs list 65 of neighbors is stored */ 66 } vkrinfo_t; 67 68 69 /*************************************************************************/ 70 /*! The following data structure holds information on degrees for k-way 71 partition */ 72 /*************************************************************************/ 73 typedef struct nrinfo_t { 74 idx_t edegrees[2]; 75 } nrinfo_t; 76 77 78 /*************************************************************************/ 79 /*! This data structure holds a graph */ 80 /*************************************************************************/ 81 typedef struct graph_t { 82 idx_t nvtxs, nedges; /* The # of vertices and edges in the graph */ 83 idx_t ncon; /* The # of constrains */ 84 idx_t *xadj; /* Pointers to the locally stored vertices */ 85 idx_t *vwgt; /* Vertex weights */ 86 idx_t *vsize; /* Vertex sizes for min-volume formulation */ 87 idx_t *adjncy; /* Array that stores the adjacency lists of nvtxs */ 88 idx_t *adjwgt; /* Array that stores the weights of the adjacency lists */ 89 90 idx_t *tvwgt; /* The sum of the vertex weights in the graph */ 91 real_t *invtvwgt; /* The inverse of the sum of the vertex weights in the graph */ 92 93 94 /* These are to keep track control if the corresponding fields correspond to 95 application or library memory */ 96 int free_xadj, free_vwgt, free_vsize, free_adjncy, free_adjwgt; 97 98 idx_t *label; 99 100 idx_t *cmap; 101 102 /* Partition parameters */ 103 idx_t mincut, minvol; 104 idx_t *where, *pwgts; 105 idx_t nbnd; 106 idx_t *bndptr, *bndind; 107 108 /* Bisection refinement parameters */ 109 idx_t *id, *ed; 110 111 /* K-way refinement parameters */ 112 ckrinfo_t *ckrinfo; /*!< The per-vertex cut-based refinement info */ 113 vkrinfo_t *vkrinfo; /*!< The per-vertex volume-based refinement info */ 114 115 /* Node refinement information */ 116 nrinfo_t *nrinfo; 117 118 struct graph_t *coarser, *finer; 119 } graph_t; 120 121 122 /*************************************************************************/ 123 /*! This data structure holds a mesh */ 124 /*************************************************************************/ 125 typedef struct mesh_t { 126 idx_t ne, nn; /*!< The # of elements and nodes in the mesh */ 127 idx_t ncon; /*!< The number of element balancing constraints (element weights) */ 128 129 idx_t *eptr, *eind; /*!< The CSR-structure storing the nodes in the elements */ 130 idx_t *ewgt; /*!< The weights of the elements */ 131 } mesh_t; 132 133 134 135 /*************************************************************************/ 136 /*! The following structure stores information used by Metis */ 137 /*************************************************************************/ 138 typedef struct ctrl_t { 139 moptype_et optype; /* Type of operation */ 140 mobjtype_et objtype; /* Type of refinement objective */ 141 mdbglvl_et dbglvl; /* Controls the debuging output of the program */ 142 mctype_et ctype; /* The type of coarsening */ 143 miptype_et iptype; /* The type of initial partitioning */ 144 mrtype_et rtype; /* The type of refinement */ 145 146 idx_t CoarsenTo; /* The # of vertices in the coarsest graph */ 147 idx_t nIparts; /* The number of initial partitions to compute */ 148 idx_t no2hop; /* Indicates if 2-hop matching will be used */ 149 idx_t minconn; /* Indicates if the subdomain connectivity will be minimized */ 150 idx_t contig; /* Indicates if contigous partitions are required */ 151 idx_t nseps; /* The number of separators to be found during multiple bisections */ 152 idx_t ufactor; /* The user-supplied load imbalance factor */ 153 idx_t compress; /* If the graph will be compressed prior to ordering */ 154 idx_t ccorder; /* If connected components will be ordered separately */ 155 idx_t seed; /* The seed for the random number generator */ 156 idx_t ncuts; /* The number of different partitionings to compute */ 157 idx_t niter; /* The number of iterations during each refinement */ 158 idx_t numflag; /* The user-supplied numflag for the graph */ 159 idx_t *maxvwgt; /* The maximum allowed weight for a vertex */ 160 161 idx_t ncon; /*!< The number of balancing constraints */ 162 idx_t nparts; /*!< The number of partitions */ 163 164 real_t pfactor; /* .1*(user-supplied prunning factor) */ 165 166 real_t *ubfactors; /*!< The per-constraint ubfactors */ 167 168 real_t *tpwgts; /*!< The target partition weights */ 169 real_t *pijbm; /*!< The nparts*ncon multiplies for the ith partition 170 and jth constraint for obtaining the balance */ 171 172 real_t cfactor; /*!< The achieved compression factor */ 173 174 /* Various Timers */ 175 double TotalTmr, InitPartTmr, MatchTmr, ContractTmr, CoarsenTmr, UncoarsenTmr, 176 RefTmr, ProjectTmr, SplitTmr, Aux1Tmr, Aux2Tmr, Aux3Tmr; 177 178 /* Workspace information */ 179 gk_mcore_t *mcore; /*!< The persistent memory core for within function 180 mallocs/frees */ 181 182 /* These are for use by the k-way refinement routines */ 183 size_t nbrpoolsize; /*!< The number of {c,v}nbr_t entries that have been allocated */ 184 size_t nbrpoolcpos; /*!< The position of the first free entry in the array */ 185 size_t nbrpoolreallocs; /*!< The number of times the pool was resized */ 186 187 cnbr_t *cnbrpool; /*!< The pool of cnbr_t entries to be used during refinement. 188 The size and current position of the pool is controlled 189 by nnbrs & cnbrs */ 190 vnbr_t *vnbrpool; /*!< The pool of vnbr_t entries to be used during refinement. 191 The size and current position of the pool is controlled 192 by nnbrs & cnbrs */ 193 194 /* The subdomain graph, in sparse format */ 195 idx_t *maxnads; /* The maximum allocated number of adjacent domains */ 196 idx_t *nads; /* The number of adjacent domains */ 197 idx_t **adids; /* The IDs of the adjacent domains */ 198 idx_t **adwgts; /* The edge-weight to the adjacent domains */ 199 idx_t *pvec1, *pvec2; /* Auxiliar nparts-size vectors for efficiency */ 200 201 } ctrl_t; 202 203 204 205 #endif 206