PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
graph_compute_projection.c
Go to the documentation of this file.
1/**
2 *
3 * @file graph_compute_projection.c
4 *
5 * PaStiX graph routine to compute projection of lower levels supernodes
6 *
7 * @copyright 2004-2025 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8 * Univ. Bordeaux. All rights reserved.
9 *
10 * @version 6.4.0
11 * @author Gregoire Pichon
12 * @author Pierre Ramet
13 * @author Mathieu Faverge
14 * @author Tony Delarue
15 * @date 2024-07-05
16 *
17 **/
18#include "common.h"
19#include "pastix/order.h"
20#include "blend/extendVector.h"
21#include "graph/graph.h"
22
23/**
24 *******************************************************************************
25 *
26 * @brief TODO
27 *
28 *******************************************************************************
29 *
30 * @param[in] graph
31 * TODO
32 *
33 * @param[in] vertlvl
34 * TODO
35 *
36 * @param[in] order
37 * TODO
38 *
39 * @param[in] subgraph
40 * TODO
41 *
42 * @param[in] suborder
43 * TODO
44 *
45 * @param[in] fnode
46 * TODO
47 *
48 * @param[in] lnode
49 * TODO
50 *
51 * @param[in] sn_level
52 * TODO
53 *
54 * @param[in] distance
55 * TODO
56 *
57 * @param[in] maxdepth
58 * TODO
59 *
60 * @param[in] maxwidth
61 * TODO
62 *
63 * @param[in] depthsze
64 * TODO
65 *
66 *******************************************************************************/
67void
68graphComputeProjection( const pastix_graph_t *graph,
69 const int *vertlvl,
70 pastix_order_t *order,
71 const pastix_graph_t *subgraph,
72 pastix_order_t *suborder,
73 pastix_int_t fnode,
74 pastix_int_t lnode,
75 pastix_int_t sn_level,
76 pastix_int_t distance,
77 pastix_int_t maxdepth,
78 pastix_int_t maxwidth,
79 pastix_int_t *depthsze )
80{
82 pastix_int_t baseval = graph->colptr[0];
83 pastix_int_t n, i, ip, j, jp, jj, d, k, sze;
84 pastix_int_t lvl, depth;
85 const pastix_int_t *colptr;
86 const pastix_int_t *rows;
87 pastix_int_t *peritab, *subvertlvl, *subvert;
88 pastix_int_t *perm, *invp;
89
90 n = lnode - fnode;
91 MALLOC_INTERN( subvertlvl, n, pastix_int_t );
92 extendint_Init( &vec, (sqrt(n)+1) * pastix_imax( distance, maxwidth ) * 2 );
93
94 /* (i, j ) in initial ordering */
95 /* (ip,jp) in permuted ordering */
96 colptr = graph->colptr;
97 rows = graph->rowptr;
98 peritab = order->peritab;
99 subvert = subvertlvl;
100
101 for (ip=fnode; ip<lnode; ip++, subvert++) {
102 extendint_Clear( &vec );
103
104 /* i^th vertex in the initial numbering */
105 extendint_Add( &vec, peritab[ip] );
106 *subvert = -maxdepth-1;
107 sze = 1;
108 d = -1;
109 k = 0;
110
111 while( d < distance ) {
112 for(; k<sze; k++) {
113 i = extendint_Read( &vec, k );
114
115 for (jj = colptr[i ]-baseval;
116 jj < colptr[i+1]-baseval; jj++) {
117
118 j = rows[jj]-baseval;
119 lvl = vertlvl[j];
120
121 /*
122 * If lvl is equal to sn_level, the node belong to the same supernode,
123 * and if lvl is lower than sn_level, then the node belongs to a
124 * supernode higher in the elimination tree.
125 * In both cases, we avoid to connect to a supernode through them.
126 */
127 if ( lvl <= sn_level ) {
128 continue;
129 }
130
131 /*
132 * Store the negative depth to sort in ascending order with
133 * nodes connected to deeper levels first
134 */
135 depth = sn_level - lvl;
136 *subvert = pastix_imax( depth, *subvert );
137
138 extendint_Add( &vec, j );
139 }
140 }
141 d++;
142 sze = extendint_Size( &vec );
143 }
144 }
145
146 perm = suborder->permtab;
147 invp = suborder->peritab;
148
149 /*
150 * Enlarge the projections
151 */
152 if ( maxwidth > 0 ) {
153 pastix_int_t *subvertlv2;
154 void *sortptr[3];
155
156 sortptr[0] = subvertlvl;
157 sortptr[1] = invp;
158 sortptr[2] = order->peritab + fnode;
159
160 qsort3IntAsc( sortptr, n );
161
162 /* Generate the new perm array for the subgraph */
163 for(i=0; i<n; i++) {
164 j = invp[i];
165 assert( (j >= 0) && (j < n) );
166 perm[j] = i;
167 }
168
169 MALLOC_INTERN( subvertlv2, n, pastix_int_t );
170 memcpy( subvertlv2, subvertlvl, n * sizeof(pastix_int_t) );
171
172 colptr = subgraph->colptr;
173 rows = subgraph->rowptr;
174 maxdepth = -maxdepth;
175
176 /*
177 * We do the loop in reverse order to first enlarge the nodes connected
178 * to the highest supernodes.
179 */
180 for (ip=n-1; ip>=0; ip--) {
181 if ( subvertlv2[ip] < maxdepth ) {
182 break;
183 }
184
185 extendint_Clear( &vec );
186 /* i^th vertex in the initial numbering */
187 extendint_Add( &vec, invp[ip] );
188 sze = 1;
189 d = 0;
190 k = 0;
191
192 while( d < maxwidth ) {
193 for(; k<sze; k++) {
194 i = extendint_Read( &vec, k );
195 assert( subvertlvl[ip] == subvertlvl[ perm[i] ] );
196
197 for (jj = colptr[i ];
198 jj < colptr[i+1]; jj++) {
199
200 j = rows[jj];
201 jp = perm[j];
202
203 /* If j has already been seen because connected to an higher sn_level */
204 if ( subvertlv2[jp] > subvertlv2[ip] ) {
205 continue;
206 }
207 subvertlvl[jp] = subvertlvl[ip];
208 extendint_Add( &vec, j );
209 }
210 }
211 d++;
212 sze = extendint_Size( &vec );
213 }
214 }
215 maxdepth = -maxdepth;
216
217 memFree_null( subvertlv2 );
218 }
219
220 /* Sort again the peritab array associated to the subgraph */
221 {
222 void *sortptr[3];
223 sortptr[0] = subvertlvl;
224 sortptr[1] = invp;
225 sortptr[2] = order->peritab + fnode;
226
227 qsort3IntAsc( sortptr, n );
228
229 /* Update the perm array */
230 for(i=0; i<n; i++) {
231 perm[invp[i]] = i;
232 }
233 }
234
235 /* Compute the sizes of each depth */
236 memset( depthsze, 0, maxdepth * sizeof(pastix_int_t) );
237 {
238 int d = 0;
239 for(i=n-1; i >= 0; i--) {
240 while ( subvertlvl[i] < (-d-1) ) {
241 d++;
242 }
243 if ( d >= maxdepth ) {
244 break;
245 }
246 depthsze[d] ++;
247 }
248 }
249
250 extendint_Exit( &vec );
251 free(subvertlvl);
252}
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
pastix_int_t extendint_Size(const ExtendVectorINT *)
Return the number of element stored in the vector.
void extendint_Clear(ExtendVectorINT *)
Cleanup the vector.
pastix_int_t extendint_Read(const ExtendVectorINT *, pastix_int_t)
Return the element of index eltnum.
pastix_int_t * extendint_Init(ExtendVectorINT *, pastix_int_t)
Initialize the extendVector structure with the initial size given.
void extendint_Add(ExtendVectorINT *, pastix_int_t)
Add an element elt to the end of the vector.
void extendint_Exit(ExtendVectorINT *)
Free the extendVector structure.
The extend integer array structure.
void graphComputeProjection(const pastix_graph_t *graph, const int *vertlvl, pastix_order_t *order, const pastix_graph_t *subgraph, pastix_order_t *suborder, pastix_int_t fnode, pastix_int_t lnode, pastix_int_t sn_level, pastix_int_t distance, pastix_int_t maxdepth, pastix_int_t maxwidth, pastix_int_t *depthsze)
TODO.
pastix_int_t * permtab
Definition order.h:51
pastix_int_t * peritab
Definition order.h:52
Order structure.
Definition order.h:47