diff --git a/testings/CMakeLists.txt b/testings/CMakeLists.txt index 3bd2e5a2367a48a46b3a9799df9ed671124ff24b..c6c9da9fdd83580109cf72b4a30cbad44f715c71 100644 --- a/testings/CMakeLists.txt +++ b/testings/CMakeLists.txt @@ -14,7 +14,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(TESTINGS draw_hqr.c draw_systolic.c - testing_pivgen.c + testing_hqr.c testing_tileinit.c ) diff --git a/testings/testing_hqr.c b/testings/testing_hqr.c new file mode 100644 index 0000000000000000000000000000000000000000..dc3e2e1983b275365363537c98edb15eef40b6c9 --- /dev/null +++ b/testings/testing_hqr.c @@ -0,0 +1,208 @@ +/** + * + * @file testing_hqr.c + * + * Testing file for all combinations of trees. + * + * @copyright 2010-2017 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * + * @copyright 2012-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * @version 1.0.0 + * @author Raphael Boucherie + * @author Mathieu Faverge + * @date 2017-03-21 + * + */ +#include <stdlib.h> +#include <stdio.h> +#include "libhqr.h" +#include "common.h" + +int +main(int argc, char ** argv) +{ + libhqr_tree_t qrtree; + libhqr_tiledesc_t matrix; + + int iparam[IPARAM_SIZEOF]; + int rc, ret = 0; + + /* Get options */ + parse_arguments( &argc, &argv, iparam ); + PASTE_CODE_IPARAM_LOCALS( iparam ); + + /* Test many combinations */ + if ( check ) { + int all_llvl[] = { 0, 1, 2, 3, 4 }; + int all_hlvl[] = { 0, 1, 2, 3, 4 }; + int all_qr_p[] = { 3, 5, 7, 8 }; + int all_qr_a[] = { 1, 2, 4, 7 }; + int all_mt[] = { 1, 3, 4, 10, 17, 25, 128 }; + int all_nt[] = { 1, 2, 5, 13, 26, 58 }; + + int nb_llvl = sizeof( all_llvl ) / sizeof( int ); + int nb_hlvl = sizeof( all_hlvl ) / sizeof( int ); + int nb_qr_p = sizeof( all_qr_p ) / sizeof( int ); + int nb_qr_a = sizeof( all_qr_a ) / sizeof( int ); + int nb_mt = sizeof( all_mt ) / sizeof( int ); + int nb_nt = sizeof( all_nt ) / sizeof( int ); + + int rc, ret = 0; + int P = 1; + int nbnodes = P; + int l, h, p, a, m, n; + int done, todo; + todo = 0; + done = 0; + + /* HQR */ + todo += nb_llvl * nb_mt * nb_nt * (2 * nb_qr_a - 1) * (1 + (2 * nb_hlvl - 1) * nb_qr_p); + + for( l=0; l<nb_llvl; l++) { + llvl = all_llvl[l]; + + /* + * Tests w/o high level trees + */ + hlvl = -1; domino = 0; qr_p = -1; + matrix.nodes = 1; + matrix.p = 1; + + /* qr_a */ + for( a=0; a<nb_qr_a; a++) { + qr_a = all_qr_a[a]; + + /* MT */ + for( m=0; m<nb_mt; m++) { + MT = all_mt[m]; + matrix.mt = MT; + + /* NT */ + for( n=0; n<nb_nt; n++) { + NT = all_nt[n]; + matrix.nt = NT; + + /* TS Round-robin */ + for( tsrr=0; tsrr<2; tsrr++) { + + /* Useless case */ + if (tsrr==1 && a==1) + continue; + + libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, + llvl, hlvl, qr_a, qr_p, domino, tsrr ); + + rc = libhqr_tree_check( &matrix, &qrtree ); + libhqr_matrix_finalize( &qrtree ); + + if (rc != 0) { + fprintf(stderr, "%s -M %d -N %d --treel=%d --qr_a=%d %s FAILED(%d)\n", + argv[0], MT, NT, llvl, qr_a, (tsrr ? "-r" : " "), rc); + ret |= 1; + return 0; + } + + done++; + printf("\r%6d / %6d", done, todo); + } + } + } + } + + /* + * Tests w/ high level trees + */ + matrix.nodes = nbnodes; + + for( domino=0; domino<2; domino++) { /* Domino */ + if ((domino == 1) && (llvl == LIBHQR_GREEDY1P_TREE)) + continue; + + /* High level tree */ + for( h=0; h<nb_hlvl; h++) { + hlvl = all_hlvl[h]; + + /* qr_p */ + for( p=0; p<nb_qr_p; p++) { + qr_p = all_qr_p[p]; + + P = qr_p; + matrix.nodes = P; + matrix.p = P; + + /* qr_a */ + for( a=0; a<nb_qr_a; a++) { + qr_a = all_qr_a[a]; + + /* MT */ + for( m=0; m<nb_mt; m++) { + MT = all_mt[m]; + matrix.mt = MT; + + /* NT */ + for( n=0; n<nb_nt; n++) { + NT = all_nt[n]; + matrix.nt = NT; + + /* TS Round-robin */ + for( tsrr=0; tsrr<2; tsrr++) { + + /* Useless case */ + if (tsrr==1 && a==1) + continue; + + libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, + llvl, hlvl, qr_a, qr_p, domino, tsrr ); + + rc = libhqr_tree_check( &matrix, &qrtree ); + libhqr_matrix_finalize( &qrtree ); + + if (rc != 0) { + fprintf(stderr, "%s -M %d -N %d --treel=%d --treeh=%d --qr_a=%d --qr_p=%d -d=%d %s FAILED(%d)\n", + argv[0], MT, NT, llvl, hlvl, qr_a, qr_p, domino, (tsrr ? "-r" : " "), rc); + ret |= 1; + return 0; + } + + done++; + printf("\r%6d / %6d", done, todo); + } + } + } + } + } + } + } + } + } + else { + matrix.nodes = nodes; + matrix.p = P; + matrix.mt = MT; + matrix.nt = NT; + + libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, + llvl, hlvl, qr_a, qr_p, domino, tsrr ); + + rc = libhqr_tree_check( &matrix, &qrtree ); + libhqr_matrix_finalize( &qrtree ); + + if (rc != 0) { + fprintf(stderr, "%s -M %d -N %d --treel=%d --treeh=%d --qr_a=%d --qr_p=%d -d=%d %s FAILED(%d)\n", + argv[0], MT, NT, llvl, hlvl, qr_a, qr_p, domino, (tsrr ? "-r" : " "), rc); + ret |= 1; + } + } + + if ( ret == 0 ) { + return EXIT_SUCCESS; + } + else { + fprintf(stderr, "ret = %d\n", ret); + return EXIT_FAILURE; + } +} diff --git a/testings/testing_pivgen.c b/testings/testing_pivgen.c deleted file mode 100644 index 669755cc2d23166b67d3f73b2c5917c8f83dfb1d..0000000000000000000000000000000000000000 --- a/testings/testing_pivgen.c +++ /dev/null @@ -1,166 +0,0 @@ -/** - * - * @file testing_pivgen.c - * - * Testing file for all combinations of trees. - * - * @copyright 2010-2017 The University of Tennessee and The University - * of Tennessee Research Foundation. All rights - * reserved. - * - * @copyright 2012-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, - * Univ. Bordeaux. All rights reserved. - * - * @version 1.0.0 - * @author Raphael Boucherie - * @author Mathieu Faverge - * @date 2017-03-21 - * - */ -#include <stdlib.h> -#include <stdio.h> -#include "libhqr.h" - -int -main(int argc, char ** argv) -{ - libhqr_tree_t qrtree; - libhqr_tiledesc_t matrix; - int alltreel[] = { 0, 1, 2, 3, 4 }; - int alltreeh[] = { 0, 1, 2, 3, 4 }; - int allP[] = { 3, 5, 7, 8 }; - int allA[] = { 1, 2, 4, 7 }; - int allM[] = { 1, 3, 4, 10, 17, 25, 128 }; - int allN[] = { 1, 2, 5, 13, 26, 58 }; - int nbtreel = 4; - int nbtreeh = 5; - int nbP = 4; - int nbA = 4; - int nbM = 7; - int nbN = 6; - int rc, ret = 0; - int nbnodes = 1; - int P = 1; - int l, h, p, a, m, n, d, r; - int done, todo; - todo = 0; - done = 0; - - /* HQR */ - todo += nbtreel * nbM * nbN * (2 * nbA - 1) * (1 + 2 * nbtreeh * nbP); - /* systolic */ - todo += nbM * nbN * nbA * nbP; - - /* - * - * Tests for HQR code - * - */ - matrix.nodes = nbnodes; - matrix.p = P; - for( l=0; l<nbtreel; l++) { - /* No High Level */ - h = 0; d = 0; p = -1; - for( a=0; a<nbA; a++) { - for( m=0; m<nbM; m++) { - matrix.mt = allM[m]; - for( n=0; n<nbN; n++) { - matrix.nt = allN[n]; - for( r=0; r<2; r++) { - if (r==1 && a==1) - continue; - - libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, alltreel[l], 0, allA[a], -1, 0, r ); - - rc = libhqr_tree_check( &matrix, &qrtree ); - if (rc != 0) { - fprintf(stderr, "-M %d -N %d --treel=%d --qr_a=%d --tsrr=%d FAILED(%d)\n", - allM[m], allN[n], alltreel[l], allA[a], r, rc); - ret |= 1; - libhqr_matrix_finalize( &qrtree ); - return 0; - } - libhqr_matrix_finalize( &qrtree ); - - done++; - printf("\r%6d / %6d", done, todo); - } - } - } - } - /* With High level */ - matrix.nodes = nbnodes; - for( d=0; d<2; d++) { /* Domino */ - if (d == 1 && alltreel[l] == LIBHQR_GREEDY1P_TREE) - continue; - for( h=0; h<nbtreeh; h++) { - for( p=0; p<nbP; p++) { - matrix.p = allP[p]; - for( a=0; a<nbA; a++) { - for( m=0; m<nbM; m++) { - matrix.mt = allM[m]; - for( n=0; n<nbN; n++) { - matrix.nt = allN[n]; - for( r=0; r<2; r++) { - if (r==1 && a==1) - continue; - libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, alltreel[l], alltreeh[h], allA[a], allP[p], d, r); - - rc = libhqr_tree_check( &matrix, &qrtree ); - if (rc != 0) { - fprintf(stderr, "-M %d -N %d --treel=%d --qr_a=%d --tsrr=%d --qr_p=%d --treeh=%d --domino=%d FAILED(%d)\n", - allM[m], allN[n], alltreel[l], allA[a], r, allP[p], alltreeh[h], d, rc); - ret |= 1; - } - - libhqr_matrix_finalize( &qrtree ); - - done++; - printf("\r%6d / %6d", done, todo); - } - } - } - } - } - } - } - } - - /* - * - * Tests for systolic code - * - */ - /* With High level */ - for( p=0; p<nbP; p++) { - matrix.p = allP[p]; - for( a=0; a<nbA; a++) { - for( m=0; m<nbM; m++) { - matrix.mt = allM[m]; - for( n=0; n<nbN; n++) { - matrix.nt = allN[n]; - libhqr_systolic_init( &qrtree, LIBHQR_QR, &matrix, allA[a], allP[p]); - - rc = libhqr_tree_check( &matrix, &qrtree ); - if (rc != 0) { - fprintf(stderr, "systolic: -M %d -N %d --qr_a=%d --qr_p=%d FAILED(%d)\n", - allM[m], allN[n], allA[a], allP[p], rc); - ret |= 1; - } - - libhqr_matrix_finalize( &qrtree ); - - done++; - printf("\r%6d / %6d", done, todo); - } - } - } - } - - if ( ret == 0 ) - return EXIT_SUCCESS; - else { - fprintf(stderr, "ret = %d\n", ret); - return EXIT_FAILURE; - } -}