00001
00005 #ifndef __SUPERLU_UTIL
00006 #define __SUPERLU_UTIL
00007
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include <string.h>
00011 #include <assert.h>
00012 #include "superlu_enum_consts.h"
00013
00014
00015
00016
00017 #ifndef USER_ABORT
00018 #define USER_ABORT(msg) superlu_abort_and_exit_dist(msg)
00019 #endif
00020
00021 #define ABORT(err_msg) \
00022 { char msg[256];\
00023 sprintf(msg,"%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\
00024 USER_ABORT(msg); }
00025
00026
00027 #ifndef USER_MALLOC
00028 #define USER_MALLOC(size) superlu_malloc_dist(size)
00029 #endif
00030
00031 #define SUPERLU_MALLOC(size) USER_MALLOC(size)
00032
00033 #ifndef USER_FREE
00034 #define USER_FREE(addr) superlu_free_dist(addr)
00035 #endif
00036
00037 #define SUPERLU_FREE(addr) USER_FREE(addr)
00038
00039 #define CHECK_MALLOC(pnum, where) { \
00040 extern long int superlu_malloc_total; \
00041 printf("(%d) %s: superlu_malloc_total (MB) %.2f\n", \
00042 pnum, where, superlu_malloc_total*1e-6); \
00043 }
00044
00045 #define SUPERLU_MAX(x, y) ( (x) > (y) ? (x) : (y) )
00046 #define SUPERLU_MIN(x, y) ( (x) < (y) ? (x) : (y) )
00047
00048
00049
00050
00051 #define EMPTY (-1)
00052 #ifndef FALSE
00053 #define FALSE (0)
00054 #endif
00055 #ifndef TRUE
00056 #define TRUE (1)
00057 #endif
00058
00059
00060
00061
00062 typedef float flops_t;
00063 typedef unsigned char Logical;
00064
00065
00066
00067
00068
00069
00070
00071 typedef struct {
00072 int *panel_histo;
00073 double *utime;
00074 flops_t *ops;
00075 int TinyPivots;
00076 int RefineSteps;
00077 int num_look_aheads;
00078 } SuperLUStat_t;
00079
00080
00081 typedef struct e_node {
00082 int size;
00083 void *mem;
00084 } ExpHeader;
00085
00086 typedef struct {
00087 int size;
00088 int used;
00089 int top1;
00090 int top2;
00091 void *array;
00092 } LU_stack_t;
00093
00094
00095 #define GluIntArray(n) (5 * (n) + 5)
00096 #define NO_MEMTYPE 6
00097
00098
00099
00100
00101
00102
00103
00104
00105 #define StackFull(x) ( x + stack.used >= stack.size )
00106 #define NotDoubleAlign(addr) ( (long)addr & 7 )
00107 #define DoubleAlign(addr) ( ((long)addr + 7) & ~7L )
00108 #define TempSpace(n, w) ( (2*w + 4 + NO_MARKER)*m*sizeof(int) + \
00109 (w + 1)*n*sizeof(double) )
00110 #define Reduce(alpha) ((alpha + 1) / 2)
00111
00112 #define FIRSTCOL_OF_SNODE(i) (xsup[i])
00113
00114 #if ( PROFlevel>=1 )
00115 #define TIC(t) t = SuperLU_timer_()
00116 #define TOC(t2, t1) t2 = SuperLU_timer_() - t1
00117 #else
00118 #define TIC(t)
00119 #define TOC(t2, t1)
00120 #endif
00121
00122
00123
00124
00125 #define L_SUB_START(col) ( Lstore->rowind_colptr[col] )
00126 #define L_SUB(ptr) ( Lstore->rowind[ptr] )
00127 #define L_NZ_START(col) ( Lstore->nzval_colptr[col] )
00128 #define L_FST_SUPC(superno) ( Lstore->sup_to_col[superno] )
00129 #define U_NZ_START(col) ( Ustore->colptr[col] )
00130 #define U_SUB(ptr) ( Ustore->rowind[ptr] )
00131
00132 #endif