source: CIVL/examples/omp/amg2013/par_relax_more/utilities.h@ 1b509f2c

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since 1b509f2c was 431dec9, checked in by Matthew B. Dwyer <matthewbdwyer@…>, 10 years ago

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

  • Property mode set to 100644
File size: 37.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#include "HYPRE_utilities.h"
101
102#ifndef hypre_UTILITIES_HEADER
103#define hypre_UTILITIES_HEADER
104
105#ifdef __cplusplus
106extern "C" {
107#endif
108
109#define __FILE__ 0
110#define __LINE__ 0
111
112
113/******************************************************************************
114 *
115 * General structures and values
116 *
117 *****************************************************************************/
118
119#ifndef hypre_GENERAL_HEADER
120#define hypre_GENERAL_HEADER
121
122/*--------------------------------------------------------------------------
123 * Define various functions
124 *--------------------------------------------------------------------------*/
125
126#ifndef hypre_max
127#define hypre_max(a,b) (((a)<(b)) ? (b) : (a))
128#endif
129#ifndef hypre_min
130#define hypre_min(a,b) (((a)<(b)) ? (a) : (b))
131#endif
132
133#ifndef hypre_round
134#define hypre_round(x) ( ((x) < 0.0) ? ((int)(x - 0.5)) : ((int)(x + 0.5)) )
135#endif
136
137#endif
138
139/******************************************************************************
140 *
141 * Fake mpi stubs to generate serial codes without mpi
142 *
143 *****************************************************************************/
144
145#ifndef hypre_MPISTUBS
146#define hypre_MPISTUBS
147
148#ifdef HYPRE_SEQUENTIAL
149
150#ifdef __cplusplus
151extern "C" {
152#endif
153
154/*--------------------------------------------------------------------------
155 * Change all MPI names to hypre_MPI names to avoid link conflicts
156 *
157 * NOTE: MPI_Comm is the only MPI symbol in the HYPRE user interface,
158 * and is defined in `HYPRE_utilities.h'.
159 *--------------------------------------------------------------------------*/
160
161#define MPI_Comm hypre_MPI_Comm
162#define MPI_Group hypre_MPI_Group
163#define MPI_Request hypre_MPI_Request
164#define MPI_Datatype hypre_MPI_Datatype
165#define MPI_Status hypre_MPI_Status
166#define MPI_Op hypre_MPI_Op
167#define MPI_Aint hypre_MPI_Aint
168
169#define MPI_COMM_WORLD hypre_MPI_COMM_WORLD
170#define MPI_COMM_NULL hypre_MPI_COMM_NULL
171
172#define MPI_BOTTOM hypre_MPI_BOTTOM
173
174#define MPI_DOUBLE hypre_MPI_DOUBLE
175#define MPI_INT hypre_MPI_INT
176#define MPI_CHAR hypre_MPI_CHAR
177#define MPI_LONG hypre_MPI_LONG
178#define MPI_BYTE hypre_MPI_BYTE
179
180#define MPI_SUM hypre_MPI_SUM
181#define MPI_MIN hypre_MPI_MIN
182#define MPI_MAX hypre_MPI_MAX
183#define MPI_LOR hypre_MPI_LOR
184
185#define MPI_UNDEFINED hypre_MPI_UNDEFINED
186#define MPI_REQUEST_NULL hypre_MPI_REQUEST_NULL
187#define MPI_ANY_SOURCE hypre_MPI_ANY_SOURCE
188#define MPI_ANY_TAG hypre_MPI_ANY_TAG
189
190#define MPI_Init hypre_MPI_Init
191#define MPI_Finalize hypre_MPI_Finalize
192#define MPI_Abort hypre_MPI_Abort
193#define MPI_Wtime hypre_MPI_Wtime
194#define MPI_Wtick hypre_MPI_Wtick
195#define MPI_Barrier hypre_MPI_Barrier
196#define MPI_Comm_create hypre_MPI_Comm_create
197#define MPI_Comm_dup hypre_MPI_Comm_dup
198#define MPI_Comm_group hypre_MPI_Comm_group
199#define MPI_Comm_size hypre_MPI_Comm_size
200#define MPI_Comm_rank hypre_MPI_Comm_rank
201#define MPI_Comm_free hypre_MPI_Comm_free
202#define MPI_Comm_split hypre_MPI_Comm_split
203#define MPI_Group_incl hypre_MPI_Group_incl
204#define MPI_Group_free hypre_MPI_Group_free
205#define MPI_Address hypre_MPI_Address
206#define MPI_Get_count hypre_MPI_Get_count
207#define MPI_Alltoall hypre_MPI_Alltoall
208#define MPI_Allgather hypre_MPI_Allgather
209#define MPI_Allgatherv hypre_MPI_Allgatherv
210#define MPI_Gather hypre_MPI_Gather
211#define MPI_Scatter hypre_MPI_Scatter
212#define MPI_Bcast hypre_MPI_Bcast
213#define MPI_Send hypre_MPI_Send
214#define MPI_Recv hypre_MPI_Recv
215#define MPI_Isend hypre_MPI_Isend
216#define MPI_Irecv hypre_MPI_Irecv
217#define MPI_Send_init hypre_MPI_Send_init
218#define MPI_Recv_init hypre_MPI_Recv_init
219#define MPI_Irsend hypre_MPI_Irsend
220#define MPI_Startall hypre_MPI_Startall
221#define MPI_Probe hypre_MPI_Probe
222#define MPI_Iprobe hypre_MPI_Iprobe
223#define MPI_Test hypre_MPI_Test
224#define MPI_Testall hypre_MPI_Testall
225#define MPI_Wait hypre_MPI_Wait
226#define MPI_Waitall hypre_MPI_Waitall
227#define MPI_Waitany hypre_MPI_Waitany
228#define MPI_Allreduce hypre_MPI_Allreduce
229#define MPI_Reduce hypre_MPI_Reduce
230#define MPI_Request_free hypre_MPI_Request_free
231#define MPI_Type_contiguous hypre_MPI_Type_contiguous
232#define MPI_Type_vector hypre_MPI_Type_vector
233#define MPI_Type_hvector hypre_MPI_Type_hvector
234#define MPI_Type_struct hypre_MPI_Type_struct
235#define MPI_Type_commit hypre_MPI_Type_commit
236#define MPI_Type_free hypre_MPI_Type_free
237
238/*--------------------------------------------------------------------------
239 * Types, etc.
240 *--------------------------------------------------------------------------*/
241
242/* These types have associated creation and destruction routines */
243typedef int hypre_MPI_Comm;
244typedef int hypre_MPI_Group;
245typedef int hypre_MPI_Request;
246typedef int hypre_MPI_Datatype;
247
248typedef struct { int MPI_SOURCE; int MPI_TAG; } hypre_MPI_Status;
249typedef int hypre_MPI_Op;
250typedef int hypre_MPI_Aint;
251
252#define hypre_MPI_COMM_WORLD 0
253#define hypre_MPI_COMM_NULL -1
254
255#define hypre_MPI_BOTTOM 0x0
256
257#define hypre_MPI_DOUBLE 0
258#define hypre_MPI_INT 1
259#define hypre_MPI_CHAR 2
260#define hypre_MPI_LONG 3
261#define hypre_MPI_BYTE 4
262
263#define hypre_MPI_SUM 0
264#define hypre_MPI_MIN 1
265#define hypre_MPI_MAX 2
266#define hypre_MPI_LOR 3
267
268#define hypre_MPI_UNDEFINED -9999
269#define hypre_MPI_REQUEST_NULL 0
270#define hypre_MPI_ANY_SOURCE 1
271#define hypre_MPI_ANY_TAG 1
272
273/*--------------------------------------------------------------------------
274 * Prototypes
275 *--------------------------------------------------------------------------*/
276
277/* mpistubs.c */
278int hypre_MPI_Init( int *argc , char ***argv );
279int hypre_MPI_Finalize( void );
280int hypre_MPI_Abort( hypre_MPI_Comm comm , int errorcode );
281double hypre_MPI_Wtime( void );
282double hypre_MPI_Wtick( void );
283int hypre_MPI_Barrier( hypre_MPI_Comm comm );
284int hypre_MPI_Comm_create( hypre_MPI_Comm comm , hypre_MPI_Group group , hypre_MPI_Comm *newcomm );
285int hypre_MPI_Comm_dup( hypre_MPI_Comm comm , hypre_MPI_Comm *newcomm );
286int hypre_MPI_Comm_size( hypre_MPI_Comm comm , int *size );
287int hypre_MPI_Comm_rank( hypre_MPI_Comm comm , int *rank );
288int hypre_MPI_Comm_free( hypre_MPI_Comm *comm );
289int hypre_MPI_Comm_group( hypre_MPI_Comm comm , hypre_MPI_Group *group );
290int hypre_MPI_Comm_split( hypre_MPI_Comm comm, int n, int m, hypre_MPI_Comm * comms );
291int hypre_MPI_Group_incl( hypre_MPI_Group group , int n , int *ranks , hypre_MPI_Group *newgroup );
292int hypre_MPI_Group_free( hypre_MPI_Group *group );
293int hypre_MPI_Address( void *location , hypre_MPI_Aint *address );
294int hypre_MPI_Get_count( hypre_MPI_Status *status , hypre_MPI_Datatype datatype , int *count );
295int hypre_MPI_Alltoall( void *sendbuf , int sendcount , hypre_MPI_Datatype sendtype , void *recvbuf , int recvcount , hypre_MPI_Datatype recvtype , hypre_MPI_Comm comm );
296int hypre_MPI_Allgather( void *sendbuf , int sendcount , hypre_MPI_Datatype sendtype , void *recvbuf , int recvcount , hypre_MPI_Datatype recvtype , hypre_MPI_Comm comm );
297int hypre_MPI_Allgatherv( void *sendbuf , int sendcount , hypre_MPI_Datatype sendtype , void *recvbuf , int *recvcounts , int *displs , hypre_MPI_Datatype recvtype , hypre_MPI_Comm comm );
298int hypre_MPI_Gather( void *sendbuf , int sendcount , hypre_MPI_Datatype sendtype , void *recvbuf , int recvcount , hypre_MPI_Datatype recvtype , int root , hypre_MPI_Comm comm );
299int hypre_MPI_Scatter( void *sendbuf , int sendcount , hypre_MPI_Datatype sendtype , void *recvbuf , int recvcount , hypre_MPI_Datatype recvtype , int root , hypre_MPI_Comm comm );
300int hypre_MPI_Bcast( void *buffer , int count , hypre_MPI_Datatype datatype , int root , hypre_MPI_Comm comm );
301int hypre_MPI_Send( void *buf , int count , hypre_MPI_Datatype datatype , int dest , int tag , hypre_MPI_Comm comm );
302int hypre_MPI_Recv( void *buf , int count , hypre_MPI_Datatype datatype , int source , int tag , hypre_MPI_Comm comm , hypre_MPI_Status *status );
303int hypre_MPI_Isend( void *buf , int count , hypre_MPI_Datatype datatype , int dest , int tag , hypre_MPI_Comm comm , hypre_MPI_Request *request );
304int hypre_MPI_Irecv( void *buf , int count , hypre_MPI_Datatype datatype , int source , int tag , hypre_MPI_Comm comm , hypre_MPI_Request *request );
305int hypre_MPI_Send_init( void *buf , int count , hypre_MPI_Datatype datatype , int dest , int tag , hypre_MPI_Comm comm , hypre_MPI_Request *request );
306int hypre_MPI_Recv_init( void *buf , int count , hypre_MPI_Datatype datatype , int dest , int tag , hypre_MPI_Comm comm , hypre_MPI_Request *request );
307int hypre_MPI_Irsend( void *buf , int count , hypre_MPI_Datatype datatype , int dest , int tag , hypre_MPI_Comm comm , hypre_MPI_Request *request );
308int hypre_MPI_Startall( int count , hypre_MPI_Request *array_of_requests );
309int hypre_MPI_Probe( int source , int tag , hypre_MPI_Comm comm , hypre_MPI_Status *status );
310int hypre_MPI_Iprobe( int source , int tag , hypre_MPI_Comm comm , int *flag , hypre_MPI_Status *status );
311int hypre_MPI_Test( hypre_MPI_Request *request , int *flag , hypre_MPI_Status *status );
312int hypre_MPI_Testall( int count , hypre_MPI_Request *array_of_requests , int *flag , hypre_MPI_Status *array_of_statuses );
313int hypre_MPI_Wait( hypre_MPI_Request *request , hypre_MPI_Status *status );
314int hypre_MPI_Waitall( int count , hypre_MPI_Request *array_of_requests , hypre_MPI_Status *array_of_statuses );
315int hypre_MPI_Waitany( int count , hypre_MPI_Request *array_of_requests , int *index , hypre_MPI_Status *status );
316int hypre_MPI_Allreduce( void *sendbuf , void *recvbuf , int count , hypre_MPI_Datatype datatype , hypre_MPI_Op op , hypre_MPI_Comm comm );
317int hypre_MPI_Reduce( void *sendbuf , void *recvbuf , int count , hypre_MPI_Datatype datatype , hypre_MPI_Op op , int root , hypre_MPI_Comm comm );
318int hypre_MPI_Request_free( hypre_MPI_Request *request );
319int hypre_MPI_Type_contiguous( int count , hypre_MPI_Datatype oldtype , hypre_MPI_Datatype *newtype );
320int hypre_MPI_Type_vector( int count , int blocklength , int stride , hypre_MPI_Datatype oldtype , hypre_MPI_Datatype *newtype );
321int hypre_MPI_Type_hvector( int count , int blocklength , hypre_MPI_Aint stride , hypre_MPI_Datatype oldtype , hypre_MPI_Datatype *newtype );
322int hypre_MPI_Type_struct( int count , int *array_of_blocklengths , hypre_MPI_Aint *array_of_displacements , hypre_MPI_Datatype *array_of_types , hypre_MPI_Datatype *newtype );
323int hypre_MPI_Type_commit( hypre_MPI_Datatype *datatype );
324int hypre_MPI_Type_free( hypre_MPI_Datatype *datatype );
325
326#ifdef __cplusplus
327}
328#endif
329
330#endif
331
332#endif
333
334/******************************************************************************
335 *
336 * Header file for memory management utilities
337 *
338 *****************************************************************************/
339
340#ifndef hypre_MEMORY_HEADER
341#define hypre_MEMORY_HEADER
342
343#ifdef __cplusplus
344extern "C" {
345#endif
346
347/*--------------------------------------------------------------------------
348 * Use "Debug Malloc Library", dmalloc
349 *--------------------------------------------------------------------------*/
350
351#ifdef HYPRE_MEMORY_DMALLOC
352
353#define hypre_InitMemoryDebug(id) hypre_InitMemoryDebugDML(id)
354#define hypre_FinalizeMemoryDebug() hypre_FinalizeMemoryDebugDML()
355
356#define hypre_TAlloc(type, count) \
357( (type *)hypre_MAllocDML((unsigned int)(sizeof(type) * (count)),\
358 __FILE__, __LINE__) )
359
360#define hypre_CTAlloc(type, count) \
361( (type *)hypre_CAllocDML((unsigned int)(count), (unsigned int)sizeof(type),\
362 __FILE__, __LINE__) )
363
364#define hypre_TReAlloc(ptr, type, count) \
365( (type *)hypre_ReAllocDML((char *)ptr,\
366 (unsigned int)(sizeof(type) * (count)),\
367 __FILE__, __LINE__) )
368
369#define hypre_TFree(ptr) \
370( hypre_FreeDML((char *)ptr, __FILE__, __LINE__), ptr = NULL )
371
372/*--------------------------------------------------------------------------
373 * Use standard memory routines
374 *--------------------------------------------------------------------------*/
375
376#else
377
378#define hypre_InitMemoryDebug(id)
379#define hypre_FinalizeMemoryDebug()
380
381#define hypre_TAlloc(type, count) \
382( (type *)hypre_MAlloc((unsigned int)(sizeof(type) * (count))) )
383
384#define hypre_CTAlloc(type, count) \
385( (type *)hypre_CAlloc((unsigned int)(count), (unsigned int)sizeof(type)) )
386
387#define hypre_TReAlloc(ptr, type, count) \
388( (type *)hypre_ReAlloc((char *)ptr, (unsigned int)(sizeof(type) * (count))) )
389
390#define hypre_TFree(ptr) \
391( hypre_Free((char *)ptr), ptr = NULL )
392
393#endif
394
395
396#ifdef HYPRE_USE_PTHREADS
397
398#define hypre_SharedTAlloc(type, count) \
399( (type *)hypre_SharedMAlloc((unsigned int)(sizeof(type) * (count))) )
400
401
402#define hypre_SharedCTAlloc(type, count) \
403( (type *)hypre_SharedCAlloc((unsigned int)(count),\
404 (unsigned int)sizeof(type)) )
405
406#define hypre_SharedTReAlloc(ptr, type, count) \
407( (type *)hypre_SharedReAlloc((char *)ptr,\
408 (unsigned int)(sizeof(type) * (count))) )
409
410#define hypre_SharedTFree(ptr) \
411( hypre_SharedFree((char *)ptr), ptr = NULL )
412
413#else
414
415#define hypre_SharedTAlloc(type, count) hypre_TAlloc(type, (count))
416#define hypre_SharedCTAlloc(type, count) hypre_CTAlloc(type, (count))
417#define hypre_SharedTReAlloc(type, count) hypre_TReAlloc(type, (count))
418#define hypre_SharedTFree(ptr) hypre_TFree(ptr)
419
420#endif
421
422/*--------------------------------------------------------------------------
423 * Prototypes
424 *--------------------------------------------------------------------------*/
425
426/* hypre_memory.c */
427int hypre_OutOfMemory( int size );
428char *hypre_MAlloc( int size );
429char *hypre_CAlloc( int count , int elt_size );
430char *hypre_ReAlloc( char *ptr , int size );
431void hypre_Free( char *ptr );
432char *hypre_SharedMAlloc( int size );
433char *hypre_SharedCAlloc( int count , int elt_size );
434char *hypre_SharedReAlloc( char *ptr , int size );
435void hypre_SharedFree( char *ptr );
436double *hypre_IncrementSharedDataPtr( double *ptr , int size );
437
438/* memory_dmalloc.c */
439int hypre_InitMemoryDebugDML( int id );
440int hypre_FinalizeMemoryDebugDML( void );
441char *hypre_MAllocDML( int size , char *file , int line );
442char *hypre_CAllocDML( int count , int elt_size , char *file , int line );
443char *hypre_ReAllocDML( char *ptr , int size , char *file , int line );
444void hypre_FreeDML( char *ptr , char *file , int line );
445
446#ifdef __cplusplus
447}
448#endif
449
450#endif
451
452/* random.c */
453void hypre_SeedRand ( int seed );
454double hypre_Rand ( void );
455
456/******************************************************************************
457 *
458 * Fake mpi stubs to generate serial codes without mpi
459 *
460 *****************************************************************************/
461/*just a test comment*/
462#ifndef hypre_thread_MPISTUBS
463#define hypre_thread_MPISTUBS
464
465#ifdef HYPRE_USE_PTHREADS
466
467#ifdef __cplusplus
468extern "C" {
469#endif
470
471#ifndef HYPRE_USING_THREAD_MPISTUBS
472
473#define MPI_Init hypre_thread_MPI_Init
474#define MPI_Wtime hypre_thread_MPI_Wtime
475#define MPI_Wtick hypre_thread_MPI_Wtick
476#define MPI_Barrier hypre_thread_MPI_Barrier
477#define MPI_Finalize hypre_thread_MPI_Finalize
478#define MPI_Comm_group hypre_thread_MPI_Comm_group
479#define MPI_Comm_dup hypre_thread_MPI_Comm_dup
480#define MPI_Group_incl hypre_thread_MPI_Group_incl
481#define MPI_Comm_create hypre_thread_MPI_Comm_create
482#define MPI_Allgather hypre_thread_MPI_Allgather
483#define MPI_Allgatherv hypre_thread_MPI_Allgatherv
484#define MPI_Bcast hypre_thread_MPI_Bcast
485#define MPI_Send hypre_thread_MPI_Send
486#define MPI_Recv hypre_thread_MPI_Recv
487
488#define MPI_Isend hypre_thread_MPI_Isend
489#define MPI_Irecv hypre_thread_MPI_Irecv
490#define MPI_Wait hypre_thread_MPI_Wait
491#define MPI_Waitall hypre_thread_MPI_Waitall
492#define MPI_Waitany hypre_thread_MPI_Waitany
493#define MPI_Comm_size hypre_thread_MPI_Comm_size
494#define MPI_Comm_rank hypre_thread_MPI_Comm_rank
495#define MPI_Allreduce hypre_thread_MPI_Allreduce
496#define MPI_Type_hvector hypre_thread_MPI_Type_hvector
497#define MPI_Type_struct hypre_thread_MPI_Type_struct
498#define MPI_Type_free hypre_thread_MPI_Type_free
499#define MPI_Type_commit hypre_thread_MPI_Type_commit
500
501#endif
502
503/*--------------------------------------------------------------------------
504 * Prototypes
505 *--------------------------------------------------------------------------*/
506
507/* mpistubs.c */
508int MPI_Init( int *argc , char ***argv );
509double MPI_Wtime( void );
510double MPI_Wtick( void );
511int MPI_Barrier( MPI_Comm comm );
512int MPI_Finalize( void );
513int MPI_Abort( MPI_Comm comm , int errorcode );
514int MPI_Comm_group( MPI_Comm comm , MPI_Group *group );
515int MPI_Comm_dup( MPI_Comm comm , MPI_Comm *newcomm );
516int MPI_Group_incl( MPI_Group group , int n , int *ranks , MPI_Group *newgroup );
517int MPI_Comm_create( MPI_Comm comm , MPI_Group group , MPI_Comm *newcomm );
518int MPI_Get_count( MPI_Status *status , MPI_Datatype datatype , int *count );
519int MPI_Alltoall( void *sendbuf , int sendcount , MPI_Datatype sendtype , void *recvbuf , int recvcount , MPI_Datatype recvtype , MPI_Comm comm );
520int MPI_Allgather( void *sendbuf , int sendcount , MPI_Datatype sendtype , void *recvbuf , int recvcount , MPI_Datatype recvtype , MPI_Comm comm );
521int MPI_Allgatherv( void *sendbuf , int sendcount , MPI_Datatype sendtype , void *recvbuf , int *recvcounts , int *displs , MPI_Datatype recvtype , MPI_Comm comm );
522int MPI_Gather( void *sendbuf , int sendcount , MPI_Datatype sendtype , void *recvbuf , int recvcount , MPI_Datatype recvtype , int root , MPI_Comm comm );
523int MPI_Scatter( void *sendbuf , int sendcount , MPI_Datatype sendtype , void *recvbuf , int recvcount , MPI_Datatype recvtype , int root , MPI_Comm comm );
524int MPI_Bcast( void *buffer , int count , MPI_Datatype datatype , int root , MPI_Comm comm );
525int MPI_Send( void *buf , int count , MPI_Datatype datatype , int dest , int tag , MPI_Comm comm );
526int MPI_Recv( void *buf , int count , MPI_Datatype datatype , int source , int tag , MPI_Comm comm , MPI_Status *status );
527int MPI_Isend( void *buf , int count , MPI_Datatype datatype , int dest , int tag , MPI_Comm comm , MPI_Request *request );
528int MPI_Irecv( void *buf , int count , MPI_Datatype datatype , int source , int tag , MPI_Comm comm , MPI_Request *request );
529int MPI_Wait( MPI_Request *request , MPI_Status *status );
530int MPI_Waitall( int count , MPI_Request *array_of_requests , MPI_Status *array_of_statuses );
531int MPI_Waitany( int count , MPI_Request *array_of_requests , int *index , MPI_Status *status );
532int MPI_Comm_size( MPI_Comm comm , int *size );
533int MPI_Comm_rank( MPI_Comm comm , int *rank );
534int MPI_Allreduce( void *sendbuf , void *recvbuf , int count , MPI_Datatype datatype , MPI_Op op , MPI_Comm comm );
535int MPI_Address( void *location , MPI_Aint *address );
536int MPI_Type_contiguous( int count , MPI_Datatype oldtype , MPI_Datatype *newtype );
537int MPI_Type_vector( int count , int blocklength , int stride , MPI_Datatype oldtype , MPI_Datatype *newtype );
538int MPI_Type_hvector( int count , int blocklength , MPI_Aint stride , MPI_Datatype oldtype , MPI_Datatype *newtype );
539int MPI_Type_struct( int count , int *array_of_blocklengths , MPI_Aint *array_of_displacements , MPI_Datatype *array_of_types , MPI_Datatype *newtype );
540int MPI_Type_free( MPI_Datatype *datatype );
541int MPI_Type_commit( MPI_Datatype *datatype );
542int MPI_Request_free( MPI_Request *request );
543int MPI_Send_init( void *buf , int count , MPI_Datatype datatype , int dest , int tag , MPI_Comm comm , MPI_Request *request );
544int MPI_Recv_init( void *buf , int count , MPI_Datatype datatype , int dest , int tag , MPI_Comm comm , MPI_Request *request );
545int MPI_Startall( int count , MPI_Request *array_of_requests );
546int MPI_Iprobe( int source , int tag , MPI_Comm comm , int *flag , MPI_Status *status );
547int MPI_Probe( int source , int tag , MPI_Comm comm , MPI_Status *status );
548int MPI_Irsend( void *buf , int count , MPI_Datatype datatype , int dest , int tag , MPI_Comm comm , MPI_Request *request );
549
550#ifdef __cplusplus
551}
552#endif
553
554#endif
555
556#endif
557
558
559#ifndef hypre_THREADING_HEADER
560#define hypre_THREADING_HEADER
561
562#if defined(HYPRE_USING_OPENMP) || defined (HYPRE_USING_PGCC_SMP)
563
564int hypre_NumThreads( void );
565int hypre_NumActiveThreads( void );
566int hypre_GetThreadNum( void );
567
568#else
569
570#define hypre_NumThreads() 1
571#define hypre_NumActiveThreads() 1
572#define hypre_GetThreadNum() 0
573
574#endif
575
576
577/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
578/* The pthreads stuff needs to be reworked */
579
580#ifdef HYPRE_USE_PTHREADS
581
582#ifndef MAX_QUEUE
583#define MAX_QUEUE 256
584#endif
585
586#include <pthread.h>
587
588/* hypre_work_proc_t typedef'd to be a pointer to a function with a void*
589 argument and a void return type */
590typedef void (*hypre_work_proc_t)(void *);
591
592typedef struct hypre_workqueue_struct {
593 pthread_mutex_t lock;
594 pthread_cond_t work_wait;
595 pthread_cond_t finish_wait;
596 hypre_work_proc_t worker_proc_queue[MAX_QUEUE];
597 int n_working;
598 int n_waiting;
599 int n_queue;
600 int inp;
601 int outp;
602 void *argqueue[MAX_QUEUE];
603} *hypre_workqueue_t;
604
605void hypre_work_put( hypre_work_proc_t funcptr, void *argptr );
606void hypre_work_wait( void );
607int HYPRE_InitPthreads( int num_threads );
608void HYPRE_DestroyPthreads( void );
609void hypre_pthread_worker( int threadid );
610int ifetchadd( int *w, pthread_mutex_t *mutex_fetchadd );
611int hypre_fetch_and_add( int *w );
612void hypre_barrier(pthread_mutex_t *mpi_mtx, int unthreaded);
613int hypre_GetThreadID( void );
614
615pthread_t initial_thread;
616pthread_t hypre_thread[hypre_MAX_THREADS];
617pthread_mutex_t hypre_mutex_boxloops;
618pthread_mutex_t talloc_mtx;
619pthread_mutex_t worker_mtx;
620hypre_workqueue_t hypre_qptr;
621pthread_mutex_t mpi_mtx;
622pthread_mutex_t time_mtx;
623volatile int hypre_thread_release;
624
625#ifdef HYPRE_THREAD_GLOBALS
626int hypre_NumThreads = 4;
627#else
628extern int hypre_NumThreads;
629#endif
630
631#endif
632/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
633
634#endif
635
636
637/******************************************************************************
638 *
639 * Header file for doing timing
640 *
641 *****************************************************************************/
642
643#ifndef HYPRE_TIMING_HEADER
644#define HYPRE_TIMING_HEADER
645
646#include <stdlib.h>
647#include <stdio.h>
648#include <string.h>
649
650#ifdef __cplusplus
651extern "C" {
652#endif
653
654/*--------------------------------------------------------------------------
655 * Prototypes for low-level timing routines
656 *--------------------------------------------------------------------------*/
657
658/* timer.c */
659double time_getWallclockSeconds( void );
660double time_getCPUSeconds( void );
661double time_get_wallclock_seconds_( void );
662double time_get_cpu_seconds_( void );
663
664/*--------------------------------------------------------------------------
665 * With timing off
666 *--------------------------------------------------------------------------*/
667
668#ifndef HYPRE_TIMING
669
670#define hypre_InitializeTiming(name) 0
671#define hypre_IncFLOPCount(inc)
672#define hypre_BeginTiming(i)
673#define hypre_EndTiming(i)
674#define hypre_PrintTiming(heading, wall_time_ptr, comm)
675#define hypre_FinalizeTiming(index)
676
677/*--------------------------------------------------------------------------
678 * With timing on
679 *--------------------------------------------------------------------------*/
680
681#else
682
683/*-------------------------------------------------------
684 * Global timing structure
685 *-------------------------------------------------------*/
686
687typedef struct
688{
689 double *wall_time;
690 double *cpu_time;
691 double *flops;
692 char **name;
693 int *state; /* boolean flag to allow for recursive timing */
694 int *num_regs; /* count of how many times a name is registered */
695
696 int num_names;
697 int size;
698
699 double wall_count;
700 double CPU_count;
701 double FLOP_count;
702
703} hypre_TimingType;
704
705#ifdef HYPRE_TIMING_GLOBALS
706hypre_TimingType *hypre_global_timing = NULL;
707#else
708extern hypre_TimingType *hypre_global_timing;
709#endif
710
711/*-------------------------------------------------------
712 * Accessor functions
713 *-------------------------------------------------------*/
714
715#ifndef HYPRE_USE_PTHREADS
716#define hypre_TimingWallTime(i) (hypre_global_timing -> wall_time[(i)])
717#define hypre_TimingCPUTime(i) (hypre_global_timing -> cpu_time[(i)])
718#define hypre_TimingFLOPS(i) (hypre_global_timing -> flops[(i)])
719#define hypre_TimingName(i) (hypre_global_timing -> name[(i)])
720#define hypre_TimingState(i) (hypre_global_timing -> state[(i)])
721#define hypre_TimingNumRegs(i) (hypre_global_timing -> num_regs[(i)])
722#define hypre_TimingWallCount (hypre_global_timing -> wall_count)
723#define hypre_TimingCPUCount (hypre_global_timing -> CPU_count)
724#define hypre_TimingFLOPCount (hypre_global_timing -> FLOP_count)
725#else
726#define hypre_TimingWallTime(i) (hypre_global_timing[threadid].wall_time[(i)])
727#define hypre_TimingCPUTime(i) (hypre_global_timing[threadid].cpu_time[(i)])
728#define hypre_TimingFLOPS(i) (hypre_global_timing[threadid].flops[(i)])
729#define hypre_TimingName(i) (hypre_global_timing[threadid].name[(i)])
730#define hypre_TimingState(i) (hypre_global_timing[threadid].state[(i)])
731#define hypre_TimingNumRegs(i) (hypre_global_timing[threadid].num_regs[(i)])
732#define hypre_TimingWallCount (hypre_global_timing[threadid].wall_count)
733#define hypre_TimingCPUCount (hypre_global_timing[threadid].CPU_count)
734#define hypre_TimingFLOPCount (hypre_global_timing[threadid].FLOP_count)
735#define hypre_TimingAllFLOPS (hypre_global_timing[hypre_NumThreads].FLOP_count)
736#endif
737
738/*-------------------------------------------------------
739 * Prototypes
740 *-------------------------------------------------------*/
741
742/* timing.c */
743int hypre_InitializeTiming( const char *name );
744int hypre_FinalizeTiming( int time_index );
745int hypre_IncFLOPCount( int inc );
746int hypre_BeginTiming( int time_index );
747int hypre_EndTiming( int time_index );
748int hypre_ClearTiming( void );
749int hypre_PrintTiming( const char *heading , double *wall_time_ptr, MPI_Comm comm );
750
751#endif
752
753#ifdef __cplusplus
754}
755#endif
756
757#endif
758
759
760/******************************************************************************
761 *
762 * Header file link lists
763 *
764 *****************************************************************************/
765
766#ifndef HYPRE_LINKLIST_HEADER
767#define HYPRE_LINKLIST_HEADER
768
769#include <stdlib.h>
770#include <stdio.h>
771#include <string.h>
772
773#ifdef __cplusplus
774extern "C" {
775#endif
776
777#define LIST_HEAD -1
778#define LIST_TAIL -2
779
780struct double_linked_list
781{
782 int data;
783 struct double_linked_list *next_elt;
784 struct double_linked_list *prev_elt;
785 int head;
786 int tail;
787};
788
789typedef struct double_linked_list hypre_ListElement;
790typedef hypre_ListElement *hypre_LinkList;
791
792#ifdef __cplusplus
793}
794#endif
795
796#endif
797
798#ifndef hypre_EXCHANGE_DATA_HEADER
799#define hypre_EXCHANGE_DATA_HEADER
800
801#define hypre_BinaryTreeParentId(tree) (tree->parent_id)
802#define hypre_BinaryTreeNumChild(tree) (tree->num_child)
803#define hypre_BinaryTreeChildIds(tree) (tree->child_id)
804#define hypre_BinaryTreeChildId(tree, i) (tree->child_id[i])
805
806
807typedef struct
808{
809 int parent_id;
810 int num_child;
811 int *child_id;
812} hypre_BinaryTree;
813
814
815
816/* In the fill_response() function the user needs to set the recv__buf
817 and the response_message_size. Memory of size send_response_storage has been
818 alllocated for the send_buf (in exchange_data) - if more is needed, then
819 realloc and adjust
820 the send_response_storage. The realloc amount should be storage+overhead.
821 If the response is an empty "confirmation" message, then set
822 response_message_size =0 (and do not modify the send_buf) */
823
824
825typedef struct
826{
827 int (*fill_response)(void* recv_buf, int contact_size,
828 int contact_proc, void* response_obj,
829 MPI_Comm comm, void** response_buf,
830 int* response_message_size);
831 int send_response_overhead; /*set by exchange data */
832 int send_response_storage; /*storage allocated for send_response_buf*/
833 void *data1; /*data fields user may want to access in fill_response */
834 void *data2;
835
836} hypre_DataExchangeResponse;
837
838
839int hypre_CreateBinaryTree(int, int, hypre_BinaryTree*);
840int hypre_DestroyBinaryTree(hypre_BinaryTree*);
841
842
843int hypre_DataExchangeList(int num_contacts,
844 int *contact_proc_list, void *contact_send_buf,
845 int *contact_send_buf_starts, int contact_obj_size,
846 int response_obj_size,
847 hypre_DataExchangeResponse *response_obj, int max_response_size,
848 int rnum, MPI_Comm comm, void **p_response_recv_buf,
849 int **p_response_recv_buf_starts);
850
851
852#endif /* end of header */
853
854/* amg_linklist.c */
855void dispose_elt ( hypre_LinkList element_ptr );
856void remove_point ( hypre_LinkList *LoL_head_ptr , hypre_LinkList *LoL_tail_ptr , int measure , int index , int *lists , int *where );
857hypre_LinkList create_elt ( int Item );
858void enter_on_lists ( hypre_LinkList *LoL_head_ptr , hypre_LinkList *LoL_tail_ptr , int measure , int index , int *lists , int *where );
859
860int hypre_BinarySearch ( int *list , int value , int list_length );
861int hypre_BigBinarySearch ( HYPRE_BigInt *list , HYPRE_BigInt value , int list_length );
862
863/* qsplit.c */
864int hypre_DoubleQuickSplit ( double *values , int *indices , int list_length , int NumberKept );
865
866/* hypre_qsort.c */
867void swap ( int *v , int i , int j );
868void swap2 ( int *v , double *w , int i , int j );
869void hypre_swap2i ( int *v , int *w , int i , int j );
870void hypre_swap3i ( int *v , int *w , int *z , int i , int j );
871void qsort0 ( int *v , int left , int right );
872void qsort1 ( int *v , double *w , int left , int right );
873void hypre_qsort2i ( int *v , int *w , int left , int right );
874void hypre_qsort2 ( int *v , double *w , int left , int right );
875void hypre_qsort3i ( int *v , int *w , int *z , int left , int right );
876void hypre_BigSwapbi ( HYPRE_BigInt *v , int *w , int i , int j );
877void hypre_BigQsortbi ( HYPRE_BigInt *v , int *w , int left , int right );
878void hypre_BigSwapLoc ( HYPRE_BigInt *v , int *w , int i , int j );
879void hypre_BigQsortbLoc ( HYPRE_BigInt *v , int *w , int left , int right );
880void hypre_BigSwapb2i ( HYPRE_BigInt *v , int *w , int *z , int i , int j );
881void hypre_BigQsortb2i ( HYPRE_BigInt *v , int *w , int *z , int left , int right );
882void hypre_BigSwap ( HYPRE_BigInt *v , int i , int j );
883void hypre_BigQsort0 ( HYPRE_BigInt *v , int left , int right );
884
885
886#ifndef hypre_ERROR_HEADER
887#define hypre_ERROR_HEADER
888
889/*--------------------------------------------------------------------------
890 * HYPRE error codes
891 *--------------------------------------------------------------------------*/
892
893#define HYPRE_ERROR_GENERIC 1 /* generic error */
894#define HYPRE_ERROR_MEMORY 2 /* unable to allocate memory */
895#define HYPRE_ERROR_ARG 4 /* argument error */
896/* bits 4-8 are reserved for the index of the argument error */
897#define HYPRE_ERROR_CONV 256 /* method did not converge as expected */
898
899/*--------------------------------------------------------------------------
900 * Global variable used in hypre error checking
901 *--------------------------------------------------------------------------*/
902
903extern int hypre__global_error;
904#define hypre_error_flag hypre__global_error
905
906/*--------------------------------------------------------------------------
907 * HYPRE error macros
908 *--------------------------------------------------------------------------*/
909
910void hypre_error_handler(char *filename, int line, int ierr);
911#define hypre_error(IERR) hypre_error_handler(__FILE__, __LINE__, IERR)
912#define hypre_error_in_arg(IARG) hypre_error(HYPRE_ERROR_ARG | IARG<<3)
913#ifdef NDEBUG
914#define hypre_assert(EX)
915#else
916#define hypre_assert(EX) if (!(EX)) {fprintf(stderr,"hypre_assert failed: %s\n", #EX); hypre_error(1);}
917#endif
918
919#endif
920
921#ifdef __cplusplus
922}
923#endif
924
925#endif
926
Note: See TracBrowser for help on using the repository browser.