Actual source code: tfs.h


  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 petsc.h
 26:  #include petscsys.h
 27: #if defined(PETSC_HAVE_STDLIB_H)
 28: #include <stdlib.h>
 29: #endif
 30: #if defined(PETSC_HAVE_MALLOC_H)
 31: #include <malloc.h>
 32: #endif
 33:  #include petscblaslapack.h
 34: #include <limits.h>
 35: #include <float.h>

 37: #define X          0
 38: #define Y          1
 39: #define Z          2
 40: #define XY         3
 41: #define XZ         4
 42: #define YZ         5


 45: #define THRESH          0.2
 46: #define N_HALF          4096
 47: #define PRIV_BUF_SZ     45

 49: /*4096 8192 32768 65536 1048576 */
 50: #define MAX_MSG_BUF     32768

 52: #define FULL          2
 53: #define PARTIAL       1
 54: #define NONE          0

 56: #define BYTE                8
 57: #define BIT_0                0x1
 58: #define BIT_1                0x2
 59: #define BIT_2                0x4
 60: #define BIT_3                0x8
 61: #define BIT_4                0x10
 62: #define BIT_5                0x20
 63: #define BIT_6                0x40
 64: #define BIT_7                0x80
 65: #define TOP_BIT         INT_MIN
 66: #define ALL_ONES        -1

 68: #define FALSE                0
 69: #define TRUE                1

 71: #define C                0


 74: #define MAX_VEC                1674
 75: #define FORMAT                30
 76: #define MAX_COL_LEN            100
 77: #define MAX_LINE        FORMAT*MAX_COL_LEN
 78: #define   DELIM         " \n \t"
 79: #define LINE                12
 80: #define C_LINE                80

 82: #define REAL_MAX        DBL_MAX
 83: #define REAL_MIN        DBL_MIN

 85: #define   UT            5               /* dump upper 1/2 */
 86: #define   LT            6               /* dump lower 1/2 */
 87: #define   SYMM          8               /* we assume symm and dump upper 1/2 */
 88: #define   NON_SYMM      9

 90: #define   ROW          10
 91: #define   COL          11

 93: #define EPS   1.0e-14
 94: #define EPS2  1.0e-07


 97: #define MPI   1
 98: #define NX    2

100: #define LOG2(x)                (PetscScalar)log((double)x)/log(2)
101: #define SWAP(a,b)       temp=(a); (a)=(b); (b)=temp;
102: #define P_SWAP(a,b)     ptr=(a); (a)=(b); (b)=ptr;

104: #define MAX_FABS(x,y)   (PetscAbsScalar(x)>PetscAbsScalar(y)) ? ((PetscScalar)x) : ((PetscScalar)y)
105: #define MIN_FABS(x,y)   (PetscAbsScalar(x)<PetscAbsScalar(y)) ? ((PetscScalar)x) : ((PetscScalar)y)

107: /* specer's existence ... can be done w/MAX_ABS */
108: #define EXISTS(x,y)     ((x)==0.0) ? (y) : (x)

110: #define MULT_NEG_ONE(a) (a) *= -1;
111: #define NEG(a)          (a) |= BIT_31;
112: #define POS(a)          (a) &= INT_MAX;




117: /**********************************types.h*************************************

119: Author: Henry M. Tufo III

121: e-mail: hmt@cs.brown.edu

123: snail-mail:
124: Division of Applied Mathematics
125: Brown University
126: Providence, RI 02912

128: Last Modification: 
129: 6.21.97
130: ***********************************types.h************************************/

132: typedef PetscErrorCode (*vfp)(void*,void*,PetscInt,...);
133: typedef PetscErrorCode (*rbfp)(PetscScalar *, PetscScalar *, PetscInt len);
134: typedef PetscInt (*bfp)(void*, void *, PetscInt *len, MPI_Datatype *dt);

136: /***********************************comm.h*************************************

138: Author: Henry M. Tufo III

140: e-mail: hmt@cs.brown.edu

142: snail-mail:
143: Division of Applied Mathematics
144: Brown University
145: Providence, RI 02912

147: Last Modification: 
148: 6.21.97
149: ***********************************comm.h*************************************/


162: #define MSGTAG0 101
163: #define MSGTAG1 1001
164: #define MSGTAG2 76207
165: #define MSGTAG3 100001
166: #define MSGTAG4 163841
167: #define MSGTAG5 249439
168: #define MSGTAG6 10000001

