OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
multisector.c File Reference
#include <space.h>

Go to the source code of this file.

Functions

multisector_tnewMultisector (graph_t *G)
void freeMultisector (multisector_t *ms)
multisector_ttrivialMultisector (graph_t *G)
multisector_tconstructMultisector (graph_t *G, options_t *options, timings_t *cpus)
multisector_textractMS2stage (nestdiss_t *ndroot)
multisector_textractMSmultistage (nestdiss_t *ndroot)

Function Documentation

◆ constructMultisector()

multisector_t * constructMultisector ( graph_t * G,
options_t * options,
timings_t * cpus )

Definition at line 124 of file multisector.c.

125{ multisector_t *ms;
126 nestdiss_t *ndroot;
127 PORD_INT *map, nvtx, ordtype;
128
129 nvtx = G->nvtx;
130
131 /* ------------------------------
132 check number of nodes in graph
133 ------------------------------ */
134 /* -----------------------------------
135 JY: inserted the condition
136 "&& (options[OPTION_MSGLVL] > 0)"
137 below, to avoid systematic printing
138 ----------------------------------- */
139 if ((nvtx <= MIN_NODES) && (options[OPTION_ORDTYPE] != MINIMUM_PRIORITY)
140 && (options[OPTION_MSGLVL] > 0))
141 { printf("\nWarning in constructMultisector\n"
142 " graph has less than %d nodes, skipping separator construction\n\n",
143 MIN_NODES);
145 }
146 /* --------------------------------------------------------
147 determine the multisector according to the ordering type
148 -------------------------------------------------------- */
149 ordtype = options[OPTION_ORDTYPE];
150 switch(ordtype)
151 { case MINIMUM_PRIORITY:
152 ms = trivialMultisector(G);
153 break;
154
155 case INCOMPLETE_ND:
156 case MULTISECTION:
158 mymalloc(map, nvtx, PORD_INT);
159 ndroot = setupNDroot(G, map);
160 buildNDtree(ndroot, options, cpus);
161 if (ordtype == MULTISECTION)
162 ms = extractMS2stage(ndroot);
163 else
164 ms = extractMSmultistage(ndroot);
165 freeNDtree(ndroot);
166 freeNDnode(ndroot);
167 free(map);
168 break;
169
170 default:
171 fprintf(stderr, "\nError in function constructMultisector\n"
172 " unrecognized ordering type %d\n", ordtype);
173 quit();
174 }
175 return(ms);
176}
#define MINIMUM_PRIORITY
Definition const.h:23
#define OPTION_ORDTYPE
Definition const.h:78
#define OPTION_MSGLVL
Definition const.h:83
#define MULTISECTION
Definition const.h:25
#define TRISTAGE_MULTISECTION
Definition const.h:26
#define INCOMPLETE_ND
Definition const.h:24
#define quit()
Definition macros.h:64
#define mymalloc(ptr, nr, type)
Definition macros.h:23
multisector_t * trivialMultisector(graph_t *G)
Definition multisector.c:96
multisector_t * extractMSmultistage(nestdiss_t *ndroot)
multisector_t * extractMS2stage(nestdiss_t *ndroot)
#define MIN_NODES
Definition params.h:15
nestdiss_t * setupNDroot(graph_t *, PORD_INT *)
Definition nestdiss.c:107
void freeNDtree(nestdiss_t *)
Definition nestdiss.c:260
void buildNDtree(nestdiss_t *, options_t *, timings_t *)
Definition nestdiss.c:213
void freeNDnode(nestdiss_t *)
Definition nestdiss.c:96
PORD_INT nvtx
Definition types.h:31
#define PORD_INT
Definition types.h:20
struct _nestdiss nestdiss_t
struct _multisector multisector_t

◆ extractMS2stage()

multisector_t * extractMS2stage ( nestdiss_t * ndroot)

Definition at line 182 of file multisector.c.

183{ multisector_t *ms;
184 nestdiss_t *nd, *parent;
185 PORD_INT *stage, *intvertex, *intcolor;
186 PORD_INT nvint, nnodes, totmswght, i;
187
188 /* -----------------------------------------------------------------
189 allocate memory for the multisector object and init. stage vector
190 ----------------------------------------------------------------- */
191 ms = trivialMultisector(ndroot->G);
192 stage = ms->stage;
193
194 /* ------------------------------------------------------------
195 extract the stages of the separator vertices:
196 stage[u] = 1, iff u belongs to a separator
197 ------------------------------------------------------------ */
198 nnodes = totmswght = 0;
199 for (nd = ndroot; nd->childB != NULL; nd = nd->childB);
200 while (nd != ndroot)
201 { parent = nd->parent;
202 if ((parent == NULL) || (parent->childB == NULL)
203 || (parent->childW == NULL))
204 { fprintf(stderr, "\nError in function extractMS2stage\n"
205 " nested dissection tree corrupted\n");
206 quit();
207 }
208 if (parent->childB == nd) /* left subtree of parent visited */
209 for (nd = parent->childW; nd->childB != NULL; nd = nd->childB);
210 else /* right subtree of parent visited */
211 { nd = parent; /* extract the separator of parent */
212 totmswght += nd->cwght[GRAY];
213 nvint = nd->nvint;
214 intvertex = nd->intvertex;
215 intcolor = nd->intcolor;
216 for (i = 0; i < nvint; i++)
217 if (intcolor[i] == GRAY)
218 { nnodes++;
219 stage[intvertex[i]] = 1;
220 }
221 }
222 }
223
224 /* ------------------------------------------
225 finalize the multisector object and return
226 ------------------------------------------ */
227 ms->nstages = 2;
228 ms->nnodes = nnodes;
229 ms->totmswght = totmswght;
230
231 return(ms);
232}
#define GRAY
Definition const.h:62
PORD_INT totmswght
Definition types.h:94
PORD_INT * stage
Definition types.h:91
PORD_INT nstages
Definition types.h:92
PORD_INT nnodes
Definition types.h:93
PORD_INT * intvertex
Definition types.h:80
PORD_INT * intcolor
Definition types.h:81
PORD_INT cwght[3]
Definition types.h:82
graph_t * G
Definition types.h:76
struct _nestdiss * parent
Definition types.h:83
struct _nestdiss * childB
Definition types.h:83
PORD_INT nvint
Definition types.h:79
struct _nestdiss * childW
Definition types.h:83

