Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 7fe99bee authored by Raphael Boucherie's avatar Raphael Boucherie
Browse files

Moved queue functions in another header, fixed some commentary, added dir-locals.el

parent d5a94704
No related branches found
No related tags found
2 merge requests!3Treewalk,!2New branch
;; C style for Emacs, to assist in following DAGuE coding conventions (originally from PETSc project)
((nil . ((indent-tabs-mode . nil)
(tab-width . 8)
(show-trailing-whitespace . t)))
(c-mode . ((c-tab-always-indent . t)
(c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open after)
(brace-entry-open)
(defun-open after)
(class-open after)
(inline-open after)
(block-open after)
(block-close . c-snug-do-while)
(statement-case-open after)
(substatement after)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-hanging-semi&comma-criteria . (c-semi&comma-no-newlines-before-nonblanks))
(c-cleanup-list . (scope-operator
brace-else-brace
brace-elseif-brace
brace-catch-brace
empty-defun-braces
list-close-comma
defun-close-semi))
(c-offsets-alist . ((inexpr-class . +)
(inexpr-statement . +)
(lambda-intro-cont . +)
(inlambda . c-lineup-inexpr-block)
(template-args-cont c-lineup-template-args +)
(incomposition . +)
(inmodule . +)
(innamespace . +)
(inextern-lang . +)
(composition-close . 0)
(module-close . 0)
(namespace-close . 0)
(extern-lang-close . 0)
(composition-open . 0)
(module-open . 0)
(namespace-open . 0)
(extern-lang-open . 0)
(objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +)
(objc-method-args-cont . c-lineup-ObjC-method-args)
(objc-method-intro .
[0])
(friend . 0)
(cpp-define-intro c-lineup-cpp-define +)
(cpp-macro-cont . +)
(cpp-macro .
[0])
(inclass . +)
(stream-op . c-lineup-streamop)
(arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist)
(arglist-cont c-lineup-gcc-asm-reg 0)
(arglist-intro . +)
(catch-clause . 0)
(else-clause . 0)
(do-while-closure . 0)
(label . 2)
(access-label . -)
(substatement-label . 2)
(substatement . +)
(statement-case-open . 0)
(statement-case-intro . +)
(statement-block-intro . +)
(statement-cont . +)
(statement . 0)
(brace-entry-open . 0)
(brace-list-entry . 0)
(brace-list-intro . +)
(brace-list-close . 0)
(brace-list-open . 0)
(block-close . 0)
(inher-cont . c-lineup-multi-inher)
(inher-intro . +)
(member-init-cont . c-lineup-multi-inher)
(member-init-intro . +)
(annotation-var-cont . +)
(annotation-top-cont . 0)
(topmost-intro-cont . c-lineup-topmost-intro-cont)
(topmost-intro . 0)
(knr-argdecl . 0)
(func-decl-cont . +)
(inline-close . 0)
(inline-open . +)
(class-close . 0)
(class-open . 0)
(defun-block-intro . +)
(defun-close . 0)
(defun-open . 0)
(string . c-lineup-dont-change)
(arglist-close . c-lineup-arglist)
(substatement-open . 0)
(case-label . 0)
(block-open . 0)
(c . 1)
(comment-intro . 0)
(knr-argdecl-intro . -)))
(fill-column . 80))))
......@@ -64,14 +64,6 @@ 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;
......@@ -162,43 +154,30 @@ 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 );
/*
* 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);
/*
* function for treewalk
*/
void libhqr_treewalk(libhqr_tree_t *qrtree,int k);
/*
* Debugging functions
*/
int libhqr_tree_check ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree );
void libhqr_tree_print_dag ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, char *filename );
void libhqr_tree_print_type ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree );
......
/**
*
* @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
*
**/
#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{
struct libhqr_queue_tile_s *prev;
struct libhqr_queue_tile_s *next;
int numero;
} libhqr_queue_tile_t;
libhqr_queue_tile_t *libhqr_queue_tile_new (void);
void libhqr_queue_tile_post (libhqr_queue_tile_t ** queue_tile,int numero);
int libhqr_queue_tile_get (libhqr_queue_tile_t ** queue_tile);
void libhqr_queue_tile_delete (libhqr_queue_tile_t ** queue_tile);
void libhqr_queue_tile_first (libhqr_queue_tile_t ** queue_tile);
void libhqr_queue_tile_prev (libhqr_queue_tile_t ** queue_tile);
void libhqr_queue_tile_last (libhqr_queue_tile_t ** queue_tile);
void libhqr_queue_tile_next (libhqr_queue_tile_t ** queue_tile);
END_C_DECLS
#endif /* _QUEUE_H_ */
This diff is collapsed.
......@@ -63,11 +63,11 @@ static int systolic_gettype( const libhqr_tree_t *qrtree, int k, int m ) {
/* Local eliminations with a TS kernel */
if ( m >= k + pq )
return 0;
return 0;
/* Element to be reduce with a single pivot */
else if ( m >= k+p )
return 1;
return 1;
/* Element to be reduced with sq_p pivot */
else return 3;
......@@ -88,16 +88,16 @@ static int systolic_currpiv(const libhqr_tree_t *qrtree, int k, int m)
switch( systolic_gettype( qrtree, k, m ) )
{
case 0:
return (m - k) % pq + k;
break;
return (m - k) % pq + k;
break;
case 1:
return (m - k) % p + k;
break;
return (m - k) % p + k;
break;
case 3:
return k;
break;
return k;
break;
default:
return qrtree->mt;
return qrtree->mt;
}
};
......@@ -136,59 +136,59 @@ static int systolic_nextpiv(const libhqr_tree_t *qrtree, int k, int pivot, int s
lp = systolic_gettype( qrtree, k, pivot );
switch( ls )
{
case -1:
{
case -1:
if ( lp == LIBHQR_KILLED_BY_TS ) {
myassert( start == mt );
return mt;
}
if ( lp == LIBHQR_KILLED_BY_TS ) {
myassert( start == mt );
return mt;
}
case LIBHQR_KILLED_BY_TS:
case LIBHQR_KILLED_BY_TS:
if ( start == mt )
nextp = pivot + pq;
else
nextp = start + pq;
if ( start == mt )
nextp = pivot + pq;
else
nextp = start + pq;
if ( nextp < mt )
return nextp;
if ( nextp < mt )
return nextp;
start = mt;
start = mt;
case LIBHQR_KILLED_BY_LOCALTREE:
case LIBHQR_KILLED_BY_LOCALTREE:
if (lp < LIBHQR_KILLED_BY_DISTTREE)
return mt;
if (lp < LIBHQR_KILLED_BY_DISTTREE)
return mt;
if ( start == mt )
nextp = pivot + p;
else
nextp = start + p;
if ( start == mt )
nextp = pivot + p;
else
nextp = start + p;
if ( (nextp >= k + p) &&
(nextp < k + pq) &&
(nextp < mt) )
return nextp;
if ( (nextp >= k + p) &&
(nextp < k + pq) &&
(nextp < mt) )
return nextp;
start = mt;
start = mt;
case LIBHQR_KILLED_BY_DISTTREE:
case LIBHQR_KILLED_BY_DISTTREE:
if (pivot > k)
return mt;
if (pivot > k)
return mt;
if ( start == mt )
nextp = pivot + 1;
else
nextp = start + 1;
if ( start == mt )
nextp = pivot + 1;
else
nextp = start + 1;
if ( nextp < k + p )
return nextp;
if ( nextp < k + p )
return nextp;
default:
return mt;
}
default:
return mt;
}
}
/**
......@@ -232,63 +232,63 @@ static int systolic_prevpiv(const libhqr_tree_t *qrtree, int k, int pivot, int s
myassert( lp >= ls );
switch( ls )
{
case LIBHQR_KILLED_BY_DISTTREE:
if ( pivot == k ) {
if ( start == pivot ) {
nextp = start + p-1;
while( pivot < nextp && nextp >= mt )
nextp--;
} else {
nextp = start - 1;
}
if ( pivot < nextp &&
nextp < k + p )
return nextp;
}
start = pivot;
case LIBHQR_KILLED_BY_LOCALTREE:
if ( lp > LIBHQR_KILLED_BY_LOCALTREE ) {
if ( start == pivot ) {
nextp = start + (q-1) * p;
while( pivot < nextp &&
nextp >= mt )
nextp -= p;
} else {
nextp = start - p;
}
if ( pivot < nextp &&
nextp < k + pq )
return nextp;
}
start = pivot;
case LIBHQR_KILLED_BY_TS:
/* Search for predecessor in TS tree */
if ( lp > LIBHQR_KILLED_BY_TS ) {
if ( start == pivot ) {
nextp = mt - (mt - rpivot - 1)%pq - 1;
while( pivot < nextp && nextp >= mt )
nextp -= pq;
} else {
nextp = start - pq;
}
assert(nextp < mt);
if ( pivot < nextp )
return nextp;
}
default:
return mt;
}
{
case LIBHQR_KILLED_BY_DISTTREE:
if ( pivot == k ) {
if ( start == pivot ) {
nextp = start + p-1;
while( pivot < nextp && nextp >= mt )
nextp--;
} else {
nextp = start - 1;
}
if ( pivot < nextp &&
nextp < k + p )
return nextp;
}
start = pivot;
case LIBHQR_KILLED_BY_LOCALTREE:
if ( lp > LIBHQR_KILLED_BY_LOCALTREE ) {
if ( start == pivot ) {
nextp = start + (q-1) * p;
while( pivot < nextp &&
nextp >= mt )
nextp -= p;
} else {
nextp = start - p;
}
if ( pivot < nextp &&
nextp < k + pq )
return nextp;
}
start = pivot;
case LIBHQR_KILLED_BY_TS:
/* Search for predecessor in TS tree */
if ( lp > LIBHQR_KILLED_BY_TS ) {
if ( start == pivot ) {
nextp = mt - (mt - rpivot - 1)%pq - 1;
while( pivot < nextp && nextp >= mt )
nextp -= pq;
} else {
nextp = start - pq;
}
assert(nextp < mt);
if ( pivot < nextp )
return nextp;
}
default:
return mt;
}
};
/**
......@@ -349,29 +349,29 @@ static int systolic_prevpiv(const libhqr_tree_t *qrtree, int k, int pivot, int 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 )
{
if (qrtree == NULL) {
fprintf(stderr, "libhqr_systolic_init, illegal value of qrtree");
return -1;
fprintf(stderr, "libhqr_systolic_init, illegal value of qrtree");
return -1;
}
if ((trans != LIBHQR_QR) &&
(trans != LIBHQR_LQ)) {
fprintf(stderr, "libhqr_systolic_init, illegal value of trans");
return -2;
(trans != LIBHQR_LQ)) {
fprintf(stderr, "libhqr_systolic_init, illegal value of trans");
return -2;
}
if (A == NULL) {
fprintf(stderr, "libhqr_systolic_init, illegal value of A");
return -3;
fprintf(stderr, "libhqr_systolic_init, illegal value of A");
return -3;
}
if ( p < 0 ) {
fprintf(stderr, "libhqr_systolic_init, illegal value of p");
return -4;
fprintf(stderr, "libhqr_systolic_init, illegal value of p");
return -4;
}
if ( q < -1 ) {
fprintf(stderr, "libhqr_systolic_init, illegal value of q");
return -5;
fprintf(stderr, "libhqr_systolic_init, illegal value of q");
return -5;
}
qrtree->getnbgeqrf = systolic_getnbgeqrf;
......@@ -415,6 +415,6 @@ void
libhqr_systolic_finalize( libhqr_tree_t *qrtree )
{
if ( qrtree->args != NULL) {
free( qrtree->args );
free( qrtree->args );
}
}
/**
*
* @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
*
**/
#include "libhqr.h"
#include "queue.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
......@@ -16,167 +34,141 @@
/****************************************************
*
* Generic functions for file
*
* Generic functions for queue
***************************************************/
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)
libhqr_queue_tile_t *libhqr_queue_tile_new (void)
{
return (NULL);
}
static void libhqr_file_tile_first (libhqr_file_tile_t ** file_tile)
void libhqr_queue_tile_first (libhqr_queue_tile_t ** queue_tile)
{
if (file_tile != NULL && *file_tile != NULL)
if (queue_tile != NULL && *queue_tile != NULL)
{
while ((*file_tile)->prev != NULL)
libhqr_file_tile_prev (file_tile);
while ((*queue_tile)->prev != NULL)
libhqr_queue_tile_prev (queue_tile);
}
return;
}
static void libhqr_file_tile_prev (libhqr_file_tile_t ** file_tile)
void libhqr_queue_tile_prev (libhqr_queue_tile_t ** queue_tile)
{
if (file_tile != NULL && *file_tile != NULL)
*file_tile = (*file_tile)->prev;
if (queue_tile != NULL && *queue_tile != NULL)
*queue_tile = (*queue_tile)->prev;
return;
}
static void libhqr_file_tile_last (libhqr_file_tile_t ** file_tile)
void libhqr_queue_tile_last (libhqr_queue_tile_t ** queue_tile)
{
if (file_tile != NULL && *file_tile != NULL)
if (queue_tile != NULL && *queue_tile != NULL)
{
while ((*file_tile)->next != NULL)
libhqr_file_tile_next (file_tile);
while ((*queue_tile)->next != NULL)
libhqr_queue_tile_next (queue_tile);
}
return;
}
static void libhqr_file_tile_next (libhqr_file_tile_t ** file_tile)
void libhqr_queue_tile_next (libhqr_queue_tile_t ** queue_tile)
{
if (file_tile != NULL && *file_tile != NULL)
*file_tile = (*file_tile)->next;
if (queue_tile != NULL && *queue_tile != NULL)
*queue_tile = (*queue_tile)->next;
return;
}
void libhqr_file_tile_post (libhqr_file_tile_t ** file_tile, int numero)
void libhqr_queue_tile_post (libhqr_queue_tile_t ** queue_tile, int numero)
{
if (file_tile != NULL)
if (queue_tile != NULL)
{
libhqr_file_tile_t *p_l = NULL;
libhqr_file_tile_t *p_p = NULL;
libhqr_queue_tile_t *p_l = NULL;
libhqr_queue_tile_t *p_p = NULL;
libhqr_file_tile_first (file_tile);
p_l = *file_tile;
libhqr_queue_tile_first (queue_tile);
p_l = *queue_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;
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;
}
int libhqr_file_tile_get (libhqr_file_tile_t ** file_tile)
int libhqr_queue_tile_get (libhqr_queue_tile_t ** queue_tile)
{
int ret;
if (file_tile != NULL && *file_tile != NULL)
if (queue_tile != NULL && *queue_tile != NULL)
{
libhqr_file_tile_t *p_l = NULL;
libhqr_file_tile_t *p_p = NULL;
libhqr_queue_tile_t *p_l = NULL;
libhqr_queue_tile_t *p_p = NULL;
libhqr_file_tile_last (file_tile);
p_l = *file_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;
*file_tile = p_p;
p_p->next = NULL;
*queue_tile = p_p;
}
return (ret);
}
void libhqr_file_tile_delete (libhqr_file_tile_t ** file_tile)
void libhqr_queue_tile_delete (libhqr_queue_tile_t ** queue_tile)
{
if (file_tile != NULL && *file_tile != NULL)
if (queue_tile != NULL && *queue_tile != NULL)
{
while (*file_tile != NULL)
libhqr_file_tile_get (file_tile);
while (*queue_tile != NULL)
libhqr_queue_tile_get (queue_tile);
}
return;
}
/****************************************************
*
* fonctions pour parcourir arbre
*
* LIBHQR_TREEWALK
***************************************************/
void libhqr_treewalk(libhqr_tree_t *qrtree,int k){
libhqr_file_tile_t **tt;
libhqr_file_tile_t **ts;
libhqr_file_tile_t *p_l = NULL;
libhqr_file_tile_t *p_p = NULL;
libhqr_queue_tile_t *tt;
libhqr_queue_tile_t *ts;
tt->next = libhqr_queue_tile_new();
ts->next = libhqr_queue_tile_new();
tt->prev = libhqr_queue_tile_new();
ts->prev = libhqr_queue_tile_new();
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);
int a,b;
while(p = qrtree->nextpiv(qrtree, k, pivot, p)){
while(p = qrtree->prevpiv(qrtree, k, pivot, p)){
if(qrtree->gettype(qrtree, k, p)) libhqr_queue_tile_post(&tt,p); //segfault
libhqr_queue_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;
libhqr_queue_tile_last(&ts);
a = ts->numero;
libhqr_queue_tile_last(&tt);
b = tt->numero;
while(a != b){
libhqr_file_tile_get(ts);
libhqr_file_tile_last(ts);
p_l = *ts;
a = p_l->numero;
printf("%d/n" , a);
libhqr_queue_tile_get(&ts);
libhqr_queue_tile_last(&ts);
a = ts->numero;
}
libhqr_file_tile_get(tt);
libhqr_queue_tile_get(&tt);
libhqr_queue_tile_last(&tt);
b = tt->numero;
}
libhqr_file_tile_delete(tt);
libhqr_file_tile_delete(ts);
}
/****************************************************
*
* fonction utilisant l'algo de parcours d'arbre
*
***************************************************/
void libhqr_print_tree(libhqr_tree_t qrtree){
libhqr_queue_tile_delete(&tt);
libhqr_queue_tile_delete(&ts);
}
......@@ -41,7 +41,7 @@ int main(int argc, char ** argv)
todo += nbtreel * nbM * nbN * (2 * nbA - 1) * (1 + 2 * nbtreeh * nbP);
/* systolic */
todo += nbM * nbN * nbA * nbP;
/*
*
* Tests for HQR code
......
/*
* Copyright (c) 2009-2011 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
*
* @precisions normal z -> s d c
*
*/
/**
*
* @file testing_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
*
**/
#include "libhqr.h"
#include "queue.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment