From 8d2048a3e5a4d9f15107909d50e0cc8c0f70e51c Mon Sep 17 00:00:00 2001
From: Raphael Boucherie <rboucher@zimbra.inria.fr>
Date: Wed, 5 Apr 2017 14:43:22 +0200
Subject: [PATCH] fixed commentary, added common header

---
 Makefile                    |  14 +++--
 include/common.h            |  34 ++++++++++++
 include/common.h~           |  32 +++++++++++
 include/libhqr.h            |  77 +++++++++++--------------
 include/queue.h             |  37 +++++-------
 src/libhqr.c                |  99 ++++++++++++++++++++++++++-------
 src/libhqr_dbg.c            |  40 ++++++-------
 src/libhqr_systolic.c       |  39 ++++++-------
 src/treewalk.c              | 108 +++++++++++++++---------------------
 testings/testing_pivgen.c   |  39 ++++++-------
 testings/testing_treewalk.c |  57 +++++++++----------
 11 files changed, 321 insertions(+), 255 deletions(-)
 create mode 100644 include/common.h
 create mode 100644 include/common.h~

diff --git a/Makefile b/Makefile
index 620948a..2fd1ed9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,12 @@
-testing_pivgen : 
-	gcc -Iinclude/ src/* testings/testing_pivgen.c -lm
+CC = gcc
+CFLAGS = -Iinclude/ src/*
+LDFLAGS = -lm
 
-testing_treewalk : 
-	gcc -Iinclude/ src/* testings/testing_treewalk.c -lm
+testing_pivgen :
+	$(CC) $(CFLAGS) testings/testing_pivgen.c $(LDFLAGS)
+
+testing_treewalk :
+	$(CC) $(CFLAGS) testings/testing_treewalk.c $(LDFLAGS)
 
 clean :
-	rm testing_pivgen testing_treewalk src/*~ testings/*~ include/*~
+	rm testing_pivgen testing_treewalk
diff --git a/include/common.h b/include/common.h
new file mode 100644
index 0000000..85138a0
--- /dev/null
+++ b/include/common.h
@@ -0,0 +1,34 @@
+/**
+ *
+ * @file common.h
+ *
+ * Header file for common maccro
+ *
+ * @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-04-05
+ *
+ */
+
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#undef BEGIN_C_DECLS
+#undef END_C_DECLS
+#if defined(c_plusplus) || defined(__cplusplus)
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else
+#define BEGIN_C_DECLS          /* empty */
+#define END_C_DECLS            /* empty */
+#endif
+
+#endif /* _COMMON_H_ */
diff --git a/include/common.h~ b/include/common.h~
new file mode 100644
index 0000000..76e747e
--- /dev/null
+++ b/include/common.h~
@@ -0,0 +1,32 @@
+/**
+ *
+ * @file common.h
+ *
+ * Header file for common maccro
+ *
+ * @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-04-05
+ *
+ */
+
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#undef BEGIN_C_DECLS
+#undef END_C_DECLS
+#if defined(c_plusplus) || defined(__cplusplus)
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else
+#define BEGIN_C_DECLS          /* empty */
+#define END_C_DECLS            /* empty */
+#endif
diff --git a/include/libhqr.h b/include/libhqr.h
index c1aedcc..3be90ed 100644
--- a/include/libhqr.h
+++ b/include/libhqr.h
@@ -1,48 +1,37 @@
 /**
-  *
-  * @file libhqr.h
-  *
-  * PaStiX symbol structure routines
-  *
-  * @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
-  *
-  **/
+ *
+ * @file libhqr.h
+ *
+ * @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 "common.h"
 
 #ifndef _LIBHQR_H_
 #define _LIBHQR_H_
 
-#undef BEGIN_C_DECLS
-#undef END_C_DECLS
-#if defined(c_plusplus) || defined(__cplusplus)
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else
-#define BEGIN_C_DECLS          /* empty */
-#define END_C_DECLS            /* empty */
-#endif
-
 BEGIN_C_DECLS
 
 static inline int libhqr_imin(int a, int b){
-  return (a > b) ? b : a;
+    return (a > b) ? b : a;
 }
 
 static inline int libhqr_imax(int a, int b){
-  return (a > b) ? a : b;
+    return (a > b) ? a : b;
 }
 
 static inline int libhqr_iceil(int a, int b){
-  return (a + b - 1) / b;
+    return (a + b - 1) / b;
 }
 
 /**
@@ -85,18 +74,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,
+    LIBHQR_LQ = 1,
 } 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;
 
 struct libhqr_tree_s;
@@ -186,18 +175,18 @@ struct libhqr_tree_s {
 };
 
 int  libhqr_systolic_init( libhqr_tree_t *qrtree,
-			    libhqr_typefacto_e trans, libhqr_tiledesc_t *A,
-			    int p, int q );
+                           libhqr_typefacto_e trans, libhqr_tiledesc_t *A,
+                           int p, int q );
 void libhqr_systolic_finalize( libhqr_tree_t *qrtree );
 
 int  libhqr_svd_init( libhqr_tree_t *qrtree,
-		       libhqr_typefacto_e trans, libhqr_tiledesc_t *A,
-		       int type_hlvl, int p, int nbcores_per_node, int ratio );
+                      libhqr_typefacto_e trans, libhqr_tiledesc_t *A,
+                      int type_hlvl, int p, int nbcores_per_node, int ratio );
 
 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 );
 void libhqr_hqr_finalize( libhqr_tree_t *qrtree );
 
 /*
diff --git a/include/queue.h b/include/queue.h
index ebd2fd3..2b18e11 100644
--- a/include/queue.h
+++ b/include/queue.h
@@ -1,32 +1,21 @@
 /**
-  *
-  * @file queue.h
-  *
-  * PaStiX symbol structure routines
-  *
-  * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
-  *                      Univ. Bordeaux. All rights reserved.
-  *
-  * @version 1.0.0
-  * @author Raphael Boucherie
-  * @author Matthieu Faverge
-  * @date 2017-03-21
-  *
-  **/
+ *
+ * @file queue.h
+ *
+ * @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 "common.h"
 
 #ifndef _QUEUE_H_
 #define _QUEUE_H_
 
-#undef BEGIN_C_DECLS
-#undef END_C_DECLS
-#if defined(c_plusplus) || defined(__cplusplus)
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else
-#define BEGIN_C_DECLS          /* empty */
-#define END_C_DECLS            /* empty */
-#endif
-
 BEGIN_C_DECLS
 
 typedef struct libhqr_queue_tile_s{
diff --git a/src/libhqr.c b/src/libhqr.c
index a5df560..434bf2f 100644
--- a/src/libhqr.c
+++ b/src/libhqr.c
@@ -1,31 +1,88 @@
 /**
-  *
-  * @file libhqr.c
-  *
-  * PaStiX symbol structure routines
-  *
-  * Copyright (c) 2010      The University of Tennessee and The University
-  *                         of Tennessee Research Foundation.  All rights
-  *                         reserved.
-  *
-  * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
-  *                      Univ. Bordeaux. All rights reserved.
-  *
-  * @version 1.0.0
-  * @author Raphael Boucherie
-  * @author Matthieu Faverge
-  * @date 2017-03-21
-  *
-  **/
-
+ *
+ * @file libhqr.c
+ *
+ * @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
+ *
+ * This file contains all the function to describe the dependencies
+ * used in the Xgeqrf_param.jdf file.
+ * The QR factorization done with this file relies on three levels:
+ *     - the first one is using a flat tree with TS kernels. The
+ *       height of this tree is defined by the parameter 'a'. If 'a'
+ *       is set to A->mt, the factorization is identical to the one
+ *       perform by PLASMA_zgeqrf.
+ *       For all subdiagonal "macro-tiles", the line reduced is always
+ *       the first.  For all diagonal "macro-tiles", the factorization
+ *       performed is identical to the one performed by PLASMA_zgeqrf.
+ *
+ *     - the third level is using a reduction tree of size 'p'. By
+ *       default, the parameter 'p' should be equal to the number of
+ *       processors used for the computation, but can be set
+ *       differently. (see further example). The type of tree used at
+ *       this level is defined by the hlvl parameter. It can be flat
+ *       or greedy.
+ *       CODE DETAILS: This tree and all the function related to it
+ *       are performing a QR factorization on a band matrix with 'p'
+ *       the size of the band. All the functions take global indices
+ *       as input and return global indices as output.
+ *
+ *     - Finally, a second 'low' level of reduction tree is applied.
+ *       The size of this tree is induced by the parameters 'a' and 'p'
+ *       from the first and third levels and is A->mt / ( p * a ). This
+ *       tree is reproduced p times for each subset of tiles
+ *       S_k = {i in [0, A->mt-1] \ i%p*a = k } with k in [0, p-1].
+ *       The tree used for the reduction is defined by the llvl
+ *       parameter and can be: flat, greedy, fibonacci or binary.
+ *       CODE DETAILS: For commodity, the size of this tree is always
+ *       ceil(A->mt / (p * a) ) inducing some extra tests in the code.
+ *       All the functions related to this level of tree take as input
+ *       the local indices in the A->mt / (p*a) matrix and the global
+ *       k. They return the local index. The reductions are so
+ *       performed on a trapezoidal matrices where the step is defined
+ *       by a:
+ *                                    <- min( lhlvl_mt, min( mt, nt ) ) ->
+ *                                     __a__   a     a
+ *                                    |     |_____
+ *                                    |           |_____
+ *                                    |                 |_____
+ *        llvl_mt = ceil(MT/ (a*p))   |                       |_____
+ *                                    |                             |_____
+ *                                    |___________________________________|
+ *
+ *
+ *
+ *   At each step of the factorization, the lines of tiles are divided
+ *   in 4 types:
+ *     - QRPARAM_TILE_TS: They are the lines annihilated by a TS
+ *     kernel, these lines are never used as an annihilator.  They are
+ *     the lines i, with 1 < (i/p)%a < a and i > (k+1)*p
+ *     - QRPARAM_TILE_LOCALTT: They are the lines used as annhilitor
+ *     in the TS kernels annihiling the QRPARAM_TILE_TS lines.  They
+ *     are themselves annihilated by the TT kernel of the low level
+ *     reduction tree.  The roots of the local trees are the lines i,
+ *     with i/p = k.
+ *     - QRPARAM_TILE_DOMINO: These are the lines that are
+ *     annhilihated with a domino effect in the band defined by (i/p)
+ *     <= k and i >= k
+ *     - QRPARAM_TILE_DISTTT: These are the lines annihilated by the
+ *     high level tree to reduce communications.
+ *     These lines are defined by (i-k)/p = 0.
+ */
 #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
diff --git a/src/libhqr_dbg.c b/src/libhqr_dbg.c
index 05ff4b7..85e8f27 100644
--- a/src/libhqr_dbg.c
+++ b/src/libhqr_dbg.c
@@ -1,32 +1,26 @@
 /**
-  *
-  * @file libhqr_dbg.c
-  *
-  * PaStiX symbol structure routines
-  *
-  * Copyright (c) 2010      The University of Tennessee and The University
-  *                         of Tennessee Research Foundation.  All rights
-  *                         reserved.
-  *
-  * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
-  *                      Univ. Bordeaux. All rights reserved.
-  *
-  * @version 1.0.0
-  * @author Raphael Boucherie
-  * @author Matthieu Faverge
-  * @date 2017-03-21
-  *
-  **/
-
+ *
+ * @file libhqr_dbg.c
+ *
+ * @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 Matthieu Faverge
+ * @date 2017-03-21
+ *
+ */
 #include "libhqr.h"
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-//#if defined(LIBHQR_HAVE_STRING_H)
 #include <string.h>
-//#endif  /* defined(LIBHQR_HAVE_STRING_H) */
 
-/* static int dplasma_qrtree_getinon0( const qr_piv_t *arg,  */
+/* static int libhqr_qrtree_getinon0( const qr_piv_t *arg,  */
 /*                                 const int k, int i, int mt ); */
 
 #define ENDCHECK( test, ret )                   \
diff --git a/src/libhqr_systolic.c b/src/libhqr_systolic.c
index 6313fc4..66153a3 100644
--- a/src/libhqr_systolic.c
+++ b/src/libhqr_systolic.c
@@ -1,31 +1,24 @@
 /**
-  *
-  * @file libhqr_systolic.c
-  *
-  * PaStiX symbol structure routines
-  *
-  * Copyright (c) 2010      The University of Tennessee and The University
-  *                         of Tennessee Research Foundation.  All rights
-  *                         reserved.
-  *
-  * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
-  *                      Univ. Bordeaux. All rights reserved.
-  *
-  * @version 1.0.0
-  * @author Raphael Boucherie
-  * @author Matthieu Faverge
-  * @date 2017-03-21
-  *
-  **/
-
+ *
+ * @file libhqr_systolic.c
+ *
+ * @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 <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-//#if defined(LIBHQR_HAVE_STRING_H)
-#include <string.h>
-//#endif  /* defined(LIBHQR_HAVE_STRING_H) */
 
 #define PRINT_PIVGEN 0
 #ifdef PRINT_PIVGEN
diff --git a/src/treewalk.c b/src/treewalk.c
index de909c4..2618310 100644
--- a/src/treewalk.c
+++ b/src/treewalk.c
@@ -1,37 +1,22 @@
 /**
-  *
-  * @file treewalk.c
-  *
-  * PaStiX symbol structure routines
-  *
-  * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
-  *                      Univ. Bordeaux. All rights reserved.
-  *
-  * @version 1.0.0
-  * @author Raphael Boucherie
-  * @author Matthieu Faverge
-  * @date 2017-03-21
-  *
-  **/
-
-
+ *
+ * @file treewalk.c
+ *
+ * File for queue functions, and algorithm of treewalking.
+ *
+ * @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-03-21
+ *
+ */
 #include "libhqr.h"
 #include "queue.h"
-#include <assert.h>
 #include <stdlib.h>
-#include <string.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 queue
@@ -47,7 +32,7 @@ void libhqr_queue_tile_first (libhqr_queue_tile_t ** queue_tile)
    if (queue_tile != NULL && *queue_tile != NULL)
    {
       while ((*queue_tile)->prev != NULL)
-	 libhqr_queue_tile_prev (queue_tile);
+         libhqr_queue_tile_prev (queue_tile);
    }
    return;
 }
