diff --git a/include/libhqr.h b/include/libhqr.h index 49b3f427e67df9dd7edc78fedd81d26d06b8104a..c700df5b40239bba896df3a2f2a3a4e239233d14 100644 --- a/include/libhqr.h +++ b/include/libhqr.h @@ -64,6 +64,14 @@ typedef struct libhqr_tiledesc_s{ int p; } libhqr_tiledesc_t; + +typedef struct libhqr_file_tile_s{ + struct libhqr_file_tile_s *prev; + struct libhqr_file_tile_s *next; + int numero; +}libhqr_file_tile_t; + + struct libhqr_tree_s; typedef struct libhqr_tree_s libhqr_tree_t; @@ -168,6 +176,18 @@ int libhqr_hqr_init( libhqr_tree_t *qrtree, int a, int p, int domino, int tsrr ); void libhqr_hqr_finalize( libhqr_tree_t *qrtree ); + + + +/* + * functions for manipulate file + */ + +libhqr_file_tile_t *libhqr_file_tile_new (void); +void libhqr_file_tile_post (libhqr_file_tile_t ** file_tile,int numero); +int libhqr_file_tile_get (libhqr_file_tile_t ** file_tile); +void libhqr_file_tile_delete (libhqr_file_tile_t ** file_tile); + /* * Debugging functions */ diff --git a/src/libhqr.c b/src/libhqr.c index 413a4caaebbd5640b1e4c48bdb5abafc73edce0b..36b4c8dc69b3aef07f51f02310274bca9e78c9d5 100644 --- a/src/libhqr.c +++ b/src/libhqr.c @@ -92,16 +92,19 @@ typedef struct hqr_args_s hqr_args_t; struct hqr_subpiv_s; typedef struct hqr_subpiv_s hqr_subpiv_t; +/** + * @brief jhj + */ struct hqr_args_s { - int domino; /* Switch to enable/disable the domino tree linking high and lw level reduction trees */ - int tsrr; /* Switch to enable/disable round-robin on TS to optimise pipelining between TS and local tree */ + int domino; /**< Switch to enable/disable the domino tree linking high and lw level reduction trees */ + int tsrr; /**< Switch to enable/disable round-robin on TS to optimise pipelining between TS and local tree */ hqr_subpiv_t *llvl; hqr_subpiv_t *hlvl; int *perm; }; struct hqr_subpiv_s { - /* + /** * currpiv * @param[in] arg pointer to the qr_piv structure * @param[in] k step in the factorization @@ -172,7 +175,6 @@ static void hqr_low_fibonacci_init(hqr_subpiv_t *arg, int minMN); * k - Step k of the QR factorization * */ - #define nbextra1_formula ( (k % pa) > (pa - p) ) ? (-k)%pa + pa : 0 /* @@ -1711,16 +1713,15 @@ hqr_getinvperm( const libhqr_tree_t *qrtree, int k, int m ) * ******************************************************************************* * - * @param[in,out] qrtree + * @param[inout] qrtree * On entry, an allocated structure uninitialized. * On exit, the structure initialized according to the parameter given. * * @param[in] trans - * @arg PlasmaNoTrans: Structure is initialized for QR factorization. - * @arg PlasmaTrans: Structure is initialized for LQ factorization. - * @arg PlasmaConjTrans: Structure is initialized for LQ factorization. + * @arg QR: Structure is initialized for QR factorization. + * @arg LQ: Structure is initialized for LQ factorization. * - * @param[in,out] A + * @param[in] A * Descriptor of the distributed matrix A to be factorized, on which * QR/LQ factorization will be performed. * The descriptor is untouched and only mt/nt/P parameters are used. @@ -1790,26 +1791,21 @@ hqr_getinvperm( const libhqr_tree_t *qrtree, int k, int m ) * ******************************************************************************* * - * @return - * \retval -i if the ith parameters is incorrect. - * \retval 0 on success. + * @retval -i if the ith parameters is incorrect. + * @retval 0 on success. * ******************************************************************************* * * @sa libhqr_hqr_finalize * @sa libhqr_systolic_init - * @sa dplasma_zgeqrf_param - * @sa dplasma_cgeqrf_param - * @sa dplasma_dgeqrf_param - * @sa dplasma_sgeqrf_param * ******************************************************************************/ int libhqr_hqr_init( libhqr_tree_t *qrtree, - libhqr_typefacto_e trans, libhqr_tiledesc_t *A, - int type_llvl, int type_hlvl, - int a, int p, - int domino, int tsrr ) + libhqr_typefacto_e trans, libhqr_tiledesc_t *A, + int type_llvl, int type_hlvl, + int a, int p, + int domino, int tsrr ) { double ratio = 0.0; int low_mt, minMN; @@ -2555,7 +2551,7 @@ svd_prevpiv(const libhqr_tree_t *qrtree, int k, int pivot, int start) /** ******************************************************************************* * - * @ingroup dplasma + * @ingroup libhqr * * libhqr_svd_init - Create the tree structures that will describes the * operation performed during QR/LQ reduction step of the gebrd_ge2gb operation. @@ -2738,3 +2734,4 @@ libhqr_svd_init( libhqr_tree_t *qrtree, return 0; } + diff --git a/src/treewalk.c b/src/treewalk.c new file mode 100644 index 0000000000000000000000000000000000000000..379072d84c840efd2f73774e25586f4acd6df8aa --- /dev/null +++ b/src/treewalk.c @@ -0,0 +1,168 @@ +#include "libhqr.h" +#include <assert.h> +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +//#if defined(LIBHQR_HAVE_STRING_H) +#include <string.h> +//#endif /* defined(PARSEC_HAVE_STRING_H) */ +#define PRINT_PIVGEN 0 +#ifdef PRINT_PIVGEN +#define myassert( test ) {if ( ! (test) ) return -1;} +#else +#define myassert(test) {assert((test)); return -1;} +#endif + + +/**************************************************** + * + * Generic functions for file + * + ***************************************************/ + + +static void libhqr_file_tile_first (libhqr_file_tile_t ** file_tile); +static void libhqr_file_tile_last (libhqr_file_tile_t ** file_tile); +static void libhqr_file_tile_prev (libhqr_file_tile_t ** file_tile); +static void libhqr_file_tile_next (libhqr_file_tile_t ** file_tile); + +libhqr_file_tile_t *libhqr_file_tile_new (void) +{ + return (NULL); +} + +static void libhqr_file_tile_first (libhqr_file_tile_t ** file_tile) +{ + if (file_tile != NULL && *file_tile != NULL) + { + while ((*file_tile)->prev != NULL) + libhqr_file_tile_prev (file_tile); + } + return; +} + +static void libhqr_file_tile_prev (libhqr_file_tile_t ** file_tile) +{ + if (file_tile != NULL && *file_tile != NULL) + *file_tile = (*file_tile)->prev; + return; +} + +static void libhqr_file_tile_last (libhqr_file_tile_t ** file_tile) +{ + if (file_tile != NULL && *file_tile != NULL) + { + while ((*file_tile)->next != NULL) + libhqr_file_tile_next (file_tile); + } + return; +} + +static void libhqr_file_tile_next (libhqr_file_tile_t ** file_tile) +{ + if (file_tile != NULL && *file_tile != NULL) + *file_tile = (*file_tile)->next; + return; +} + +void libhqr_file_tile_post (libhqr_file_tile_t ** file_tile, int numero) +{ + if (file_tile != NULL) + { + libhqr_file_tile_t *p_l = NULL; + libhqr_file_tile_t *p_p = NULL; + + libhqr_file_tile_first (file_tile); + p_l = *file_tile; + p_p = malloc (sizeof (*p_p)); + if (p_p != NULL) + { + p_p->numero = numero; + p_p->next = p_l; + p_p->prev = NULL; + if (p_l != NULL) + p_l->prev = p_p; + *file_tile = p_p; + } + else + { + fprintf (stderr, "Memoire insuffisante\n"); + exit (EXIT_FAILURE); + } + } + return; +} + +int libhqr_file_tile_get (libhqr_file_tile_t ** file_tile) +{ + int ret; + + if (file_tile != NULL && *file_tile != NULL) + { + libhqr_file_tile_t *p_l = NULL; + libhqr_file_tile_t *p_p = NULL; + + libhqr_file_tile_last (file_tile); + p_l = *file_tile; + if (p_l != NULL) + p_p = p_l->prev; + ret = p_l->numero; + free (p_l); + p_l = NULL; + if (p_p != NULL) + p_p->next = NULL; + *file_tile = p_p; + } + return (ret); +} + +void libhqr_file_tile_delete (libhqr_file_tile_t ** file_tile) +{ + if (file_tile != NULL && *file_tile != NULL) + { + while (*file_tile != NULL) + libhqr_file_tile_get (file_tile); + } + return; +} + +/**************************************************** + * + * fonctions pour parcourir arbre + * + ***************************************************/ + +void algo_parcour(libhqr_tree_t *qrtree,int k, void *func()){ + libhqr_file_tile_t **tt; + libhqr_file_tile_t **ts; + libhqr_file_tile_t *p_l = NULL; + libhqr_file_tile_t *p_p = NULL; + int pivot = qrtree->p; + int p = pivot; + while(p = qrtree->nextpiv(qrtree, k, pivot,p)){ + + while(p = qrtree->prevpiv(qrtree, k , pivot, p)){ + + if(qrtree->gettype(qrtree, k, p)) libhqr_file_tile_post(tt,p); + libhqr_file_tile_post(ts, p); + + } + libhqr_file_tile_last(ts); + p_l = *ts; + libhqr_file_tile_last(tt); + p_p = *tt; + int a = p_l->numero; + int b = p_p->numero; + while(a != b){ + libhqr_file_tile_get(ts); + libhqr_file_tile_last(ts); + p_l = *ts; + a = p_l->numero; + } + libhqr_file_tile_get(tt); + } + libhqr_file_tile_delete(tt); + libhqr_file_tile_delete(ts); +} + +