Commit 0cc4f3d2 authored by Mathieu Faverge's avatar Mathieu Faverge

Modify tshqr, to handle both cases tshqr and tphqr

parent f9a6f752
......@@ -94,7 +94,7 @@ set(srcs
src/systolic.c
src/svd.c
src/hqr.c
src/tshqr.c
src/tphqr.c
src/mtxtree.c
# Others
src/check.c
......
......@@ -205,8 +205,8 @@ int libhqr_init_hqr( libhqr_tree_t *qrtree,
int type_llvl, int type_hlvl,
int a, int p, int domino, int tsrr );
int libhqr_init_tshqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, libhqr_matrix_t *A,
int libhqr_init_tphqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, int kt, int lt, libhqr_matrix_t *A,
libhqr_tree_e hlvl, int a, int p );
void libhqr_finalize( libhqr_tree_t *qrtree );
......
......@@ -64,7 +64,7 @@ libhqr_check_nbgeqrf( const libhqr_tree_t *qrtree )
printf(" ----------------------------------------------------\n"
" - a = %d, p = %d, M = %d, N = %d\n"
" Check number of geqrt:\n"
" For k=%d => return %d instead of %d",
" For k=%d => return %d instead of %d\n",
qrtree->a, qrtree->p, qrtree->mt, qrtree->nt, k, qrtree->getnbgeqrf( qrtree, k ), nb );
}
}
......@@ -116,7 +116,7 @@ libhqr_check_geti_getm( const libhqr_tree_t *qrtree )
printf(" ----------------------------------------------------\n"
" - a = %d, p = %d, M = %d, N = %d\n"
" Check indices of geqrt:\n"
" getm( k=%d, i=%d ) => m = %d",
" getm( k=%d, i=%d ) => m = %d\n",
qrtree->a, qrtree->p, qrtree->mt, qrtree->nt, k, i, m);
}
prevm = m;
......
/**
*
* @file tshqr.c
* @file tphqr.c
*
* @copyright 2018-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
......@@ -38,7 +38,7 @@ void print_alllist( int nblist, libhqr_list_t *lists )
}
static int
tshqr_getnbgeqrf( const libhqr_tree_t *qrtree, int k )
tphqr_getnbgeqrf( const libhqr_tree_t *qrtree, int k )
{
libhqr_tile_args_t *args = (libhqr_tile_args_t*)(qrtree->args);
int *nbgeqrf = args->nbgeqrf;
......@@ -46,7 +46,7 @@ tshqr_getnbgeqrf( const libhqr_tree_t *qrtree, int k )
}
static int
tshqr_getm( const libhqr_tree_t *qrtree, int k, int i )
tphqr_getm( const libhqr_tree_t *qrtree, int k, int i )
{
libhqr_tile_args_t *args = (libhqr_tile_args_t*)(qrtree->args);
int *killers = args->killers;
......@@ -57,8 +57,8 @@ tshqr_getm( const libhqr_tree_t *qrtree, int k, int i )
}
int
libhqr_initmtx_tshqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, libhqr_matrix_t *A,
libhqr_initmtx_tphqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, int kt, int lt, libhqr_matrix_t *A,
libhqr_tree_e hlvl, int a, int p )
{
libhqr_tile_args_t *args;
......@@ -104,10 +104,10 @@ libhqr_initmtx_tshqr( libhqr_tree_t *qrtree,
libhqr_rdmtx_initfct( qrtree );
qrtree->init = LIBHQR_QRTREE_MTX;
qrtree->facto = trans;
qrtree->getnbgeqrf = tshqr_getnbgeqrf;
qrtree->getm = tshqr_getm;
qrtree->getnbgeqrf = tphqr_getnbgeqrf;
qrtree->getm = tphqr_getm;
qrtree->mt = (trans == LIBHQR_TSQR) ? A->mt : A->nt;
qrtree->nt = (trans == LIBHQR_TSQR) ? A->nt : A->mt;
qrtree->nt = kt;
a = libhqr_imin( a, qrtree->mt );
......@@ -145,7 +145,7 @@ libhqr_initmtx_tshqr( libhqr_tree_t *qrtree,
lists1 = lists2 + low_mt * p;
lists0 = lists1 + p;
for (k=0; k<qrtree->mt; k++) {
for (k=0; k<qrtree->mt-lt; k++) {
elts[k].next = NULL;
elts[k].id = k;
elts[k].date = 0;
......@@ -179,6 +179,7 @@ libhqr_initmtx_tshqr( libhqr_tree_t *qrtree,
if ( elt1 == NULL ) {
continue;
}
assert( (elt1 != NULL) && (elt1->next == NULL) );
tileinfo[elt1->id].type = LIBHQR_KILLED_BY_LOCALTREE;
......@@ -327,6 +328,30 @@ libhqr_initmtx_tshqr( libhqr_tree_t *qrtree,
assert( killer_index <= qrtree->mt );
/* assert( killer_index <= (low_mt*p) ); */
args->nbgeqrf[k] = killer_index;
/* Add the new element when performing a TT kernel */
if ( lt > 0 ) {
int last = qrtree->mt-lt;
elts[last].next = NULL;
elts[last].id = last;
elts[last].date = 0;
lp = last % p;
la = ( last / p ) / a;
assert( lp * low_mt + la < low_mt * p );
libhqr_list_push( lists3 + lp * low_mt + la, elts + last );
for( i=last; i<qrtree->mt; i++ ) {
tileinfo[i].type = -1;
tileinfo[i].index = -1;
tileinfo[i].currpiv = -1;
tileinfo[i].nextpiv = -1;
tileinfo[i].prevpiv = -1;
tileinfo[i].first_nextpiv = -1;
tileinfo[i].first_prevpiv = -1;
}
lt--;
}
}
if (0)
......@@ -359,10 +384,10 @@ libhqr_initmtx_tshqr( libhqr_tree_t *qrtree,
int
libhqr_init_tshqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, libhqr_matrix_t *A,
libhqr_init_tphqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, int kt, int lt, libhqr_matrix_t *A,
libhqr_tree_e hlvl, int a, int p )
{
return libhqr_initmtx_tshqr( qrtree, trans, A, hlvl, a, p );
return libhqr_initmtx_tphqr( qrtree, trans, kt, lt, A, hlvl, a, p );
}
......@@ -20,11 +20,11 @@ endif()
set(TESTINGS
draw_hqr.c
draw_systolic.c
draw_tshqr.c
draw_tphqr.c
testing_hqr.c
testing_svd.c
testing_systolic.c
testing_tshqr.c
testing_tphqr.c
testing_print.c
)
......@@ -45,9 +45,9 @@ endforeach()
add_test( draw_hqr ./draw_hqr -M 27 -N 7 -P 2 -d -a 3 -p 2 )
add_test( draw_systolic ./draw_systolic -M 27 -N 7 -P 3 -L 3 -l 2 )
add_test( draw_tshqr ./draw_tshqr -M 27 -P 2)
add_test( draw_tphqr ./draw_tphqr -M 27 -P 2)
add_test( test_hqr ./testing_hqr -X )
add_test( test_svd ./testing_svd -X )
add_test( test_systolic ./testing_systolic -X )
add_test( test_tshqr ./testing_tshqr -X )
add_test( test_tphqr ./testing_tphqr -X )
add_test( test_print ./testing_print -M 27 -N 7 -P 3 )
/**
*
* @file draw_tshqr.c
* @file draw_tphqr.c
*
* Binary to draw hierarchical trees used to compute the tsqrt/tslqt of a full matrix.
*
......@@ -35,11 +35,11 @@ main(int argc, char ** argv)
matrix.mt = MT;
matrix.nt = NT;
rc = libhqr_init_tshqr( &qrtree, LIBHQR_TSQR, &matrix, LIBHQR_FLAT_TREE, qr_a, qr_p );
rc = libhqr_init_tphqr( &qrtree, LIBHQR_TSQR, NT, 0, &matrix, LIBHQR_FLAT_TREE, qr_a, qr_p );
if ( rc != 0 ) {
return EXIT_FAILURE;
}
libhqr_print_svg( &qrtree, "tshqr.svg" );
libhqr_print_svg( &qrtree, "tphqr.svg" );
libhqr_finalize( &qrtree );
return EXIT_SUCCESS;
......
/**
*
* @file testing_tshqr.c
* @file testing_tphqr.c
*
* Testing file for all combinations of hierarchical QR trees.
*
......@@ -22,6 +22,10 @@
#include "libhqr.h"
#include "common.h"
static inline int libhqr_imin(int a, int b){
return (a > b) ? b : a;
}
int
main(int argc, char ** argv)
{
......@@ -29,7 +33,7 @@ main(int argc, char ** argv)
libhqr_matrix_t matrix;
int iparam[IPARAM_SIZEOF];
int rc, ret = 0;
int lt, rc, ret = 0;
/* Get options */
parse_arguments( &argc, &argv, iparam );
......@@ -54,7 +58,7 @@ main(int argc, char ** argv)
done = 0;
/* HQR */
todo = nb_mt * nb_nt * nb_qr_a * nb_qr_p * nb_hlvl;
todo = nb_mt * nb_nt * nb_qr_a * nb_qr_p * nb_hlvl * 2;
/* hlvl */
for( h=0; h<nb_hlvl; h++) {
......@@ -81,25 +85,34 @@ main(int argc, char ** argv)
NT = all_nt[n];
matrix.nt = NT;
rc = libhqr_init_tshqr( &qrtree, LIBHQR_TSQR, &matrix,
hlvl, qr_a, qr_p );
for( tsrr=0; tsrr<2; tsrr++) {
lt = ( tsrr == 0 ) ? 0 : libhqr_imin(MT, NT) - 1;
if ( rc == 0 ) {
rc = libhqr_check( &qrtree );
libhqr_finalize( &qrtree );
}
if ( lt > 0 ) {
done++;
continue;
}
rc = libhqr_init_tphqr( &qrtree, LIBHQR_TSQR, NT, lt,
&matrix, hlvl, qr_a, qr_p );
if (rc != 0) {
fprintf(stderr, "%s -M %d -N %d --hlvl=%d --qr_a=%d --qr_p=%d FAILED(%d)\n",
argv[0], MT, NT, hlvl, qr_a, qr_p, rc);
ret++;
if (check == 1) {
return 0;
if ( rc == 0 ) {
rc = libhqr_check( &qrtree );
libhqr_finalize( &qrtree );
}
if (rc != 0) {
fprintf(stderr, "%s -M %d -N %d --hlvl=%d --qr_a=%d --qr_p=%d %6s FAILED(%d)\n",
argv[0], MT, NT, hlvl, qr_a, qr_p, (tsrr == 0) ? "" : "--tsrr", rc);
ret++;
if (check == 1) {
return 0;
}
}
}
done++;
printf("\r%6d / %6d", done, todo);
done++;
printf("\r%6d / %6d", done, todo);
}
}
}
}
......@@ -111,23 +124,26 @@ main(int argc, char ** argv)
matrix.p = P;
matrix.mt = MT;
matrix.nt = NT;
lt = ( tsrr == 0 ) ? 0 : libhqr_imin(MT, NT) - 1;
rc = libhqr_init_tshqr( &qrtree, LIBHQR_TSQR, &matrix,
hlvl, qr_a, qr_p );
rc = libhqr_init_tphqr( &qrtree, LIBHQR_TSQR, NT, lt,
&matrix, hlvl, qr_a, qr_p );
if ( rc == 0 ) {
rc = libhqr_check( &qrtree );
if ( lt == 0 ) {
rc = libhqr_check( &qrtree );
}
libhqr_finalize( &qrtree );
}
if (rc != 0) {
fprintf(stderr, "%s -M %d -N %d --hlvl=%d --qr_a=%d --qr_p=%d FAILED(%d)\n",
argv[0], MT, NT, hlvl, qr_a, qr_p, rc);
fprintf(stderr, "%s -M %d -N %d --hlvl=%d --qr_a=%d --qr_p=%d %6s FAILED(%d)\n",
argv[0], MT, NT, hlvl, qr_a, qr_p, (tsrr == 0) ? "" : "--tsrr", rc);
ret++;
}
else {
fprintf(stderr, "%s -M %d -N %d --hlvl=%d --qr_a=%d --qr_p=%d SUCCESS\n",
argv[0], MT, NT, hlvl, qr_a, qr_p);
fprintf(stderr, "%s -M %d -N %d --hlvl=%d --qr_a=%d --qr_p=%d %6s SUCCESS\n",
argv[0], MT, NT, hlvl, qr_a, qr_p, (tsrr == 0) ? "" : "--tsrr");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment