Commit 07e8b3cc authored by Mathieu Faverge's avatar Mathieu Faverge

Add missing comments and remove perm field

parent c44bd18a
......@@ -56,11 +56,10 @@ typedef struct hqr_subpiv_s hqr_subpiv_t;
* @brief Argument structure to store the high and low level trees used in the hierarchical reduction tree
*/
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 */
hqr_subpiv_t *llvl;
hqr_subpiv_t *hlvl;
int *perm;
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; /**< Pointer to the low level tree data structure (shared memory) */
hqr_subpiv_t *hlvl; /**< Pointer to the high level tree data structure (distributed memory) */
};
struct hqr_subpiv_s {
......@@ -73,7 +72,7 @@ struct hqr_subpiv_s {
* @return the annihilator p used with m at step k
*/
int (*currpiv)(const hqr_subpiv_t *arg, int k, int m);
/*
/**
* nextpiv
* @param[in] arg pointer to the qr_piv structure
* @param[in] k step in the factorization
......@@ -85,7 +84,7 @@ struct hqr_subpiv_s {
* mt if p will never be used again as an annihilator.
*/
int (*nextpiv)(const hqr_subpiv_t *arg, int k, int p, int m);
/*
/**
* prevpiv
* @param[in] arg pointer to the qr_piv structure
* @param[in] k step in the factorization
......@@ -97,12 +96,12 @@ struct hqr_subpiv_s {
* mt if p has never been used before that as an annihilator.
*/
int (*prevpiv)(const hqr_subpiv_t *arg, int k, int p, int m);
int *ipiv;
int minMN;
int ldd;
int a;
int p;
int domino;
int *ipiv; /**< Pivot array for tree that uses pre-computed information */
int minMN; /**< Minimum tile numbers min(A->mt, A->nt) */
int ldd; /**< Leading dimension of the local subtree */
int a; /**< a parameter of the subtree to define the set of tiles killes by TS */
int p; /**< p parameter defining the number od distributed processes */
int domino; /**< domino switch to enable the domino tree in distributed */
};
/**
......@@ -129,24 +128,35 @@ typedef struct libhqr_tile_args_s {
step when it is not possible to compute them */
} libhqr_tile_args_t;
/**
* @brief Return the minimum of two integers
*/
static inline int libhqr_imin(int a, int b){
return (a > b) ? b : a;
}
/**
* @brief Return the maximum of two integers
*/
static inline int libhqr_imax(int a, int b){
return (a > b) ? a : b;
}
/**
* @brief Return ceil division of two integers
*/
static inline int libhqr_iceil(int a, int b){
return (a + b - 1) / b;
}
/* Number of extra tile of type 1 between the tile of type 3 and the first of nb11 */
/**
* @brief Number of extra tile of type 1 between the tile of type 3 and the first of nb11
*/
#define nbextra1_formula (( (k % pa) > (pa - p) ) ? (-k)%pa + pa : 0)
/*
* function for drawing the tree
/**
* @name Drawing functions
* @{
*/
void draw_rectangle(int k, int p, int m, int step_m, FILE *file);
void draw_lines(const libhqr_tree_t *qrtree, int k, int *tiles, int *step, FILE *file);
......@@ -154,6 +164,8 @@ void draw_horizontal_line(int k, int p, int m, int step_p, int step_m, FILE *fil
void draw_vertical_line( int k, int p, int m, int step_m, FILE *file);
/**
* @}
*
* @name Low level trees
* @{
*/
......@@ -177,9 +189,16 @@ void hqr_high_greedy_init ( hqr_subpiv_t *arg, int minMN );
void hqr_high_greedy1p_init ( hqr_subpiv_t *arg );
/**
* @}
*
* @name Matrix reduction trees
* @{
*/
void libhqr_fct_to_mtx( const libhqr_tree_t *in, libhqr_tree_t *out );
void libhqr_rdmtx_initfct( libhqr_tree_t *out );
/**
* @}
*/
#endif /* _libhqr_internal_h_ */
......@@ -29,8 +29,10 @@
char *colortree[] = {"red", "blue", "green", "orange", "cyan", "purple", "yellow" };
#define NBCOLORS (sizeof( colortree ) / sizeof( char* ))
/*
* functions writing in the svg file
/**
* @brief Write the svg header
* @param[in,out] file
* The opened file decriptor on which the data is written
*/
static void
drawsvg_header( FILE *file )
......@@ -48,6 +50,21 @@ drawsvg_header( FILE *file )
return;
}
/**
* @brief Write the box for the top node of a TS elimination
* @param[in,out] file
* The opened file decriptor on which the data is written
* @param[in] k
* The factorization step that defines the color.
* @param[in] x
* The abscissa coordinate of the node
* @param[in] y
* The ordinate coordinate of the node
* @param[in] w
* The width of the node
* @param[in] h
* The height of the node
*/
static void
drawsvg_top_TS( FILE *file, int k, int x, int y, int w, int h )
{
......@@ -60,6 +77,21 @@ drawsvg_top_TS( FILE *file, int k, int x, int y, int w, int h )
return;
}
/**
* @brief Write the box for the bottom node of a TS elimination
* @param[in,out] file
* The opened file decriptor on which the data is written
* @param[in] k
* The factorization step that defines the color.
* @param[in] x
* The abscissa coordinate of the node
* @param[in] y
* The ordinate coordinate of the node
* @param[in] w
* The width of the node
* @param[in] h
* The height of the node
*/
static void
drawsvg_bot_TS( FILE *file, int k, int x, int y, int w, int h )
{
......@@ -83,6 +115,21 @@ drawsvg_bot_TS( FILE *file, int k, int x, int y, int w, int h )
return;
}
/**
* @brief Write the circle for the top node of a TT elimination
* @param[in,out] file
* The opened file decriptor on which the data is written
* @param[in] k
* The factorization step that defines the color.
* @param[in] x
* The abscissa coordinate of the node
* @param[in] y
* The ordinate coordinate of the node
* @param[in] w
* The width of the node
* @param[in] h
* The height of the node
*/
static void
drawsvg_top_TT( FILE *file, int k, int x, int y, int w, int h )
{
......@@ -95,6 +142,21 @@ drawsvg_top_TT( FILE *file, int k, int x, int y, int w, int h )
return;
}
/**
* @brief Write the circle for the bottom node of a TT elimination
* @param[in,out] file
* The opened file decriptor on which the data is written
* @param[in] k
* The factorization step that defines the color.
* @param[in] x
* The abscissa coordinate of the node
* @param[in] y
* The ordinate coordinate of the node
* @param[in] w
* The width of the node
* @param[in] h
* The height of the node
*/
static void
drawsvg_bot_TT( FILE *file, int k, int x, int y, int w, int h )
{
......@@ -114,6 +176,21 @@ drawsvg_bot_TT( FILE *file, int k, int x, int y, int w, int h )
return;
}
/**
* @brief Write an svg line from (x1,y1) to (x2,y2)
* @param[in,out] file
* The opened file decriptor on which the data is written
* @param[in] k
* The factorization step that defines the color.
* @param[in] x1
* The abscissa coordinate of the origin node
* @param[in] y1
* The ordinate coordinate of the origin node
* @param[in] x2
* The abscissa coordinate of the destination node
* @param[in] y2
* The ordinate coordinate of the destination node
*/
static void
drawsvg_line( FILE *file, int k, int x1, int y1, int x2, int y2 )
{
......@@ -126,6 +203,11 @@ drawsvg_line( FILE *file, int k, int x1, int y1, int x2, int y2 )
return;
}
/**
* @brief Write the svg footer
* @param[in,out] file
* The opened file decriptor on which the data is written
*/
static void
drawsvg_footer( FILE *file )
{
......@@ -137,7 +219,23 @@ drawsvg_footer( FILE *file )
return;
}
/**
* @brief Draw the line corresponding to one TT/TS kernel
* @param[in,out] file
* The opened file decriptor on which the data is written
* @param[in] k
* The factorization step that defines the color.
* @param[in] p
* The index of the pivot
* @param[in] m
* The index of the tile being killed
* @param[in] beg_p
* The last modification date of p
* @param[in] beg_m
* The last modification date of m
* @param[in] end
* The computed end of the operation
*/
static void
drawsvg_lines_rowm( FILE *file, int k,
int p, int m, int beg_p, int beg_m, int end )
......@@ -164,6 +262,25 @@ drawsvg_lines_rowm( FILE *file, int k,
drawsvg_line( file, k, x, ym, x, yp );
}
/**
* @brief Draw all the lines related to a single step of the factorization
* @param[in] qrtree
* The reduction tree structure
* @param[in,out] file
* The opened file decriptor on which the data is written
* @param[in] full
* Defines if all the rows are involved in the process (tpqrt
* kernels), or only the lower triangular (geqrt kernels)
* @param[in] k
* The factorization step that defines the color.
* @param[in,out] tiles
* A temporary buffer of size qrtree->mt to store the list of tiles
* sorted by order of reduction
* @param[in,out] step
* A buffer of size qrtree->mt with the date of last modification
* for each tile. On exit, the dates are updated with the performed
* updates.
*/
static void
drawsvg_lines_stepk( const libhqr_tree_t *qrtree, FILE *file,
int full, int k, int *tiles, int *step )
......@@ -190,9 +307,24 @@ drawsvg_lines_stepk( const libhqr_tree_t *qrtree, FILE *file,
}
}
/**
* @brief Draw the two nodes related to one single reduction
* @param[in,out] file
* The opened file decriptor on which the data is written
* @param[in] k
* The factorization step that defines the color.
* @param[in] type
* The type of reduction performed in the libhqr_type_e
* @param[in] p
* The index of the pivot
* @param[in] m
* The index of the tile being killed
* @param[in] step_m
* The date at which the reduction occurs
*/
static void
drawsvg_nodes_rowm( FILE *file, int k,
int type, int p, int m, int step_m )
libhqr_type_e type, int p, int m, int step_m )
{
int x, yp, ym;
x = ((SIZE * 3) / 4) + SIZE * step_m;
......@@ -209,6 +341,13 @@ drawsvg_nodes_rowm( FILE *file, int k,
}
}
/**
* @brief Draw a given reduction tree in an output svg file
* @param[in] qrtree
* The reduction tree to draw
* @param[in] filename
* The output filename of the svg
*/
void
libhqr_print_svg( const libhqr_tree_t *qrtree,
const char *filename )
......
......@@ -89,10 +89,6 @@ static int hqr_getm( const libhqr_tree_t *qrtree, int k, int i );
static int hqr_geti( const libhqr_tree_t *qrtree, int k, int m );
static int hqr_gettype( const libhqr_tree_t *qrtree, int k, int m );
/* Permutation */
static void hqr_genperm ( libhqr_tree_t *qrtree );
static int hqr_getinvperm( const libhqr_tree_t *qrtree, int k, int m );
/****************************************************
* Common ipiv
***************************************************
......@@ -604,109 +600,6 @@ hqr_prevpiv(const libhqr_tree_t *qrtree, int k, int pivot, int start)
}
}
/****************************************************
*
* Generate the permutation required for the round-robin on TS
*
***************************************************/
static void
hqr_genperm( libhqr_tree_t *qrtree )
{
hqr_args_t *arg = (hqr_args_t*)(qrtree->args);
int m = qrtree->mt;
int n = qrtree->nt;
int a = qrtree->a;
int p = qrtree->p;
int domino = arg->domino;
int minMN = libhqr_imin( m, n );
int pa = p * a;
int i, j, k;
int nbextra1;
int end2;
int mpa = m % pa;
int endpa = m - mpa;
int *perm;
arg->perm = (int*)malloc( (m+1) * minMN * sizeof(int) );
perm = arg->perm;
if ( arg->tsrr ) {
for(k=0; k<minMN; k++) {
for( i=0; i<m+1; i++) {
perm[i] = -1;
}
perm += m+1;
}
perm = arg->perm;
for(k=0; k<minMN; k++) {
nbextra1 = nbextra1_formula;
end2 = p + ( domino ? k*p : k + nbextra1 );
end2 = (( end2 + pa - 1 ) / pa ) * pa;
end2 = libhqr_imin( end2, m );
/*
* All tiles of type 3, 2 and:
* - 1 when domino is disabled
* - 0 before the first multiple of pa under the considered diagonal
*/
for( i=k; i<end2; i++) {
perm[i] = i;
}
/* All permutations in groups of pa tiles */
assert( i%pa == 0 || i>=endpa);
for( ; i<endpa; i+=pa ) {
for(j=0; j<pa; j++) {
perm[i+j] = i + ( j + p * (k%a) )%pa;
}
}
/* Last group of tiles */
for( ; i<m; i++) {
perm[i] = i;
}
perm[m] = m;
perm += m+1;
}
}
else {
for(k=0; k<minMN; k++) {
for( i=0; i<m+1; i++) {
perm[i] = i;
}
perm += m+1;
}
}
}
static inline int
hqr_getinvperm( const libhqr_tree_t *qrtree, int k, int m )
{
int gmt = qrtree->mt + 1;
int a = qrtree->a;
int p = qrtree->p;
int pa = p * a;
int start = m / pa * pa;
int stop = libhqr_imin( start + pa, gmt ) - start;
int i;
if (a == 1) {
return m;
}
for ( i=m%p; i < stop; i+=p ) {
//if( perm[i] == m )
if( i == m ) {
return i+start;
}
}
/* We should never arrive here */
myassert( 0 );
(void)k;
}
/**
*******************************************************************************
*
......@@ -912,7 +805,6 @@ libhqr_initfct_hqr( libhqr_tree_t *qrtree,
arg = (hqr_args_t*) malloc( sizeof(hqr_args_t) );
arg->domino = domino;
arg->tsrr = tsrr;
arg->perm = NULL;
arg->llvl = (hqr_subpiv_t*) malloc( sizeof(hqr_subpiv_t) );
arg->hlvl = NULL;
......@@ -978,7 +870,6 @@ libhqr_initfct_hqr( libhqr_tree_t *qrtree,
}
qrtree->args = (void*)arg;
hqr_genperm( qrtree );
return 0;
}
......@@ -1170,10 +1061,6 @@ libhqr_finalize( libhqr_tree_t *qrtree )
}
free( arg->hlvl );
}
if ( arg->perm != NULL ) {
free(arg->perm);
}
}
if ( qrtree->init == LIBHQR_QRTREE_MTX ) {
libhqr_tile_args_t *args = qrtree->args;
......
......@@ -620,8 +620,7 @@ libhqr_initfct_svd( libhqr_tree_t *qrtree,
arg = (hqr_args_t*) malloc( sizeof(hqr_args_t) );
arg->domino = 0;
arg->tsrr = 0;
arg->perm = NULL;
arg->tsrr = 0;
arg->llvl = (hqr_subpiv_t*) malloc( sizeof(hqr_subpiv_t) );
arg->hlvl = NULL;
......
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