21 #include "symbol_reorder.h"
53 if ( levels[cblknum] != 0 ) {
54 return levels[cblknum];
109 return vectors_size[xj];
112 return vectors_size[xi];
121 if ( vectors_size[xi] - vectors_size[xj] >= stop ) {
124 if ( vectors_size[xj] - vectors_size[xi] >= stop ) {
128 while( ( set1 < end1 ) && ( set2 < end2 ) ) {
129 if( *set1 == *set2 ) {
133 else if( *set1 < *set2 ) {
134 while ( ( set1 < end1 ) && ( *set1 < *set2 ) ) {
139 else if( *set1 > *set2 ) {
140 while ( ( set2 < end2 ) && ( *set1 > *set2 ) ) {
146 pastix_print_error(
"reordering: fatal error occured" );
231 memset( tmplen, 0, ( size + 1 ) *
sizeof(
pastix_int_t) );
237 distance =
hamming_distance( lw_vectors, lw_vectors_size, 0, -1, stop_criterion );
239 tmplen[0] = distance;
240 tmplen[1] = distance;
242 for (i=1; i<size; i++) {
258 tmpinvp[0], stop_criterion );
260 tmpinvp[1], stop_criterion );
264 minl = lw_before_pos + lw_after_pos - tmplen[0];
268 for (j=1; j<i; j++) {
269 up_before_pos = up_after_pos;
273 if ( (up_before_pos < 1) ||
277 if ( lw_after_pos == -1 ) {
279 tmpinvp[j], stop_criterion );
282 lw_before_pos = lw_after_pos;
286 tmpinvp[j+1], stop_criterion );
288 l = lw_before_pos + lw_after_pos - tmplen[j];
292 if ( lw_before_pos < min_cut ) {
293 min_cut = lw_before_pos;
297 if ( lw_after_pos < min_cut ) {
298 min_cut = lw_after_pos;
306 min_cut = lw_before_pos;
309 if ( lw_after_pos < min_cut ) {
310 min_cut = lw_after_pos;
315 if ( lw_after_pos == 0 ) {
329 tmpinvp[0], stop_criterion );
331 tmpinvp[i], stop_criterion );
334 tmpinvp[mpos-1], stop_criterion );
336 tmpinvp[mpos ], stop_criterion );
338 l = first_pos + last_pos - tmplen[i];
345 tmplen[mpos-1] = lw_before_pos;
348 if ( mpos < ( i + 1 ) ) {
354 for (j=mpos; j<i+2; j++) {
367 tmplen[i+1] = first_pos;
373 for (i=0; i<size; i++) {
374 if ( tmpinvp[i] == -1 ) {
385 for (i=0; i<size; i++) {
386 sn_connected[i] = peritab[ tmpinvp[(i + 1 + elected)%(size+1)] ];
388 memcpy( peritab, sn_connected, size *
sizeof(
pastix_int_t) );
389 memFree_null( sn_connected );
392 memFree_null( tmpinvp );
393 memFree_null( tmplen );
474 for (iterblok=cblk[0].brownum; iterblok<cblk[1].
brownum; iterblok++) {
475 blok = symbptr->
bloktab + brow[iterblok];
478 depthweight[ levels[ blok->
lcblknm ] - 1 ] += blokweight;
479 weight += blokweight;
497 for (i=0; i<local_split_level; i++) {
498 up_total += depthweight[i];
500 for (; i<depthmax; i++) {
501 lw_total += depthweight[i];
505 if ( (lw_total < (5 * up_total)) &&
506 (lw_total > 10) && (up_total > 10) && (sign <= 0)) {
513 if ( (lw_total > (3 * up_total)) &&
514 (lw_total > 10) && (up_total > 10) && (sign >= 0) ) {
523 memset( up_vectors_size, 0, size *
sizeof(
pastix_int_t) );
525 memset( lw_vectors_size, 0, size *
sizeof(
pastix_int_t) );
527 for (iterblok=cblk[0].brownum; iterblok<cblk[1].
brownum; iterblok++) {
528 blok = symbptr->
bloktab + brow[iterblok];
531 if (levels[blok->
lcblknm] <= local_split_level) {
532 for (i=blok->
frownum; i<=blok->lrownum; i++) {
534 up_vectors_size[index]++;
538 for (i=blok->
frownum; i<=blok->lrownum; i++) {
540 lw_vectors_size[index]++;
548 for (i=0; i<size; i++) {
549 MALLOC_INTERN(lw_vectors[i], lw_vectors_size[i],
pastix_int_t);
550 MALLOC_INTERN(up_vectors[i], up_vectors_size[i],
pastix_int_t);
551 memset(lw_vectors[i], 0, lw_vectors_size[i] *
sizeof(
pastix_int_t));
552 memset(up_vectors[i], 0, up_vectors_size[i] *
sizeof(
pastix_int_t));
554 memset( lw_vectors_size, 0, size *
sizeof(
pastix_int_t) );
555 memset( up_vectors_size, 0, size *
sizeof(
pastix_int_t) );
558 for (iterblok=cblk[0].brownum; iterblok<cblk[1].
brownum; iterblok++)
560 blok = symbptr->
bloktab + brow[iterblok];
563 if (levels[blok->
lcblknm] <= local_split_level) {
564 for (i=blok->
frownum; i<=blok->lrownum; i++) {
566 up_vectors[index][up_vectors_size[index]] = blok->
lcblknm;
567 up_vectors_size[index]++;
571 for (i=blok->
frownum; i<=blok->lrownum; i++) {
573 lw_vectors[index][lw_vectors_size[index]] = blok->
lcblknm;
574 lw_vectors_size[index]++;
583 lw_vectors, lw_vectors_size,
584 up_vectors, up_vectors_size,
587 for (i=0; i<size; i++) {
588 memFree_null( lw_vectors[i] );
589 memFree_null( up_vectors[i] );
591 memFree_null( lw_vectors );
592 memFree_null( up_vectors );
593 memFree_null( lw_vectors_size );
594 memFree_null( up_vectors_size );
633 for (i=0; i<cblknbr; i++) {
635 maxdepth = pastix_imax( maxdepth, levels[i] );
645 for (i=0; i<symbptr->
nodenbr; i++) {
648 memFree_null( levels );
683 for (itercblk=0; itercblk<cblknbr; itercblk++, cblk++) {
690 for (iterblok=cblk[0].brownum; iterblok<cblk[1].
brownum; iterblok++) {
692 assert( blok->
fcblknm == itercblk );
697 nbiops += nbcblk * (width-1);
699 if ( itercblk == (cblknbr-1) ) {
700 schur_nbiops = nbcblk * (width-1);
707 fprintf( stdout, OUT_REORDERING_OPS,
708 (
long)schur_nbiops, (
double)schur_nbiops / (
double)(nbiops) * 100.,
BEGIN_C_DECLS typedef int pastix_int_t
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.
Symbol column block structure.
pastix_order_t * ordemesh
symbol_matrix_t * symbmtx
Main PaStiX data structure.
void symbol_reorder(pastix_data_t *pastix_data, pastix_int_t maxdepth, pastix_int_t *levels)
Reorder all node.
static pastix_int_t hamming_distance(pastix_int_t **vectors, pastix_int_t *vectors_size, pastix_int_t xi, pastix_int_t xj, pastix_int_t stop)
Compute the distance between two rows of a same supernode.
static void symbol_reorder_tsp(pastix_int_t size, pastix_order_t *order, pastix_int_t sn_id, pastix_int_t **lw_vectors, pastix_int_t *lw_vectors_size, pastix_int_t **up_vectors, pastix_int_t *up_vectors_size, pastix_int_t stop_criterion)
Reorder rows of a supernode with the nearest insertion TSP heuristic.
static pastix_int_t compute_cblklevel(const pastix_int_t *treetab, const pastix_int_t *levels, pastix_int_t cblknum)
Compute the level of supernode cblknum, with Scotch treetab.
void symbol_reorder_cblk(const symbol_matrix_t *symbptr, const symbol_cblk_t *cblk, pastix_order_t *order, const pastix_int_t *levels, pastix_int_t *depthweight, pastix_int_t depthmax, pastix_int_t split_level, pastix_int_t stop_criterion)
Reorder a supernode.