PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
pastix_subtask_reordering.c
Go to the documentation of this file.
1/**
2 *
3 * @file pastix_subtask_reordering.c
4 *
5 * PaStiX reordering task
6 *
7 * @copyright 2015-2024 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 Mathieu Faverge
13 * @author Pierre Ramet
14 * @author Vincent Bridonneau
15 * @date 2024-07-05
16 *
17 */
18#include "common.h"
19#include "pastix/order.h"
20
21/**
22 *******************************************************************************
23 *
24 * @ingroup pastix_analyze
25 *
26 * @brief Apply the reordering step to compact off-diagonal blocks
27 *
28 * During this step, unknowns are reordered within each supernode to compact
29 * off-diagonal blocks. It takes as input the ordering provided by
30 * pastix_subtask_order(), and the symbolic factorization computed by
31 * pastix_subtask_symbfact(). It returns boths structures Order and Symbol updated.
32 *
33 * This function reorders the unknowns of the problem based on traveller
34 * salesman problem to gather together the contibutions facing each supernodes.
35 *
36 * See reordering paper: http://epubs.siam.org/doi/10.1137/16M1062454.
37 *
38 * This routine is affected by the following parameters:
39 * IPARM_VERBOSE, IPARM_IO_STRATEGY, IPARM_REORDERING_SPLIT,
40 * IPARM_REORDERING_STOP
41 *
42 *******************************************************************************
43 *
44 * @param[inout] pastix_data
45 * The pastix_data structure that describes the solver instance. On
46 * exit, the field symbmtx is updated with the new symbol matrix, and
47 * the field ordemesh is updated with the new ordering.
48 * - IPARM_IO_STRATEGY will enable to load/store the result to files.
49 * If set to PastixIOSave, the symbmtx and the generated ordemesh are
50 * dump to file.
51 * If set to PastixIOLoad, the symbmtx (only) is loaded from the files.
52 *
53 *******************************************************************************
54 *
55 * @retval PASTIX_SUCCESS on successful exit
56 * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect.
57 *
58 *******************************************************************************/
59int
61{
62 Clock timer;
63 pastix_int_t *iparm;
64 pastix_order_t *ordemesh;
65 pastix_int_t procnum;
66 int verbose;
67
68 /**
69 * Check parameters
70 */
71 if (pastix_data == NULL) {
72 pastix_print_error( "pastix_subtask_reordering: wrong pastix_data parameter" );
74 }
75 iparm = pastix_data->iparm;
76 procnum = pastix_data->procnum;
77 ordemesh = pastix_data->ordemesh;
78
79 assert(ordemesh->rangtab);
80 assert(ordemesh->treetab);
81
82 /* Start the step */
83 if (iparm[IPARM_VERBOSE] > PastixVerboseNot ) {
84 pastix_int_t criterion = (iparm[IPARM_REORDERING_STOP] == PASTIX_INT_MAX) ? -1 : iparm[IPARM_REORDERING_STOP];
85 pastix_print( procnum, 0, OUT_STEP_REORDER,
86 (long)iparm[IPARM_REORDERING_SPLIT],
87 (long)criterion );
88 }
89
90 /* Print the reordering complexity */
91 if (iparm[IPARM_VERBOSE] > PastixVerboseYes) {
93 }
94
95 clockStart(timer);
96
97 /**
98 * Reorder the rows of each supernode in order to compact coupling blocks
99 */
100 pastixSymbolReordering( pastix_data );
101
102 /* Backup the new ordering */
103 if ( iparm[IPARM_IO_STRATEGY] & PastixIOSave )
104 {
105 if (procnum == 0) {
106 pastixOrderSave( pastix_data, ordemesh );
107 }
108 }
109
110 pastixSymbolExit( pastix_data->symbmtx );
111 memFree_null( pastix_data->symbmtx );
112 pastix_data->symbmtx = NULL;
113
114 /* Re-build the symbolic structure */
115 /* TODO: Create a function to update the symbolic factorization, instead of computing it from scratch,
116 this can be easily made in // per column, as opposed to the symbolic factorization itself */
117 verbose = iparm[IPARM_VERBOSE];
118 iparm[IPARM_VERBOSE] = pastix_imax( 0, verbose-2 );
119
120 pastix_subtask_symbfact( pastix_data );
121
122 iparm[IPARM_VERBOSE] = verbose;
123
124#if !defined(NDEBUG)
125 if ( pastixOrderCheck( ordemesh ) != 0) {
126 pastix_print_error( "pastix_subtask_reordering: pastixOrderCheck on final ordering failed !!!" );
127 assert(0);
128 }
129 if( pastixSymbolCheck(pastix_data->symbmtx) != 0 ) {
130 pastix_print_error( "pastix_subtask_reordering: symbolCheck on final symbol matrix failed !!!" );
131 assert(0);
132 }
133#endif
134
135 clockStop(timer);
136 pastix_data->dparm[DPARM_REORDER_TIME] = clockVal(timer);
137
138 if ( iparm[IPARM_VERBOSE] > PastixVerboseNot ) {
139 pastix_print( procnum, 0, OUT_REORDERING_TIME,
140 (double)clockVal(timer) );
141 }
142 return PASTIX_SUCCESS;
143}
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
int pastix_subtask_symbfact(pastix_data_t *pastix_data)
Computes the symbolic factorization step.
int pastix_subtask_reordering(pastix_data_t *pastix_data)
Apply the reordering step to compact off-diagonal blocks.
@ PastixIOSave
Definition api.h:231
@ DPARM_REORDER_TIME
Definition api.h:166
@ IPARM_VERBOSE
Definition api.h:36
@ IPARM_REORDERING_STOP
Definition api.h:79
@ IPARM_REORDERING_SPLIT
Definition api.h:78
@ IPARM_IO_STRATEGY
Definition api.h:37
@ PastixVerboseYes
Definition api.h:222
@ PastixVerboseNot
Definition api.h:220
@ PASTIX_SUCCESS
Definition api.h:367
@ PASTIX_ERR_BADPARAMETER
Definition api.h:374
pastix_int_t * treetab
Definition order.h:54
pastix_int_t * rangtab
Definition order.h:53
int pastixOrderSave(pastix_data_t *pastix_data, const pastix_order_t *ordeptr)
Save an ordering to a file.
Definition order_io.c:293
int pastixOrderCheck(const pastix_order_t *ordeptr)
This routine checks the correctness of the ordering structure.
Definition order_check.c:39
Order structure.
Definition order.h:47
void pastixSymbolReordering(pastix_data_t *)
Compute the reordering on the complete matrix.
void pastixSymbolReorderingPrintComplexity(const symbol_matrix_t *symbptr)
Compute the number of operations required to compute the reordering on the complete matrix.
void pastixSymbolExit(symbol_matrix_t *symbptr)
Free the content of symbolic matrix.
Definition symbol.c:137
int pastixSymbolCheck(const symbol_matrix_t *symbptr)
Checks the consistency of the given symbolic block matrix.
pastix_order_t * ordemesh
Definition pastixdata.h:98
pastix_int_t * iparm
Definition pastixdata.h:70
double * dparm
Definition pastixdata.h:71
symbol_matrix_t * symbmtx
Definition pastixdata.h:100
Main PaStiX data structure.
Definition pastixdata.h:68