source: CIVL/examples/mpi-omp/AMG2013/struct_mv/struct_mv.h@ beab7f2

main test-branch
Last change on this file since beab7f2 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 100.7 KB
Line 
1/*BHEADER**********************************************************************
2 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
3 * Produced at the Lawrence Livermore National Laboratory.
4 * This file is part of HYPRE. See file COPYRIGHT for details.
5 *
6 * HYPRE is free software; you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License (as published by the Free
8 * Software Foundation) version 2.1 dated February 1999.
9 *
10 * $Revision: 2.4 $
11 ***********************************************************************EHEADER*/
12/*BHEADER**********************************************************************
13 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
14 * Produced at the Lawrence Livermore National Laboratory.
15 * This file is part of HYPRE. See file COPYRIGHT for details.
16 *
17 * HYPRE is free software; you can redistribute it and/or modify it under the
18 * terms of the GNU Lesser General Public License (as published by the Free
19 * Software Foundation) version 2.1 dated February 1999.
20 *
21 * $Revision: 2.4 $
22 ***********************************************************************EHEADER*/
23/*BHEADER**********************************************************************
24 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
25 * Produced at the Lawrence Livermore National Laboratory.
26 * This file is part of HYPRE. See file COPYRIGHT for details.
27 *
28 * HYPRE is free software; you can redistribute it and/or modify it under the
29 * terms of the GNU Lesser General Public License (as published by the Free
30 * Software Foundation) version 2.1 dated February 1999.
31 *
32 * $Revision: 2.4 $
33 ***********************************************************************EHEADER*/
34/*BHEADER**********************************************************************
35 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
36 * Produced at the Lawrence Livermore National Laboratory.
37 * This file is part of HYPRE. See file COPYRIGHT for details.
38 *
39 * HYPRE is free software; you can redistribute it and/or modify it under the
40 * terms of the GNU Lesser General Public License (as published by the Free
41 * Software Foundation) version 2.1 dated February 1999.
42 *
43 * $Revision: 2.4 $
44 ***********************************************************************EHEADER*/
45/*BHEADER**********************************************************************
46 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
47 * Produced at the Lawrence Livermore National Laboratory.
48 * This file is part of HYPRE. See file COPYRIGHT for details.
49 *
50 * HYPRE is free software; you can redistribute it and/or modify it under the
51 * terms of the GNU Lesser General Public License (as published by the Free
52 * Software Foundation) version 2.1 dated February 1999.
53 *
54 * $Revision: 2.4 $
55 ***********************************************************************EHEADER*/
56/*BHEADER**********************************************************************
57 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
58 * Produced at the Lawrence Livermore National Laboratory.
59 * This file is part of HYPRE. See file COPYRIGHT for details.
60 *
61 * HYPRE is free software; you can redistribute it and/or modify it under the
62 * terms of the GNU Lesser General Public License (as published by the Free
63 * Software Foundation) version 2.1 dated February 1999.
64 *
65 * $Revision: 2.4 $
66 ***********************************************************************EHEADER*/
67/*BHEADER**********************************************************************
68 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
69 * Produced at the Lawrence Livermore National Laboratory.
70 * This file is part of HYPRE. See file COPYRIGHT for details.
71 *
72 * HYPRE is free software; you can redistribute it and/or modify it under the
73 * terms of the GNU Lesser General Public License (as published by the Free
74 * Software Foundation) version 2.1 dated February 1999.
75 *
76 * $Revision: 2.4 $
77 ***********************************************************************EHEADER*/
78/*BHEADER**********************************************************************
79 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
80 * Produced at the Lawrence Livermore National Laboratory.
81 * This file is part of HYPRE. See file COPYRIGHT for details.
82 *
83 * HYPRE is free software; you can redistribute it and/or modify it under the
84 * terms of the GNU Lesser General Public License (as published by the Free
85 * Software Foundation) version 2.1 dated February 1999.
86 *
87 * $Revision: 2.4 $
88 ***********************************************************************EHEADER*/
89/*BHEADER**********************************************************************
90 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
91 * Produced at the Lawrence Livermore National Laboratory.
92 * This file is part of HYPRE. See file COPYRIGHT for details.
93 *
94 * HYPRE is free software; you can redistribute it and/or modify it under the
95 * terms of the GNU Lesser General Public License (as published by the Free
96 * Software Foundation) version 2.1 dated February 1999.
97 *
98 * $Revision: 2.4 $
99 ***********************************************************************EHEADER*/
100/*BHEADER**********************************************************************
101 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
102 * Produced at the Lawrence Livermore National Laboratory.
103 * This file is part of HYPRE. See file COPYRIGHT for details.
104 *
105 * HYPRE is free software; you can redistribute it and/or modify it under the
106 * terms of the GNU Lesser General Public License (as published by the Free
107 * Software Foundation) version 2.1 dated February 1999.
108 *
109 * $Revision: 2.4 $
110 ***********************************************************************EHEADER*/
111
112
113
114
115
116
117
118
119
120
121
122#include "utilities.h"
123
124#include "HYPRE_struct_mv.h"
125
126#ifndef hypre_STRUCT_MV_HEADER
127#define hypre_STRUCT_MV_HEADER
128
129#ifdef __cplusplus
130extern "C" {
131#endif
132
133
134/******************************************************************************
135 *
136 * Header info for the Box structures
137 *
138 *****************************************************************************/
139
140#ifndef hypre_BOX_HEADER
141#define hypre_BOX_HEADER
142
143/*--------------------------------------------------------------------------
144 * hypre_Index:
145 * This is used to define indices in index space, or dimension
146 * sizes of boxes.
147 *
148 * The spatial dimensions x, y, and z may be specified by the
149 * integers 0, 1, and 2, respectively (see the hypre_IndexD macro below).
150 * This simplifies the code in the hypre_Box class by reducing code
151 * replication.
152 *--------------------------------------------------------------------------*/
153
154typedef int hypre_Index[3];
155typedef int *hypre_IndexRef;
156
157/*--------------------------------------------------------------------------
158 * hypre_Box:
159 *--------------------------------------------------------------------------*/
160
161typedef struct hypre_Box_struct
162{
163 hypre_Index imin; /* min bounding indices */
164 hypre_Index imax; /* max bounding indices */
165
166} hypre_Box;
167
168/*--------------------------------------------------------------------------
169 * hypre_BoxArray:
170 * An array of boxes.
171 *--------------------------------------------------------------------------*/
172
173typedef struct hypre_BoxArray_struct
174{
175 hypre_Box *boxes; /* Array of boxes */
176 int size; /* Size of box array */
177 int alloc_size; /* Size of currently alloced space */
178
179} hypre_BoxArray;
180
181#define hypre_BoxArrayExcess 10
182
183/*--------------------------------------------------------------------------
184 * hypre_BoxArrayArray:
185 * An array of box arrays.
186 *--------------------------------------------------------------------------*/
187
188typedef struct hypre_BoxArrayArray_struct
189{
190 hypre_BoxArray **box_arrays; /* Array of pointers to box arrays */
191 int size; /* Size of box array array */
192
193} hypre_BoxArrayArray;
194
195
196/*--------------------------------------------------------------------------
197 * Accessor macros: hypre_Index
198 *--------------------------------------------------------------------------*/
199
200#define hypre_IndexD(index, d) (index[d])
201
202#define hypre_IndexX(index) hypre_IndexD(index, 0)
203#define hypre_IndexY(index) hypre_IndexD(index, 1)
204#define hypre_IndexZ(index) hypre_IndexD(index, 2)
205
206/*--------------------------------------------------------------------------
207 * Member functions: hypre_Index
208 *--------------------------------------------------------------------------*/
209
210#define hypre_SetIndex(index, ix, iy, iz) \
211( hypre_IndexX(index) = ix,\
212 hypre_IndexY(index) = iy,\
213 hypre_IndexZ(index) = iz )
214
215#define hypre_ClearIndex(index) hypre_SetIndex(index, 0, 0, 0)
216
217#define hypre_CopyIndex(index1, index2) \
218( hypre_IndexX(index2) = hypre_IndexX(index1),\
219 hypre_IndexY(index2) = hypre_IndexY(index1),\
220 hypre_IndexZ(index2) = hypre_IndexZ(index1) )
221
222#define hypre_CopyToCleanIndex(in_index, ndim, out_index) \
223{\
224 int d;\
225 for (d = 0; d < ndim; d++)\
226 {\
227 hypre_IndexD(out_index, d) = hypre_IndexD(in_index, d);\
228 }\
229 for (d = ndim; d < 3; d++)\
230 {\
231 hypre_IndexD(out_index, d) = 0;\
232 }\
233}
234
235/*--------------------------------------------------------------------------
236 * Accessor macros: hypre_Box
237 *--------------------------------------------------------------------------*/
238
239#define hypre_BoxIMin(box) ((box) -> imin)
240#define hypre_BoxIMax(box) ((box) -> imax)
241
242#define hypre_AddIndex(index1, index2, index3) \
243( hypre_IndexX(index3) = hypre_IndexX(index2) + hypre_IndexX(index1),\
244 hypre_IndexY(index3) = hypre_IndexY(index2) + hypre_IndexY(index1),\
245 hypre_IndexZ(index3) = hypre_IndexZ(index2) + hypre_IndexZ(index1) )
246
247#define hypre_SubtractIndex(index1, index2, index3) \
248( hypre_IndexX(index3) = hypre_IndexX(index1) - hypre_IndexX(index2),\
249 hypre_IndexY(index3) = hypre_IndexY(index1) - hypre_IndexY(index2),\
250 hypre_IndexZ(index3) = hypre_IndexZ(index1) - hypre_IndexZ(index2) )
251
252#define hypre_BoxIMinD(box, d) (hypre_IndexD(hypre_BoxIMin(box), d))
253#define hypre_BoxIMaxD(box, d) (hypre_IndexD(hypre_BoxIMax(box), d))
254#define hypre_BoxSizeD(box, d) \
255hypre_max(0, (hypre_BoxIMaxD(box, d) - hypre_BoxIMinD(box, d) + 1))
256
257#define hypre_BoxIMinX(box) hypre_BoxIMinD(box, 0)
258#define hypre_BoxIMinY(box) hypre_BoxIMinD(box, 1)
259#define hypre_BoxIMinZ(box) hypre_BoxIMinD(box, 2)
260
261#define hypre_BoxIMaxX(box) hypre_BoxIMaxD(box, 0)
262#define hypre_BoxIMaxY(box) hypre_BoxIMaxD(box, 1)
263#define hypre_BoxIMaxZ(box) hypre_BoxIMaxD(box, 2)
264
265#define hypre_BoxSizeX(box) hypre_BoxSizeD(box, 0)
266#define hypre_BoxSizeY(box) hypre_BoxSizeD(box, 1)
267#define hypre_BoxSizeZ(box) hypre_BoxSizeD(box, 2)
268
269#define hypre_BoxEqualP( box1, box2 ) (\
270 hypre_BoxIMinX(box1)==hypre_BoxIMinX(box2) &&\
271 hypre_BoxIMaxX(box1)==hypre_BoxIMaxX(box2) &&\
272 hypre_BoxIMinY(box1)==hypre_BoxIMinY(box2) &&\
273 hypre_BoxIMaxY(box1)==hypre_BoxIMaxY(box2) &&\
274 hypre_BoxIMinZ(box1)==hypre_BoxIMinZ(box2) &&\
275 hypre_BoxIMaxZ(box1)==hypre_BoxIMaxZ(box2) )
276
277#define hypre_IndexInBoxP( index, box ) (\
278 hypre_IndexX(index)>=hypre_BoxIMinX(box) &&\
279 hypre_IndexX(index)<=hypre_BoxIMaxX(box) &&\
280 hypre_IndexY(index)>=hypre_BoxIMinY(box) &&\
281 hypre_IndexY(index)<=hypre_BoxIMaxY(box) &&\
282 hypre_IndexZ(index)>=hypre_BoxIMinZ(box) &&\
283 hypre_IndexZ(index)<=hypre_BoxIMaxZ(box) )
284
285
286#define hypre_IndexDInBoxP( index, d, box ) (\
287 hypre_IndexD(index, d)>=hypre_BoxIMinD(box, d) &&\
288 hypre_IndexD(index, d)<=hypre_BoxIMaxD(box, d) )
289
290#define hypre_CopyBox(box1, box2) \
291( hypre_CopyIndex(hypre_BoxIMin(box1), hypre_BoxIMin(box2)),\
292 hypre_CopyIndex(hypre_BoxIMax(box1), hypre_BoxIMax(box2)) )
293
294#define hypre_BoxVolume(box) \
295(hypre_BoxSizeX(box) * hypre_BoxSizeY(box) * hypre_BoxSizeZ(box))
296
297#define hypre_BoxShiftPos(box, shift) \
298{\
299 hypre_BoxIMinX(box) += hypre_IndexX(shift);\
300 hypre_BoxIMinY(box) += hypre_IndexY(shift);\
301 hypre_BoxIMinZ(box) += hypre_IndexZ(shift);\
302 hypre_BoxIMaxX(box) += hypre_IndexX(shift);\
303 hypre_BoxIMaxY(box) += hypre_IndexY(shift);\
304 hypre_BoxIMaxZ(box) += hypre_IndexZ(shift);\
305}
306
307#define hypre_BoxShiftNeg(box, shift) \
308{\
309 hypre_BoxIMinX(box) -= hypre_IndexX(shift);\
310 hypre_BoxIMinY(box) -= hypre_IndexY(shift);\
311 hypre_BoxIMinZ(box) -= hypre_IndexZ(shift);\
312 hypre_BoxIMaxX(box) -= hypre_IndexX(shift);\
313 hypre_BoxIMaxY(box) -= hypre_IndexY(shift);\
314 hypre_BoxIMaxZ(box) -= hypre_IndexZ(shift);\
315}
316
317#define hypre_BoxIndexRank(box, index) \
318((hypre_IndexX(index) - hypre_BoxIMinX(box)) + \
319 ((hypre_IndexY(index) - hypre_BoxIMinY(box)) + \
320 ((hypre_IndexZ(index) - hypre_BoxIMinZ(box)) * \
321 hypre_BoxSizeY(box))) * \
322 hypre_BoxSizeX(box))
323
324/* The first hypre_CCBoxIndexRank is better style because it keeps
325 its similarity to the variable coefficient hypre_BoxIndexRank.
326 The second one sometimes avoids compiler warnings...*/
327#define hypre_CCBoxIndexRank(box, index) 0
328#define hypre_CCBoxIndexRank_noargs() 0
329
330#define hypre_BoxOffsetDistance(box, index) \
331(hypre_IndexX(index) + \
332 (hypre_IndexY(index) + \
333 (hypre_IndexZ(index) * \
334 hypre_BoxSizeY(box))) * \
335 hypre_BoxSizeX(box))
336
337#define hypre_CCBoxOffsetDistance(box, index) 0
338
339/*--------------------------------------------------------------------------
340 * Accessor macros: hypre_BoxArray
341 *--------------------------------------------------------------------------*/
342
343#define hypre_BoxArrayBoxes(box_array) ((box_array) -> boxes)
344#define hypre_BoxArrayBox(box_array, i) &((box_array) -> boxes[(i)])
345#define hypre_BoxArraySize(box_array) ((box_array) -> size)
346#define hypre_BoxArrayAllocSize(box_array) ((box_array) -> alloc_size)
347
348/*--------------------------------------------------------------------------
349 * Accessor macros: hypre_BoxArrayArray
350 *--------------------------------------------------------------------------*/
351
352#define hypre_BoxArrayArrayBoxArrays(box_array_array) \
353((box_array_array) -> box_arrays)
354#define hypre_BoxArrayArrayBoxArray(box_array_array, i) \
355((box_array_array) -> box_arrays[(i)])
356#define hypre_BoxArrayArraySize(box_array_array) \
357((box_array_array) -> size)
358
359/*--------------------------------------------------------------------------
360 * Looping macros:
361 *--------------------------------------------------------------------------*/
362
363#define hypre_ForBoxI(i, box_array) \
364for (i = 0; i < hypre_BoxArraySize(box_array); i++)
365
366#define hypre_ForBoxArrayI(i, box_array_array) \
367for (i = 0; i < hypre_BoxArrayArraySize(box_array_array); i++)
368
369/*--------------------------------------------------------------------------
370 * BoxLoop macros:
371 *
372 * NOTE: PThreads version of BoxLoop looping macros are in `box_pthreads.h'.
373 *
374 *--------------------------------------------------------------------------*/
375
376#ifndef HYPRE_USE_PTHREADS
377
378#define hypre_BoxLoopDeclareS(dbox, stride, sx, sy, sz) \
379int sx = (hypre_IndexX(stride));\
380int sy = (hypre_IndexY(stride)*hypre_BoxSizeX(dbox));\
381int sz = (hypre_IndexZ(stride)*\
382 hypre_BoxSizeX(dbox)*hypre_BoxSizeY(dbox))
383
384#define hypre_BoxLoopDeclareN(loop_size) \
385int hypre__nx = hypre_IndexX(loop_size);\
386int hypre__ny = hypre_IndexY(loop_size);\
387int hypre__nz = hypre_IndexZ(loop_size);\
388int hypre__mx = hypre__nx;\
389int hypre__my = hypre__ny;\
390int hypre__mz = hypre__nz;\
391int hypre__dir, hypre__max;\
392int hypre__div, hypre__mod;\
393int hypre__block, hypre__num_blocks;\
394hypre__dir = 0;\
395hypre__max = hypre__nx;\
396if (hypre__ny > hypre__max)\
397{\
398 hypre__dir = 1;\
399 hypre__max = hypre__ny;\
400}\
401if (hypre__nz > hypre__max)\
402{\
403 hypre__dir = 2;\
404 hypre__max = hypre__nz;\
405}\
406hypre__num_blocks = hypre_NumThreads();\
407if (hypre__max < hypre__num_blocks)\
408{\
409 hypre__num_blocks = hypre__max;\
410}\
411if (hypre__num_blocks > 0)\
412{\
413 hypre__div = hypre__max / hypre__num_blocks;\
414 hypre__mod = hypre__max % hypre__num_blocks;\
415}
416
417#define hypre_BoxLoopSet(i, j, k) \
418i = 0;\
419j = 0;\
420k = 0;\
421hypre__nx = hypre__mx;\
422hypre__ny = hypre__my;\
423hypre__nz = hypre__mz;\
424if (hypre__num_blocks > 1)\
425{\
426 if (hypre__dir == 0)\
427 {\
428 i = hypre__block * hypre__div + hypre_min(hypre__mod, hypre__block);\
429 hypre__nx = hypre__div + ((hypre__mod > hypre__block) ? 1 : 0);\
430 }\
431 else if (hypre__dir == 1)\
432 {\
433 j = hypre__block * hypre__div + hypre_min(hypre__mod, hypre__block);\
434 hypre__ny = hypre__div + ((hypre__mod > hypre__block) ? 1 : 0);\
435 }\
436 else if (hypre__dir == 2)\
437 {\
438 k = hypre__block * hypre__div + hypre_min(hypre__mod, hypre__block);\
439 hypre__nz = hypre__div + ((hypre__mod > hypre__block) ? 1 : 0);\
440 }\
441}
442
443#define hypre_BoxLoopGetIndex( index, base, i, j, k )\
444 hypre_SetIndex( index, i+hypre_IndexX(base),\
445 j+hypre_IndexY(base), k+hypre_IndexZ(base) )
446
447/*-----------------------------------*/
448
449#define hypre_BoxLoop0Begin(loop_size)\
450{\
451 hypre_BoxLoopDeclareN(loop_size);
452
453#define hypre_BoxLoop0For(i, j, k)\
454 for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
455 {\
456 hypre_BoxLoopSet(i, j, k);\
457 for (k = 0; k < hypre__nz; k++)\
458 {\
459 for (j = 0; j < hypre__ny; j++)\
460 {\
461 for (i = 0; i < hypre__nx; i++)\
462 {
463
464#define hypre_BoxLoop0End()\
465 }\
466 }\
467 }\
468 }\
469}
470
471/*-----------------------------------*/
472
473#define hypre_BoxLoop1Begin(loop_size,\
474 dbox1, start1, stride1, i1)\
475{\
476 int hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
477 hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
478 hypre_BoxLoopDeclareN(loop_size);
479
480#define hypre_BoxLoop1For(i, j, k, i1)\
481 for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
482 {\
483 hypre_BoxLoopSet(i, j, k);\
484 i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
485 for (k = 0; k < hypre__nz; k++)\
486 {\
487 for (j = 0; j < hypre__ny; j++)\
488 {\
489 for (i = 0; i < hypre__nx; i++)\
490 {
491
492#define hypre_BoxLoop1End(i1)\
493 i1 += hypre__sx1;\
494 }\
495 i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
496 }\
497 i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
498 }\
499 }\
500}
501
502/*-----------------------------------*/
503
504#define hypre_BoxLoop2Begin(loop_size,\
505 dbox1, start1, stride1, i1,\
506 dbox2, start2, stride2, i2)\
507{\
508 int hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
509 int hypre__i2start = hypre_BoxIndexRank(dbox2, start2);\
510 hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
511 hypre_BoxLoopDeclareS(dbox2, stride2, hypre__sx2, hypre__sy2, hypre__sz2);\
512 hypre_BoxLoopDeclareN(loop_size);
513
514#define hypre_BoxLoop2For(i, j, k, i1, i2)\
515 for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
516 {\
517 hypre_BoxLoopSet(i, j, k);\
518 i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
519 i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
520 for (k = 0; k < hypre__nz; k++)\
521 {\
522 for (j = 0; j < hypre__ny; j++)\
523 {\
524 for (i = 0; i < hypre__nx; i++)\
525 {
526
527#define hypre_BoxLoop2End(i1, i2)\
528 i1 += hypre__sx1;\
529 i2 += hypre__sx2;\
530 }\
531 i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
532 i2 += hypre__sy2 - hypre__nx*hypre__sx2;\
533 }\
534 i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
535 i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
536 }\
537 }\
538}
539
540/* incomplete BoxLoop2 macros leave out the inner loop so it can be hand-coded */
541#define hypre_BoxLoop2For_INC(i, j, k, i1, i2)\
542 for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
543 {\
544 hypre_BoxLoopSet(i, j, k);\
545 i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
546 i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
547 for (k = 0; k < hypre__nz; k++)\
548 {\
549 for (j = 0; j < hypre__ny; j++)\
550 {
551
552#define hypre_BoxLoop2End_INC(i1, i2)\
553 i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
554 i2 += hypre__sy2 - hypre__nx*hypre__sx2;\
555 }\
556 i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
557 i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
558 }\
559 }\
560}
561
562/* BoxLoop2 macros, but only for when all strides are equal. To improve
563 runtime, only one index is computed in the innermost loop, the internal
564 index i.
565 Since only the internal index, i, is updated in the innermost loop, you
566 can't reference i1, i2 inside the innermost loop. To get the effect of i1, i2
567 you have to use a macro (see below) to do pointer aliasing. It works because
568 you know that i has the same stride as i1, i2.
569 This macro set invokes the user-defined macro hypre_UserOutsideInnerLoop inside
570 the outer loops, just before the innermost loop. The user can define this macro
571 for pointer aliasing.
572 It's safer to redefine hypre_UserOutsideInnerLoop to do nothing afterwards.
573 The Begin_OneStride macro isn't really needed, the Begin macro does the same
574 thing, but without ensuring that the strides are the same.
575 */
576
577#define hypre_UserOutsideInnerLoop
578
579#define hypre_BoxLoop2Begin_OneStride(loop_size, stride1,\
580 dbox1, start1, i1,\
581 dbox2, start2, i2)\
582{\
583 int hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
584 int hypre__i2start = hypre_BoxIndexRank(dbox2, start2);\
585 hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
586 hypre_BoxLoopDeclareS(dbox2, stride1, hypre__sx2, hypre__sy2, hypre__sz2);\
587 hypre_BoxLoopDeclareN(loop_size);
588
589#define hypre_BoxLoop2For_OneStride(i, j, k, i1, i2)\
590 for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
591 {\
592 hypre_BoxLoopSet(i, j, k);\
593 i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
594 i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
595 for (k = 0; k < hypre__nz; k++)\
596 {\
597 for (j = 0; j < hypre__ny; j++)\
598 {\
599 hypre_UserOutsideInnerLoop;\
600 for ( i=0; i<hypre__nx*hypre__sx1; i+=hypre__sx1 )\
601 {
602
603#define hypre_BoxLoop2End_OneStride(i1, i2)\
604 }\
605 i1 += hypre__sy1;\
606 i2 += hypre__sy2;\
607 }\
608 i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
609 i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
610 }\
611 }\
612}
613
614
615
616
617/*-----------------------------------*/
618
619#define hypre_BoxLoop3Begin(loop_size,\
620 dbox1, start1, stride1, i1,\
621 dbox2, start2, stride2, i2,\
622 dbox3, start3, stride3, i3)\
623{\
624 int hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
625 int hypre__i2start = hypre_BoxIndexRank(dbox2, start2);\
626 int hypre__i3start = hypre_BoxIndexRank(dbox3, start3);\
627 hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
628 hypre_BoxLoopDeclareS(dbox2, stride2, hypre__sx2, hypre__sy2, hypre__sz2);\
629 hypre_BoxLoopDeclareS(dbox3, stride3, hypre__sx3, hypre__sy3, hypre__sz3);\
630 hypre_BoxLoopDeclareN(loop_size);
631
632#define hypre_BoxLoop3For(i, j, k, i1, i2, i3)\
633 for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
634 {\
635 hypre_BoxLoopSet(i, j, k);\
636 i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
637 i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
638 i3 = hypre__i3start + i*hypre__sx3 + j*hypre__sy3 + k*hypre__sz3;\
639 for (k = 0; k < hypre__nz; k++)\
640 {\
641 for (j = 0; j < hypre__ny; j++)\
642 {\
643 for (i = 0; i < hypre__nx; i++)\
644 {
645
646#define hypre_BoxLoop3End(i1, i2, i3)\
647 i1 += hypre__sx1;\
648 i2 += hypre__sx2;\
649 i3 += hypre__sx3;\
650 }\
651 i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
652 i2 += hypre__sy2 - hypre__nx*hypre__sx2;\
653 i3 += hypre__sy3 - hypre__nx*hypre__sx3;\
654 }\
655 i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
656 i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
657 i3 += hypre__sz3 - hypre__ny*hypre__sy3;\
658 }\
659 }\
660}
661
662/*-----------------------------------*/
663
664#define hypre_BoxLoop4Begin(loop_size,\
665 dbox1, start1, stride1, i1,\
666 dbox2, start2, stride2, i2,\
667 dbox3, start3, stride3, i3,\
668 dbox4, start4, stride4, i4)\
669{\
670 int hypre__i1start = hypre_BoxIndexRank(dbox1, start1);\
671 int hypre__i2start = hypre_BoxIndexRank(dbox2, start2);\
672 int hypre__i3start = hypre_BoxIndexRank(dbox3, start3);\
673 int hypre__i4start = hypre_BoxIndexRank(dbox4, start4);\
674 hypre_BoxLoopDeclareS(dbox1, stride1, hypre__sx1, hypre__sy1, hypre__sz1);\
675 hypre_BoxLoopDeclareS(dbox2, stride2, hypre__sx2, hypre__sy2, hypre__sz2);\
676 hypre_BoxLoopDeclareS(dbox3, stride3, hypre__sx3, hypre__sy3, hypre__sz3);\
677 hypre_BoxLoopDeclareS(dbox4, stride4, hypre__sx4, hypre__sy4, hypre__sz4);\
678 hypre_BoxLoopDeclareN(loop_size);
679
680#define hypre_BoxLoop4For(i, j, k, i1, i2, i3, i4)\
681 for (hypre__block = 0; hypre__block < hypre__num_blocks; hypre__block++)\
682 {\
683 hypre_BoxLoopSet(i, j, k);\
684 i1 = hypre__i1start + i*hypre__sx1 + j*hypre__sy1 + k*hypre__sz1;\
685 i2 = hypre__i2start + i*hypre__sx2 + j*hypre__sy2 + k*hypre__sz2;\
686 i3 = hypre__i3start + i*hypre__sx3 + j*hypre__sy3 + k*hypre__sz3;\
687 i4 = hypre__i4start + i*hypre__sx4 + j*hypre__sy4 + k*hypre__sz4;\
688 for (k = 0; k < hypre__nz; k++)\
689 {\
690 for (j = 0; j < hypre__ny; j++)\
691 {\
692 for (i = 0; i < hypre__nx; i++)\
693 {
694
695#define hypre_BoxLoop4End(i1, i2, i3, i4)\
696 i1 += hypre__sx1;\
697 i2 += hypre__sx2;\
698 i3 += hypre__sx3;\
699 i4 += hypre__sx4;\
700 }\
701 i1 += hypre__sy1 - hypre__nx*hypre__sx1;\
702 i2 += hypre__sy2 - hypre__nx*hypre__sx2;\
703 i3 += hypre__sy3 - hypre__nx*hypre__sx3;\
704 i4 += hypre__sy4 - hypre__nx*hypre__sx4;\
705 }\
706 i1 += hypre__sz1 - hypre__ny*hypre__sy1;\
707 i2 += hypre__sz2 - hypre__ny*hypre__sy2;\
708 i3 += hypre__sz3 - hypre__ny*hypre__sy3;\
709 i4 += hypre__sz4 - hypre__ny*hypre__sy4;\
710 }\
711 }\
712}
713
714/*-----------------------------------*/
715
716#endif /* ifndef HYPRE_USE_PTHREADS */
717
718#endif
719
720/******************************************************************************
721 *
722 * Header info for the Box structures
723 *
724 *****************************************************************************/
725
726#ifdef HYPRE_USE_PTHREADS
727
728#ifndef hypre_BOX_PTHREADS_HEADER
729#define hypre_BOX_PTHREADS_HEADER
730
731#include <pthread.h>
732#include "threading.h"
733
734
735extern volatile int hypre_thread_counter;
736extern int iteration_counter;
737
738/*--------------------------------------------------------------------------
739 * Threaded Looping macros:
740 *--------------------------------------------------------------------------*/
741
742#ifndef CHUNK_GOAL
743#define CHUNK_GOAL (hypre_NumThreads*1)
744#endif
745#ifndef MIN_VOL
746#define MIN_VOL 125
747#endif
748#ifndef MAX_VOL
749#define MAX_VOL 64000
750#endif
751
752#define hypre_BoxLoopDeclare(loop_size, data_box, stride, iinc, jinc, kinc) \
753int iinc = (hypre_IndexX(stride));\
754int jinc = (hypre_IndexY(stride)*hypre_BoxSizeX(data_box) -\
755 hypre_IndexX(loop_size)*hypre_IndexX(stride));\
756int kinc = (hypre_IndexZ(stride)*\
757 hypre_BoxSizeX(data_box)*hypre_BoxSizeY(data_box) -\
758 hypre_IndexY(loop_size)*\
759 hypre_IndexY(stride)*hypre_BoxSizeX(data_box))
760
761#define vol_cbrt(vol) (int) pow((double)(vol), 1. / 3.)
762
763#define hypre_ThreadLoopBegin(local_counter, init_val, stop_val, tl_index,\
764 tl_mtx, tl_body)\
765 for (local_counter = ifetchadd(&tl_index, &tl_mtx) + init_val;\
766 local_counter < stop_val;\
767 local_counter = ifetchadd(&tl_index, &tl_mtx) + init_val)\
768 {\
769 tl_body;
770
771#define hypre_ThreadLoop(tl_index,\
772 tl_count, tl_release, tl_mtx)\
773 if (pthread_equal(initial_thread, pthread_self()) == 0)\
774 {\
775 pthread_mutex_lock(&tl_mtx);\
776 tl_count++;\
777 if (tl_count < hypre_NumThreads)\
778 {\
779 pthread_mutex_unlock(&tl_mtx);\
780 while (!tl_release);\
781 pthread_mutex_lock(&tl_mtx);\
782 tl_count--;\
783 pthread_mutex_unlock(&tl_mtx);\
784 while (tl_release);\
785 }\
786 else\
787 {\
788 tl_count--;\
789 tl_index = 0;\
790 pthread_mutex_unlock(&tl_mtx);\
791 tl_release = 1;\
792 while (tl_count);\
793 tl_release = 0;\
794 }\
795 }\
796 else\
797 tl_index = 0
798
799#define hypre_ThreadLoopOld(local_counter, init_val, stop_val, tl_index,\
800 tl_count, tl_release, tl_mtx, tl_body)\
801{\
802 for (local_counter = ifetchadd(&tl_index, &tl_mtx) + init_val;\
803 local_counter < stop_val;\
804 local_counter = ifetchadd(&tl_index, &tl_mtx) + init_val)\
805 {\
806 tl_body;\
807 }\
808 if (pthread_equal(initial_thread, pthread_self()) == 0)\
809 {\
810 pthread_mutex_lock(&tl_mtx);\
811 tl_count++;\
812 if (tl_count < hypre_NumThreads)\
813 {\
814 pthread_mutex_unlock(&tl_mtx);\
815 while (!tl_release);\
816 pthread_mutex_lock(&tl_mtx);\
817 tl_count--;\
818 pthread_mutex_unlock(&tl_mtx);\
819 while (tl_release);\
820 }\
821 else\
822 {\
823 tl_count--;\
824 tl_index = 0;\
825 pthread_mutex_unlock(&tl_mtx);\
826 tl_release = 1;\
827 while (tl_count);\
828 tl_release = 0;\
829 }\
830 }\
831 else\
832 tl_index = 0;\
833}
834
835#define hypre_ChunkLoopExternalSetup(hypre__nx, hypre__ny, hypre__nz)\
836 int target_vol, target_area, target_len;\
837 int cbrt_tar_vol, sqrt_tar_area;\
838 int edge_divisor;\
839 int znumchunk, ynumchunk, xnumchunk;\
840 int hypre__cz, hypre__cy, hypre__cx;\
841 int numchunks;\
842 int clfreq[3], clreset[3];\
843 int clstart[3];\
844 int clfinish[3];\
845 int chunkcount;\
846 target_vol = hypre_min(hypre_max((hypre__nx * hypre__ny * hypre__nz) / CHUNK_GOAL,\
847 MIN_VOL), MAX_VOL);\
848 cbrt_tar_vol = (int) (pow ((double)target_vol, 1./3.));\
849 edge_divisor = hypre__nz / cbrt_tar_vol + !!(hypre__nz % cbrt_tar_vol);\
850 hypre__cz = hypre__nz / edge_divisor + !!(hypre__nz % edge_divisor);\
851 znumchunk = hypre__nz / hypre__cz + !!(hypre__nz % hypre__cz);\
852 target_area = target_vol / hypre__cz;\
853 sqrt_tar_area = (int) (sqrt((double)target_area));\
854 edge_divisor = hypre__ny / sqrt_tar_area + !!(hypre__ny % sqrt_tar_area);\
855 hypre__cy = hypre__ny / edge_divisor + !!(hypre__ny % edge_divisor);\
856 ynumchunk = hypre__ny / hypre__cy + !!(hypre__ny % hypre__cy);\
857 target_len = target_area / hypre__cy;\
858 edge_divisor = hypre__nx / target_len + !!(hypre__nx % target_len);\
859 hypre__cx = hypre__nx / edge_divisor + !!(hypre__nx % edge_divisor);\
860 xnumchunk = hypre__nx / hypre__cx + !!(hypre__nx % hypre__cx);\
861 numchunks = znumchunk * ynumchunk * xnumchunk;\
862 clfreq[0] = 1;\
863 clreset[0] = xnumchunk;\
864 clfreq[1] = clreset[0];\
865 clreset[1] = ynumchunk * xnumchunk;\
866 clfreq[2] = clreset[1];\
867 clreset[2] = znumchunk * ynumchunk * xnumchunk
868
869#define hypre_ChunkLoopInternalSetup(clstart, clfinish, clreset, clfreq,\
870 hypre__nx, hypre__ny, hypre__nz,\
871 hypre__cx, hypre__cy, hypre__cz,\
872 chunkcount)\
873 clstart[0] = ((chunkcount % clreset[0]) / clfreq[0]) * hypre__cx;\
874 if (clstart[0] < hypre__nx - hypre__cx)\
875 clfinish[0] = clstart[0] + hypre__cx;\
876 else\
877 clfinish[0] = hypre__nx;\
878 clstart[1] = ((chunkcount % clreset[1]) / clfreq[1]) * hypre__cy;\
879 if (clstart[1] < hypre__ny - hypre__cy)\
880 clfinish[1] = clstart[1] + hypre__cy;\
881 else\
882 clfinish[1] = hypre__ny;\
883 clstart[2] = ((chunkcount % clreset[2]) / clfreq[2]) * hypre__cz;\
884 if (clstart[2] < hypre__nz - hypre__cz)\
885 clfinish[2] = clstart[2] + hypre__cz;\
886 else\
887 clfinish[2] = hypre__nz
888
889#define hypre_BoxLoop0Begin(loop_size)\
890{\
891 int hypre__nx = hypre_IndexX(loop_size);\
892 int hypre__ny = hypre_IndexY(loop_size);\
893 int hypre__nz = hypre_IndexZ(loop_size);\
894 if (hypre__nx && hypre__ny && hypre__nz )\
895 {\
896 hypre_ChunkLoopExternalSetup(hypre__nx, hypre__ny, hypre__nz);\
897 hypre_ThreadLoopBegin(chunkcount, 0, numchunks, iteration_counter,\
898 hypre_mutex_boxloops,\
899 hypre_ChunkLoopInternalSetup(clstart, clfinish, clreset, clfreq,\
900 hypre__nx, hypre__ny, hypre__nz,\
901 hypre__cx, hypre__cy, hypre__cz,\
902 chunkcount));
903
904#define hypre_BoxLoop0For(i, j, k)\
905 for (k = clstart[2]; k < clfinish[2]; k++ )\
906 {\
907 for (j = clstart[1]; j < clfinish[1]; j++ )\
908 {\
909 for (i = clstart[0]; i < clfinish[0]; i++ )\
910 {
911
912#define hypre_BoxLoop0End() }}}hypre_ThreadLoop(iteration_counter,\
913 hypre_thread_counter, hypre_thread_release,\
914 hypre_mutex_boxloops);}}}
915
916
917#define hypre_BoxLoop1Begin(loop_size,\
918 data_box1, start1, stride1, i1)\
919{\
920 hypre_BoxLoopDeclare(loop_size, data_box1, stride1,\
921 hypre__iinc1, hypre__jinc1, hypre__kinc1);\
922 int hypre__nx = hypre_IndexX(loop_size);\
923 int hypre__ny = hypre_IndexY(loop_size);\
924 int hypre__nz = hypre_IndexZ(loop_size);\
925 int orig_i1 = hypre_BoxIndexRank(data_box1, start1);\
926 if (hypre__nx && hypre__ny && hypre__nz )\
927 {\
928 hypre_ChunkLoopExternalSetup(hypre__nx, hypre__ny, hypre__nz);\
929 hypre_ThreadLoopBegin(chunkcount, 0, numchunks, iteration_counter,\
930 hypre_mutex_boxloops,\
931 hypre_ChunkLoopInternalSetup(clstart, clfinish, clreset, clfreq,\
932 hypre__nx, hypre__ny, hypre__nz,\
933 hypre__cx, hypre__cy, hypre__cz,\
934 chunkcount));
935
936#define hypre_BoxLoop1For(i, j, k, i1)\
937 for (k = clstart[2]; k < clfinish[2]; k++)\
938 {\
939 for (j = clstart[1]; j < clfinish[1]; j++)\
940 {\
941 for (i = clstart[0]; i < clfinish[0]; i++)\
942 {\
943 i1 = orig_i1 +\
944 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc1 +\
945 (j + hypre__ny*k)*hypre__jinc1 + k*hypre__kinc1;
946
947#define hypre_BoxLoop1End(i1) }}}hypre_ThreadLoop(iteration_counter,\
948 hypre_thread_counter, hypre_thread_release,\
949 hypre_mutex_boxloops);}}}
950
951#define hypre_BoxLoop2Begin(loop_size,\
952 data_box1, start1, stride1, i1,\
953 data_box2, start2, stride2, i2)\
954{\
955 hypre_BoxLoopDeclare(loop_size, data_box1, stride1,\
956 hypre__iinc1, hypre__jinc1, hypre__kinc1);\
957 hypre_BoxLoopDeclare(loop_size, data_box2, stride2,\
958 hypre__iinc2, hypre__jinc2, hypre__kinc2);\
959 int hypre__nx = hypre_IndexX(loop_size);\
960 int hypre__ny = hypre_IndexY(loop_size);\
961 int hypre__nz = hypre_IndexZ(loop_size);\
962 int orig_i1 = hypre_BoxIndexRank(data_box1, start1);\
963 int orig_i2 = hypre_BoxIndexRank(data_box2, start2);\
964 if (hypre__nx && hypre__ny && hypre__nz )\
965 {\
966 hypre_ChunkLoopExternalSetup(hypre__nx, hypre__ny, hypre__nz);\
967 hypre_ThreadLoopBegin(chunkcount, 0, numchunks, iteration_counter,\
968 hypre_mutex_boxloops,\
969 hypre_ChunkLoopInternalSetup(clstart, clfinish, clreset, clfreq,\
970 hypre__nx, hypre__ny, hypre__nz,\
971 hypre__cx, hypre__cy, hypre__cz,\
972 chunkcount))
973
974#define hypre_BoxLoop2For(i, j, k, i1, i2)\
975 for (k = clstart[2]; k < clfinish[2]; k++)\
976 {\
977 for (j = clstart[1]; j < clfinish[1]; j++)\
978 {\
979 for (i = clstart[0]; i < clfinish[0]; i++)\
980 {\
981 i1 = orig_i1 +\
982 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc1 +\
983 (j + hypre__ny*k)*hypre__jinc1 + k*hypre__kinc1;\
984 i2 = orig_i2 +\
985 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc2 +\
986 (j + hypre__ny*k)*hypre__jinc2 + k*hypre__kinc2;
987
988#define hypre_BoxLoop2End(i1, i2) }}}hypre_ThreadLoop(iteration_counter,\
989 hypre_thread_counter, hypre_thread_release,\
990 hypre_mutex_boxloops);}}}
991
992
993
994
995#define hypre_BoxLoop3Begin(loop_size,\
996 data_box1, start1, stride1, i1,\
997 data_box2, start2, stride2, i2,\
998 data_box3, start3, stride3, i3)\
999{\
1000 hypre_BoxLoopDeclare(loop_size, data_box1, stride1,\
1001 hypre__iinc1, hypre__jinc1, hypre__kinc1);\
1002 hypre_BoxLoopDeclare(loop_size, data_box2, stride2,\
1003 hypre__iinc2, hypre__jinc2, hypre__kinc2);\
1004 hypre_BoxLoopDeclare(loop_size, data_box3, stride3,\
1005 hypre__iinc3, hypre__jinc3, hypre__kinc3);\
1006 int hypre__nx = hypre_IndexX(loop_size);\
1007 int hypre__ny = hypre_IndexY(loop_size);\
1008 int hypre__nz = hypre_IndexZ(loop_size);\
1009 int orig_i1 = hypre_BoxIndexRank(data_box1, start1);\
1010 int orig_i2 = hypre_BoxIndexRank(data_box2, start2);\
1011 int orig_i3 = hypre_BoxIndexRank(data_box3, start3);\
1012 if (hypre__nx && hypre__ny && hypre__nz )\
1013 {\
1014 hypre_ChunkLoopExternalSetup(hypre__nx, hypre__ny, hypre__nz);\
1015 hypre_ThreadLoopBegin(chunkcount, 0, numchunks, iteration_counter,\
1016 hypre_mutex_boxloops,\
1017 hypre_ChunkLoopInternalSetup(clstart, clfinish, clreset, clfreq,\
1018 hypre__nx, hypre__ny, hypre__nz,\
1019 hypre__cx, hypre__cy, hypre__cz,\
1020 chunkcount))
1021
1022#define hypre_BoxLoop3For(i, j, k, i1, i2, i3)\
1023 for (k = clstart[2]; k < clfinish[2]; k++)\
1024 {\
1025 for (j = clstart[1]; j < clfinish[1]; j++)\
1026 {\
1027 for (i = clstart[0]; i < clfinish[0]; i++)\
1028 {\
1029 i1 = orig_i1 +\
1030 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc1 +\
1031 (j + hypre__ny*k)*hypre__jinc1 + k*hypre__kinc1;\
1032 i2 = orig_i2 +\
1033 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc2 +\
1034 (j + hypre__ny*k)*hypre__jinc2 + k*hypre__kinc2;\
1035 i3 = orig_i3 +\
1036 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc3 +\
1037 (j + hypre__ny*k)*hypre__jinc3 + k*hypre__kinc3;\
1038
1039#define hypre_BoxLoop3End(i1, i2, i3) }}}hypre_ThreadLoop(iteration_counter,\
1040 hypre_thread_counter, hypre_thread_release,\
1041 hypre_mutex_boxloops);}}}
1042
1043
1044#define hypre_BoxLoop4Begin(loop_size,\
1045 data_box1, start1, stride1, i1,\
1046 data_box2, start2, stride2, i2,\
1047 data_box3, start3, stride3, i3,\
1048 data_box4, start4, stride4, i4)\
1049{\
1050 hypre_BoxLoopDeclare(loop_size, data_box1, stride1,\
1051 hypre__iinc1, hypre__jinc1, hypre__kinc1);\
1052 hypre_BoxLoopDeclare(loop_size, data_box2, stride2,\
1053 hypre__iinc2, hypre__jinc2, hypre__kinc2);\
1054 hypre_BoxLoopDeclare(loop_size, data_box3, stride3,\
1055 hypre__iinc3, hypre__jinc3, hypre__kinc3);\
1056 hypre_BoxLoopDeclare(loop_size, data_box4, stride4,\
1057 hypre__iinc4, hypre__jinc4, hypre__kinc4);\
1058 int hypre__nx = hypre_IndexX(loop_size);\
1059 int hypre__ny = hypre_IndexY(loop_size);\
1060 int hypre__nz = hypre_IndexZ(loop_size);\
1061 int orig_i1 = hypre_BoxIndexRank(data_box1, start1);\
1062 int orig_i2 = hypre_BoxIndexRank(data_box2, start2);\
1063 int orig_i3 = hypre_BoxIndexRank(data_box3, start3);\
1064 int orig_i4 = hypre_BoxIndexRank(data_box4, start4);\
1065 if (hypre__nx && hypre__ny && hypre__nz )\
1066 {\
1067 hypre_ChunkLoopExternalSetup(hypre__nx, hypre__ny, hypre__nz);\
1068 hypre_ThreadLoopBegin(chunkcount, 0, numchunks, iteration_counter,\
1069 hypre_mutex_boxloops,\
1070 hypre_ChunkLoopInternalSetup(clstart, clfinish, clreset, clfreq,\
1071 hypre__nx, hypre__ny, hypre__nz,\
1072 hypre__cx, hypre__cy, hypre__cz,\
1073 chunkcount))
1074
1075#define hypre_BoxLoop4For(i, j, k, i1, i2, i3, i4)\
1076 for (k = clstart[2]; k < clfinish[2]; k++)\
1077 {\
1078 for (j = clstart[1]; j < clfinish[1]; j++)\
1079 {\
1080 for (i = clstart[0]; i < clfinish[0]; i++)\
1081 {\
1082 i1 = orig_i1 +\
1083 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc1 +\
1084 (j + hypre__ny*k)*hypre__jinc1 + k*hypre__kinc1;\
1085 i2 = orig_i2 +\
1086 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc2 +\
1087 (j + hypre__ny*k)*hypre__jinc2 + k*hypre__kinc2;\
1088 i3 = orig_i3 +\
1089 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc3 +\
1090 (j + hypre__ny*k)*hypre__jinc3 + k*hypre__kinc3;\
1091 i4 = orig_i4 +\
1092 (i + hypre__nx*j + hypre__nx*hypre__ny*k)*hypre__iinc4 +\
1093 (j + hypre__ny*k)*hypre__jinc4 + k*hypre__kinc4;\
1094
1095
1096#define hypre_BoxLoop4End(i1, i2, i3, i4) }}}hypre_ThreadLoop(iteration_counter,\
1097 hypre_thread_counter, hypre_thread_release,\
1098 hypre_mutex_boxloops);}}}
1099
1100
1101#endif
1102
1103#endif
1104
1105
1106/******************************************************************************
1107 *
1108 * Header info for the hypre_BoxNeighbors structures
1109 *
1110 *****************************************************************************/
1111
1112#ifndef hypre_BOX_NEIGHBORS_HEADER
1113#define hypre_BOX_NEIGHBORS_HEADER
1114
1115/*--------------------------------------------------------------------------
1116 * hypre_RankLink:
1117 *--------------------------------------------------------------------------*/
1118
1119typedef struct hypre_RankLink_struct
1120{
1121 int rank;
1122 int prank;
1123 struct hypre_RankLink_struct *next;
1124
1125} hypre_RankLink;
1126
1127/*--------------------------------------------------------------------------
1128 * hypre_BoxNeighbors:
1129 *--------------------------------------------------------------------------*/
1130
1131typedef struct hypre_BoxNeighbors_struct
1132{
1133 hypre_BoxArray *boxes; /* boxes in the neighborhood */
1134 int *procs; /* procs for 'boxes' */
1135 int *boxnums; /* local boxnums for 'boxes' */
1136 int *ids; /* ids for 'boxes' */
1137 int first_local; /* first local box address */
1138 int num_local; /* number of local boxes */
1139
1140 hypre_Index periodic; /* directions of periodicity */
1141 int id_period; /* period used for box ids */
1142 int num_periods; /* number of box set periods */
1143 hypre_Index *pshifts; /* shifts of periodicity */
1144
1145 hypre_RankLink **rank_links; /* neighbors of local boxes */
1146
1147} hypre_BoxNeighbors;
1148
1149/*--------------------------------------------------------------------------
1150 * Accessor macros: hypre_RankLink
1151 *--------------------------------------------------------------------------*/
1152
1153#define hypre_RankLinkRank(link) ((link) -> rank)
1154#define hypre_RankLinkPRank(link) ((link) -> prank)
1155#define hypre_RankLinkNext(link) ((link) -> next)
1156
1157/*--------------------------------------------------------------------------
1158 * Accessor macros: hypre_BoxNeighbors
1159 *--------------------------------------------------------------------------*/
1160
1161#define hypre_BoxNeighborsBoxes(neighbors) ((neighbors) -> boxes)
1162#define hypre_BoxNeighborsProcs(neighbors) ((neighbors) -> procs)
1163#define hypre_BoxNeighborsBoxnums(neighbors) ((neighbors) -> boxnums)
1164#define hypre_BoxNeighborsIDs(neighbors) ((neighbors) -> ids)
1165#define hypre_BoxNeighborsFirstLocal(neighbors) ((neighbors) -> first_local)
1166#define hypre_BoxNeighborsNumLocal(neighbors) ((neighbors) -> num_local)
1167#define hypre_BoxNeighborsPeriodic(neighbors) ((neighbors) -> periodic)
1168#define hypre_BoxNeighborsIDPeriod(neighbors) ((neighbors) -> id_period)
1169#define hypre_BoxNeighborsNumPeriods(neighbors) ((neighbors) -> num_periods)
1170#define hypre_BoxNeighborsPShifts(neighbors) ((neighbors) -> pshifts)
1171#define hypre_BoxNeighborsPShift(neighbors, i) ((neighbors) -> pshifts[i])
1172#define hypre_BoxNeighborsRankLinks(neighbors) ((neighbors) -> rank_links)
1173
1174#define hypre_BoxNeighborsNumBoxes(neighbors) \
1175(hypre_BoxArraySize(hypre_BoxNeighborsBoxes(neighbors)))
1176#define hypre_BoxNeighborsRankLink(neighbors, b) \
1177(hypre_BoxNeighborsRankLinks(neighbors)[b])
1178
1179/*--------------------------------------------------------------------------
1180 * Looping macros:
1181 *--------------------------------------------------------------------------*/
1182
1183#define hypre_BeginBoxNeighborsLoop(n, neighbors, b)\
1184{\
1185 hypre_RankLink *hypre__rank_link;\
1186 int hypre__num_boxes;\
1187\
1188 hypre__num_boxes = hypre_BoxNeighborsNumBoxes(neighbors) / \
1189 hypre_BoxNeighborsNumPeriods(neighbors);\
1190\
1191 hypre__rank_link = hypre_BoxNeighborsRankLink(neighbors, b);\
1192 while (hypre__rank_link)\
1193 {\
1194 n = hypre_RankLinkRank(hypre__rank_link) +\
1195 hypre_RankLinkPRank(hypre__rank_link)*hypre__num_boxes;
1196
1197#define hypre_EndBoxNeighborsLoop\
1198 hypre__rank_link = hypre_RankLinkNext(hypre__rank_link);\
1199 }\
1200}
1201
1202#endif
1203
1204/******************************************************************************
1205 *
1206 * Header info for the hypre_StructGrid structures
1207 *
1208 *****************************************************************************/
1209
1210#ifndef hypre_STRUCT_GRID_HEADER
1211#define hypre_STRUCT_GRID_HEADER
1212
1213/*--------------------------------------------------------------------------
1214 * hypre_StructGrid:
1215 *--------------------------------------------------------------------------*/
1216
1217typedef struct hypre_StructGrid_struct
1218{
1219 MPI_Comm comm;
1220
1221 int dim; /* Number of grid dimensions */
1222
1223 hypre_BoxArray *boxes; /* Array of boxes in this process */
1224 int *ids; /* Unique IDs for boxes */
1225
1226 hypre_BoxNeighbors *neighbors; /* Neighbors of boxes */
1227 int max_distance; /* Neighborhood size */
1228
1229 hypre_Box *bounding_box; /* Bounding box around grid */
1230
1231 int local_size; /* Number of grid points locally */
1232 int global_size; /* Total number of grid points */
1233
1234 hypre_Index periodic; /* Indicates if grid is periodic */
1235
1236 int ref_count;
1237
1238 /* GEC0902 additions for ghost expansion of boxes */
1239
1240 int ghlocal_size; /* Number of vars in box including ghosts */
1241 int num_ghost[6]; /* ghost layer size for each box */
1242
1243
1244} hypre_StructGrid;
1245
1246/*--------------------------------------------------------------------------
1247 * Accessor macros: hypre_StructGrid
1248 *--------------------------------------------------------------------------*/
1249
1250#define hypre_StructGridComm(grid) ((grid) -> comm)
1251#define hypre_StructGridDim(grid) ((grid) -> dim)
1252#define hypre_StructGridBoxes(grid) ((grid) -> boxes)
1253#define hypre_StructGridIDs(grid) ((grid) -> ids)
1254#define hypre_StructGridNeighbors(grid) ((grid) -> neighbors)
1255#define hypre_StructGridMaxDistance(grid) ((grid) -> max_distance)
1256#define hypre_StructGridBoundingBox(grid) ((grid) -> bounding_box)
1257#define hypre_StructGridLocalSize(grid) ((grid) -> local_size)
1258#define hypre_StructGridGlobalSize(grid) ((grid) -> global_size)
1259#define hypre_StructGridPeriodic(grid) ((grid) -> periodic)
1260#define hypre_StructGridRefCount(grid) ((grid) -> ref_count)
1261#define hypre_StructGridGhlocalSize(grid) ((grid) -> ghlocal_size)
1262#define hypre_StructGridNumGhost(grid) ((grid) -> num_ghost)
1263
1264#define hypre_StructGridBox(grid, i) \
1265(hypre_BoxArrayBox(hypre_StructGridBoxes(grid), i))
1266#define hypre_StructGridNumBoxes(grid) \
1267(hypre_BoxArraySize(hypre_StructGridBoxes(grid)))
1268
1269#define hypre_StructGridIDPeriod(grid) \
1270hypre_BoxNeighborsIDPeriod(hypre_StructGridNeighbors(grid))
1271
1272/*--------------------------------------------------------------------------
1273 * Looping macros:
1274 *--------------------------------------------------------------------------*/
1275
1276#define hypre_ForStructGridBoxI(i, grid) \
1277hypre_ForBoxI(i, hypre_StructGridBoxes(grid))
1278
1279#endif
1280
1281
1282/******************************************************************************
1283 *
1284 * Header info for hypre_StructStencil data structures
1285 *
1286 *****************************************************************************/
1287
1288#ifndef hypre_STRUCT_STENCIL_HEADER
1289#define hypre_STRUCT_STENCIL_HEADER
1290
1291/*--------------------------------------------------------------------------
1292 * hypre_StructStencil
1293 *--------------------------------------------------------------------------*/
1294
1295typedef struct hypre_StructStencil_struct
1296{
1297 hypre_Index *shape; /* Description of a stencil's shape */
1298 int size; /* Number of stencil coefficients */
1299 int max_offset;
1300
1301 int dim; /* Number of dimensions */
1302
1303 int ref_count;
1304
1305} hypre_StructStencil;
1306
1307/*--------------------------------------------------------------------------
1308 * Accessor functions for the hypre_StructStencil structure
1309 *--------------------------------------------------------------------------*/
1310
1311#define hypre_StructStencilShape(stencil) ((stencil) -> shape)
1312#define hypre_StructStencilSize(stencil) ((stencil) -> size)
1313#define hypre_StructStencilMaxOffset(stencil) ((stencil) -> max_offset)
1314#define hypre_StructStencilDim(stencil) ((stencil) -> dim)
1315#define hypre_StructStencilRefCount(stencil) ((stencil) -> ref_count)
1316
1317#define hypre_StructStencilElement(stencil, i) \
1318hypre_StructStencilShape(stencil)[i]
1319
1320#endif
1321
1322
1323#ifndef hypre_COMMUNICATION_HEADER
1324#define hypre_COMMUNICATION_HEADER
1325
1326/*--------------------------------------------------------------------------
1327 * hypre_CommInfo:
1328 *--------------------------------------------------------------------------*/
1329
1330typedef struct hypre_CommInfo_struct
1331{
1332 hypre_BoxArrayArray *send_boxes;
1333 hypre_BoxArrayArray *recv_boxes;
1334 hypre_Index send_stride;
1335 hypre_Index recv_stride;
1336 int **send_processes;
1337 int **recv_processes;
1338 int **send_rboxnums;
1339 int **recv_rboxnums; /* required for "inverse" communication */
1340 hypre_BoxArrayArray *send_rboxes;
1341
1342} hypre_CommInfo;
1343
1344/*--------------------------------------------------------------------------
1345 * hypre_CommEntryType:
1346 *--------------------------------------------------------------------------*/
1347
1348typedef struct hypre_CommEntryType_struct
1349{
1350 int offset; /* offset for the data */
1351 int dim; /* dimension of the communication */
1352 int length_array[4];
1353 int stride_array[4];
1354
1355} hypre_CommEntryType;
1356
1357/*--------------------------------------------------------------------------
1358 * hypre_CommType:
1359 *--------------------------------------------------------------------------*/
1360
1361typedef struct hypre_CommType_struct
1362{
1363 int proc;
1364 int bufsize; /* message buffer size (in doubles) */
1365 int num_entries;
1366 hypre_CommEntryType *entries;
1367
1368 int *loc_boxnums; /* entry local box numbers */
1369 int *rem_boxnums; /* entry remote box numbers */
1370 hypre_Box *loc_boxes; /* entry local boxes */
1371 hypre_Box *rem_boxes; /* entry remote boxes */
1372
1373} hypre_CommType;
1374
1375/*--------------------------------------------------------------------------
1376 * hypre_CommPkg:
1377 * Structure containing information for doing communications
1378 *--------------------------------------------------------------------------*/
1379
1380typedef struct hypre_CommPkg_struct
1381{
1382 MPI_Comm comm;
1383
1384 int first_send; /* is this the first send? */
1385 int first_recv; /* is this the first recv? */
1386
1387 int num_values;
1388 hypre_Index send_stride;
1389 hypre_Index recv_stride;
1390 int send_bufsize; /* total send buffer size (in doubles) */
1391 int recv_bufsize; /* total recv buffer size (in doubles) */
1392
1393 int num_sends;
1394 int num_recvs;
1395 hypre_CommType *send_types;
1396 hypre_CommType *recv_types;
1397
1398 hypre_CommType *copy_from_type;
1399 hypre_CommType *copy_to_type;
1400
1401 int *recv_data_offsets; /* offsets into recv data (by box) */
1402 hypre_BoxArray *recv_data_space; /* recv data dimensions (by box) */
1403
1404} hypre_CommPkg;
1405
1406/*--------------------------------------------------------------------------
1407 * CommHandle:
1408 *--------------------------------------------------------------------------*/
1409
1410typedef struct hypre_CommHandle_struct
1411{
1412 hypre_CommPkg *comm_pkg;
1413 double *send_data;
1414 double *recv_data;
1415
1416 int num_requests;
1417 MPI_Request *requests;
1418 MPI_Status *status;
1419
1420 double **send_buffers;
1421 double **recv_buffers;
1422
1423} hypre_CommHandle;
1424
1425/*--------------------------------------------------------------------------
1426 * Accessor macros: hypre_CommInto
1427 *--------------------------------------------------------------------------*/
1428
1429#define hypre_CommInfoSendBoxes(info) (info -> send_boxes)
1430#define hypre_CommInfoRecvBoxes(info) (info -> recv_boxes)
1431#define hypre_CommInfoSendStride(info) (info -> send_stride)
1432#define hypre_CommInfoRecvStride(info) (info -> recv_stride)
1433#define hypre_CommInfoSendProcesses(info) (info -> send_processes)
1434#define hypre_CommInfoRecvProcesses(info) (info -> recv_processes)
1435#define hypre_CommInfoSendRBoxnums(info) (info -> send_rboxnums)
1436#define hypre_CommInfoRecvRBoxnums(info) (info -> recv_rboxnums)
1437#define hypre_CommInfoSendRBoxes(info) (info -> send_rboxes)
1438
1439/*--------------------------------------------------------------------------
1440 * Accessor macros: hypre_CommEntryType
1441 *--------------------------------------------------------------------------*/
1442
1443#define hypre_CommEntryTypeOffset(entry) (entry -> offset)
1444#define hypre_CommEntryTypeDim(entry) (entry -> dim)
1445#define hypre_CommEntryTypeLengthArray(entry) (entry -> length_array)
1446#define hypre_CommEntryTypeStrideArray(entry) (entry -> stride_array)
1447
1448/*--------------------------------------------------------------------------
1449 * Accessor macros: hypre_CommType
1450 *--------------------------------------------------------------------------*/
1451
1452#define hypre_CommTypeProc(type) (type -> proc)
1453#define hypre_CommTypeBufsize(type) (type -> bufsize)
1454#define hypre_CommTypeNumEntries(type) (type -> num_entries)
1455#define hypre_CommTypeEntries(type) (type -> entries)
1456#define hypre_CommTypeEntry(type, i) &(type -> entries[i])
1457#define hypre_CommTypeLocBoxnums(type) (type -> loc_boxnums)
1458#define hypre_CommTypeLocBoxnum(type, i) (type -> loc_boxnums[i])
1459#define hypre_CommTypeRemBoxnums(type) (type -> rem_boxnums)
1460#define hypre_CommTypeRemBoxnum(type, i) (type -> rem_boxnums[i])
1461#define hypre_CommTypeLocBoxes(type) (type -> loc_boxes)
1462#define hypre_CommTypeLocBox(type, i) &(type -> loc_boxes[i])
1463#define hypre_CommTypeRemBoxes(type) (type -> rem_boxes)
1464#define hypre_CommTypeRemBox(type, i) &(type -> rem_boxes[i])
1465
1466/*--------------------------------------------------------------------------
1467 * Accessor macros: hypre_CommPkg
1468 *--------------------------------------------------------------------------*/
1469
1470#define hypre_CommPkgComm(comm_pkg) (comm_pkg -> comm)
1471
1472#define hypre_CommPkgFirstSend(comm_pkg) (comm_pkg -> first_send)
1473#define hypre_CommPkgFirstRecv(comm_pkg) (comm_pkg -> first_recv)
1474
1475#define hypre_CommPkgNumValues(comm_pkg) (comm_pkg -> num_values)
1476#define hypre_CommPkgSendStride(comm_pkg) (comm_pkg -> send_stride)
1477#define hypre_CommPkgRecvStride(comm_pkg) (comm_pkg -> recv_stride)
1478#define hypre_CommPkgSendBufsize(comm_pkg) (comm_pkg -> send_bufsize)
1479#define hypre_CommPkgRecvBufsize(comm_pkg) (comm_pkg -> recv_bufsize)
1480
1481#define hypre_CommPkgNumSends(comm_pkg) (comm_pkg -> num_sends)
1482#define hypre_CommPkgNumRecvs(comm_pkg) (comm_pkg -> num_recvs)
1483#define hypre_CommPkgSendTypes(comm_pkg) (comm_pkg -> send_types)
1484#define hypre_CommPkgSendType(comm_pkg, i) &(comm_pkg -> send_types[i])
1485#define hypre_CommPkgRecvTypes(comm_pkg) (comm_pkg -> recv_types)
1486#define hypre_CommPkgRecvType(comm_pkg, i) &(comm_pkg -> recv_types[i])
1487
1488#define hypre_CommPkgCopyFromType(comm_pkg) (comm_pkg -> copy_from_type)
1489#define hypre_CommPkgCopyToType(comm_pkg) (comm_pkg -> copy_to_type)
1490
1491#define hypre_CommPkgRecvDataOffsets(comm_pkg) (comm_pkg -> recv_data_offsets)
1492#define hypre_CommPkgRecvDataSpace(comm_pkg) (comm_pkg -> recv_data_space)
1493
1494/*--------------------------------------------------------------------------
1495 * Accessor macros: hypre_CommHandle
1496 *--------------------------------------------------------------------------*/
1497
1498#define hypre_CommHandleCommPkg(comm_handle) (comm_handle -> comm_pkg)
1499#define hypre_CommHandleSendData(comm_handle) (comm_handle -> send_data)
1500#define hypre_CommHandleRecvData(comm_handle) (comm_handle -> recv_data)
1501#define hypre_CommHandleNumRequests(comm_handle) (comm_handle -> num_requests)
1502#define hypre_CommHandleRequests(comm_handle) (comm_handle -> requests)
1503#define hypre_CommHandleStatus(comm_handle) (comm_handle -> status)
1504#define hypre_CommHandleSendBuffers(comm_handle) (comm_handle -> send_buffers)
1505#define hypre_CommHandleRecvBuffers(comm_handle) (comm_handle -> recv_buffers)
1506
1507#endif
1508
1509/******************************************************************************
1510 *
1511 * Header info for computation
1512 *
1513 *****************************************************************************/
1514
1515#ifndef hypre_COMPUTATION_HEADER
1516#define hypre_COMPUTATION_HEADER
1517
1518/*--------------------------------------------------------------------------
1519 * hypre_ComputeInfo:
1520 *--------------------------------------------------------------------------*/
1521
1522typedef struct hypre_ComputeInfo_struct
1523{
1524 hypre_CommInfo *comm_info;
1525
1526 hypre_BoxArrayArray *indt_boxes;
1527 hypre_BoxArrayArray *dept_boxes;
1528 hypre_Index stride;
1529
1530} hypre_ComputeInfo;
1531
1532/*--------------------------------------------------------------------------
1533 * hypre_ComputePkg:
1534 * Structure containing information for doing computations.
1535 *--------------------------------------------------------------------------*/
1536
1537typedef struct hypre_ComputePkg_struct
1538{
1539 hypre_CommPkg *comm_pkg;
1540
1541 hypre_BoxArrayArray *indt_boxes;
1542 hypre_BoxArrayArray *dept_boxes;
1543 hypre_Index stride;
1544
1545 hypre_StructGrid *grid;
1546 hypre_BoxArray *data_space;
1547 int num_values;
1548
1549} hypre_ComputePkg;
1550
1551/*--------------------------------------------------------------------------
1552 * Accessor macros: hypre_ComputeInfo
1553 *--------------------------------------------------------------------------*/
1554
1555#define hypre_ComputeInfoCommInfo(info) (info -> comm_info)
1556#define hypre_ComputeInfoIndtBoxes(info) (info -> indt_boxes)
1557#define hypre_ComputeInfoDeptBoxes(info) (info -> dept_boxes)
1558#define hypre_ComputeInfoStride(info) (info -> stride)
1559
1560/*--------------------------------------------------------------------------
1561 * Accessor macros: hypre_ComputePkg
1562 *--------------------------------------------------------------------------*/
1563
1564#define hypre_ComputePkgCommPkg(compute_pkg) (compute_pkg -> comm_pkg)
1565
1566#define hypre_ComputePkgIndtBoxes(compute_pkg) (compute_pkg -> indt_boxes)
1567#define hypre_ComputePkgDeptBoxes(compute_pkg) (compute_pkg -> dept_boxes)
1568#define hypre_ComputePkgStride(compute_pkg) (compute_pkg -> stride)
1569
1570#define hypre_ComputePkgGrid(compute_pkg) (compute_pkg -> grid)
1571#define hypre_ComputePkgDataSpace(compute_pkg) (compute_pkg -> data_space)
1572#define hypre_ComputePkgNumValues(compute_pkg) (compute_pkg -> num_values)
1573
1574#endif
1575
1576/******************************************************************************
1577 *
1578 * Header info for the hypre_StructMatrix structures
1579 *
1580 *****************************************************************************/
1581
1582#ifndef hypre_STRUCT_MATRIX_HEADER
1583#define hypre_STRUCT_MATRIX_HEADER
1584
1585#include <assert.h>
1586
1587/*--------------------------------------------------------------------------
1588 * hypre_StructMatrix:
1589 *--------------------------------------------------------------------------*/
1590
1591typedef struct hypre_StructMatrix_struct
1592{
1593 MPI_Comm comm;
1594
1595 hypre_StructGrid *grid;
1596 hypre_StructStencil *user_stencil;
1597 hypre_StructStencil *stencil;
1598 int num_values; /* Number of "stored" coefficients */
1599
1600 hypre_BoxArray *data_space;
1601
1602 double *data; /* Pointer to matrix data */
1603 int data_alloced; /* Boolean used for freeing data */
1604 int data_size; /* Size of matrix data */
1605 int **data_indices; /* num-boxes by stencil-size array
1606 of indices into the data array.
1607 data_indices[b][s] is the starting
1608 index of matrix data corresponding
1609 to box b and stencil coefficient s */
1610 int constant_coefficient; /* normally 0; set to 1 for
1611 constant coefficient matrices
1612 or 2 for constant coefficient
1613 with variable diagonal */
1614
1615 int symmetric; /* Is the matrix symmetric */
1616 int *symm_elements;/* Which elements are "symmetric" */
1617 int num_ghost[6]; /* Num ghost layers in each direction */
1618
1619 int global_size; /* Total number of nonzero coeffs */
1620
1621 int OffProcAdd; /* offproc set values flag */
1622
1623 int add_num_ghost[6]; /* ghostlayers to scan for offproc
1624 add values */
1625
1626 hypre_CommPkg *comm_pkg; /* Info on how to update ghost data */
1627
1628 int ref_count;
1629
1630} hypre_StructMatrix;
1631
1632/*--------------------------------------------------------------------------
1633 * Accessor macros: hypre_StructMatrix
1634 *--------------------------------------------------------------------------*/
1635
1636#define hypre_StructMatrixComm(matrix) ((matrix) -> comm)
1637#define hypre_StructMatrixGrid(matrix) ((matrix) -> grid)
1638#define hypre_StructMatrixUserStencil(matrix) ((matrix) -> user_stencil)
1639#define hypre_StructMatrixStencil(matrix) ((matrix) -> stencil)
1640#define hypre_StructMatrixNumValues(matrix) ((matrix) -> num_values)
1641#define hypre_StructMatrixDataSpace(matrix) ((matrix) -> data_space)
1642#define hypre_StructMatrixData(matrix) ((matrix) -> data)
1643#define hypre_StructMatrixDataAlloced(matrix) ((matrix) -> data_alloced)
1644#define hypre_StructMatrixDataSize(matrix) ((matrix) -> data_size)
1645#define hypre_StructMatrixDataIndices(matrix) ((matrix) -> data_indices)
1646#define hypre_StructMatrixConstantCoefficient(matrix) ((matrix) -> constant_coefficient)
1647#define hypre_StructMatrixSymmetric(matrix) ((matrix) -> symmetric)
1648#define hypre_StructMatrixSymmElements(matrix) ((matrix) -> symm_elements)
1649#define hypre_StructMatrixNumGhost(matrix) ((matrix) -> num_ghost)
1650#define hypre_StructMatrixGlobalSize(matrix) ((matrix) -> global_size)
1651#define hypre_StructMatrixOffProcAdd(matrix) ((matrix) -> OffProcAdd)
1652#define hypre_StructMatrixAddNumGhost(matrix) ((matrix) -> add_num_ghost)
1653#define hypre_StructMatrixCommPkg(matrix) ((matrix) -> comm_pkg)
1654#define hypre_StructMatrixRefCount(matrix) ((matrix) -> ref_count)
1655
1656#define hypre_StructMatrixBox(matrix, b) \
1657hypre_BoxArrayBox(hypre_StructMatrixDataSpace(matrix), b)
1658
1659#define hypre_StructMatrixBoxData(matrix, b, s) \
1660(hypre_StructMatrixData(matrix) + hypre_StructMatrixDataIndices(matrix)[b][s])
1661
1662#define hypre_StructMatrixBoxDataValue(matrix, b, s, index) \
1663(hypre_StructMatrixBoxData(matrix, b, s) + \
1664 hypre_BoxIndexRank(hypre_StructMatrixBox(matrix, b), index))
1665
1666#define hypre_CCStructMatrixBoxDataValue(matrix, b, s, index) \
1667(hypre_StructMatrixBoxData(matrix, b, s) + \
1668 hypre_CCBoxIndexRank(hypre_StructMatrixBox(matrix, b), index))
1669
1670#endif
1671
1672/******************************************************************************
1673 *
1674 * Header info for the hypre_StructVector structures
1675 *
1676 *****************************************************************************/
1677
1678#ifndef hypre_STRUCT_VECTOR_HEADER
1679#define hypre_STRUCT_VECTOR_HEADER
1680
1681/*--------------------------------------------------------------------------
1682 * hypre_StructVector:
1683 *--------------------------------------------------------------------------*/
1684
1685typedef struct hypre_StructVector_struct
1686{
1687 MPI_Comm comm;
1688
1689 hypre_StructGrid *grid;
1690
1691 hypre_BoxArray *data_space;
1692
1693 double *data; /* Pointer to vector data */
1694 int data_alloced; /* Boolean used for freeing data */
1695 int data_size; /* Size of vector data */
1696 int *data_indices; /* num-boxes array of indices into
1697 the data array. data_indices[b]
1698 is the starting index of vector
1699 data corresponding to box b. */
1700
1701 int num_ghost[6]; /* Num ghost layers in each direction */
1702
1703 int global_size; /* Total number coefficients */
1704
1705 int OffProcAdd; /* offproc addto value flag */
1706
1707 int add_num_ghost[6]; /* ghostlayers to scan for offproc
1708 add values */
1709
1710 int ref_count;
1711
1712} hypre_StructVector;
1713
1714/*--------------------------------------------------------------------------
1715 * Accessor macros: hypre_StructVector
1716 *--------------------------------------------------------------------------*/
1717
1718#define hypre_StructVectorComm(vector) ((vector) -> comm)
1719#define hypre_StructVectorGrid(vector) ((vector) -> grid)
1720#define hypre_StructVectorDataSpace(vector) ((vector) -> data_space)
1721#define hypre_StructVectorData(vector) ((vector) -> data)
1722#define hypre_StructVectorDataAlloced(vector) ((vector) -> data_alloced)
1723#define hypre_StructVectorDataSize(vector) ((vector) -> data_size)
1724#define hypre_StructVectorDataIndices(vector) ((vector) -> data_indices)
1725#define hypre_StructVectorNumGhost(vector) ((vector) -> num_ghost)
1726#define hypre_StructVectorGlobalSize(vector) ((vector) -> global_size)
1727#define hypre_StructVectorOffProcAdd(vector) ((vector) -> OffProcAdd)
1728#define hypre_StructVectorAddNumGhost(vector) ((vector) -> add_num_ghost)
1729#define hypre_StructVectorRefCount(vector) ((vector) -> ref_count)
1730
1731#define hypre_StructVectorBox(vector, b) \
1732hypre_BoxArrayBox(hypre_StructVectorDataSpace(vector), b)
1733
1734#define hypre_StructVectorBoxData(vector, b) \
1735(hypre_StructVectorData(vector) + hypre_StructVectorDataIndices(vector)[b])
1736
1737#define hypre_StructVectorBoxDataValue(vector, b, index) \
1738(hypre_StructVectorBoxData(vector, b) + \
1739 hypre_BoxIndexRank(hypre_StructVectorBox(vector, b), index))
1740
1741#endif
1742
1743/******************************************************************************
1744 *
1745 * Header info for the struct assumed partition
1746 *
1747 *****************************************************************************/
1748
1749#ifndef hypre_ASSUMED_PART_HEADER
1750#define hypre_ASSUMED_PART_HEADER
1751
1752
1753/* to prevent overflow */
1754
1755#define hypre_doubleBoxVolume(box) \
1756 ((double) hypre_BoxSizeX(box) * (double) hypre_BoxSizeY(box) * (double) hypre_BoxSizeZ(box))
1757
1758
1759typedef struct
1760{
1761 /* the entries will be the same for all procs */
1762 hypre_BoxArray *regions;
1763 int num_regions;
1764 int *proc_partitions;
1765 hypre_Index *divisions;
1766 /* these entries are specific to each proc */
1767 hypre_BoxArray *my_partition;
1768 hypre_BoxArray *my_partition_boxes;
1769 int *my_partition_proc_ids;
1770 int *my_partition_boxnums;
1771 int my_partition_ids_size;
1772 int my_partition_ids_alloc;
1773 int my_partition_num_distinct_procs;
1774
1775} hypre_StructAssumedPart;
1776
1777
1778/*Accessor macros */
1779
1780#define hypre_StructAssumedPartRegions(apart) ((apart)->regions)
1781#define hypre_StructAssumedPartNumRegions(apart) ((apart)->num_regions)
1782#define hypre_StructAssumedPartDivisions(apart) ((apart)->divisions)
1783#define hypre_StructAssumedPartDivision(apart, i) ((apart)->divisions[i])
1784#define hypre_StructAssumedPartProcPartitions(apart) ((apart)->proc_partitions)
1785#define hypre_StructAssumedPartProcPartition(apart, i) ((apart)->proc_partitions[i])
1786#define hypre_StructAssumedPartMyPartition(apart) ((apart)->my_partition)
1787#define hypre_StructAssumedPartMyPartitionBoxes(apart) ((apart)->my_partition_boxes)
1788#define hypre_StructAssumedPartMyPartitionProcIds(apart) ((apart)->my_partition_proc_ids)
1789#define hypre_StructAssumedPartMyPartitionIdsSize(apart) ((apart)->my_partition_ids_size)
1790#define hypre_StructAssumedPartMyPartitionIdsAlloc(apart) ((apart)->my_partition_ids_alloc)
1791#define hypre_StructAssumedPartMyPartitionNumDistinctProcs(apart) ((apart)->my_partition_num_distinct_procs)
1792#define hypre_StructAssumedPartMyPartitionBoxnums(apart) ((apart)->my_partition_boxnums)
1793
1794
1795
1796#endif
1797#ifndef hypre_BOX_MANAGER_HEADER
1798#define hypre_BOX_MANAGER_HEADER
1799
1800
1801/*---------------------------------------------------------------------------
1802 *
1803 * Box Manager: organizes arbitrary information in a spatial way
1804 *
1805 *----------------------------------------------------------------------------*/
1806
1807
1808typedef struct hypre_BoxManEntry_struct
1809{
1810 hypre_Index imin; /*extents of box */
1811 hypre_Index imax;
1812
1813 int proc; /*this is a two-part unique id: (proc, id) */
1814 int id;
1815 int num_ghost[6];
1816
1817 void *info;
1818
1819 struct hypre_BoxManEntry_struct *next;
1820
1821} hypre_BoxManEntry;
1822
1823
1824/*-----------------------------------------------------------------------------*/
1825
1826typedef struct
1827{
1828
1829 MPI_Comm comm;
1830
1831 int max_nentries; /* storage in entries allocated to this
1832 amount */
1833
1834
1835 int is_gather_called; /* boolean to indicate whether GatherEntries
1836 function has been called (prior to
1837 assemble) - may not want this (can tell
1838 by the size of gather_regions array) */
1839
1840 hypre_BoxArray *gather_regions; /*this is where we collect boxes input
1841 by calls to BoxManGatherEntries - to be
1842 gathered in the assemble. These are then
1843 deleted after the assemble */
1844
1845
1846 int all_global_known; /* Boolean to say that every
1847 processor already has all
1848 of the global data for
1849 this manager (this could be
1850 acessed by a coarsening routine,
1851 for example) */
1852
1853
1854 int entry_info_size; /* in bytes, the (max) size of the info
1855 object for the entries */
1856
1857 /* storing the entries */
1858 int nentries; /* number of entries stored */
1859 hypre_BoxManEntry *entries; /* These are the actual box manager entries */
1860
1861
1862
1863 /* for accessing an entry via (proc, id) */
1864
1865 hypre_BoxManEntry **sort_table; /* points into *entries and is sorted
1866 by each entry's unique two-part id:
1867 (proc, id) */
1868
1869 int *procs_sort; /* the sorted procs corresponding to entries*/
1870 int *ids_sort; /* sorted ids corresponding to the entries */
1871
1872 int num_procs_sort; /* number of distinct procs in *entries */
1873 int *procs_sort_offsets; /* offsets for procs into the
1874 *entry_sort array */
1875 int first_local; /* position of local infomation */
1876 int local_proc_offset; /*position of local information in offsets */
1877
1878 /* here is the table that organizes the entires spatially (by index)*/
1879 hypre_BoxManEntry **index_table; /* this points into 'entries' array
1880 and corresponds to the index arays*/
1881
1882 int *indexes[3]; /* here we have the x,y,z indexes (ordered)
1883 for the imin and imax
1884 of each box in the entries array*/
1885 int size[3]; /* how many indexes we have in each direction
1886 - x,y,z */
1887
1888 int last_index[3]; /* the last index used in the indexes map */
1889
1890 /* extra stuff needed for AP implementation */
1891
1892 int num_my_entries; /* number of entries with proc_id = myid */
1893 int *my_ids; /* an array of ids corresponding to my entries */
1894 hypre_BoxManEntry **my_entries; /* points into *entries that are mine & corresponds to
1895 my_ids array. This is destroyed in the assemble */
1896
1897 hypre_StructAssumedPart *assumed_partition; /* the assumed partition object - for now this is only
1898 us ed during the assemble (where it is created)*/
1899 int dim; /* problem dimension (known in the grid) */
1900
1901 /* ghost stuff - leave for now */
1902
1903 int num_ghost[6];
1904
1905
1906
1907} hypre_BoxManager;
1908
1909
1910/*--------------------------------------------------------------------------
1911 * Accessor macros: hypre_BoxMan
1912 *--------------------------------------------------------------------------*/
1913
1914#define hypre_BoxManComm(manager) ((manager) -> comm)
1915
1916#define hypre_BoxManMaxNEntries(manager) ((manager) -> max_nentries)
1917
1918#define hypre_BoxManIsGatherCalled(manager) ((manager) -> is_gather_called)
1919#define hypre_BoxManGatherRegions(manager) ((manager) -> gather_regions)
1920#define hypre_BoxManAllGlobalKnown(manager) ((manager) -> all_global_known)
1921#define hypre_BoxManEntryInfoSize(manager) ((manager) -> entry_info_size)
1922#define hypre_BoxManNEntries(manager) ((manager) -> nentries)
1923#define hypre_BoxManEntries(manager) ((manager) -> entries)
1924
1925#define hypre_BoxManSortTable(manager) ((manager) -> sort_table)
1926#define hypre_BoxManProcsSort(manager) ((manager) -> procs_sort)
1927#define hypre_BoxManIdsSort(manager) ((manager) -> ids_sort)
1928#define hypre_BoxManNumProcsSort(manager) ((manager) -> num_procs_sort)
1929#define hypre_BoxManProcsSortOffsets(manager) ((manager) -> procs_sort_offsets)
1930#define hypre_BoxManLocalProcOffset(manager) ((manager) -> local_proc_offset)
1931
1932#define hypre_BoxManFirstLocal(manager) ((manager) -> first_local)
1933
1934#define hypre_BoxManIndexTable(manager) ((manager) -> index_table)
1935#define hypre_BoxManIndexes(manager) ((manager) -> indexes)
1936#define hypre_BoxManSize(manager) ((manager) -> size)
1937#define hypre_BoxManLastIndex(manager) ((manager) -> last_index)
1938
1939#define hypre_BoxManNumMyEntries(manager) ((manager) -> num_my_entries)
1940#define hypre_BoxManMyIds(manager) ((manager) -> my_ids)
1941#define hypre_BoxManMyEntries(manager) ((manager) -> my_entries)
1942#define hypre_BoxManAssumedPartition(manager) ((manager) -> assumed_partition)
1943#define hypre_BoxManDim(manager) ((manager) -> dim)
1944
1945#define hypre_BoxManNumGhost(manager) ((manager) -> num_ghost)
1946
1947#define hypre_BoxManIndexesD(manager, d) hypre_BoxManIndexes(manager)[d]
1948#define hypre_BoxManSizeD(manager, d) hypre_BoxManSize(manager)[d]
1949#define hypre_BoxManLastIndexD(manager, d) hypre_BoxManLastIndex(manager)[d]
1950#define hypre_BoxManIndexTableEntry(manager, i, j, k) \
1951hypre_BoxManIndexTable(manager)[((k*hypre_BoxManSizeD(manager, 1) + j)*\
1952 hypre_BoxManSizeD(manager, 0) + i)]
1953
1954
1955
1956
1957/*--------------------------------------------------------------------------
1958 * Accessor macros: hypre_BoxManEntry
1959 *--------------------------------------------------------------------------*/
1960
1961#define hypre_BoxManEntryIMin(entry) ((entry) -> imin)
1962#define hypre_BoxManEntryIMax(entry) ((entry) -> imax)
1963#define hypre_BoxManEntryProc(entry) ((entry) -> proc)
1964#define hypre_BoxManEntryId(entry) ((entry) -> id)
1965#define hypre_BoxManEntryInfo(entry) ((entry) -> info)
1966#define hypre_BoxManEntryNumGhost(entry) ((entry) -> num_ghost)
1967#define hypre_BoxManEntryNext(entry) ((entry) -> next)
1968
1969
1970
1971
1972/*--------------------------------------------------------------------------
1973 * Info objects
1974 *--------------------------------------------------------------------------*/
1975
1976
1977
1978typedef struct
1979{
1980 int type;
1981 int proc;
1982 int offset;
1983 int box;
1984 int ghoffset;
1985
1986} hypre_BoxManInfoDefault;
1987
1988#define hypre_BoxManInfoDType(info) ((info) -> type)
1989#define hypre_BoxManInfoDProc(info) ((info) -> proc)
1990#define hypre_BoxManInfoDOffset(info) ((info) -> offset)
1991#define hypre_BoxManInfoDBox(info) ((info) -> box)
1992#define hypre_BoxManInfoDGhoffset(info) ((info) -> ghoffset)
1993
1994
1995#endif
1996
1997/* assumed_part.c */
1998int hypre_APSubdivideRegion ( hypre_Box *region , int dim , int level , hypre_BoxArray *box_array , int *num_new_boxes );
1999int hypre_APFindMyBoxesInRegions ( hypre_BoxArray *region_array , hypre_BoxArray *my_box_array , int **p_count_array , double **p_vol_array );
2000int hypre_APGetAllBoxesInRegions ( hypre_BoxArray *region_array , hypre_BoxArray *my_box_array , int **p_count_array , double **p_vol_array , MPI_Comm comm );
2001int hypre_APShrinkRegions ( hypre_BoxArray *region_array , hypre_BoxArray *my_box_array , MPI_Comm comm );
2002int hypre_APPruneRegions ( hypre_BoxArray *region_array , int **p_count_array , double **p_vol_array );
2003int hypre_APRefineRegionsByVol ( hypre_BoxArray *region_array , double *vol_array , int max_regions , double gamma , int dim , int *return_code , MPI_Comm comm );
2004int hypre_StructAssumedPartitionCreate ( int dim , hypre_Box *bounding_box , double global_boxes_size , int global_num_boxes , hypre_BoxArray *local_boxes , int *local_boxnums , int max_regions , int max_refinements , double gamma , MPI_Comm comm , hypre_StructAssumedPart **p_assumed_partition );
2005int hypre_StructAssumedPartitionDestroy ( hypre_StructAssumedPart *assumed_part );
2006int hypre_APFillResponseStructAssumedPart ( void *p_recv_contact_buf , int contact_size , int contact_proc , void *ro , MPI_Comm comm , void **p_send_response_buf , int *response_message_size );
2007int hypre_StructAssumedPartitionGetRegionsFromProc ( hypre_StructAssumedPart *assumed_part , int proc_id , hypre_BoxArray *assumed_regions );
2008int hypre_StructAssumedPartitionGetProcsFromBox ( hypre_StructAssumedPart *assumed_part , hypre_Box *box , int *num_proc_array , int *size_alloc_proc_array , int **p_proc_array );
2009
2010/* box_algebra.c */
2011int hypre_IntersectBoxes ( hypre_Box *box1 , hypre_Box *box2 , hypre_Box *ibox );
2012int hypre_SubtractBoxes ( hypre_Box *box1 , hypre_Box *box2 , hypre_BoxArray *box_array );
2013int hypre_SubtractBoxArrays ( hypre_BoxArray *box_array1 , hypre_BoxArray *box_array2 , hypre_BoxArray *tmp_box_array );
2014int hypre_SubtractBoxArraysExceptBoxes ( hypre_BoxArray *box_array1 , hypre_BoxArray *box_array2 , hypre_BoxArray *tmp_box_array , hypre_Box *boxa , hypre_Box *boxb );
2015int hypre_UnionBoxes ( hypre_BoxArray *boxes );
2016int hypre_MinUnionBoxes ( hypre_BoxArray *boxes );
2017
2018/* box_alloc.c */
2019int hypre_BoxInitializeMemory ( const int at_a_time );
2020int hypre_BoxFinalizeMemory ( void );
2021hypre_Box *hypre_BoxAlloc ( void );
2022int hypre_BoxFree ( hypre_Box *box );
2023
2024/* box_boundary.c */
2025int hypre_BoxArraySubtractAdjacentBoxArray ( hypre_BoxArray *boxes1 , hypre_BoxArray *boxes2 , hypre_Box *box , int thick );
2026int hypre_BoxArraySubtractAdjacentBoxArrayD ( hypre_BoxArray *boxes1 , hypre_BoxArray *boxes2 , hypre_Box *box , int ds , int thick );
2027int hypre_BoxBoundaryDNT ( hypre_Box *box , hypre_BoxArray *neighbor_boxes , hypre_BoxArray *boundary , int ds , int thick );
2028int hypre_BoxBoundaryNT ( hypre_Box *box , hypre_BoxArray *neighbor_boxes , hypre_BoxArray *boundary , int *thickness );
2029int hypre_BoxBoundaryG ( hypre_Box *box , hypre_StructGrid *g , hypre_BoxArray *boundary );
2030int hypre_BoxBoundaryDG ( hypre_Box *box , hypre_StructGrid *g , hypre_BoxArray *boundarym , hypre_BoxArray *boundaryp , int d );
2031
2032/* box.c */
2033hypre_Box *hypre_BoxCreate ( void );
2034int hypre_BoxSetExtents ( hypre_Box *box , hypre_Index imin , hypre_Index imax );
2035hypre_BoxArray *hypre_BoxArrayCreate ( int size );
2036int hypre_BoxArraySetSize ( hypre_BoxArray *box_array , int size );
2037hypre_BoxArrayArray *hypre_BoxArrayArrayCreate ( int size );
2038int hypre_BoxDestroy ( hypre_Box *box );
2039int hypre_BoxArrayDestroy ( hypre_BoxArray *box_array );
2040int hypre_BoxArrayArrayDestroy ( hypre_BoxArrayArray *box_array_array );
2041hypre_Box *hypre_BoxDuplicate ( hypre_Box *box );
2042hypre_BoxArray *hypre_BoxArrayDuplicate ( hypre_BoxArray *box_array );
2043hypre_BoxArrayArray *hypre_BoxArrayArrayDuplicate ( hypre_BoxArrayArray *box_array_array );
2044int hypre_AppendBox ( hypre_Box *box , hypre_BoxArray *box_array );
2045int hypre_DeleteBox ( hypre_BoxArray *box_array , int index );
2046int hypre_AppendBoxArray ( hypre_BoxArray *box_array_0 , hypre_BoxArray *box_array_1 );
2047int hypre_BoxGetSize ( hypre_Box *box , hypre_Index size );
2048int hypre_BoxGetStrideSize ( hypre_Box *box , hypre_Index stride , hypre_Index size );
2049int hypre_BoxGetStrideVolume ( hypre_Box *box , hypre_Index stride , int *volume_ptr );
2050int hypre_BoxExpand ( hypre_Box *box , int *numexp );
2051int hypre_DeleteMultipleBoxes ( hypre_BoxArray *box_array , int *indices , int num );
2052int hypre_MaxIndexPosition ( hypre_Index index , int *position );
2053int hypre_MinIndexPosition ( hypre_Index index , int *position );
2054int hypre_BoxExpandConstant ( hypre_Box *box , int expand );
2055
2056/* box_manager.c */
2057int hypre_BoxManEntrySetInfo ( hypre_BoxManEntry *entry , void *info );
2058int hypre_BoxManEntryGetInfo ( hypre_BoxManEntry *entry , void **info_ptr );
2059int hypre_BoxManEntryGetExtents ( hypre_BoxManEntry *entry , hypre_Index imin , hypre_Index imax );
2060int hypre_BoxManEntryCopy ( hypre_BoxManEntry *fromentry , hypre_BoxManEntry *toentry );
2061int hypre_BoxManDeleteMultipleEntries ( hypre_BoxManager *manager , int *indices , int num );
2062int hypre_BoxManCreate ( int max_nentries , int info_size , int dim , MPI_Comm comm , hypre_BoxManager **manager_ptr );
2063int hypre_BoxManIncSize ( hypre_BoxManager *manager , int inc_size );
2064int hypre_BoxManDestroy ( hypre_BoxManager *manager );
2065int hypre_BoxManAddEntry ( hypre_BoxManager *manager , hypre_Index imin , hypre_Index imax , int proc_id , int box_id , void *info );
2066int hypre_BoxManGetEntry ( hypre_BoxManager *manager , int proc , int id , hypre_BoxManEntry **entry_ptr );
2067int hypre_BoxManGetAllEntries ( hypre_BoxManager *manager , int *num_entries , hypre_BoxManEntry ***entries_ptr );
2068int hypre_BoxManGatherEntries ( hypre_BoxManager *manager , hypre_Index imin , hypre_Index imax );
2069int hypre_BoxManAssemble ( hypre_BoxManager *manager );
2070int hypre_BoxManIntersect ( hypre_BoxManager *manager , hypre_Index ilower , hypre_Index iupper , hypre_BoxManEntry ***entries_ptr , int *nentries_ptr );
2071int hypre_BoxManSetNumGhost ( hypre_BoxManager *manager , int *num_ghost );
2072int hypre_FillResponseBoxMapAssemble1 ( void *p_recv_contact_buf , int contact_size , int contact_proc , void *ro , MPI_Comm comm , void **p_send_response_buf , int *response_message_size );
2073int hypre_FillResponseBoxMapAssemble2 ( void *p_recv_contact_buf , int contact_size , int contact_proc , void *ro , MPI_Comm comm , void **p_send_response_buf , int *response_message_size );
2074void hypre_entryqsort2 ( int *v , hypre_BoxManEntry **ent , int left , int right );
2075void hypre_entryswap2 ( int *v , hypre_BoxManEntry **ent , int i , int j );
2076
2077/* box_neighbors.c */
2078int hypre_RankLinkCreate ( int rank , int prank , hypre_RankLink **rank_link_ptr );
2079int hypre_RankLinkDestroy ( hypre_RankLink *rank_link );
2080int hypre_BoxNeighborsCreate ( hypre_BoxArray *boxes , int *procs , int *ids , int first_local , int num_local , hypre_BoxNeighbors **neighbors_ptr );
2081int hypre_BoxNeighborsAssemble ( hypre_BoxNeighbors *neighbors , hypre_Index periodic , int max_distance , int prune );
2082int hypre_BoxNeighborsDestroy ( hypre_BoxNeighbors *neighbors );
2083
2084/* communication_info.c */
2085int hypre_CommInfoCreate ( hypre_BoxArrayArray *send_boxes , hypre_BoxArrayArray *recv_boxes , int **send_procs , int **recv_procs , int **send_rboxnums , int **recv_rboxnums , hypre_BoxArrayArray *send_rboxes , hypre_CommInfo **comm_info_ptr );
2086int hypre_CommInfoProjectSend ( hypre_CommInfo *comm_info , hypre_Index index , hypre_Index stride );
2087int hypre_CommInfoProjectRecv ( hypre_CommInfo *comm_info , hypre_Index index , hypre_Index stride );
2088int hypre_CommInfoDestroy ( hypre_CommInfo *comm_info );
2089int hypre_CreateCommInfoFromStencil ( hypre_StructGrid *grid , hypre_StructStencil *stencil , hypre_CommInfo **comm_info_ptr );
2090int hypre_CreateCommInfoFromNumGhost ( hypre_StructGrid *grid , int *num_ghost , hypre_CommInfo **comm_info_ptr );
2091int hypre_CreateCommInfoFromGrids ( hypre_StructGrid *from_grid , hypre_StructGrid *to_grid , hypre_CommInfo **comm_info_ptr );
2092
2093/* computation.c */
2094int hypre_ComputeInfoCreate ( hypre_CommInfo *comm_info , hypre_BoxArrayArray *indt_boxes , hypre_BoxArrayArray *dept_boxes , hypre_ComputeInfo **compute_info_ptr );
2095int hypre_ComputeInfoProjectSend ( hypre_ComputeInfo *compute_info , hypre_Index index , hypre_Index stride );
2096int hypre_ComputeInfoProjectRecv ( hypre_ComputeInfo *compute_info , hypre_Index index , hypre_Index stride );
2097int hypre_ComputeInfoProjectComp ( hypre_ComputeInfo *compute_info , hypre_Index index , hypre_Index stride );
2098int hypre_ComputeInfoDestroy ( hypre_ComputeInfo *compute_info );
2099int hypre_CreateComputeInfo ( hypre_StructGrid *grid , hypre_StructStencil *stencil , hypre_ComputeInfo **compute_info_ptr );
2100int hypre_ComputePkgCreate ( hypre_ComputeInfo *compute_info , hypre_BoxArray *data_space , int num_values , hypre_StructGrid *grid , hypre_ComputePkg **compute_pkg_ptr );
2101int hypre_ComputePkgDestroy ( hypre_ComputePkg *compute_pkg );
2102int hypre_InitializeIndtComputations ( hypre_ComputePkg *compute_pkg , double *data , hypre_CommHandle **comm_handle_ptr );
2103int hypre_FinalizeIndtComputations ( hypre_CommHandle *comm_handle );
2104
2105/* grow.c */
2106hypre_BoxArray *hypre_GrowBoxByStencil ( hypre_Box *box , hypre_StructStencil *stencil , int transpose );
2107hypre_BoxArrayArray *hypre_GrowBoxArrayByStencil ( hypre_BoxArray *box_array , hypre_StructStencil *stencil , int transpose );
2108
2109/* HYPRE_struct_grid.c */
2110int HYPRE_StructGridCreate ( MPI_Comm comm , int dim , HYPRE_StructGrid *grid );
2111int HYPRE_StructGridDestroy ( HYPRE_StructGrid grid );
2112int HYPRE_StructGridSetExtents ( HYPRE_StructGrid grid , int *ilower , int *iupper );
2113int HYPRE_StructGridSetPeriodic ( HYPRE_StructGrid grid , int *periodic );
2114int HYPRE_StructGridAssemble ( HYPRE_StructGrid grid );
2115int HYPRE_StructGridSetNumGhost ( HYPRE_StructGrid grid , int *num_ghost );
2116
2117/* HYPRE_struct_matrix.c */
2118int HYPRE_StructMatrixCreate ( MPI_Comm comm , HYPRE_StructGrid grid , HYPRE_StructStencil stencil , HYPRE_StructMatrix *matrix );
2119int HYPRE_StructMatrixDestroy ( HYPRE_StructMatrix matrix );
2120int HYPRE_StructMatrixInitialize ( HYPRE_StructMatrix matrix );
2121int HYPRE_StructMatrixSetValues ( HYPRE_StructMatrix matrix , int *grid_index , int num_stencil_indices , int *stencil_indices , double *values );
2122int HYPRE_StructMatrixSetBoxValues ( HYPRE_StructMatrix matrix , int *ilower , int *iupper , int num_stencil_indices , int *stencil_indices , double *values );
2123int HYPRE_StructMatrixGetBoxValues ( HYPRE_StructMatrix matrix , int *ilower , int *iupper , int num_stencil_indices , int *stencil_indices , double *values );
2124int HYPRE_StructMatrixSetConstantValues ( HYPRE_StructMatrix matrix , int num_stencil_indices , int *stencil_indices , double *values );
2125int HYPRE_StructMatrixAddToValues ( HYPRE_StructMatrix matrix , int *grid_index , int num_stencil_indices , int *stencil_indices , double *values );
2126int HYPRE_StructMatrixAddToBoxValues ( HYPRE_StructMatrix matrix , int *ilower , int *iupper , int num_stencil_indices , int *stencil_indices , double *values );
2127int HYPRE_StructMatrixAddToConstantValues ( HYPRE_StructMatrix matrix , int num_stencil_indices , int *stencil_indices , double *values );
2128int HYPRE_StructMatrixAssemble ( HYPRE_StructMatrix matrix );
2129int HYPRE_StructMatrixSetNumGhost ( HYPRE_StructMatrix matrix , int *num_ghost );
2130int HYPRE_StructMatrixGetGrid ( HYPRE_StructMatrix matrix , HYPRE_StructGrid *grid );
2131int HYPRE_StructMatrixSetSymmetric ( HYPRE_StructMatrix matrix , int symmetric );
2132int HYPRE_StructMatrixSetConstantEntries ( HYPRE_StructMatrix matrix , int nentries , int *entries );
2133int HYPRE_StructMatrixPrint ( const char *filename , HYPRE_StructMatrix matrix , int all );
2134int HYPRE_StructMatrixMatvec ( double alpha , HYPRE_StructMatrix A , HYPRE_StructVector x , double beta , HYPRE_StructVector y );
2135
2136/* HYPRE_struct_stencil.c */
2137int HYPRE_StructStencilCreate ( int dim , int size , HYPRE_StructStencil *stencil );
2138int HYPRE_StructStencilSetElement ( HYPRE_StructStencil stencil , int element_index , int *offset );
2139int HYPRE_StructStencilDestroy ( HYPRE_StructStencil stencil );
2140
2141/* HYPRE_struct_vector.c */
2142int HYPRE_StructVectorCreate ( MPI_Comm comm , HYPRE_StructGrid grid , HYPRE_StructVector *vector );
2143int HYPRE_StructVectorDestroy ( HYPRE_StructVector struct_vector );
2144int HYPRE_StructVectorInitialize ( HYPRE_StructVector vector );
2145int HYPRE_StructVectorClearGhostValues ( HYPRE_StructVector vector );
2146int HYPRE_StructVectorSetValues ( HYPRE_StructVector vector , int *grid_index , double values );
2147int HYPRE_StructVectorSetBoxValues ( HYPRE_StructVector vector , int *ilower , int *iupper , double *values );
2148int HYPRE_StructVectorAddToValues ( HYPRE_StructVector vector , int *grid_index , double values );
2149int HYPRE_StructVectorAddToBoxValues ( HYPRE_StructVector vector , int *ilower , int *iupper , double *values );
2150int HYPRE_StructVectorScaleValues ( HYPRE_StructVector vector , double factor );
2151int HYPRE_StructVectorGetValues ( HYPRE_StructVector vector , int *grid_index , double *values_ptr );
2152int HYPRE_StructVectorGetBoxValues ( HYPRE_StructVector vector , int *ilower , int *iupper , double *values );
2153int HYPRE_StructVectorAssemble ( HYPRE_StructVector vector );
2154int HYPRE_StructVectorPrint ( const char *filename , HYPRE_StructVector vector , int all );
2155int HYPRE_StructVectorSetNumGhost ( HYPRE_StructVector vector , int *num_ghost );
2156int HYPRE_StructVectorCopy ( HYPRE_StructVector x , HYPRE_StructVector y );
2157int HYPRE_StructVectorSetConstantValues ( HYPRE_StructVector vector , double values );
2158int HYPRE_StructVectorGetMigrateCommPkg ( HYPRE_StructVector from_vector , HYPRE_StructVector to_vector , HYPRE_CommPkg *comm_pkg );
2159int HYPRE_StructVectorMigrate ( HYPRE_CommPkg comm_pkg , HYPRE_StructVector from_vector , HYPRE_StructVector to_vector );
2160int HYPRE_CommPkgDestroy ( HYPRE_CommPkg comm_pkg );
2161
2162/* new_assemble.c */
2163int hypre_StructGridAssembleWithAP ( hypre_StructGrid *grid );
2164int hypre_FillResponseStructAssembleAP ( void *p_recv_contact_buf , int contact_size , int contact_proc , void *ro , MPI_Comm comm , void **p_send_response_buf , int *response_message_size );
2165int hypre_StructGridSetIDs ( hypre_StructGrid *grid , int *ids );
2166
2167/* new_box_neighbors.c */
2168int hypre_BoxNeighborsCreateWithAP ( hypre_BoxArray *boxes , int *procs , int *boxnums , int first_local , int num_local , hypre_Index *pshifts , hypre_BoxNeighbors **neighbors_ptr );
2169int hypre_BoxNeighborsAssembleWithAP ( hypre_BoxNeighbors *neighbors , hypre_Index periodic , int max_distance , int prune );
2170
2171/* project.c */
2172int hypre_ProjectBox ( hypre_Box *box , hypre_Index index , hypre_Index stride );
2173int hypre_ProjectBoxArray ( hypre_BoxArray *box_array , hypre_Index index , hypre_Index stride );
2174int hypre_ProjectBoxArrayArray ( hypre_BoxArrayArray *box_array_array , hypre_Index index , hypre_Index stride );
2175
2176/* struct_axpy.c */
2177int hypre_StructAxpy ( double alpha , hypre_StructVector *x , hypre_StructVector *y );
2178
2179/* struct_communication.c */
2180int hypre_CommPkgCreate ( hypre_CommInfo *comm_info , hypre_BoxArray *send_data_space , hypre_BoxArray *recv_data_space , int num_values , MPI_Comm comm , hypre_CommPkg **comm_pkg_ptr );
2181int hypre_CommTypeSetEntries ( hypre_CommType *comm_type , int *boxnums , hypre_Box *boxes , hypre_Index stride , int num_values , hypre_BoxArray *data_space , int *data_offsets );
2182int hypre_CommTypeSetEntry ( hypre_Box *box , hypre_Index stride , hypre_Box *data_box , int num_values , int data_box_offset , hypre_CommEntryType *comm_entry );
2183int hypre_InitializeCommunication ( hypre_CommPkg *comm_pkg , double *send_data , double *recv_data , hypre_CommHandle **comm_handle_ptr );
2184int hypre_FinalizeCommunication ( hypre_CommHandle *comm_handle );
2185int hypre_ExchangeLocalData ( hypre_CommPkg *comm_pkg , double *send_data , double *recv_data );
2186int hypre_CommPkgDestroy ( hypre_CommPkg *comm_pkg );
2187
2188/* struct_copy.c */
2189int hypre_StructCopy ( hypre_StructVector *x , hypre_StructVector *y );
2190int hypre_StructPartialCopy ( hypre_StructVector *x , hypre_StructVector *y , hypre_BoxArrayArray *array_boxes );
2191
2192/* struct_grid.c */
2193int hypre_StructGridCreate ( MPI_Comm comm , int dim , hypre_StructGrid **grid_ptr );
2194int hypre_StructGridRef ( hypre_StructGrid *grid , hypre_StructGrid **grid_ref );
2195int hypre_StructGridDestroy ( hypre_StructGrid *grid );
2196int hypre_StructGridSetHoodInfo ( hypre_StructGrid *grid , int max_distance );
2197int hypre_StructGridSetPeriodic ( hypre_StructGrid *grid , hypre_Index periodic );
2198int hypre_StructGridSetExtents ( hypre_StructGrid *grid , hypre_Index ilower , hypre_Index iupper );
2199int hypre_StructGridSetBoxes ( hypre_StructGrid *grid , hypre_BoxArray *boxes );
2200int hypre_StructGridSetHood ( hypre_StructGrid *grid , hypre_BoxArray *hood_boxes , int *hood_procs , int *hood_ids , int first_local , int num_local , hypre_Box *bounding_box );
2201int hypre_StructGridAssemble ( hypre_StructGrid *grid );
2202int hypre_GatherAllBoxes ( MPI_Comm comm , hypre_BoxArray *boxes , hypre_BoxArray **all_boxes_ptr , int **all_procs_ptr , int *first_local_ptr );
2203int hypre_ComputeBoxnums ( hypre_BoxArray *boxes , int *procs , int **boxnums_ptr );
2204int hypre_StructGridPrint ( FILE *file , hypre_StructGrid *grid );
2205int hypre_StructGridRead ( MPI_Comm comm , FILE *file , hypre_StructGrid **grid_ptr );
2206int hypre_StructGridSetNumGhost ( hypre_StructGrid *grid , int *num_ghost );
2207
2208/* struct_innerprod.c */
2209double hypre_StructInnerProd ( hypre_StructVector *x , hypre_StructVector *y );
2210
2211/* struct_io.c */
2212int hypre_PrintBoxArrayData ( FILE *file , hypre_BoxArray *box_array , hypre_BoxArray *data_space , int num_values , double *data );
2213int hypre_PrintCCVDBoxArrayData ( FILE *file , hypre_BoxArray *box_array , hypre_BoxArray *data_space , int num_values , int center_rank , int stencil_size , int *symm_elements , double *data );
2214int hypre_PrintCCBoxArrayData ( FILE *file , hypre_BoxArray *box_array , hypre_BoxArray *data_space , int num_values , double *data );
2215int hypre_ReadBoxArrayData ( FILE *file , hypre_BoxArray *box_array , hypre_BoxArray *data_space , int num_values , double *data );
2216int hypre_ReadBoxArrayData_CC ( FILE *file , hypre_BoxArray *box_array , hypre_BoxArray *data_space , int stencil_size , int real_stencil_size , int constant_coefficient , double *data );
2217
2218/* struct_matrix.c */
2219double *hypre_StructMatrixExtractPointerByIndex ( hypre_StructMatrix *matrix , int b , hypre_Index index );
2220hypre_StructMatrix *hypre_StructMatrixCreate ( MPI_Comm comm , hypre_StructGrid *grid , hypre_StructStencil *user_stencil );
2221hypre_StructMatrix *hypre_StructMatrixRef ( hypre_StructMatrix *matrix );
2222int hypre_StructMatrixDestroy ( hypre_StructMatrix *matrix );
2223int hypre_StructMatrixInitializeShell ( hypre_StructMatrix *matrix );
2224int hypre_StructMatrixInitializeData ( hypre_StructMatrix *matrix , double *data );
2225int hypre_StructMatrixInitialize ( hypre_StructMatrix *matrix );
2226int hypre_StructMatrixSetValues ( hypre_StructMatrix *matrix , hypre_Index grid_index , int num_stencil_indices , int *stencil_indices , double *values , int action );
2227int hypre_StructMatrixSetBoxValues ( hypre_StructMatrix *matrix , hypre_Box *value_box , int num_stencil_indices , int *stencil_indices , double *values , int action );
2228int hypre_StructMatrixSetConstantValues ( hypre_StructMatrix *matrix , int num_stencil_indices , int *stencil_indices , double *values , int action );
2229int hypre_StructMatrixAssemble ( hypre_StructMatrix *matrix );
2230int hypre_StructMatrixSetNumGhost ( hypre_StructMatrix *matrix , int *num_ghost );
2231int hypre_StructMatrixSetConstantCoefficient ( hypre_StructMatrix *matrix , int constant_coefficient );
2232int hypre_StructMatrixSetConstantEntries ( hypre_StructMatrix *matrix , int nentries , int *entries );
2233int hypre_StructMatrixPrint ( const char *filename , hypre_StructMatrix *matrix , int all );
2234int hypre_StructMatrixMigrate ( hypre_StructMatrix *from_matrix , hypre_StructMatrix *to_matrix );
2235hypre_StructMatrix *hypre_StructMatrixRead ( MPI_Comm comm , const char *filename , int *num_ghost );
2236
2237/* struct_matrix_mask.c */
2238hypre_StructMatrix *hypre_StructMatrixCreateMask ( hypre_StructMatrix *matrix , int num_stencil_indices , int *stencil_indices );
2239
2240/* struct_matvec.c */
2241void *hypre_StructMatvecCreate ( void );
2242int hypre_StructMatvecSetup ( void *matvec_vdata , hypre_StructMatrix *A , hypre_StructVector *x );
2243int hypre_StructMatvecCompute ( void *matvec_vdata , double alpha , hypre_StructMatrix *A , hypre_StructVector *x , double beta , hypre_StructVector *y );
2244int hypre_StructMatvecCC0 ( double alpha , hypre_StructMatrix *A , hypre_StructVector *x , hypre_StructVector *y , hypre_BoxArrayArray *compute_box_aa , hypre_IndexRef stride );
2245int hypre_StructMatvecCC1 ( double alpha , hypre_StructMatrix *A , hypre_StructVector *x , hypre_StructVector *y , hypre_BoxArrayArray *compute_box_aa , hypre_IndexRef stride );
2246int hypre_StructMatvecCC2 ( double alpha , hypre_StructMatrix *A , hypre_StructVector *x , hypre_StructVector *y , hypre_BoxArrayArray *compute_box_aa , hypre_IndexRef stride );
2247int hypre_StructMatvecDestroy ( void *matvec_vdata );
2248int hypre_StructMatvec ( double alpha , hypre_StructMatrix *A , hypre_StructVector *x , double beta , hypre_StructVector *y );
2249
2250/* struct_overlap_innerprod.c */
2251double hypre_StructOverlapInnerProd ( hypre_StructVector *x , hypre_StructVector *y );
2252
2253/* struct_scale.c */
2254int hypre_StructScale ( double alpha , hypre_StructVector *y );
2255
2256/* struct_stencil.c */
2257hypre_StructStencil *hypre_StructStencilCreate ( int dim , int size , hypre_Index *shape );
2258hypre_StructStencil *hypre_StructStencilRef ( hypre_StructStencil *stencil );
2259int hypre_StructStencilDestroy ( hypre_StructStencil *stencil );
2260int hypre_StructStencilElementRank ( hypre_StructStencil *stencil , hypre_Index stencil_element );
2261int hypre_StructStencilSymmetrize ( hypre_StructStencil *stencil , hypre_StructStencil **symm_stencil_ptr , int **symm_elements_ptr );
2262
2263/* struct_vector.c */
2264hypre_StructVector *hypre_StructVectorCreate ( MPI_Comm comm , hypre_StructGrid *grid );
2265hypre_StructVector *hypre_StructVectorRef ( hypre_StructVector *vector );
2266int hypre_StructVectorDestroy ( hypre_StructVector *vector );
2267int hypre_StructVectorInitializeShell ( hypre_StructVector *vector );
2268int hypre_StructVectorInitializeData ( hypre_StructVector *vector , double *data );
2269int hypre_StructVectorInitialize ( hypre_StructVector *vector );
2270int hypre_StructVectorSetValues ( hypre_StructVector *vector , hypre_Index grid_index , double values , int add_to );
2271int hypre_StructVectorSetBoxValues ( hypre_StructVector *vector , hypre_Box *value_box , double *values , int add_to );
2272int hypre_StructVectorGetValues ( hypre_StructVector *vector , hypre_Index grid_index , double *values_ptr );
2273int hypre_StructVectorGetBoxValues ( hypre_StructVector *vector , hypre_Box *value_box , double *values );
2274int hypre_StructVectorSetNumGhost ( hypre_StructVector *vector , int *num_ghost );
2275int hypre_StructVectorAssemble ( hypre_StructVector *vector );
2276int hypre_StructVectorCopy ( hypre_StructVector *x , hypre_StructVector *y );
2277int hypre_StructVectorSetConstantValues ( hypre_StructVector *vector , double values );
2278int hypre_StructVectorSetFunctionValues ( hypre_StructVector *vector , double (*fcn )(int, int, int));
2279int hypre_StructVectorClearGhostValues ( hypre_StructVector *vector );
2280int hypre_StructVectorClearBoundGhostValues ( hypre_StructVector *vector );
2281int hypre_StructVectorScaleValues ( hypre_StructVector *vector , double factor );
2282int hypre_StructVectorClearAllValues ( hypre_StructVector *vector );
2283hypre_CommPkg *hypre_StructVectorGetMigrateCommPkg ( hypre_StructVector *from_vector , hypre_StructVector *to_vector );
2284int hypre_StructVectorMigrate ( hypre_CommPkg *comm_pkg , hypre_StructVector *from_vector , hypre_StructVector *to_vector );
2285int hypre_StructVectorPrint ( const char *filename , hypre_StructVector *vector , int all );
2286hypre_StructVector *hypre_StructVectorRead ( MPI_Comm comm , const char *filename , int *num_ghost );
2287int hypre_StructVectorMaxValue ( hypre_StructVector *vector , double *max_value , int *max_index , hypre_Index max_xyz_index );
2288
2289#ifdef __cplusplus
2290}
2291#endif
2292
2293#endif
2294
Note: See TracBrowser for help on using the repository browser.