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