170: #define NON_UNIFORM     0
171: #define GL_MAX          1
172: #define GL_MIN          2
173: #define GL_MULT         3
174: #define GL_ADD          4
175: #define GL_B_XOR        5
176: #define GL_B_OR         6
177: #define GL_B_AND        7
178: #define GL_L_XOR        8
179: #define GL_L_OR         9
180: #define GL_L_AND        10
181: #define GL_MAX_ABS      11
182: #define GL_MIN_ABS      12
183: #define GL_EXISTS       13








217: #define SORT_INTEGER 1
218: #define SORT_INT_PTR 2



235: /***********************************gs.h***************************************

237: Author: Henry M. Tufo III

239: e-mail: hmt@cs.brown.edu

241: snail-mail:
242: Division of Applied Mathematics
243: Brown University
244: Providence, RI 02912

246: Last Modification: 
247: 6.21.97
248: ************************************gs.h**************************************/

250: typedef struct gather_scatter_id *gs_ADT;
251: typedef PetscErrorCode (*Rbfp)(PetscScalar *, PetscScalar *, PetscInt len);


261: /*************************************xxt.h************************************
262: Module Name: xxt
263: Module Info: need xxt.{c,h} gs.{c,h} comm.{c,h} ivec.{c,h} error.{c,h} 

265: author:  Henry M. Tufo III
266: e-mail:  hmt@asci.uchicago.edu
267: contact:
268: +--------------------------------+--------------------------------+
269: |MCS Division - Building 221     |Department of Computer Science  |
270: |Argonne National Laboratory     |Ryerson 152                     |
271: |9700 S. Cass Avenue             |The University of Chicago       |
272: |Argonne, IL  60439              |Chicago, IL  60637              |
273: |(630) 252-5354/5986 ph/fx       |(773) 702-6019/8487 ph/fx       |
274: +--------------------------------+--------------------------------+

276: Last Modification: 3.20.01
277: **************************************xxt.h***********************************/

279: typedef struct xxt_CDT *xxt_ADT;


282: /*************************************xxt.h************************************
283: Function: XXT_new()

285: Return: ADT ptr or NULL upon failure.
286: Description: This function allocates and returns an xxt handle
287: Usage: xxt_handle = xxt_new();
288: **************************************xxt.h***********************************/


292: /*************************************xxt.h************************************
293: Function: XXT_free()

295: Input : pointer to ADT.

297: Description: This function frees the storage associated with an xxt handle
298: Usage: XXT_free(xxt_handle);
299: **************************************xxt.h***********************************/
300: EXTERN PetscInt XXT_free(xxt_ADT xxt_handle);


303: /*************************************xxt.h************************************
304: Function: XXT_factor

306: Input : ADT ptr,  and pointer to object
307: Return: 0 on failure, 1 on success
308: Description: This function sets the xxt solver 

310: xxt assumptions: given n rows of global coarse matrix (E_loc) where
311:    o global dofs N = sum_p(n), p=0,P-1 
312:    (i.e. row dist. with no dof replication)
313:    (5.21.00 will handle dif replication case)
314:    o m is the number of columns in E_loc (m>=n)
315:    o local2global holds global number of column i (i=0,...,m-1)
316:    o local2global holds global number of row    i (i=0,...,n-1)
317:    o mylocmatvec performs E_loc . x_loc where x_loc is an vector of
318:    length m in 1-1 correspondence with local2global
319:    (note that gs package takes care of communication).
320:    (note do not zero out upper m-n entries!)
321:    o mylocmatvec(void *grid_data, double *in, double *out)

323: ML beliefs/usage: move this to to ML_XXT_factor routine
324:    o my_ml holds address of ML struct associated w/E_loc, grid_data, grid_tag
325:    o grid_tag, grid_data, my_ml used in
326:       ML_Set_CSolve(my_ml, grid_tag, grid_data, ML_Do_CoarseDirect);
327:    o grid_data used in 
328:       A_matvec(grid_data,v,u);

330: Usage: 
331: **************************************xxt.h***********************************/
333:                       PetscInt *local2global,    /* global column mapping       */
334:                       PetscInt n,                /* local num rows              */
335:                       PetscInt m,                /* local num cols              */
336:                       void *mylocmatvec,    /* b_loc=A_local.x_loc         */
337:                       void *grid_data       /* grid data for matvec        */
338:                       );


341: /*************************************xxt.h************************************
342: Function: XXT_solve

344: Input : ADT ptr, b (rhs)
345: Output: x (soln)
346: Return:
347: Description: This function performs x = E^-1.b
348: Usage: 
349: XXT_solve(xxt_handle, double *x, double *b)
350: XXT_solve(xxt_handle, double *x, NULL)
351: assumes x has been initialized to be b
352: **************************************xxt.h***********************************/