@@ -64,7 +49,7 @@ void libhqr_queue_tile_last (libhqr_queue_tile_t ** queue_tile)
    if (queue_tile != NULL && *queue_tile != NULL)
    {
       while ((*queue_tile)->next != NULL)
-	 libhqr_queue_tile_next (queue_tile);
+         libhqr_queue_tile_next (queue_tile);
    }
    return;
 }
@@ -88,17 +73,17 @@ void libhqr_queue_tile_post (libhqr_queue_tile_t ** queue_tile, int numero)
       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;
-	 *queue_tile = p_p;
+         p_p->numero = numero;
+         p_p->next = p_l;
+         p_p->prev = NULL;
+         if (p_l != NULL)
+            p_l->prev = p_p;
+         *queue_tile = p_p;
       }
       else
       {
-	 fprintf (stderr, "Memoire insuffisante\n");
-	 exit (EXIT_FAILURE);
+         fprintf (stderr, "Memoire insuffisante\n");
+         exit (EXIT_FAILURE);
       }
    }
    return;
@@ -116,12 +101,12 @@ int libhqr_queue_tile_get (libhqr_queue_tile_t ** queue_tile)
       libhqr_queue_tile_last (queue_tile);
       p_l = *queue_tile;
       if (p_l != NULL)
-	 p_p = p_l->prev;
+         p_p = p_l->prev;
       ret = p_l->numero;
       free (p_l);
       p_l = NULL;
       if (p_p != NULL)
-	 p_p->next = NULL;
+         p_p->next = NULL;
       *queue_tile = p_p;
    }
    return (ret);
@@ -132,7 +117,7 @@ void libhqr_queue_tile_delete (libhqr_queue_tile_t ** queue_tile)
    if (queue_tile != NULL && *queue_tile != NULL)
    {
       while (*queue_tile != NULL)
-	 libhqr_queue_tile_get (queue_tile);
+         libhqr_queue_tile_get (queue_tile);
    }
    return;
 }
