XC Open source finite element analysis program
SuperLU_MT_util.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program.
25 // If not, see <http://www.gnu.org/licenses/>.
26 //----------------------------------------------------------------------------
27 /* ****************************************************************** **
28 ** OpenSees - Open System for Earthquake Engineering Simulation **
29 ** Pacific Earthquake Engineering Research Center **
30 ** **
31 ** **
32 ** (C) Copyright 1999, The Regents of the University of California **
33 ** All Rights Reserved. **
34 ** **
35 ** Commercial use of this program without express permission of the **
36 ** University of California, Berkeley, is strictly prohibited. See **
37 ** file 'COPYRIGHT' in main directory for information on usage and **
38 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
39 ** **
40 ** Developed by: **
41 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
42 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
43 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
44 ** **
45 ** ****************************************************************** */
46 
47 // $Revision: 1.1.1.1 $
48 // $Date: 2000/09/15 08:23:30 $
49 // $Source: /usr/local/cvs/OpenSees/SRC/system_of_eqn/linearSOE/sparseGEN/SuperLU_MT_util.h,v $
50 
51 
52 /*
53  * -- SuperLU MT routine (alpha version) --
54  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
55  * and Lawrence Berkeley National Lab.
56  * August 15, 1997
57  *
58  */
59 
60 #ifndef __SUPERLU_UTIL /* allow multiple inclusions */
61 #define __SUPERLU_UTIL
62 
63 #include <cstdio>
64 #include <cstdlib>
65 #include <cstring>
66 #include <malloc.h>
67 
68 /* Macros */
69 #ifndef USER_ABORT
70 #define USER_ABORT(msg) superlu_abort_and_exit(msg)
71 #endif
72 
73 #define ABORT(err_msg) \
74  { char msg[256];\
75  sprintf(msg,"%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\
76  USER_ABORT(msg); }
77 
78 
79 #ifndef USER_MALLOC
80 #define USER_MALLOC(size) superlu_malloc(size)
81 #endif
82 
83 #define SUPERLU_MALLOC(size) USER_MALLOC(size)
84 
85 #ifndef USER_FREE
86 #define USER_FREE(addr) superlu_free(addr)
87 #endif
88 
89 #define SUPERLU_FREE(addr) USER_FREE(addr)
90 
91 
92 /*
93  * Constants
94  */
95 #define EMPTY (-1)
96 #define FALSE 0
97 #define TRUE 1
98 
99 /*
100  * Type definitions
101  */
102 typedef float flops_t;
103 typedef unsigned char Logical;
104 typedef enum {
105  RELAX,
106  ETREE,
107  EQUIL,
108  FINDDOMAIN,
109  FACT,
110  DFS,
111  FLOAT,
112  TRSV,
113  GEMV,
114  RCOND,
115  TRISOLVE,
116  SOLVE,
117  REFINE,
118  FERR,
119  NPHASES
120 } PhaseType;
121 
122 /* ----------------------------------------------
123  The definitions below are used for profiling.
124  ---------------------------------------------- */
125 
126 /* The statistics to be kept by each processor. */
127 typedef struct {
128  int panels; /* number of panels taken */
129  float fcops; /* factor floating-point operations */
130  double fctime; /* factor time */
131  int skedwaits; /* how many times the processor fails to get a task */
132  double skedtime; /* time spent in the scheduler */
133  double cs_time; /* time spent in the critical sections */
134  double spintime; /* spin-wait time */
135  int pruned;
136  int unpruned;
137 } procstat_t;
138 
139 
140 /* Statistics about each panel. */
141 
142 typedef struct {
143  int size; /* size of the panel */
144  int pnum; /* which processor grabs this panel */
145  double starttime; /* at waht time this panel is assigned to a proc */
146  double fctime; /* factorization time */
147  float flopcnt; /* floating-point operations */
148  int pipewaits; /* how many times the panel waited during pipelining */
149  double spintime; /* spin waiting time during pipelining */
150 } panstat_t;
151 
152 /* How was a panel selected by the scheduler */
153 typedef enum {NOPIPE, DADPAN, PIPE} how_selected_t;
154 
155 
156 typedef struct {
157  flops_t flops;
158  int nzs;
159  double fctime;
160 } stat_relax_t;
161 
162 typedef struct {
163  flops_t flops;
164  int nzs;
165  double fctime;
166 } stat_col_t;
167 
168 typedef struct {
169  int ncols;
170  flops_t flops;
171  int nzs;
172  double fctime;
173 } stat_snode_t;
174 
175 /* -------------------------------------------------------------------
176  The definitions below are used to simulate parallel execution time.
177  ------------------------------------------------------------------- */
178 typedef struct {
179  float est; /* earliest (possible) start time of the panel */
180  float pdiv; /* time in flops spent in the (inner) panel factorization */
181 } cp_panel_t;
182 
183 typedef struct {
184  float eft; /* earliest finishing time */
185  float pmod; /* pmod update to the ancestor panel */
186 } desc_eft_t;
187 
188 /* All statistics. */
189 typedef struct {
190  int *panel_histo; /* Panel size distribution */
191  double *utime;
192  flops_t *ops;
193  procstat_t *procstat;
194  panstat_t *panstat;
195  int num_panels;
196  float dom_flopcnt;
197  float flops_last_P_panels;
198 
199  stat_relax_t *stat_relax;
200  stat_col_t *stat_col;
201  stat_snode_t *stat_snode;
202  int *panhows;
203  cp_panel_t *cp_panel; /* panels on the critical path */
204  desc_eft_t *desc_eft; /* all we need to know from descendants */
205  int *cp_firstkid, *cp_nextkid; /* linked list of children */
206  int *height;
207  float *flops_by_height;
208 } Gstat_t;
209 
210 struct Branch {
211  int root, first_desc, which_bin;
212  struct Branch *next;
213 };
214 
215 
216 #if 0
217 
218 /* Statistics for supernode and panel size */
219 int no_panels;
220 float sum_w; /* Sum (Wi) */
221 float sum_np_w; /* Sum (Npi*Wi) */
222 int max_np;
223 int no_sups;
224 float sum_sup; /* Sum (Supi) */
225 int max_sup;
226 flops_t reuse_flops; /* Triangular solve and matrix vector multiply */
227 float reuse_data; /* Doubles in updating supernode */
228 
229 /* Statistics for blas operations */
230 int num_blas; /* no of BLAS2 operations, including trsv/gemv */
231 int max_blas_n; /* max dimension n in tri-solve and mat-vec */
232 int min_blas_n; /* min dimension n in tri-solve and mat-vec */
233 float sum_blas_n; /* sum of " " " */
234 int max_gemv_m; /* max dimension m in mat-vec */
235 int min_gemv_m; /* max dimension m in mat-vec */
236 float sum_gemv_m; /* sum of " " " */
237 int lda_blas_m;
238 int lda_blas_n;
239 flops_t *gemv_ops; /* flops distribution on (m,n) */
240 flops_t *trsv_ops; /* flops distribution on n */
241 
242 #define i_trsv_ops(i) trsv_ops[i]
243 #define ij_gemv_ops(i,j) gemv_ops[j*lda_blas_m + i]
244 
245 #endif
246 
247 
248 #endif /* __SUPERLU_UTIL */
249 
Definition: SuperLU_MT_util.h:142
Definition: SuperLU_MT_util.h:189
Definition: SuperLU_MT_util.h:156
Definition: SuperLU_MT_util.h:183
Definition: SuperLU_MT_util.h:178
Definition: SuperLU_MT_util.h:162
Definition: SuperLU_MT_util.h:210
Definition: SuperLU_MT_util.h:168
Definition: SuperLU_MT_util.h:127