355: /*************************************xxt.h************************************
356: Function: XXT_stats

358: Input : handle
359: **************************************xxt.h***********************************/


363: /*************************************xxt.h************************************
364: Function: XXT_sp_1()

366: Input : pointer to ADT
367: Output: 
368: Return: 
369: Description: sets xxt parameter 1 in xxt_handle
370: Usage: implement later

372: void XXT_sp_1(xxt_handle,parameter 1 value)
373: **************************************xxt.h***********************************/


376: /*************************************xyt.h************************************
377: Module Name: xyt
378: Module Info: need xyt.{c,h} gs.{c,h} comm.{c,h} ivec.{c,h} error.{c,h} 

380: author:  Henry M. Tufo III
381: e-mail:  hmt@asci.uchicago.edu
382: contact:
383: +--------------------------------+--------------------------------+
384: |MCS Division - Building 221     |Department of Computer Science  |
385: |Argonne National Laboratory     |Ryerson 152                     |
386: |9700 S. Cass Avenue             |The University of Chicago       |
387: |Argonne, IL  60439              |Chicago, IL  60637              |
388: |(630) 252-5354/5986 ph/fx       |(773) 702-6019/8487 ph/fx       |
389: +--------------------------------+--------------------------------+

391: Last Modification: 3.20.01
392: **************************************xyt.h***********************************/

394: typedef struct xyt_CDT *xyt_ADT;


397: /*************************************xyt.h************************************
398: Function: XYT_new()

400: Return: ADT ptr or NULL upon failure.
401: Description: This function allocates and returns an xyt handle
402: Usage: xyt_handle = xyt_new();
403: **************************************xyt.h***********************************/


407: /*************************************xyt.h************************************
408: Function: XYT_free()

410: Input : pointer to ADT.
411: Description: This function frees the storage associated with an xyt handle
412: Usage: XYT_free(xyt_handle);
413: **************************************xyt.h***********************************/
414: EXTERN PetscInt XYT_free(xyt_ADT xyt_handle);


417: /*************************************xyt.h************************************
418: Function: XYT_factor

420: Input : ADT ptr,  and pointer to object
421: Output:
422: Return: 0 on failure, 1 on success
423: Description: This function sets the xyt solver 

425: xyt assumptions: given n rows of global coarse matrix (E_loc) where
426:    o global dofs N = sum_p(n), p=0,P-1 
427:    (i.e. row dist. with no dof replication)
428:    (5.21.00 will handle dif replication case)
429:    o m is the number of columns in E_loc (m>=n)
430:    o local2global holds global number of column i (i=0,...,m-1)
431:    o local2global holds global number of row    i (i=0,...,n-1)
432:    o mylocmatvec performs E_loc . x_loc where x_loc is an vector of
433:    length m in 1-1 correspondence with local2global
434:    (note that gs package takes care of communication).
435:    (note do not zero out upper m-n entries!)
436:    o mylocmatvec(void *grid_data, double *in, double *out)

438: ML beliefs/usage: move this to to ML_XYT_factor routine
439:    o my_ml holds address of ML struct associated w/E_loc, grid_data, grid_tag
440:    o grid_tag, grid_data, my_ml used in
441:       ML_Set_CSolve(my_ml, grid_tag, grid_data, ML_Do_CoarseDirect);
442:    o grid_data used in 
443:       A_matvec(grid_data,v,u);

445: Usage: 
446: **************************************xyt.h***********************************/
448:                       PetscInt *local2global,    /* global column mapping       */
449:                       PetscInt n,                /* local num rows              */
450:                       PetscInt m,                /* local num cols              */
451:                       void *mylocmatvec,    /* b_loc=A_local.x_loc         */
452:                       void *grid_data       /* grid data for matvec        */
453:                       );


456: /*************************************xyt.h************************************
457: Function: XYT_solve

459: Input : ADT ptr, b (rhs)
460: Output: x (soln)
461: Return:
462: Description: This function performs x = E^-1.b
463: Usage: XYT_solve(xyt_handle, double *x, double *b)
464: **************************************xyt.h***********************************/


468: /*************************************xyt.h************************************
469: Function: XYT_stats

471: Input : handle
472: **************************************xyt.h***********************************/


476: /********************************bit_mask.h************************************

478: Author: Henry M. Tufo III

480: e-mail: hmt@cs.brown.edu

482: snail-mail:
483: Division of Applied Mathematics
484: Brown University
485: Providence, RI 02912

487: Last Modification: 
488: 11.21.97
489: *********************************bit_mask.h***********************************/

497: #endif