◆ extractMSmultistage()

multisector_t * extractMSmultistage ( nestdiss_t * ndroot)

Definition at line 238 of file multisector.c.

239{ multisector_t *ms;
240 nestdiss_t *nd, *parent;
241 PORD_INT *stage, *intvertex, *intcolor;
242 PORD_INT nvtx, nvint, maxstage, istage, nnodes, totmswght, i, u;
243
244 /* -----------------------------------------------------------------
245 allocate memory for the multisector object and init. stage vector
246 ----------------------------------------------------------------- */
247 ms = trivialMultisector(ndroot->G);
248 stage = ms->stage;
249
250 /* ------------------------------------------------------------
251 extract the stages of the separator vertices:
252 stage[u] = i, i>0, iff u belongs to a separator in depth i-1
253 ------------------------------------------------------------ */
254 maxstage = nnodes = totmswght = 0;
255 for (nd = ndroot; nd->childB != NULL; nd = nd->childB);
256 while (nd != ndroot)
257 { parent = nd->parent;
258 if ((parent == NULL) || (parent->childB == NULL)
259 || (parent->childW == NULL))
260 { fprintf(stderr, "\nError in function extractMSmultistage\n"
261 " nested dissection tree corrupted\n");
262 quit();
263 }
264 if (parent->childB == nd) /* left subtree of parent visited */
265 for (nd = parent->childW; nd->childB != NULL; nd = nd->childB);
266 else /* right subtree of parent visited */
267 { nd = parent; /* extract the separator of parent */
268 istage = nd->depth + 1; /* sep. vertices belong to this stage */
269 maxstage = max(maxstage, istage);
270 totmswght += nd->cwght[GRAY];
271 nvint = nd->nvint;
272 intvertex = nd->intvertex;
273 intcolor = nd->intcolor;
274 for (i = 0; i < nvint; i++)
275 if (intcolor[i] == GRAY)
276 { nnodes++;
277 stage[intvertex[i]] = istage;
278 }
279 }
280 }
281
282 /* --------------------------------------------------------------------
283 we have: stage[u] = 0 => u belongs to a domain
284 stage[u] = 1 => u belongs to the root separator (depth = 0)
285 :
286 stage[u] = maxstage => u belongs to a leaf separator
287 but we must eliminate the separators in a bottom-up fashion; we like
288 to have: stage[u] = 0 => u belongs to a domain
289 stage[u] = 1 => u belongs to a leaf separator
290 :
291 stage[u] = maxstage => u belongs to the root separator
292 -------------------------------------------------------------------- */
293 nvtx = ndroot->G->nvtx;
294 for (u = 0; u < nvtx; u++)
295 if (stage[u] > 0)
296 stage[u] = maxstage - stage[u] + 1;
297
298 /* ------------------------------------------
299 finalize the multisector object and return
300 ------------------------------------------ */
301 ms->nstages = maxstage + 1;
302 ms->nnodes = nnodes;
303 ms->totmswght = totmswght;
304
305 return(ms);
306}
#define max(a, b)
Definition macros.h:21
PORD_INT depth
Definition types.h:78

◆ freeMultisector()

void freeMultisector ( multisector_t * ms)

Definition at line 86 of file multisector.c.

87{
88 free(ms->stage);
89 free(ms);
90}

◆ newMultisector()

multisector_t * newMultisector ( graph_t * G)

Definition at line 68 of file multisector.c.

69{ multisector_t *ms;
70
71 mymalloc(ms, 1, multisector_t);
72 mymalloc(ms->stage, G->nvtx, PORD_INT);
73
74 ms->G = G;
75 ms->nstages = 0;
76 ms->nnodes = 0;
77 ms->totmswght = 0;
78
79 return(ms);
80}
graph_t * G
Definition types.h:90

◆ trivialMultisector()

multisector_t * trivialMultisector ( graph_t * G)

Definition at line 96 of file multisector.c.

97{ multisector_t *ms;
98 PORD_INT *stage, nvtx, u;
99
100 /* -----------------------------------------------------------------
101 allocate memory for the multisector object and init. stage vector
102 ----------------------------------------------------------------- */
103 nvtx = G->nvtx;
104 ms = newMultisector(G);
105 stage = ms->stage;
106
107 for (u = 0; u < nvtx; u++)
108 stage[u] = 0; /* no vertex belongs to a separator */
109
110 /* -------------------------------
111 finalize the multisector object
112 ------------------------------- */
113 ms->nstages = 1;
114 ms->nnodes = 0;
115 ms->totmswght = 0;
116
117 return(ms);
118}
multisector_t * newMultisector(graph_t *G)
Definition multisector.c:68