Actual source code: tfs.h
1: #pragma once
2: #if defined(__GNUC__) || defined(__clang__)
3: #pragma GCC diagnostic ignored "-Wconversion"
4: #endif
6: /*
8: Author: Henry M. Tufo III
10: e-mail: hmt@cs.brown.edu
12: snail-mail:
13: Division of Applied Mathematics
14: Brown University
15: Providence, RI 02912
17: Last Modification:
18: 6.21.97
20: File Description:
21: */
22: #include <petscblaslapack.h>
24: #define X 0
25: #define Y 1
26: #define Z 2
27: #define XY 3
28: #define XZ 4
29: #define YZ 5
31: #define THRESH 0.2
32: #define N_HALF 4096
33: #define PRIV_BUF_SZ 45
35: /*4096 8192 32768 65536 1048576 */
36: #define MAX_MSG_BUF 32768
38: #define FULL 2
39: #define PARTIAL 1
40: #define NONE 0
42: #define BYTE 8
43: #define BIT_0 0x1
44: #define BIT_1 0x2
45: #define BIT_2 0x4
46: #define BIT_3 0x8
47: #define BIT_4 0x10
48: #define BIT_5 0x20
49: #define BIT_6 0x40
50: #define BIT_7 0x80
51: #define TOP_BIT PETSC_INT_MIN
53: #define C 0
55: #define MAX_VEC 1674
56: #define FORMAT 30
57: #define MAX_COL_LEN 100
58: #define MAX_LINE FORMAT *MAX_COL_LEN
59: #define DELIM " \n \t"
60: #define LINE 12
61: #define C_LINE 80
63: #define UT 5 /* dump upper 1/2 */
64: #define LT 6 /* dump lower 1/2 */
65: #define SYMM 8 /* we assume symm and dump upper 1/2 */
66: #define NON_SYMM 9
68: #define ROW 10
69: #define COL 11
71: #define EPS 1.0e-14
72: #define EPS2 1.0e-07
74: #define MPI 1
75: #define NX 2
77: #define SWAP(a, b) \
78: do { \
79: temp = (a); \
80: (a) = (b); \
81: (b) = temp; \
82: } while (0)
83: #define P_SWAP(a, b) \
84: do { \
85: ptr = (a); \
86: (a) = (b); \
87: (b) = ptr; \
88: } while (0)
90: #define MAX_FABS(x, y) (PetscAbsScalar(x) > PetscAbsScalar(y)) ? ((PetscScalar)(x)) : ((PetscScalar)(y))
91: #define MIN_FABS(x, y) (PetscAbsScalar(x) < PetscAbsScalar(y)) ? ((PetscScalar)(x)) : ((PetscScalar)(y))
93: /* specer's existence ... can be done w/MAX_ABS */
94: #define EXISTS(x, y) ((x) == 0.0) ? (y) : (x)
96: #define MULT_NEG_ONE(a) (a) *= -1;
97: #define NEG(a) (a) |= BIT_31;
98: #define POS(a) (a) &= INT_MAX;
100: /*
101: Author: Henry M. Tufo III
103: e-mail: hmt@cs.brown.edu
105: snail-mail:
106: Division of Applied Mathematics
107: Brown University
108: Providence, RI 02912
110: Last Modification:
111: 6.21.97
112: */
114: typedef PetscErrorCode (*vfp)(void *, void *, PetscInt, ...);
115: typedef PetscErrorCode (*rbfp)(PetscScalar *, PetscScalar *, PetscInt);
116: typedef PetscInt (*bfp)(void *, void *, PetscInt *, MPI_Datatype *);
118: /*
120: Author: Henry M. Tufo III
122: e-mail: hmt@cs.brown.edu
124: snail-mail:
125: Division of Applied Mathematics
126: Brown University
127: Providence, RI 02912
129: Last Modification:
130: 6.21.97
131: */
132: PETSC_INTERN PetscMPIInt PCTFS_my_id;
133: PETSC_INTERN PetscMPIInt PCTFS_num_nodes;
134: PETSC_INTERN PetscMPIInt PCTFS_floor_num_nodes;
135: PETSC_INTERN PetscMPIInt PCTFS_i_log2_num_nodes;
137: PETSC_INTERN PetscErrorCode PCTFS_giop(PetscInt *, PetscInt *, PetscInt, PetscInt *);
138: PETSC_INTERN PetscErrorCode PCTFS_grop(PetscScalar *, PetscScalar *, PetscInt, PetscInt *);
139: PETSC_INTERN PetscErrorCode PCTFS_comm_init(void);
140: PETSC_INTERN PetscErrorCode PCTFS_giop_hc(PetscInt *, PetscInt *, PetscInt, PetscInt *, PetscInt);
141: PETSC_INTERN PetscErrorCode PCTFS_grop_hc(PetscScalar *, PetscScalar *, PetscInt, PetscInt *, PetscInt);
142: PETSC_INTERN PetscErrorCode PCTFS_ssgl_radd(PetscScalar *, PetscScalar *, PetscInt, PetscInt *);
144: #define MSGTAG0 101
145: #define MSGTAG1 1001
146: #define MSGTAG2 76207
147: #define MSGTAG3 100001
148: #define MSGTAG4 163841
149: #define MSGTAG5 249439
150: #define MSGTAG6 10000001
152: #define NON_UNIFORM 0
153: #define GL_MAX 1
154: #define GL_MIN 2
155: #define GL_MULT 3
156: #define GL_ADD 4
157: #define GL_B_XOR 5
158: #define GL_B_OR 6
159: #define GL_B_AND 7
160: #define GL_L_XOR 8
161: #define GL_L_OR 9
162: #define GL_L_AND 10
163: #define GL_MAX_ABS 11
164: #define GL_MIN_ABS 12
165: #define GL_EXISTS 13
167: PETSC_INTERN PetscInt *PCTFS_ivec_copy(PetscInt *, PetscInt *, PetscInt);
168: PETSC_INTERN PetscErrorCode PCTFS_ivec_zero(PetscInt *, PetscInt);
169: PETSC_INTERN PetscErrorCode PCTFS_ivec_set(PetscInt *, PetscInt, PetscInt);
171: PETSC_INTERN PetscInt PCTFS_ivec_sum(PetscInt *, PetscInt);
172: PETSC_INTERN vfp PCTFS_ivec_fct_addr(PetscInt);
174: PETSC_INTERN PetscErrorCode PCTFS_ivec_non_uniform(PetscInt *, PetscInt *, PetscInt, ...);
175: PETSC_INTERN PetscErrorCode PCTFS_ivec_max(PetscInt *, PetscInt *, PetscInt);
176: PETSC_INTERN PetscErrorCode PCTFS_ivec_min(PetscInt *, PetscInt *, PetscInt);
177: PETSC_INTERN PetscErrorCode PCTFS_ivec_mult(PetscInt *, PetscInt *, PetscInt);
178: PETSC_INTERN PetscErrorCode PCTFS_ivec_add(PetscInt *, PetscInt *, PetscInt);
179: PETSC_INTERN PetscErrorCode PCTFS_ivec_xor(PetscInt *, PetscInt *, PetscInt);
180: PETSC_INTERN PetscErrorCode PCTFS_ivec_or(PetscInt *, PetscInt *, PetscInt);
181: PETSC_INTERN PetscErrorCode PCTFS_ivec_and(PetscInt *, PetscInt *, PetscInt);
182: PETSC_INTERN PetscErrorCode PCTFS_ivec_lxor(PetscInt *, PetscInt *, PetscInt);
183: PETSC_INTERN PetscErrorCode PCTFS_ivec_lor(PetscInt *, PetscInt *, PetscInt);
184: PETSC_INTERN PetscErrorCode PCTFS_ivec_land(PetscInt *, PetscInt *, PetscInt);
185: PETSC_INTERN PetscErrorCode PCTFS_ivec_and3(PetscInt *, PetscInt *, PetscInt *, PetscInt);
187: PETSC_INTERN PetscErrorCode PCTFS_ivec_sort_companion(PetscInt *, PetscInt *, PetscInt);
188: PETSC_INTERN PetscErrorCode PCTFS_ivec_sort(PetscInt *, PetscInt);
189: PETSC_INTERN PetscErrorCode PCTFS_SMI_sort(void *, void *, PetscInt, PetscInt);
190: PETSC_INTERN PetscInt PCTFS_ivec_binary_search(PetscInt, PetscInt *, PetscInt);
191: PETSC_INTERN PetscInt PCTFS_ivec_linear_search(PetscInt, PetscInt *, PetscInt);
193: PETSC_INTERN PetscErrorCode PCTFS_ivec_sort_companion_hack(PetscInt *, PetscInt **, PetscInt);
195: #define SORT_INTEGER 1
196: #define SORT_INT_PTR 2
198: PETSC_INTERN PetscErrorCode PCTFS_rvec_zero(PetscScalar *, PetscInt);
199: PETSC_INTERN PetscErrorCode PCTFS_rvec_one(PetscScalar *, PetscInt);
200: PETSC_INTERN PetscErrorCode PCTFS_rvec_set(PetscScalar *, PetscScalar, PetscInt);
201: PETSC_INTERN PetscErrorCode PCTFS_rvec_copy(PetscScalar *, PetscScalar *, PetscInt);
202: PETSC_INTERN PetscErrorCode PCTFS_rvec_scale(PetscScalar *, PetscScalar, PetscInt);
204: PETSC_INTERN vfp PCTFS_rvec_fct_addr(PetscInt);
205: PETSC_INTERN PetscErrorCode PCTFS_rvec_add(PetscScalar *, PetscScalar *, PetscInt);
206: PETSC_INTERN PetscErrorCode PCTFS_rvec_mult(PetscScalar *, PetscScalar *, PetscInt);
207: PETSC_INTERN PetscErrorCode PCTFS_rvec_max(PetscScalar *, PetscScalar *, PetscInt);
208: PETSC_INTERN PetscErrorCode PCTFS_rvec_max_abs(PetscScalar *, PetscScalar *, PetscInt);
209: PETSC_INTERN PetscErrorCode PCTFS_rvec_min(PetscScalar *, PetscScalar *, PetscInt);
210: PETSC_INTERN PetscErrorCode PCTFS_rvec_min_abs(PetscScalar *, PetscScalar *, PetscInt);
212: /*
213: Author: Henry M. Tufo III
215: e-mail: hmt@cs.brown.edu
217: snail-mail:
218: Division of Applied Mathematics
219: Brown University
220: Providence, RI 02912
222: Last Modification:
223: 6.21.97
224: */
226: typedef struct gather_scatter_id *PCTFS_gs_ADT;
228: PETSC_INTERN PCTFS_gs_ADT PCTFS_gs_init(PetscInt *, PetscInt, PetscInt);
229: PETSC_INTERN PetscErrorCode PCTFS_gs_gop_vec(PCTFS_gs_ADT, PetscScalar *, const char *, PetscInt);
230: PETSC_INTERN PetscErrorCode PCTFS_gs_gop_hc(PCTFS_gs_ADT, PetscScalar *, const char *, PetscInt);
231: PETSC_INTERN PetscErrorCode PCTFS_gs_free(PCTFS_gs_ADT);
232: PETSC_INTERN PetscErrorCode PCTFS_gs_init_msg_buf_sz(PetscInt);
233: PETSC_INTERN PetscErrorCode PCTFS_gs_init_vec_sz(PetscInt);
235: /*
236: Module Name: xxt
237: Module Info: need xxt.{c,h} gs.{c,h} comm.{c,h} ivec.{c,h} error.{c,h}
239: author: Henry M. Tufo III
240: e-mail: hmt@asci.uchicago.edu
241: contact:
242: +--------------------------------+--------------------------------+
243: |MCS Division - Building 221 |Department of Computer Science |
244: |Argonne National Laboratory |Ryerson 152 |
245: |9700 S. Cass Avenue |The University of Chicago |
246: |Argonne, IL 60439 |Chicago, IL 60637 |
247: |(630) 252-5354/5986 ph/fx |(773) 702-6019/8487 ph/fx |
248: +--------------------------------+--------------------------------+
250: Last Modification: 3.20.01
251: */
253: typedef struct xxt_CDT *xxt_ADT;
255: /*
256: Function: XXT_new()
258: Return: ADT ptr or NULL upon failure.
259: Description: This function allocates and returns an xxt handle
260: Usage: xxt_handle = xxt_new();
261: */
262: PETSC_INTERN xxt_ADT XXT_new(void);
264: /*
265: Function: XXT_free()
267: Input : pointer to ADT.
269: Description: This function frees the storage associated with an xxt handle
270: Usage: XXT_free(xxt_handle);
271: */
272: PETSC_INTERN PetscErrorCode XXT_free(xxt_ADT);
274: /*
275: Function: XXT_factor
277: Input : ADT ptr, and pointer to object
278: Return: 0 on failure, 1 on success
279: Description: This function sets the xxt solver
281: xxt assumptions: given n rows of global coarse matrix (E_loc) where
282: o global dofs N = sum_p(n), p=0,P-1
283: (i.e. row dist. with no dof replication)
284: (5.21.00 will handle dif replication case)
285: o m is the number of columns in E_loc (m>=n)
286: o local2global holds global number of column i (i=0,...,m-1)
287: o local2global holds global number of row i (i=0,...,n-1)
288: o mylocmatvec performs E_loc . x_loc where x_loc is an vector of
289: length m in 1-1 correspondence with local2global
290: (note that gs package takes care of communication).
291: (note do not zero out upper m-n entries!)
292: o mylocmatvec(void *grid_data, double *in, double *out)
294: ML beliefs/usage: move this to ML_XXT_factor routine
295: o my_ml holds address of ML struct associated w/E_loc, grid_data, grid_tag
296: o grid_tag, grid_data, my_ml used in
297: ML_Set_CSolve(my_ml, grid_tag, grid_data, ML_Do_CoarseDirect);
298: o grid_data used in
299: A_matvec(grid_data,v,u);
301: Usage:
302: */
303: PETSC_INTERN PetscErrorCode XXT_factor(xxt_ADT, /* prev. allocated xxt handle */
304: PetscInt *, /* global column mapping */
305: PetscInt, /* local num rows */
306: PetscInt, /* local num cols */
307: PetscErrorCode (*)(void *, PetscScalar *, PetscScalar *), /* b_loc=A_local.x_loc */
308: void *); /* grid data for matvec */
310: /*
311: Function: XXT_solve
313: Input : ADT ptr, b (rhs)
314: Output: x (soln)
315: Return:
316: Description: This function performs x = E^-1.b
317: Usage:
318: XXT_solve(xxt_handle, double *x, double *b)
319: XXT_solve(xxt_handle, double *x, NULL)
320: assumes x has been initialized to be b
321: */
322: PETSC_INTERN PetscErrorCode XXT_solve(xxt_ADT, PetscScalar *, PetscScalar *);
324: /*
325: Function: XXT_sp_1()
327: Input : pointer to ADT
328: Output:
329: Return:
330: Description: sets xxt parameter 1 in xxt_handle
331: Usage: implement later
333: void XXT_sp_1(xxt_handle,parameter 1 value)
334: */
336: /*
337: Module Name: xyt
338: Module Info: need xyt.{c,h} gs.{c,h} comm.{c,h} ivec.{c,h} error.{c,h}
340: author: Henry M. Tufo III
341: e-mail: hmt@asci.uchicago.edu
342: contact:
343: +--------------------------------+--------------------------------+
344: |MCS Division - Building 221 |Department of Computer Science |
345: |Argonne National Laboratory |Ryerson 152 |
346: |9700 S. Cass Avenue |The University of Chicago |
347: |Argonne, IL 60439 |Chicago, IL 60637 |
348: |(630) 252-5354/5986 ph/fx |(773) 702-6019/8487 ph/fx |
349: +--------------------------------+--------------------------------+
351: Last Modification: 3.20.01
352: */
354: typedef struct xyt_CDT *xyt_ADT;
356: /*
357: Function: XYT_new()
359: Return: ADT ptr or NULL upon failure.
360: Description: This function allocates and returns an xyt handle
361: Usage: xyt_handle = xyt_new();
362: */
363: PETSC_INTERN xyt_ADT XYT_new(void);
365: /*
366: Function: XYT_free()
368: Input : pointer to ADT.
369: Description: This function frees the storage associated with an xyt handle
370: Usage: XYT_free(xyt_handle);
371: */
372: PETSC_INTERN PetscErrorCode XYT_free(xyt_ADT);
374: /*
375: Function: XYT_factor
377: Input : ADT ptr, and pointer to object
378: Output:
379: Return: 0 on failure, 1 on success
380: Description: This function sets the xyt solver
382: xyt assumptions: given n rows of global coarse matrix (E_loc) where
383: o global dofs N = sum_p(n), p=0,P-1
384: (i.e. row dist. with no dof replication)
385: (5.21.00 will handle dif replication case)
386: o m is the number of columns in E_loc (m>=n)
387: o local2global holds global number of column i (i=0,...,m-1)
388: o local2global holds global number of row i (i=0,...,n-1)
389: o mylocmatvec performs E_loc . x_loc where x_loc is an vector of
390: length m in 1-1 correspondence with local2global
391: (note that gs package takes care of communication).
392: (note do not zero out upper m-n entries!)
393: o mylocmatvec(void *grid_data, double *in, double *out)
395: ML beliefs/usage: move this to ML_XYT_factor routine
396: o my_ml holds address of ML struct associated w/E_loc, grid_data, grid_tag
397: o grid_tag, grid_data, my_ml used in
398: ML_Set_CSolve(my_ml, grid_tag, grid_data, ML_Do_CoarseDirect);
399: o grid_data used in
400: A_matvec(grid_data,v,u);
402: Usage:
403: */
404: PETSC_INTERN PetscErrorCode XYT_factor(xyt_ADT, /* prev. allocated xyt handle */
405: PetscInt *, /* global column mapping */
406: PetscInt, /* local num rows */
407: PetscInt, /* local num cols */
408: PetscErrorCode (*)(void *, PetscScalar *, PetscScalar *), /* b_loc=A_local.x_loc */
409: void *); /* grid data for matvec */
411: /*
412: Function: XYT_solve
414: Input : ADT ptr, b (rhs)
415: Output: x (soln)
416: Return:
417: Description: This function performs x = E^-1.b
418: Usage: XYT_solve(xyt_handle, double *x, double *b)
419: */
420: PETSC_INTERN PetscErrorCode XYT_solve(xyt_ADT, PetscScalar *, PetscScalar *);
422: /*
423: Function: XYT_stats
425: Input : handle
426: */
427: PETSC_INTERN PetscErrorCode XYT_stats(xyt_ADT);
429: /*
431: Author: Henry M. Tufo III
433: e-mail: hmt@cs.brown.edu
435: snail-mail:
436: Division of Applied Mathematics
437: Brown University
438: Providence, RI 02912
440: Last Modification:
441: 11.21.97
442: */
443: PETSC_INTERN PetscInt PCTFS_div_ceil(PetscInt, PetscInt);
444: PETSC_INTERN PetscErrorCode PCTFS_set_bit_mask(PetscInt *, PetscInt, PetscInt);
445: PETSC_INTERN PetscInt PCTFS_len_bit_mask(PetscInt);
446: PETSC_INTERN PetscInt PCTFS_ct_bits(char *, PetscInt);
447: PETSC_INTERN PetscErrorCode PCTFS_bm_to_proc(char *, PetscInt, PetscInt *);
448: PETSC_INTERN PetscInt PCTFS_len_buf(PetscInt, PetscInt);