OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
mumps_pord.c
Go to the documentation of this file.
1/*
2 *
3 * This file is part of MUMPS 5.5.1, released
4 * on Tue Jul 12 13:17:24 UTC 2022
5 *
6 *
7 * Copyright 1991-2022 CERFACS, CNRS, ENS Lyon, INP Toulouse, Inria,
8 * Mumps Technologies, University of Bordeaux.
9 *
10 * This version of MUMPS is provided to you free of charge. It is
11 * released under the CeCILL-C license
12 * (see doc/CeCILL-C_V1-en.txt, doc/CeCILL-C_V1-fr.txt, and
13 * https://cecill.info/licences/Licence_CeCILL-C_V1-en.html)
14 *
15 */
16/*
17 * This file contains interfaces to external ordering packages.
18 * At the moment, PORD (J. Schulze) and SCOTCH are interfaced.
19 */
20#include "mumps_pord.h"
22{
23#if defined(pord)
24# if defined(PORD_INTSIZE64) || defined(INTSIZE64)
25 *pord_intsize=64;
26# else
27 *pord_intsize=32;
28# endif
29#else
30 *pord_intsize=-99999;
31#endif
32}
33#if defined(pord)
34/* Interface to PORD */
35#if defined(INTSIZE64) || defined(PORD_INTSIZE64)
36void MUMPS_CALL
37MUMPS_PORDF( MUMPS_INT8 *nvtx, MUMPS_INT8 *nedges,
38 MUMPS_INT8 *xadj, MUMPS_INT8 *adjncy,
39 MUMPS_INT8 *nv, MUMPS_INT *ncmpa )
40#else
41void MUMPS_CALL
42MUMPS_PORDF( MUMPS_INT *nvtx, MUMPS_INT *nedges,
43 MUMPS_INT *xadj, MUMPS_INT *adjncy,
44 MUMPS_INT *nv, MUMPS_INT *ncmpa )
45#endif
46{
47 *ncmpa = mumps_pord( *nvtx, *nedges, xadj, adjncy, nv );
48}
49/* Interface to PORD with weighted graph */
50#if defined(INTSIZE64) || defined(PORD_INTSIZE64)
51void MUMPS_CALL
52MUMPS_PORDF_WND( MUMPS_INT8 *nvtx, MUMPS_INT8 *nedges,
53 MUMPS_INT8 *xadj, MUMPS_INT8 *adjncy,
54 MUMPS_INT8 *nv, MUMPS_INT *ncmpa, MUMPS_INT8 *totw )
55#else
56void MUMPS_CALL
57MUMPS_PORDF_WND( MUMPS_INT *nvtx, MUMPS_INT *nedges,
58 MUMPS_INT *xadj, MUMPS_INT *adjncy,
59 MUMPS_INT *nv, MUMPS_INT *ncmpa, MUMPS_INT *totw )
60#endif
61{
62 *ncmpa = mumps_pord_wnd( *nvtx, *nedges, xadj, adjncy, nv, totw );
63}
64/************************************************************
65 mumps_pord is used in ana_aux.F
66 permutation and inverse permutation not set on output,
67 but may be printed in default file: "perm_pord" and "iperm_pord",
68 if associated part uncommneted.
69 But, if uncommetnted a bug occurs in psl_ma41_analysi.F
70******************************************************************/
71/*********************************************************/
72MUMPS_INT mumps_pord
73(
74 PORD_INT nvtx,
75 PORD_INT nedges, /* NZ-like */
76 PORD_INT *xadj_pe, /* NZ-like */
77 PORD_INT *adjncy,
78 PORD_INT *nv
79)
80{
81/**********************************
82Arguments:
83input:
84-----
85- nvtx : dimension of the Problem (N)
86- nedges : number of entries (NZ)
87- adjncy : non-zeros entries (IW input)
88input/output:
89-------------
90- xadj_pe : in: pointer through beginning of column non-zeros entries
91 out: "father array" (PE)
92ouput:
93------
94- nv : "nfront array" (NV)
95*************************************/
96 graph_t *G;
97 elimtree_t *T;
98 timings_t cpus[12];
102 PORD_INT *ncolfactor, *ncolupdate, *parent, *vtx2front;
103 PORD_INT *first, *link, nfronts, J, K, u, vertex, vertex_root, count;
104 /* Explicit shifting of indices to be optimized */
105 for (u = nvtx; u >= 0; u--)
106 {
107 xadj_pe[u] = xadj_pe[u] - 1;
108 }
109 for (K = nedges-1; K >= 0; K--)
110 {
111 adjncy[K] = adjncy[K] - 1;
112 }
113 /* initialization of the graph */
114 mymalloc(G, 1, graph_t);
115 G->xadj = xadj_pe;
116 G->adjncy = adjncy;
117 G->nvtx = nvtx;
118 G->nedges = nedges;
119 /* FIXME: G->vwght and G->tocwght accessed if G->type==UNWEIGHTED? */
120 mymalloc(G->vwght, nvtx, PORD_INT);
121 G->type = UNWEIGHTED;
122 G->totvwght = nvtx;
123 for (u = 0; u < nvtx; u++)
124 G->vwght[u] = 1;
125 /* main function of the Ordering */
126 T = SPACE_ordering(G, options, cpus);
127 nfronts = T->nfronts;
128 ncolfactor = T->ncolfactor;
129 ncolupdate = T->ncolupdate;
130 parent = T->parent;
131 /* firstchild = T->firstchild; */
132 vtx2front = T->vtx2front;
133 /* -----------------------------------------------------------
134 store the vertices/columns of a front in a bucket structure
135 ----------------------------------------------------------- */
136 mymalloc(first, nfronts, PORD_INT);
137 mymalloc(link, nvtx, PORD_INT);
138 for (J = 0; J < nfronts; J++)
139 first[J] = -1;
140 for (u = nvtx-1; u >= 0; u--)
141 {
142 J = vtx2front[u];
143 link[u] = first[J];
144 first[J] = u;
145 }
146 /* -----------------------------------------------------------
147 fill the two arrays corresponding to the MUMPS tree structure
148 ----------------------------------------------------------- */
149 count = 0;
150 for (K = firstPostorder(T); K != -1; K = nextPostorder(T, K))
151 {
152 vertex_root = first[K];
153 if (vertex_root == -1)
154 {
155 /* Should never happen */
156# if defined(PORD_INTSIZE64) || defined(INTSIZE64)
157 printf(" Internal error in mumps_pord, %ld\n",K);
158# else
159 printf(" Internal error in mumps_pord, %d\n",K);
160# endif
161 exit(-1);
162 }
163 /* for the principal column of the supervariable */
164 if (parent[K] == -1)
165 xadj_pe[vertex_root] = 0; /* root of the tree */
166 else
167 xadj_pe[vertex_root] = - (first[parent[K]]+1);
168 nv[vertex_root] = ncolfactor[K] + ncolupdate[K];
169 count++;
170 for (vertex = link[vertex_root]; vertex != -1; vertex = link[vertex])
171 /* for the secondary columns of the supervariable */
172 {
173 xadj_pe[vertex] = - (vertex_root+1);
174 nv[vertex] = 0;
175 count++;
176 }
177 }
178 /* ----------------------
179 free memory and return
180 ---------------------- */
181 free(first); free(link);
182 free(G->vwght);
183 free(G);
184 freeElimTree(T);
185 return (0);
186}
187/*********************************************************/
188MUMPS_INT mumps_pord_wnd
189(
190 PORD_INT nvtx,
191 PORD_INT nedges,
192 PORD_INT *xadj_pe,
193 PORD_INT *adjncy,
194 PORD_INT *nv,
195 PORD_INT *totw
196)
197{
198/**********************************
199Arguments:
200input:
201-----
202- nvtx : dimension of the Problem (N)
203- nedges : number of entries (NZ)
204- adjncy : non-zeros entries (IW input)
205- totw : sum of the weigth of the vertices
206input/output:
207-------------
208- xadj_pe : in: pointer through beginning of column non-zeros entries
209 out: "father array" (PE)
210- nv : in: weight of the vertices
211 out: "nfront array" (NV)
212*************************************/
213 graph_t *G;
214 elimtree_t *T;
215 timings_t cpus[12];
219 PORD_INT *ncolfactor, *ncolupdate, *parent, *vtx2front;
220 PORD_INT *first, *link, nfronts, J, K, u, vertex, vertex_root, count;
221 /* Explicit shifting of indices to be optimized */
222 for (u = nvtx; u >= 0; u--)
223 {
224 xadj_pe[u] = xadj_pe[u] - 1;
225 }
226 for (K = nedges-1; K >= 0; K--)
227 {
228 adjncy[K] = adjncy[K] - 1;
229 }
230 /* initialization of the graph */
231 mymalloc(G, 1, graph_t);
232 G->xadj = xadj_pe;
233 G->adjncy= adjncy;
234 G->nvtx = nvtx;
235 G->nedges = nedges;
236 G->type = WEIGHTED;
237 G->totvwght = (*totw);
238 /* FIXME: avoid allocation and do: G->vwght=nv; instead? */
239 mymalloc(G->vwght, nvtx, PORD_INT);
240 for (u = 0; u < nvtx; u++)
241 G->vwght[u] = nv[u];
242 /* main function of the Ordering */
243 T = SPACE_ordering(G, options, cpus);
244 nfronts = T->nfronts;
245 ncolfactor = T->ncolfactor;
246 ncolupdate = T->ncolupdate;
247 parent = T->parent;
248 /* firstchild = T->firstchild; */
249 vtx2front = T->vtx2front;
250 /* -----------------------------------------------------------
251 store the vertices/columns of a front in a bucket structure
252 ----------------------------------------------------------- */
253 mymalloc(first, nfronts, PORD_INT);
254 mymalloc(link, nvtx, PORD_INT);
255 for (J = 0; J < nfronts; J++)
256 first[J] = -1;
257 for (u = nvtx-1; u >= 0; u--)
258 {
259 J = vtx2front[u];
260 link[u] = first[J];
261 first[J] = u;
262 }
263 /* -----------------------------------------------------------
264 fill the two arrays corresponding to the MUMPS tree structure
265 ----------------------------------------------------------- */
266 count = 0;
267 for (K = firstPostorder(T); K != -1; K = nextPostorder(T, K))
268 {
269 vertex_root = first[K];
270 if (vertex_root == -1)
271 {
272 /* Should never happen */
273# if defined(PORD_INTSIZE64) || defined(INTSIZE64)
274 printf(" Internal error in mumps_pord, %ld\n",K);
275# else
276 printf(" Internal error in mumps_pord, %d\n",K);
277# endif
278 exit(-1);
279 }
280 /* for the principal column of the supervariable */
281 if (parent[K] == -1)
282 xadj_pe[vertex_root] = 0; /* root of the tree */
283 else
284 xadj_pe[vertex_root] = - (first[parent[K]]+1);
285 nv[vertex_root] = ncolfactor[K] + ncolupdate[K];
286 count++;
287 for (vertex = link[vertex_root]; vertex != -1; vertex = link[vertex])
288 /* for the secondary columns of the supervariable */
289 {
290 xadj_pe[vertex] = - (vertex_root+1);
291 nv[vertex] = 0;
292 count++;
293 }
294 }
295 /* ----------------------
296 free memory and return
297 ---------------------- */
298 free(first); free(link);
299 free(G->vwght);
300 free(G);
301 freeElimTree(T);
302 return (0);
303}
304#endif /* pord */
#define SPACE_DOMAIN_SIZE
Definition const.h:44
#define SPACE_ORDTYPE
Definition const.h:40
#define SPACE_NODE_SELECTION3
Definition const.h:43
#define WEIGHTED
Definition const.h:20
#define SPACE_NODE_SELECTION2
Definition const.h:42
#define UNWEIGHTED
Definition const.h:19
#define SPACE_NODE_SELECTION1
Definition const.h:41
#define mymalloc(ptr, nr, type)
Definition macros.h:23
#define MUMPS_INT8
#define MUMPS_INT
#define MUMPS_CALL
#define MUMPS_PORD_INTSIZE
Definition mumps_pord.h:19
integer, dimension(:), allocatable nv
Definition spbuc3.F:31
PORD_INT nextPostorder(elimtree_t *, PORD_INT)
Definition tree.c:243
elimtree_t * SPACE_ordering(graph_t *, options_t *, timings_t *)
Definition interface.c:47
PORD_INT firstPostorder(elimtree_t *)
Definition tree.c:213
void freeElimTree(elimtree_t *)
Definition tree.c:132
PORD_INT nfronts
Definition types.h:152
PORD_INT * parent
Definition types.h:156
PORD_INT * ncolfactor
Definition types.h:154
PORD_INT * vtx2front
Definition types.h:159
PORD_INT * ncolupdate
Definition types.h:155
PORD_INT totvwght
Definition types.h:34
PORD_INT * xadj
Definition types.h:35
PORD_INT type
Definition types.h:33
PORD_INT nedges
Definition types.h:32
PORD_INT nvtx
Definition types.h:31
PORD_INT * vwght
Definition types.h:37
PORD_INT * adjncy
Definition types.h:36
FLOAT timings_t
Definition types.h:25
#define PORD_INT
Definition types.h:20
struct _graph graph_t
struct _elimtree elimtree_t
PORD_INT options_t
Definition types.h:24