SRC/util_dist.h

Go to the documentation of this file.
00001 
00005 #ifndef __SUPERLU_UTIL /* allow multiple inclusions */
00006 #define __SUPERLU_UTIL
00007 
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include <string.h>
00011 #include <assert.h>
00012 
00013 /*
00014  * Macros
00015  */
00016 #ifndef USER_ABORT
00017 #define USER_ABORT(msg) superlu_abort_and_exit_dist(msg)
00018 #endif
00019 
00020 #define ABORT(err_msg) \
00021  { char msg[256];\
00022    sprintf(msg,"%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\
00023    USER_ABORT(msg); }
00024 
00025 
00026 #ifndef USER_MALLOC
00027 #define USER_MALLOC(size) superlu_malloc_dist(size)
00028 #endif
00029 
00030 #define SUPERLU_MALLOC(size) USER_MALLOC(size)
00031 
00032 #ifndef USER_FREE
00033 #define USER_FREE(addr) superlu_free_dist(addr)
00034 #endif
00035 
00036 #define SUPERLU_FREE(addr) USER_FREE(addr)
00037 
00038 #define CHECK_MALLOC(pnum, where) {                 \
00039     extern long int superlu_malloc_total;        \
00040     printf("(%d) %s: superlu_malloc_total (KBytes) %.3f\n",     \
00041            pnum, where, superlu_malloc_total*1e-3); \
00042 }
00043 
00044 #define SUPERLU_MAX(x, y)       ( (x) > (y) ? (x) : (y) )
00045 #define SUPERLU_MIN(x, y)       ( (x) < (y) ? (x) : (y) )
00046 
00047 /* 
00048  * Constants 
00049  */
00050 #define EMPTY   (-1)
00051 #ifndef FALSE
00052 #define FALSE   (0)
00053 #endif
00054 #ifndef TRUE
00055 #define TRUE    (1)
00056 #endif
00057 
00058 /*
00059  * Type definitions
00060  */
00061 typedef float    flops_t;
00062 typedef unsigned char Logical;
00063 
00064 /*
00065 #ifdef _CRAY
00066 #define int short
00067 #endif
00068 */
00069 
00070 /* 
00071  * The following enumerate type is used by the statistics variable 
00072  * to keep track of flop count and time spent at various stages.
00073  *
00074  * Note that not all of the fields are disjoint.
00075  */
00076 typedef enum {
00077     COLPERM, /* find a column ordering that minimizes fills */
00078     ROWPERM, /* find a row ordering maximizes diagonal. */
00079     RELAX,   /* find artificial supernodes */
00080     ETREE,   /* compute column etree */
00081     EQUIL,   /* equilibrate the original matrix */
00082     SYMBFAC, /* symbolic factorization. */
00083     DIST,    /* distribute matrix. */
00084     FACT,    /* perform LU factorization */
00085     COMM,    /* communication for factorization */
00086     SOL_COMM,/* communication for solve */
00087     RCOND,   /* estimate reciprocal condition number */
00088     SOLVE,   /* forward and back solves */
00089     REFINE,  /* perform iterative refinement */
00090     FLOAT,   /* time spent in floating-point operations */
00091     TRSV,    /* fraction of FACT spent in xTRSV */
00092     GEMV,    /* fraction of FACT spent in xGEMV */
00093     FERR,    /* estimate error bounds after iterative refinement */
00094     NPHASES  /* total number of phases */
00095 } PhaseType;
00096 
00097 typedef struct {
00098     int     *panel_histo; /* histogram of panel size distribution */
00099     double  *utime;       /* running time at various phases */
00100     flops_t *ops;         /* operation count at various phases */
00101     int     TinyPivots;   /* number of tiny pivots */
00102     int     RefineSteps;  /* number of iterative refinement steps */
00103 } SuperLUStat_t;
00104 
00105 /* Headers for 2 types of dynamatically managed memory */
00106 typedef struct e_node {
00107     int size;      /* length of the memory that has been used */
00108     void *mem;     /* pointer to the new malloc'd store */
00109 } ExpHeader;
00110 
00111 typedef struct {
00112     int  size;
00113     int  used;
00114     int  top1;  /* grow upward, relative to &array[0] */
00115     int  top2;  /* grow downward */
00116     void *array;
00117 } LU_stack_t;
00118 
00119 /* Constants */
00120 #define GluIntArray(n)   (5 * (n) + 5)
00121 #define NO_MEMTYPE  4      /* 0: lusup;
00122                               1: ucol;
00123                               2: lsub;
00124                               3: usub */
00125 
00126 /* Macros to manipulate stack */
00127 #define StackFull(x)         ( x + stack.used >= stack.size )
00128 #define NotDoubleAlign(addr) ( (long)addr & 7 )
00129 #define DoubleAlign(addr)    ( ((long)addr + 7) & ~7L )
00130 #define TempSpace(n, w)      ( (2*w + 4 + NO_MARKER)*m*sizeof(int) + \
00131                               (w + 1)*n*sizeof(double) )
00132 #define Reduce(alpha)        ((alpha + 1) / 2)  /* i.e. (alpha-1)/2 + 1 */
00133 
00134 #define FIRSTCOL_OF_SNODE(i)    (xsup[i])
00135 
00136 #if ( PROFlevel>=1 )
00137 #define TIC(t)          t = SuperLU_timer_()
00138 #define TOC(t2, t1)     t2 = SuperLU_timer_() - t1
00139 #else
00140 #define TIC(t)
00141 #define TOC(t2, t1)
00142 #endif
00143 
00144 /*********************************************************
00145  * Macros used for easy access of sparse matrix entries. *
00146  *********************************************************/
00147 #define L_SUB_START(col)     ( Lstore->rowind_colptr[col] )
00148 #define L_SUB(ptr)           ( Lstore->rowind[ptr] )
00149 #define L_NZ_START(col)      ( Lstore->nzval_colptr[col] )
00150 #define L_FST_SUPC(superno)  ( Lstore->sup_to_col[superno] )
00151 #define U_NZ_START(col)      ( Ustore->colptr[col] )
00152 #define U_SUB(ptr)           ( Ustore->rowind[ptr] )
00153 
00154 #endif /* __SUPERLU_UTIL */

Generated on Sat Aug 9 23:23:51 2008 for SuperLUDistributed by  doxygen 1.4.6