@@ -153,34 +138,33 @@ void libhqr_queue_tile_delete (libhqr_queue_tile_t ** queue_tile)
  */
 
 void libhqr_treewalk(const libhqr_tree_t *qrtree,int k){
-  int pivot = qrtree->mt;
-  printf("%d\n" , pivot);
-  int p = pivot;
+  int p = qrtree->mt;
+  printf("%d\n" , p);
+  int pivot = 0;
   printf("%d\n" , qrtree->nextpiv(qrtree, k, pivot, p));
   int a,b;
   libhqr_queue_tile_t *tt = libhqr_queue_tile_new();
   libhqr_queue_tile_t *ts = libhqr_queue_tile_new();
   while(p = qrtree->nextpiv(qrtree, k, pivot, p)){
-    while(p = qrtree->prevpiv(qrtree, k, pivot, p)){
-      printf("%d\n" , p);	  
-      if(qrtree->gettype(qrtree, k, p)){
-	libhqr_queue_tile_post(&tt,p);
+      while(p = qrtree->prevpiv(qrtree, k, pivot, p)){
+          if(qrtree->gettype(qrtree, k, p)){
+              libhqr_queue_tile_post(&tt,p);
+          }
+          libhqr_queue_tile_post(&ts, p);
       }
-      libhqr_queue_tile_post(&ts, p);
-    }
-    libhqr_queue_tile_last(&ts);
-    libhqr_queue_tile_last(&tt);
-    a = ts->numero;
-    printf("%d\n" , a);	  
-    b = tt->numero;
-    printf("%d\n" , b);
-    while(a != b){
-      libhqr_queue_tile_get(&ts);
       libhqr_queue_tile_last(&ts);
+      libhqr_queue_tile_last(&tt);
       a = ts->numero;
       printf("%d\n" , a);
-    }
-    libhqr_queue_tile_last(&tt);
-    libhqr_queue_tile_get(&tt);
+      b = tt->numero;
+      printf("%d\n" , b);
+      while(a != b){
+          libhqr_queue_tile_get(&ts);
+          libhqr_queue_tile_last(&ts);
+          a = ts->numero;
+          printf("%d\n" , a);
+      }
+      libhqr_queue_tile_last(&tt);
+      libhqr_queue_tile_get(&tt);
   }
 }
diff --git a/testings/testing_pivgen.c b/testings/testing_pivgen.c
index 90cabc3..3fa5add 100644
--- a/testings/testing_pivgen.c
+++ b/testings/testing_pivgen.c
@@ -1,28 +1,25 @@
 /**
-  *
-  * @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
-  *
-  **/
-
+ *
+ * @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>
-#include <string.h>
-#include <math.h>
 
 int main(int argc, char ** argv)
 {
diff --git a/testings/testing_treewalk.c b/testings/testing_treewalk.c
index 58dc610..8c9220b 100644
--- a/testings/testing_treewalk.c
+++ b/testings/testing_treewalk.c
@@ -2,48 +2,41 @@
  *
  * @file testing_treewalk.c
  *
- * PaStiX symbol structure routines
+ * Testing the treewalk algorithm using different kind of matrix
  *
- * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ * @copyright 2012-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
  *                      Univ. Bordeaux. All rights reserved.
  *
  * @version 1.0.0
  * @author Raphael Boucherie
- * @author Matthieu Faverge
+ * @author Mathieu Faverge
  * @date 2017-03-21
  *
- **/
-
-
+ */
 #include "libhqr.h"
 #include "queue.h"
-#include <stdlib.h>
 #include <stdio.h>
-#include <string.h>
-#include <math.h>
-
 
-
-int main(int argc, char ** argv)
+int
+main(int argc, char ** argv)
 {
-  libhqr_tree_t qrtree;
-  libhqr_tiledesc_t matrix;
-  int minMN, k, rc ;
-  /*
-   *
-   * Tests for HQR code
-   *
-   */
-  matrix.nodes = 1;
-  matrix.p = 1;
-  matrix.mt = 4;
-  matrix.nt = 13;
-  libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, 3 , 0, 2 , -1, 0, 0);
-  minMN = libhqr_imin(matrix.mt, matrix.nt );
-  rc = libhqr_tree_check( &matrix, &qrtree );
-  printf("%d\n", rc);
-  for (k=0; k<minMN; k++) {
-    libhqr_treewalk( &qrtree, k);
-  }
-  libhqr_hqr_finalize( &qrtree );
+    libhqr_tree_t qrtree;
+    libhqr_tiledesc_t matrix;
+    int minMN, k, rc ;
+
+    /*
+     * Test treewalk for HQR trees
+     */
+    matrix.nodes = 1;
+    matrix.p = 1;
+    matrix.mt = 4;
+    matrix.nt = 13;
+    libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, 3 , 0, 2 , -1, 0, 0);
+    minMN = libhqr_imin(matrix.mt, matrix.nt );
+    rc = libhqr_tree_check( &matrix, &qrtree );
+    printf("%d\n", rc);
+    for (k=0; k<minMN; k++) {
+        libhqr_treewalk( &qrtree, k);
+    }
+    libhqr_hqr_finalize( &qrtree );
 }
-- 
GitLab