diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..47de9e240eda75de9c36adc96cbcf8c977764376 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,56 @@ +### +# +# @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +# @version 0.1.0 +# @author Mathieu Faverge +# @date 2017-04-26 +# +### +cmake_minimum_required (VERSION 3.0) +project (LIBHQR C) + +# The current version number +set (LIBHQR_VERSION_MAJOR 0) +set (LIBHQR_VERSION_MINOR 1) +set (LIBHQR_VERSION_MICRO 0) + +set( LIBHQR_VERSION "${LIBHQR_VERSION_MAJOR}.${LIBHQR_VERSION_MINOR}.${LIBHQR_VERSION_MICRO}" ) + +### Misc options +option(BUILD_SHARED_LIBS + "Build shared libraries" OFF) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are None, Debug, Release, RelWithDebInfo and MinSizeRel." FORCE) +endif(NOT CMAKE_BUILD_TYPE) + +set(hdrs + include/common.h + include/libdraw.h + include/libhqr.h + include/queue.h +) +set(srcs + src/libhqr.c + src/libhqr_dbg.c + src/libhqr_systolic.c + src/queue.c + src/treedraw.c + src/treewalk.c +) + +include_directories(include) +add_library(hqr ${srcs}) +target_link_libraries( hqr m ) + +add_subdirectory(testings) + +install(FILES + include/libhqr.h + include/libhqr_dbg.h + DESTINATION include ) + +#-- Add a custom target to generate tags +add_custom_target (tags + COMMAND "git ls-files | xargs etags" ) diff --git a/include/libhqr.h b/include/libhqr.h index 5be6d282152952ceeda0d5b6f1433d3aff2fd8f6..4f95775f55d116e810b33f1d2316f81d53c3d659 100644 --- a/include/libhqr.h +++ b/include/libhqr.h @@ -18,8 +18,8 @@ #ifndef _LIBHQR_H_ #define _LIBHQR_H_ -#include "common.h" #include <stdio.h> +#include "libhqr_common.h" BEGIN_C_DECLS @@ -36,7 +36,7 @@ static inline int libhqr_iceil(int a, int b){ } /** - * @brief Define to which tree level the tile belongs to. + * @brief Define which tree level the tile belongs to. * * Four levels of trees are available: * - The top one (LIBHQR_KILLED_BY_DISTTREE) is meant to be the communication @@ -49,8 +49,9 @@ static inline int libhqr_iceil(int a, int b){ * the local trees in order to generate a better pipeline for tall and skinny * matrices. * - * @remark LIBHQR_KILLED_BY_TS needs to be stay 0 for all variant of QR - * factorizations in order to distinguish TT kernels from TS kernels in compuations + * @remark LIBHQR_KILLED_BY_TS needs to be 0 for all variant of QR + * factorizations in order to distinguish TT kernels from TS kernels in + * compuations * */ typedef enum libhqr_type_ { @@ -62,6 +63,10 @@ typedef enum libhqr_type_ { /** * @brief Define the type of trees that can be used for the reduction. + * + * These are the kind of trees available for low-level reduction in shared + * memory, or for high-level reduction in distributed memory. Note that all + * kinds of trees are not available for both levels. */ typedef enum libhqr_tree_ { LIBHQR_FLAT_TREE = 0, @@ -75,18 +80,18 @@ typedef enum libhqr_tree_ { * @brief Define the type of factorization to apply: QR or LQ. */ typedef enum libhqr_typefacto_ { - LIBHQR_QR = 0, - LIBHQR_LQ = 1, + LIBHQR_QR = 0, /**< QR factorization will be performed, and A shape is considered */ + LIBHQR_LQ = 1, /**< LQ factorization will be performed, and A^t shape is considered */ } libhqr_typefacto_e; /** * @brief Minimal structure to define the shape of the matrix to factorize. */ typedef struct libhqr_tiledesc_s{ - int mt; /**< The number of rows of tiles */ - int nt; /**< The number of columns of tiles */ - int nodes; /**< The number of nodes involved in the data distribution */ - int p; /**< The number of nodes per column in the data distribution */ + int mt; /**< The number of rows of tiles */ + int nt; /**< The number of columns of tiles */ + int nodes; /**< The number of nodes involved in the data distribution */ + int p; /**< The number of nodes per column in the data distribution */ } libhqr_tiledesc_t; @@ -107,6 +112,9 @@ typedef struct libhqr_tree_s libhqr_tree_t; typedef struct libhqr_context_s libhqr_context_t; +/** + * @brief Hierarchical tree structure for QR/LQ factorization like kernels. + */ struct libhqr_tree_s { /** * @brief Return the number of geqrt/gelqt kernels in the column/row k @@ -178,15 +186,17 @@ struct libhqr_tree_s { */ int (*prevpiv)(const libhqr_tree_t *qrtree, int k, int p, int m); - /** Descriptor infos associated to the factorization */ - int mt; - int nt; - /** Size of the domain where TS kernels are applied */ - int a; - /** Size of highest level tree (distributed one) */ - int p; - int domino; - void *args; + int mt; /**< Number of rows of tile A if QR factorization, and in A^t if LQ + factorization */ + int nt; /**< Number of tile reflectors to compute. This is equal to + min(A->mt, A->nt) */ + int a; /**< Size of the local flat TS trees */ + int p; /**< Size of the highest level tree (distributed one), recommended + to be the number of process rows in the 2D-cyclic distribution */ + int domino; /**< Enable the domino tree to connect high and low level trees + in T&S matrices */ + void *args; /**< Arguments of the qrtree structure (depends on the kind of + tree: hqr, systolic, svd, ...) */ }; int libhqr_systolic_init( libhqr_tree_t *qrtree, diff --git a/include/common.h b/include/libhqr_common.h similarity index 54% rename from include/common.h rename to include/libhqr_common.h index c61ff309e6ead805defaa844f5abb324c0aaea03..1ae8a4312f30cdf4195b857a0373f7cd0f083494 100644 --- a/include/common.h +++ b/include/libhqr_common.h @@ -1,14 +1,10 @@ /** * - * @file common.h + * @file libhqr_common.h * - * Header file for common maccro + * Header file for common macro * - * @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, + * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, * Univ. Bordeaux. All rights reserved. * * @version 1.0.0 @@ -17,9 +13,8 @@ * @date 2017-04-05 * */ - -#ifndef _COMMON_H_ -#define _COMMON_H_ +#ifndef _LIBHQR_COMMON_H_ +#define _LIBHQR_COMMON_H_ #undef BEGIN_C_DECLS #undef END_C_DECLS @@ -31,4 +26,4 @@ # define END_C_DECLS /* empty */ #endif -#endif /* _COMMON_H_ */ +#endif /* _LIBHQR_COMMON_H_ */ diff --git a/include/libdraw.h b/include/libhqr_draw.h similarity index 75% rename from include/libdraw.h rename to include/libhqr_draw.h index dbf6f18b37f0dab790efb311c5c09649622136bb..596151dcc7ba7afe7ca22ec0761a40aff20f1de8 100644 --- a/include/libdraw.h +++ b/include/libhqr_draw.h @@ -1,10 +1,10 @@ /** * - * @file libdraw.h + * @file libhqr_draw.h * * Header file for all the functions of drawing. * - * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, * Univ. Bordeaux. All rights reserved. * * @version 1.0.0 @@ -14,16 +14,17 @@ * **/ -#ifndef _LIBDRAW_H_ -#define _LIBDRAW_H_ +#ifndef _LIBHQR_DRAW_H_ +#define _LIBHQR_DRAW_H_ -#include <common.h> -#define WIDTH 50 -#define HEIGHT 50 -#define SIZE 100 +#include "libhqr_common.h" BEGIN_C_DECLS +#define WIDTH 50 +#define HEIGHT 50 +#define SIZE 100 + /* * Clobal array for color */ @@ -42,4 +43,4 @@ void libhqr_drawline(int x1, int y1, int x2, int y2, int k, FILE *file); END_C_DECLS -#endif /* _LIBDRAW_H_ */ +#endif /* _LIBHQR_DRAW_H_ */ diff --git a/include/queue.h b/include/libhqr_queue.h similarity index 79% rename from include/queue.h rename to include/libhqr_queue.h index 7581a5da8eaefa81bcd59208e1f5cc3c31531c27..1448ce88877c1c309b48fefd873f00037c1ef679 100644 --- a/include/queue.h +++ b/include/libhqr_queue.h @@ -1,10 +1,10 @@ /** * - * @file queue.h + * @file libhqr_queue.h * * Queue module for the treewalk algorithm. * - * @copyright 2012-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, * Univ. Bordeaux. All rights reserved. * * @version 1.0.0 @@ -13,10 +13,10 @@ * @date 2017-03-21 * */ -#ifndef _QUEUE_H_ -#define _QUEUE_H_ +#ifndef _LIBHQR_QUEUE_H_ +#define _LIBHQR_QUEUE_H_ -#include "common.h" +#include "libhqr_common.h" BEGIN_C_DECLS @@ -34,4 +34,4 @@ void libhqr_queue_tile_delete(libhqr_queue_tile_t ** queue_tile); END_C_DECLS -#endif /* _QUEUE_H_ */ +#endif /* _LIBHQR_QUEUE_H_ */ diff --git a/src/queue.c b/src/queue.c index 6afbbf7ee9f3965e0e9a6a2fe6c509b93edb33ae..eedec89126cf02bfadb826a5c3d9e856e36354b1 100644 --- a/src/queue.c +++ b/src/queue.c @@ -13,7 +13,7 @@ * @date 2017-04-05 * */ -#include "queue.h" +#include "libhqr_queue.h" #include <stdlib.h> #include <stdio.h> #include <assert.h> diff --git a/src/treedraw.c b/src/treedraw.c index 4c3a05df777ffc02f0ff7f08f6a001d70d04b258..4a22317d6fd35609769721190dc67005035fb4e6 100644 --- a/src/treedraw.c +++ b/src/treedraw.c @@ -16,7 +16,7 @@ #include <string.h> #include <stdio.h> -#include "libdraw.h" +#include "libhqr_draw.h" /* * Global array for color diff --git a/src/treewalk.c b/src/treewalk.c index 4f6e494a5390c9de3d9e09d2e30e8cfce14911e2..464304833b46de950aab48339fe69c825004aba4 100644 --- a/src/treewalk.c +++ b/src/treewalk.c @@ -15,8 +15,8 @@ */ #include "libhqr.h" -#include "libdraw.h" -#include "queue.h" +#include "libhqr_draw.h" +#include "libhqr_queue.h" #include <stdio.h> #include <assert.h> #include <stdlib.h> diff --git a/testings/CMakeLists.txt b/testings/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..88d02247ca7db9bc1f68a91e4c65c7b55a09090d --- /dev/null +++ b/testings/CMakeLists.txt @@ -0,0 +1,31 @@ +### +# +# @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +# @version 0.1.0 +# @author Mathieu Faverge +# @date 2017-04-26 +# +### + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +set(TESTINGS + draw_hqr.c + draw_systolic.c + testing_hqr.c + testing_systolic.c + testing_tileinit.c + ) + +foreach (_file ${TESTINGS}) + get_filename_component(_name_we ${_file} NAME_WE) + add_executable(${_name_we} + ${_file} common.c) + target_link_libraries(${_name_we} hqr) + + install(TARGETS ${_name_we} RUNTIME DESTINATION examples ) + install(FILES ${_file} DESTINATION examples ) + +endforeach() diff --git a/testings/common.c b/testings/common.c new file mode 100644 index 0000000000000000000000000000000000000000..53cc61fdda9a711f5a49966c19bf1fe2209a8c6b --- /dev/null +++ b/testings/common.c @@ -0,0 +1,229 @@ +/** + * + * @file common.c + * + * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * @version 0.1.0 + * @author Mathieu Faverge + * @date 2017-04-27 + * + */ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include "common.h" + +#if defined(LIBHQR_HAVE_GETOPT_H) +#include <getopt.h> +#endif /* defined(LIBHQR_HAVE_GETOPT_H) */ + +#ifndef max +#define max( _a, _b ) ((_a) < (_b) ? (_a) : (_b)) +#endif + +/** + * @brief Print usage details of the testings + */ +static void +print_usage(void) +{ + fprintf(stderr, + "Mandatory argument:\n" + " -N : Dimension (NT) of the matrices (required)\n" + "Optional arguments:\n" + " -P --grid-rows : Rows (P) in the PxQ process grid (default: 1)\n" + " -Q --grid-cols : Cols (Q) in the PxQ process grid (default: 1)\n" + " -c --cores : Number of cores per node for automatically configured trees (default: 1)\n" + "\n" + " -M : Dimension (MT) of the matrices (default: NT)\n" + "\n" + " -a --qr_a : Size of TS domain. (default: -1)\n" + " -p --qr_p : Size of the high level tree for distributed mode (default: -1)\n" + " -d --domino : Enable/Disable the domino between upper and lower trees. (default: -1)\n" + " -r --tsrr : Enable/Disable the round-robin on TS domain (under dev.). (default: Disabled)\n" + " -l --treel : Tree used for low level reduction inside nodes (default: -1).\n" + " -L --treeh : Tree used for high level reduction between nodes, only if qr_p > 1 (default: -1).\n" + " (0: Flat, 1: Greedy, 2: Fibonacci, 3: Binary, 4: Replicated greedy)\n" + "\n" + " -x --check : verify the results\n" + " -v --verbose : extra verbose output\n" + " -h --help : this message\n" + "\n" + ); +} + +#define GETOPT_STRING "M:N:P:Q:c:a:p:d::rl:L:xv::h" +#if defined(LIBHQR_HAVE_GETOPT_LONG) +static struct option long_options[] = +{ + /* Generic Options */ + {"M", required_argument, 0, 'M'}, + {"N", required_argument, 0, 'N'}, + {"grid-rows", required_argument, 0, 'P'}, + {"P", required_argument, 0, 'P'}, + {"grid-cols", required_argument, 0, 'Q'}, + {"Q", required_argument, 0, 'Q'}, + {"c", required_argument, 0, 'c'}, + {"cores", required_argument, 0, 'c'}, + + /* HQR options */ + {"a", required_argument, 0, 'a'}, + {"qr_a", required_argument, 0, 'a'}, + {"p", required_argument, 0, 'p'}, + {"qr_p", required_argument, 0, 'p'}, + {"d", optional_argument, 0, 'd'}, + {"domino", optional_argument, 0, 'd'}, + {"r", no_argument, 0, 'r'}, + {"tsrr", no_argument, 0, 'r'}, + {"l", required_argument, 0, 'l'}, + {"treel", required_argument, 0, 'l'}, + {"L", required_argument, 0, 'L'}, + {"treeh", required_argument, 0, 'L'}, + + /* Auxiliary options */ + {"check", no_argument, 0, 'x'}, + {"x", no_argument, 0, 'x'}, + {"verbose", optional_argument, 0, 'v'}, + {"v", optional_argument, 0, 'v'}, + {"help", no_argument, 0, 'h'}, + {"h", no_argument, 0, 'h'}, + {0, 0, 0, 0} +}; +#endif /* defined(LIBHQR_HAVE_GETOPT_LONG) */ + +/** + * @brief Set default values + */ +static void +iparam_default(int *iparam) +{ + /* Just in case someone forget to add the initialization :) */ + memset(iparam, 0, IPARAM_SIZEOF * sizeof(int)); + iparam[IPARAM_NNODES] = 1; + iparam[IPARAM_NCORES] = 1; + iparam[IPARAM_P] = 1; + iparam[IPARAM_Q] = 1; + iparam[IPARAM_MT] = -'N'; + iparam[IPARAM_NT] = 1; + iparam[IPARAM_CHECK] = 0; + iparam[IPARAM_VERBOSE] = 0; + iparam[IPARAM_LOWLVL_TREE] = -1; + iparam[IPARAM_HIGHLVL_TREE] = -1; + iparam[IPARAM_QR_TS_SZE] = -1; + iparam[IPARAM_QR_HLVL_SZE] = -'P'; + iparam[IPARAM_QR_DOMINO] = -1; + iparam[IPARAM_QR_TSRR] = 0; +} + +/** + * @brief Parse options + */ +void +parse_arguments(int *_argc, char ***_argv, int *iparam) +{ + int opt = 0; + int c; + int argc = *_argc; + char **argv = *_argv; + + iparam_default( iparam ); + + do { +#if defined(LIBHQR_HAVE_GETOPT_LONG) + c = getopt_long_only(argc, argv, "", + long_options, &opt); +#else + c = getopt(argc, argv, GETOPT_STRING); + (void) opt; +#endif /* defined(LIBHQR_HAVE_GETOPT_LONG) */ + + switch(c) + { + case 'c': iparam[IPARAM_NCORES] = atoi(optarg); break; + case 'P': iparam[IPARAM_P] = atoi(optarg); break; + case 'Q': iparam[IPARAM_Q] = atoi(optarg); break; + case 'M': iparam[IPARAM_MT] = atoi(optarg); break; + case 'N': iparam[IPARAM_NT] = atoi(optarg); break; + case 'x': iparam[IPARAM_CHECK] = 1; iparam[IPARAM_VERBOSE] = max(2, iparam[IPARAM_VERBOSE]); break; + + /* HQR parameters */ + case 'a': iparam[IPARAM_QR_TS_SZE] = atoi(optarg); break; + case 'p': iparam[IPARAM_QR_HLVL_SZE] = atoi(optarg); break; + case 'd': iparam[IPARAM_QR_DOMINO] = atoi(optarg) ? 1 : 0; break; + case 'r': iparam[IPARAM_QR_TSRR] = 1; break; + case 'l': iparam[IPARAM_LOWLVL_TREE] = atoi(optarg); break; + case 'L': iparam[IPARAM_HIGHLVL_TREE] = atoi(optarg); break; + + case 'v': + if(optarg) iparam[IPARAM_VERBOSE] = atoi(optarg); + else iparam[IPARAM_VERBOSE] = 2; + break; + + case 'h': print_usage(); exit(0); + case '?': /* getopt_long already printed an error message. */ + exit(1); + default: + break; /* Assume anything else is parsec/mpi stuff */ + } + } while(-1 != c); + + if(-'N' == iparam[IPARAM_MT]) iparam[IPARAM_MT] = iparam[IPARAM_NT]; + if(-'P' == iparam[IPARAM_QR_HLVL_SZE]) iparam[IPARAM_QR_HLVL_SZE] = iparam[IPARAM_P]; + if(-'Q' == iparam[IPARAM_QR_HLVL_SZE]) iparam[IPARAM_QR_HLVL_SZE] = iparam[IPARAM_Q]; + + iparam[IPARAM_NNODES] = iparam[IPARAM_P] * iparam[IPARAM_Q]; +} + +/* +static void +print_arguments(int* iparam) +{ + int verbose = iparam[IPARAM_RANK] ? 0 : iparam[IPARAM_VERBOSE]; + + if(verbose) + fprintf(stderr, "#+++++ cores detected : %d\n", iparam[IPARAM_NCORES]); + + if(verbose > 1) fprintf(stderr, "#+++++ nodes x cores + gpu : %d x %d + %d (%d+%d)\n" + "#+++++ P x Q : %d x %d (%d/%d)\n", + iparam[IPARAM_NNODES], + iparam[IPARAM_NCORES], + iparam[IPARAM_NGPUS], + iparam[IPARAM_NNODES] * iparam[IPARAM_NCORES], + iparam[IPARAM_NNODES] * iparam[IPARAM_NGPUS], + iparam[IPARAM_P], iparam[IPARAM_Q], + iparam[IPARAM_Q] * iparam[IPARAM_P], iparam[IPARAM_NNODES]); + + if(verbose) + { + fprintf(stderr, "#+++++ M x N x K|NRHS : %d x %d x %d\n", + iparam[IPARAM_M], iparam[IPARAM_N], iparam[IPARAM_K]); + } + + if(verbose > 2) + { + if(iparam[IPARAM_LDB] && iparam[IPARAM_LDC]) + fprintf(stderr, "#+++++ LDA , LDB , LDC : %d , %d , %d\n", iparam[IPARAM_LDA], iparam[IPARAM_LDB], iparam[IPARAM_LDC]); + else if(iparam[IPARAM_LDB]) + fprintf(stderr, "#+++++ LDA , LDB : %d , %d\n", iparam[IPARAM_LDA], iparam[IPARAM_LDB]); + else + fprintf(stderr, "#+++++ LDA : %d\n", iparam[IPARAM_LDA]); + } + + if(verbose) + { + if(iparam[IPARAM_IB] > 0) + fprintf(stderr, "#+++++ MB x NB , IB : %d x %d , %d\n", + iparam[IPARAM_MB], iparam[IPARAM_NB], iparam[IPARAM_IB]); + else + fprintf(stderr, "#+++++ MB x NB : %d x %d\n", + iparam[IPARAM_MB], iparam[IPARAM_NB]); + if(iparam[IPARAM_SNB] * iparam[IPARAM_SMB] != 1) + fprintf(stderr, "#+++++ SMB x SNB : %d x %d\n", iparam[IPARAM_SMB], iparam[IPARAM_SNB]); + if((iparam[IPARAM_HNB] != iparam[IPARAM_NB]) || (iparam[IPARAM_HMB] != iparam[IPARAM_MB])) + fprintf(stderr, "#+++++ HMB x HNB : %d x %d\n", iparam[IPARAM_HMB], iparam[IPARAM_HNB]); + } +} + */ diff --git a/testings/common.h b/testings/common.h new file mode 100644 index 0000000000000000000000000000000000000000..72dad3d246fa3b8cb8cb45c12d0a1693874d9d47 --- /dev/null +++ b/testings/common.h @@ -0,0 +1,58 @@ +/** + * + * @file common.h + * + * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * @version 0.1.0 + * @author Mathieu Faverge + * @date 2017-04-27 + * + */ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +/** + * @brief List of integer options + */ +typedef enum iparam_e { + IPARAM_NNODES, /**< Number of nodes */ + IPARAM_NCORES, /**< Number of cores */ + IPARAM_P, /**< Rows in the process grid */ + IPARAM_Q, /**< Columns in the process grid */ + IPARAM_MT, /**< Number of tile rows of the matrix */ + IPARAM_NT, /**< Number of tile columns of the matrix */ + IPARAM_CHECK, /**< Checking activated or not */ + IPARAM_VERBOSE, /**< How much noise do we want? */ + IPARAM_LOWLVL_TREE, /**< Tree used for reduction inside nodes */ + IPARAM_HIGHLVL_TREE, /**< Tree used for reduction between nodes */ + IPARAM_QR_TS_SZE, /**< Size of TS domain */ + IPARAM_QR_HLVL_SZE, /**< Size of the high level tree */ + IPARAM_QR_DOMINO, /**< Enable/disable the domino tree */ + IPARAM_QR_TSRR, /**< Enable/disable the round-robin on TS domain */ + IPARAM_SIZEOF /**< Size of the parameter array */ +} iparam_e; + +#define PASTE_CODE_IPARAM_LOCALS(iparam) \ + int nodes = iparam[IPARAM_NNODES]; \ + int cores = iparam[IPARAM_NCORES]; \ + int P = iparam[IPARAM_P]; \ + int Q = iparam[IPARAM_Q]; \ + int MT = iparam[IPARAM_MT]; \ + int NT = iparam[IPARAM_NT]; \ + int check = iparam[IPARAM_CHECK]; \ + int loud = iparam[IPARAM_VERBOSE]; \ + int llvl = iparam[IPARAM_LOWLVL_TREE]; \ + int hlvl = iparam[IPARAM_HIGHLVL_TREE]; \ + int qr_a = iparam[IPARAM_QR_TS_SZE]; \ + int qr_p = iparam[IPARAM_QR_HLVL_SZE]; \ + int domino= iparam[IPARAM_QR_DOMINO]; \ + int tsrr = iparam[IPARAM_QR_TSRR]; \ + (void)nodes;(void)cores;(void)P;(void)Q;(void)MT;(void)NT; \ + (void)llvl;(void)hlvl;(void)qr_a;(void)qr_p;(void)domino;(void)tsrr;\ + (void)loud;(void)check; + +void parse_arguments(int *_argc, char ***_argv, int *iparam); + +#endif /* _COMMON_H_ */ diff --git a/testings/draw_hqr.c b/testings/draw_hqr.c new file mode 100644 index 0000000000000000000000000000000000000000..7a515c39ee116e4458b64bba32bfdd3569feb43d --- /dev/null +++ b/testings/draw_hqr.c @@ -0,0 +1,44 @@ +/** + * + * @file drawhqr.c + * + * Binary to draw hierarchical trees. + * + * @copyright 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-04-04 + * + */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <libhqr.h> +#include <libhqr_draw.h> +#include "common.h" + +int +main(int argc, char ** argv) +{ + libhqr_tree_t qrtree; + libhqr_tiledesc_t matrix; + int iparam[IPARAM_SIZEOF]; + + /* Get options */ + parse_arguments( &argc, &argv, iparam ); + PASTE_CODE_IPARAM_LOCALS( iparam ); + + 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 ); + libhqr_print_tree( &qrtree, &matrix ); + libhqr_hqr_finalize( &qrtree ); + + return 1; +} diff --git a/testings/draw_systolic.c b/testings/draw_systolic.c new file mode 100644 index 0000000000000000000000000000000000000000..08a24aa14543bc3383afd28cbcb46688ed690cf5 --- /dev/null +++ b/testings/draw_systolic.c @@ -0,0 +1,44 @@ +/** + * + * @file drawsystolic.c + * + * Binary to draw systolic trees. + * + * @copyright 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-04-04 + * + */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <libhqr.h> +#include <libhqr_draw.h> +#include "common.h" + +int +main(int argc, char ** argv) +{ + libhqr_tree_t qrtree; + libhqr_tiledesc_t matrix; + int iparam[IPARAM_SIZEOF]; + + /* Get options */ + parse_arguments( &argc, &argv, iparam ); + PASTE_CODE_IPARAM_LOCALS( iparam ); + + matrix.nodes = nodes; + matrix.p = P; + matrix.mt = MT; + matrix.nt = NT; + + libhqr_systolic_init( &qrtree, LIBHQR_QR, &matrix, P, Q ); + libhqr_print_tree( &qrtree, &matrix ); + libhqr_systolic_finalize( &qrtree ); + + return 1; +} diff --git a/testings/testing_hqr.c b/testings/testing_hqr.c new file mode 100644 index 0000000000000000000000000000000000000000..e13f5529a5675f7e76954b932ff8bb92070c4064 --- /dev/null +++ b/testings/testing_hqr.c @@ -0,0 +1,204 @@ +/** + * + * @file testing_hqr.c + * + * Testing file for all combinations of hierarchical QR 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 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 + */ + 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 ) { + printf("\n"); + 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 3b805735395defff14c665540cc4f458a6c0f216..0000000000000000000000000000000000000000 --- a/testings/testing_pivgen.c +++ /dev/null @@ -1,165 +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 "libhqr.h" -#include <stdlib.h> -#include <stdio.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; - } -} diff --git a/testings/testing_systolic.c b/testings/testing_systolic.c new file mode 100644 index 0000000000000000000000000000000000000000..e39173f56ea2c4b40b9946b97e971993d9bcbdba --- /dev/null +++ b/testings/testing_systolic.c @@ -0,0 +1,122 @@ +/** + * + * @file testing_systolic.c + * + * Testing file for all combinations of systolic 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_qr_p[] = { 1, 3, 5, 7, 8 }; + int all_qr_q[] = { 1, 2, 4, 6, 7 }; + int all_mt[] = { 1, 3, 4, 10, 17, 25, 128 }; + int all_nt[] = { 1, 2, 5, 13, 26, 58 }; + + int nb_qr_p = sizeof( all_qr_p ) / sizeof( int ); + int nb_qr_q = sizeof( all_qr_q ) / sizeof( int ); + int nb_mt = sizeof( all_mt ) / sizeof( int ); + int nb_nt = sizeof( all_nt ) / sizeof( int ); + + int qrp, qrq, m, n; + int done, todo; + todo = 0; + done = 0; + + todo += nb_mt * nb_nt * nb_qr_q * nb_qr_p; + + /* P */ + for( qrp=0; qrp<nb_qr_p; qrp++) { + P = all_qr_p[qrp]; + matrix.p = P; + + /* Q */ + for( qrq=0; qrq<nb_qr_q; qrq++) { + Q = all_qr_q[qrq]; + matrix.nodes = P * Q; + + /* 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; + + libhqr_systolic_init( &qrtree, LIBHQR_QR, &matrix, P, Q ); + rc = libhqr_tree_check( &matrix, &qrtree ); + libhqr_matrix_finalize( &qrtree ); + + if (rc != 0) { + fprintf(stderr, "%s -M %d -N %d --qr_p=%d --qr_a=%d FAILED(%d)\n", + argv[0], MT, NT, P, Q, 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_systolic_init( &qrtree, LIBHQR_QR, &matrix, + qr_p, qr_a ); + + rc = libhqr_tree_check( &matrix, &qrtree ); + libhqr_matrix_finalize( &qrtree ); + + if (rc != 0) { + fprintf(stderr, "%s -M %d -N %d --qr_p=%d --qr_a=%d FAILED(%d)\n", + argv[0], MT, NT, qr_p, qr_a, rc); + ret |= 1; + } + } + + if ( ret == 0 ) { + printf("\n"); + return EXIT_SUCCESS; + } + else { + fprintf(stderr, "ret = %d\n", ret); + return EXIT_FAILURE; + } +} diff --git a/testings/testing_tileinit.c b/testings/testing_tileinit.c index 895aa63781f4c5a173e1c8b0f688f60a2b981bc5..e2cccd2adf3ed2c73f459acce53d54f4dcce740b 100644 --- a/testings/testing_tileinit.c +++ b/testings/testing_tileinit.c @@ -1,6 +1,6 @@ /** * - * @file testting_tileinit.c + * @file testing_tileinit.c * * Testing file for the functions stocking the informations of the tiles * @@ -13,8 +13,6 @@ * @date 2017-04-18 * */ - - #include <stdio.h> #include <string.h> #include <stdlib.h> diff --git a/testings/testing_treedraw.c b/testings/testing_treedraw.c deleted file mode 100644 index d37809f3e40a0746b76646a99cdf35f9991dc26c..0000000000000000000000000000000000000000 --- a/testings/testing_treedraw.c +++ /dev/null @@ -1,37 +0,0 @@ -/** - * - * @file testting_treedraw.c - * - * Testing file for drawing functions and drawing tree - * - * @copyright 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-04-04 - * - */ - - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include "libdraw.h" -#include "libhqr.h" - -int -main(int argc, char ** argv) -{ - libhqr_tree_t qrtree; - libhqr_tiledesc_t matrix; - matrix.nodes = 1; - matrix.p = 1; - matrix.mt = 16; - matrix.nt = 4; - libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, LIBHQR_BINARY_TREE, LIBHQR_FLAT_TREE, 1, 2, 0, 0); - libhqr_print_tree( &qrtree, &matrix); - libhqr_hqr_finalize( &qrtree ); - return 1; -}