Actual source code: tfs.h
petsc-3.3-p7 2013-05-11
5: /**********************************const.h*************************************
7: Author: Henry M. Tufo III
9: e-mail: hmt@cs.brown.edu
11: snail-mail:
12: Division of Applied Mathematics
13: Brown University
14: Providence, RI 02912
16: Last Modification:
17: 6.21.97
18: ***********************************const.h************************************/
20: /**********************************const.h*************************************
21: File Description:
22: -----------------
24: ***********************************const.h************************************/
25: #include <petscsys.h>
26: #include <petscblaslapack.h>
27: #if defined(PETSC_HAVE_STDLIB_H)
28: #include <stdlib.h>
29: #endif
31: #define X 0
32: #define Y 1
33: #define Z 2
34: #define XY 3
35: #define XZ 4
36: #define YZ 5
39: #define THRESH 0.2
40: #define N_HALF 4096
41: #define PRIV_BUF_SZ 45
43: /*4096 8192 32768 65536 1048576 */
44: #define MAX_MSG_BUF 32768
46: #define FULL 2
47: #define PARTIAL 1
48: #define NONE 0
50: #define BYTE 8
51: #define BIT_0 0x1
52: #define BIT_1 0x2
53: #define BIT_2 0x4
54: #define BIT_3 0x8
55: #define BIT_4 0x10
56: #define BIT_5 0x20
57: #define BIT_6 0x40
58: #define BIT_7 0x80
59: #define TOP_BIT PETSC_MIN_INT
61: #define C 0
64: #define MAX_VEC 1674
65: #define FORMAT 30
66: #define MAX_COL_LEN 100
67: #define MAX_LINE FORMAT*MAX_COL_LEN
68: #define DELIM " \n \t"
69: #define LINE 12
70: #define C_LINE 80
72: #define UT 5 /* dump upper 1/2 */
73: #define LT 6 /* dump lower 1/2 */
74: #define SYMM 8 /* we assume symm and dump upper 1/2 */
75: #define NON_SYMM 9
77: #define ROW 10
78: #define COL 11
80: #define EPS 1.0e-14
81: #define EPS2 1.0e-07
84: #define MPI 1
85: #define NX 2
87: #define LOG2(x) (PetscScalar)log((double)x)/log(2)
88: #define SWAP(a,b) temp=(a); (a)=(b); (b)=temp;
89: #define P_SWAP(a,b) ptr=(a); (a)=(b); (b)=ptr;
91: #define MAX_FABS(x,y) (PetscAbsScalar(x)>PetscAbsScalar(y)) ? ((PetscScalar)x) : ((PetscScalar)y)
92: #define MIN_FABS(x,y) (PetscAbsScalar(x)<PetscAbsScalar(y)) ? ((PetscScalar)x) : ((PetscScalar)y)
94: /* specer's existence ... can be done w/MAX_ABS */
95: #define EXISTS(x,y) ((x)==0.0) ? (y) : (x)
97: #define MULT_NEG_ONE(a) (a) *= -1;
98: #define NEG(a) (a) |= BIT_31;
99: #define POS(a) (a) &= INT_MAX;
104: /**********************************types.h*************************************
106: Author: Henry M. Tufo III
108: e-mail: hmt@cs.brown.edu
110: snail-mail:
111: Division of Applied Mathematics
112: Brown University
113: Providence, RI 02912
115: Last Modification:
116: 6.21.97
117: ***********************************types.h************************************/
119: typedef PetscErrorCode (*vfp)(void*,void*,PetscInt,...);
120: typedef PetscErrorCode (*rbfp)(PetscScalar *, PetscScalar *, PetscInt len);
121: typedef PetscInt (*bfp)(void*, void *, PetscInt *len, MPI_Datatype *dt);
123: /***********************************comm.h*************************************
125: Author: Henry M. Tufo III
127: e-mail: hmt@cs.brown.edu
129: snail-mail:
130: Division of Applied Mathematics
131: Brown University
132: Providence, RI 02912
134: Last Modification:
135: 6.21.97
136: ***********************************comm.h*************************************/
137: extern PetscMPIInt PCTFS_my_id;
138: extern PetscMPIInt PCTFS_num_nodes;
139: extern PetscMPIInt PCTFS_floor_num_nodes;
140: extern PetscMPIInt PCTFS_i_log2_num_nodes;
142: extern PetscErrorCode PCTFS_giop(PetscInt *vals, PetscInt *work, PetscInt n, PetscInt *oprs);
143: extern PetscErrorCode PCTFS_grop(PetscScalar *vals, PetscScalar *work, PetscInt n, PetscInt *oprs);
144: extern PetscErrorCode PCTFS_comm_init(void);
145: extern PetscErrorCode PCTFS_giop_hc(PetscInt *vals, PetscInt *work, PetscInt n, PetscInt *oprs, PetscInt dim);
146: extern PetscErrorCode PCTFS_grop_hc(PetscScalar *vals, PetscScalar *work, PetscInt n, PetscInt *oprs, PetscInt dim);
147: extern PetscErrorCode PCTFS_ssgl_radd(PetscScalar *vals, PetscScalar *work, PetscInt level, PetscInt *segs);
149: #define MSGTAG0 101
150: #define MSGTAG1 1001
151: #define MSGTAG2 76207
152: #define MSGTAG3 100001
153: #define MSGTAG4 163841
154: #define MSGTAG5 249439
155: #define MSGTAG6 10000001
157: #define NON_UNIFORM 0
158: #define GL_MAX 1
159: #define GL_MIN 2
160: #define GL_MULT 3
161: #define GL_ADD 4
162: #define GL_B_XOR 5
163: #define GL_B_OR 6
164: #define GL_B_AND 7
165: #define GL_L_XOR 8
166: #define GL_L_OR 9
167: #define GL_L_AND 10
168: #define GL_MAX_ABS 11
169: #define GL_MIN_ABS 12
170: #define GL_EXISTS 13
172: extern PetscInt *PCTFS_ivec_copy(PetscInt *arg1, PetscInt *arg2, PetscInt n);
174: extern PetscErrorCode PCTFS_ivec_zero(PetscInt *arg1, PetscInt n);
175: extern PetscErrorCode PCTFS_ivec_set(PetscInt *arg1, PetscInt arg2, PetscInt n);
177: extern PetscInt PCTFS_ivec_lb(PetscInt *work, PetscInt n);
178: extern PetscInt PCTFS_ivec_ub(PetscInt *work, PetscInt n);
179: extern PetscInt PCTFS_ivec_sum(PetscInt *arg1, PetscInt n);
181: extern vfp PCTFS_ivec_fct_addr(PetscInt type);
183: extern PetscErrorCode PCTFS_ivec_non_uniform(PetscInt *arg1, PetscInt *arg2, PetscInt n, PetscInt *arg3);
184: extern PetscErrorCode PCTFS_ivec_max(PetscInt *arg1, PetscInt *arg2, PetscInt n);
185: extern PetscErrorCode PCTFS_ivec_min(PetscInt *arg1, PetscInt *arg2, PetscInt n);
186: extern PetscErrorCode PCTFS_ivec_mult(PetscInt *arg1, PetscInt *arg2, PetscInt n);
187: extern PetscErrorCode PCTFS_ivec_add(PetscInt *arg1, PetscInt *arg2, PetscInt n);
188: extern PetscErrorCode PCTFS_ivec_xor(PetscInt *arg1, PetscInt *arg2, PetscInt n);
189: extern PetscErrorCode PCTFS_ivec_or(PetscInt *arg1, PetscInt *arg2, PetscInt len);
190: extern PetscErrorCode PCTFS_ivec_and(PetscInt *arg1, PetscInt *arg2, PetscInt len);
191: extern PetscErrorCode PCTFS_ivec_lxor(PetscInt *arg1, PetscInt *arg2, PetscInt n);
192: extern PetscErrorCode PCTFS_ivec_lor(PetscInt *arg1, PetscInt *arg2, PetscInt len);
193: extern PetscErrorCode PCTFS_ivec_land(PetscInt *arg1, PetscInt *arg2, PetscInt len);
194: extern PetscErrorCode PCTFS_ivec_and3( PetscInt *arg1, PetscInt *arg2, PetscInt *arg3, PetscInt n);
196: extern PetscErrorCode PCTFS_ivec_sort_companion(PetscInt *ar, PetscInt *ar2, PetscInt size);
197: extern PetscErrorCode PCTFS_ivec_sort(PetscInt *ar, PetscInt size);
198: extern PetscErrorCode PCTFS_SMI_sort(void *ar1, void *ar2, PetscInt size, PetscInt type);
199: extern PetscInt PCTFS_ivec_binary_search(PetscInt item, PetscInt *list, PetscInt n);
200: extern PetscInt PCTFS_ivec_linear_search(PetscInt item, PetscInt *list, PetscInt n);
202: extern PetscErrorCode PCTFS_ivec_sort_companion_hack(PetscInt *ar, PetscInt **ar2, PetscInt size);
204: #define SORT_INTEGER 1
205: #define SORT_INT_PTR 2
207: extern PetscErrorCode PCTFS_rvec_zero(PetscScalar *arg1, PetscInt n);
208: extern PetscErrorCode PCTFS_rvec_one(PetscScalar *arg1, PetscInt n);
209: extern PetscErrorCode PCTFS_rvec_set(PetscScalar *arg1, PetscScalar arg2, PetscInt n);
210: extern PetscErrorCode PCTFS_rvec_copy(PetscScalar *arg1, PetscScalar *arg2, PetscInt n);
211: extern PetscErrorCode PCTFS_rvec_scale(PetscScalar *arg1, PetscScalar arg2, PetscInt n);
213: extern vfp PCTFS_rvec_fct_addr(PetscInt type);
214: extern PetscErrorCode PCTFS_rvec_add(PetscScalar *arg1, PetscScalar *arg2, PetscInt n);
215: extern PetscErrorCode PCTFS_rvec_mult(PetscScalar *arg1, PetscScalar *arg2, PetscInt n);
216: extern PetscErrorCode PCTFS_rvec_max(PetscScalar *arg1, PetscScalar *arg2, PetscInt n);
217: extern PetscErrorCode PCTFS_rvec_max_abs(PetscScalar *arg1, PetscScalar *arg2, PetscInt n);
218: extern PetscErrorCode PCTFS_rvec_min(PetscScalar *arg1, PetscScalar *arg2, PetscInt n);
219: extern PetscErrorCode PCTFS_rvec_min_abs(PetscScalar *arg1, PetscScalar *arg2, PetscInt n);
220: extern PetscErrorCode PCTFS_vec_exists(PetscScalar *arg1, PetscScalar *arg2, PetscInt n);
222: /***********************************gs.h***************************************
224: Author: Henry M. Tufo III
226: e-mail: hmt@cs.brown.edu
228: snail-mail:
229: Division of Applied Mathematics
230: Brown University
231: Providence, RI 02912
233: Last Modification:
234: 6.21.97
235: ************************************gs.h**************************************/
237: typedef struct gather_scatter_id *PCTFS_gs_ADT;
238: typedef PetscErrorCode (*Rbfp)(PetscScalar *, PetscScalar *, PetscInt len);
240: extern PCTFS_gs_ADT PCTFS_gs_init(PetscInt *elms, PetscInt nel, PetscInt level);
241: extern PetscErrorCode PCTFS_gs_gop_vec(PCTFS_gs_ADT PCTFS_gs_handle, PetscScalar *vals, const char *op, PetscInt step);
242: extern PetscErrorCode PCTFS_gs_gop_binary(PCTFS_gs_ADT gs, PetscScalar *vals, Rbfp fct);
243: extern PetscErrorCode PCTFS_gs_gop_hc(PCTFS_gs_ADT PCTFS_gs_handle, PetscScalar *vals, const char *op, PetscInt dim);
244: extern PetscErrorCode PCTFS_gs_free(PCTFS_gs_ADT PCTFS_gs_handle);
245: extern PetscErrorCode PCTFS_gs_init_msg_buf_sz(PetscInt buf_size);
246: extern PetscErrorCode PCTFS_gs_init_vec_sz(PetscInt size);
248: /*************************************xxt.h************************************
249: Module Name: xxt
250: Module Info: need xxt.{c,h} gs.{c,h} comm.{c,h} ivec.{c,h} error.{c,h}
252: author: Henry M. Tufo III
253: e-mail: hmt@asci.uchicago.edu
254: contact:
255: +--------------------------------+--------------------------------+
256: |MCS Division - Building 221 |Department of Computer Science |
257: |Argonne National Laboratory |Ryerson 152 |
258: |9700 S. Cass Avenue |The University of Chicago |
259: |Argonne, IL 60439 |Chicago, IL 60637 |
260: |(630) 252-5354/5986 ph/fx |(773) 702-6019/8487 ph/fx |
261: +--------------------------------+--------------------------------+
263: Last Modification: 3.20.01
264: **************************************xxt.h***********************************/
266: typedef struct xxt_CDT *xxt_ADT;
269: /*************************************xxt.h************************************
270: Function: XXT_new()
272: Return: ADT ptr or NULL upon failure.
273: Description: This function allocates and returns an xxt handle
274: Usage: xxt_handle = xxt_new();
275: **************************************xxt.h***********************************/
276: extern xxt_ADT XXT_new(void);
279: /*************************************xxt.h************************************
280: Function: XXT_free()
282: Input : pointer to ADT.
284: Description: This function frees the storage associated with an xxt handle
285: Usage: XXT_free(xxt_handle);
286: **************************************xxt.h***********************************/
287: extern PetscInt XXT_free(xxt_ADT xxt_handle);
290: /*************************************xxt.h************************************
291: Function: XXT_factor
293: Input : ADT ptr, and pointer to object
294: Return: 0 on failure, 1 on success
295: Description: This function sets the xxt solver
297: xxt assumptions: given n rows of global coarse matrix (E_loc) where
298: o global dofs N = sum_p(n), p=0,P-1
299: (i.e. row dist. with no dof replication)
300: (5.21.00 will handle dif replication case)
301: o m is the number of columns in E_loc (m>=n)
302: o local2global holds global number of column i (i=0,...,m-1)
303: o local2global holds global number of row i (i=0,...,n-1)
304: o mylocmatvec performs E_loc . x_loc where x_loc is an vector of
305: length m in 1-1 correspondence with local2global
306: (note that gs package takes care of communication).
307: (note do not zero out upper m-n entries!)
308: o mylocmatvec(void *grid_data, double *in, double *out)
310: ML beliefs/usage: move this to to ML_XXT_factor routine
311: o my_ml holds address of ML struct associated w/E_loc, grid_data, grid_tag
312: o grid_tag, grid_data, my_ml used in
313: ML_Set_CSolve(my_ml, grid_tag, grid_data, ML_Do_CoarseDirect);
314: o grid_data used in
315: A_matvec(grid_data,v,u);
317: Usage:
318: **************************************xxt.h***********************************/
319: extern PetscInt XXT_factor(xxt_ADT xxt_handle, /* prev. allocated xxt handle */
320: PetscInt *local2global, /* global column mapping */
321: PetscInt n, /* local num rows */
322: PetscInt m, /* local num cols */
323: void *mylocmatvec, /* b_loc=A_local.x_loc */
324: void *grid_data /* grid data for matvec */
325: );
328: /*************************************xxt.h************************************
329: Function: XXT_solve
331: Input : ADT ptr, b (rhs)
332: Output: x (soln)
333: Return:
334: Description: This function performs x = E^-1.b
335: Usage:
336: XXT_solve(xxt_handle, double *x, double *b)
337: XXT_solve(xxt_handle, double *x, NULL)
338: assumes x has been initialized to be b
339: **************************************xxt.h***********************************/
340: extern PetscInt XXT_solve(xxt_ADT xxt_handle, PetscScalar *x, PetscScalar *b);
342: /*************************************xxt.h************************************
343: Function: XXT_stats
345: Input : handle
346: **************************************xxt.h***********************************/
347: extern PetscInt XXT_stats(xxt_ADT xxt_handle);
350: /*************************************xxt.h************************************
351: Function: XXT_sp_1()
353: Input : pointer to ADT
354: Output:
355: Return:
356: Description: sets xxt parameter 1 in xxt_handle
357: Usage: implement later
359: void XXT_sp_1(xxt_handle,parameter 1 value)
360: **************************************xxt.h***********************************/
363: /*************************************xyt.h************************************
364: Module Name: xyt
365: Module Info: need xyt.{c,h} gs.{c,h} comm.{c,h} ivec.{c,h} error.{c,h}
367: author: Henry M. Tufo III
368: e-mail: hmt@asci.uchicago.edu
369: contact:
370: +--------------------------------+--------------------------------+
371: |MCS Division - Building 221 |Department of Computer Science |
372: |Argonne National Laboratory |Ryerson 152 |
373: |9700 S. Cass Avenue |The University of Chicago |
374: |Argonne, IL 60439 |Chicago, IL 60637 |
375: |(630) 252-5354/5986 ph/fx |(773) 702-6019/8487 ph/fx |
376: +--------------------------------+--------------------------------+
378: Last Modification: 3.20.01
379: **************************************xyt.h***********************************/
381: typedef struct xyt_CDT *xyt_ADT;
384: /*************************************xyt.h************************************
385: Function: XYT_new()
387: Return: ADT ptr or NULL upon failure.
388: Description: This function allocates and returns an xyt handle
389: Usage: xyt_handle = xyt_new();
390: **************************************xyt.h***********************************/
391: extern xyt_ADT XYT_new(void);
394: /*************************************xyt.h************************************
395: Function: XYT_free()
397: Input : pointer to ADT.
398: Description: This function frees the storage associated with an xyt handle
399: Usage: XYT_free(xyt_handle);
400: **************************************xyt.h***********************************/
401: extern PetscInt XYT_free(xyt_ADT xyt_handle);
404: /*************************************xyt.h************************************
405: Function: XYT_factor
407: Input : ADT ptr, and pointer to object
408: Output:
409: Return: 0 on failure, 1 on success
410: Description: This function sets the xyt solver
412: xyt assumptions: given n rows of global coarse matrix (E_loc) where
413: o global dofs N = sum_p(n), p=0,P-1
414: (i.e. row dist. with no dof replication)
415: (5.21.00 will handle dif replication case)
416: o m is the number of columns in E_loc (m>=n)
417: o local2global holds global number of column i (i=0,...,m-1)
418: o local2global holds global number of row i (i=0,...,n-1)
419: o mylocmatvec performs E_loc . x_loc where x_loc is an vector of
420: length m in 1-1 correspondence with local2global
421: (note that gs package takes care of communication).
422: (note do not zero out upper m-n entries!)
423: o mylocmatvec(void *grid_data, double *in, double *out)
425: ML beliefs/usage: move this to to ML_XYT_factor routine
426: o my_ml holds address of ML struct associated w/E_loc, grid_data, grid_tag
427: o grid_tag, grid_data, my_ml used in
428: ML_Set_CSolve(my_ml, grid_tag, grid_data, ML_Do_CoarseDirect);
429: o grid_data used in
430: A_matvec(grid_data,v,u);
432: Usage:
433: **************************************xyt.h***********************************/
434: extern PetscInt XYT_factor(xyt_ADT xyt_handle, /* prev. allocated xyt handle */
435: PetscInt *local2global, /* global column mapping */
436: PetscInt n, /* local num rows */
437: PetscInt m, /* local num cols */
438: void *mylocmatvec, /* b_loc=A_local.x_loc */
439: void *grid_data /* grid data for matvec */
440: );
443: /*************************************xyt.h************************************
444: Function: XYT_solve
446: Input : ADT ptr, b (rhs)
447: Output: x (soln)
448: Return:
449: Description: This function performs x = E^-1.b
450: Usage: XYT_solve(xyt_handle, double *x, double *b)
451: **************************************xyt.h***********************************/
452: extern PetscInt XYT_solve(xyt_ADT xyt_handle, PetscScalar *x, PetscScalar *b);
455: /*************************************xyt.h************************************
456: Function: XYT_stats
458: Input : handle
459: **************************************xyt.h***********************************/
460: extern PetscInt XYT_stats(xyt_ADT xyt_handle);
463: /********************************bit_mask.h************************************
465: Author: Henry M. Tufo III
467: e-mail: hmt@cs.brown.edu
469: snail-mail:
470: Division of Applied Mathematics
471: Brown University
472: Providence, RI 02912
474: Last Modification:
475: 11.21.97
476: *********************************bit_mask.h***********************************/
477: extern PetscInt PCTFS_div_ceil(PetscInt numin, PetscInt denom);
478: extern PetscErrorCode PCTFS_set_bit_mask(PetscInt *bm, PetscInt len, PetscInt val);
479: extern PetscInt PCTFS_len_bit_mask(PetscInt num_items);
480: extern PetscInt PCTFS_ct_bits(char *ptr, PetscInt n);
481: extern PetscErrorCode PCTFS_bm_to_proc(char *ptr, PetscInt p_mask, PetscInt *msg_list);
482: extern PetscInt PCTFS_len_buf(PetscInt item_size, PetscInt num_items);
484: #endif