1 /****************************************************************************** 2 * Copyright 1998-2019 Lawrence Livermore National Security, LLC and other 3 * HYPRE Project Developers. See the top-level COPYRIGHT file for details. 4 * 5 * SPDX-License-Identifier: (Apache-2.0 OR MIT) 6 ******************************************************************************/ 7 8 /****************************************************************************** 9 * 10 * Header file for HYPRE_utilities library 11 * 12 *****************************************************************************/ 13 14 #ifndef HYPRE_UTILITIES_HEADER 15 #define HYPRE_UTILITIES_HEADER 16 17 #include <HYPRE_config.h> 18 19 #ifndef HYPRE_SEQUENTIAL 20 #include "mpi.h" 21 #endif 22 23 #ifdef HYPRE_USING_OPENMP 24 #include <omp.h> 25 #endif 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /*-------------------------------------------------------------------------- 32 * Big int stuff 33 *--------------------------------------------------------------------------*/ 34 35 #if defined(HYPRE_BIGINT) 36 typedef long long int HYPRE_BigInt; 37 typedef long long int HYPRE_Int; 38 #define HYPRE_MPI_BIG_INT MPI_LONG_LONG_INT 39 #define HYPRE_MPI_INT MPI_LONG_LONG_INT 40 41 #elif defined(HYPRE_MIXEDINT) 42 typedef long long int HYPRE_BigInt; 43 typedef int HYPRE_Int; 44 #define HYPRE_MPI_BIG_INT MPI_LONG_LONG_INT 45 #define HYPRE_MPI_INT MPI_INT 46 47 #else /* default */ 48 typedef int HYPRE_BigInt; 49 typedef int HYPRE_Int; 50 #define HYPRE_MPI_BIG_INT MPI_INT 51 #define HYPRE_MPI_INT MPI_INT 52 #endif 53 54 /*-------------------------------------------------------------------------- 55 * Real and Complex types 56 *--------------------------------------------------------------------------*/ 57 58 #include <float.h> 59 60 #if defined(HYPRE_SINGLE) 61 typedef float HYPRE_Real; 62 #define HYPRE_REAL_MAX FLT_MAX 63 #define HYPRE_REAL_MIN FLT_MIN 64 #define HYPRE_REAL_EPSILON FLT_EPSILON 65 #define HYPRE_REAL_MIN_EXP FLT_MIN_EXP 66 #define HYPRE_MPI_REAL MPI_FLOAT 67 68 #elif defined(HYPRE_LONG_DOUBLE) 69 typedef long double HYPRE_Real; 70 #define HYPRE_REAL_MAX LDBL_MAX 71 #define HYPRE_REAL_MIN LDBL_MIN 72 #define HYPRE_REAL_EPSILON LDBL_EPSILON 73 #define HYPRE_REAL_MIN_EXP DBL_MIN_EXP 74 #define HYPRE_MPI_REAL MPI_LONG_DOUBLE 75 76 #else /* default */ 77 typedef double HYPRE_Real; 78 #define HYPRE_REAL_MAX DBL_MAX 79 #define HYPRE_REAL_MIN DBL_MIN 80 #define HYPRE_REAL_EPSILON DBL_EPSILON 81 #define HYPRE_REAL_MIN_EXP DBL_MIN_EXP 82 #define HYPRE_MPI_REAL MPI_DOUBLE 83 #endif 84 85 #if defined(HYPRE_COMPLEX) 86 typedef double _Complex HYPRE_Complex; 87 #define HYPRE_MPI_COMPLEX MPI_C_DOUBLE_COMPLEX /* or MPI_LONG_DOUBLE ? */ 88 89 #else /* default */ 90 typedef HYPRE_Real HYPRE_Complex; 91 #define HYPRE_MPI_COMPLEX HYPRE_MPI_REAL 92 #endif 93 94 /*-------------------------------------------------------------------------- 95 * Sequential MPI stuff 96 *--------------------------------------------------------------------------*/ 97 98 #ifdef HYPRE_SEQUENTIAL 99 typedef HYPRE_Int MPI_Comm; 100 #endif 101 102 /*-------------------------------------------------------------------------- 103 * HYPRE error codes 104 *--------------------------------------------------------------------------*/ 105 106 #define HYPRE_ERROR_GENERIC 1 /* generic error */ 107 #define HYPRE_ERROR_MEMORY 2 /* unable to allocate memory */ 108 #define HYPRE_ERROR_ARG 4 /* argument error */ 109 /* bits 4-8 are reserved for the index of the argument error */ 110 #define HYPRE_ERROR_CONV 256 /* method did not converge as expected */ 111 112 /*-------------------------------------------------------------------------- 113 * HYPRE init/finalize 114 *--------------------------------------------------------------------------*/ 115 116 HYPRE_Int HYPRE_Init(); 117 HYPRE_Int HYPRE_Finalize(); 118 119 /*-------------------------------------------------------------------------- 120 * HYPRE error user functions 121 *--------------------------------------------------------------------------*/ 122 123 /* Return the current hypre error flag */ 124 HYPRE_Int HYPRE_GetError(); 125 126 /* Check if the given error flag contains the given error code */ 127 HYPRE_Int HYPRE_CheckError(HYPRE_Int hypre_ierr, HYPRE_Int hypre_error_code); 128 129 /* Return the index of the argument (counting from 1) where 130 argument error (HYPRE_ERROR_ARG) has occured */ 131 HYPRE_Int HYPRE_GetErrorArg(); 132 133 /* Describe the given error flag in the given string */ 134 void HYPRE_DescribeError(HYPRE_Int hypre_ierr, char *descr); 135 136 /* Clears the hypre error flag */ 137 HYPRE_Int HYPRE_ClearAllErrors(); 138 139 /* Clears the given error code from the hypre error flag */ 140 HYPRE_Int HYPRE_ClearError(HYPRE_Int hypre_error_code); 141 142 /* Print GPU information */ 143 HYPRE_Int HYPRE_PrintDeviceInfo(); 144 145 /*-------------------------------------------------------------------------- 146 * HYPRE Version routines 147 *--------------------------------------------------------------------------*/ 148 149 /* RDF: This macro is used by the FEI code. Want to eventually remove. */ 150 #define HYPRE_VERSION "HYPRE_RELEASE_NAME Date Compiled: " __DATE__ " " __TIME__ 151 152 /** 153 * Allocates and returns a string with version number information in it. 154 **/ 155 HYPRE_Int 156 HYPRE_Version( char **version_ptr ); 157 158 /** 159 * Returns version number information in integer form. Use 'NULL' for values 160 * not needed. The argument {\tt single} is a single sortable integer 161 * representation of the release number. 162 **/ 163 HYPRE_Int 164 HYPRE_VersionNumber( HYPRE_Int *major_ptr, 165 HYPRE_Int *minor_ptr, 166 HYPRE_Int *patch_ptr, 167 HYPRE_Int *single_ptr ); 168 169 /*-------------------------------------------------------------------------- 170 * HYPRE AP user functions 171 *--------------------------------------------------------------------------*/ 172 173 /*Checks whether the AP is on */ 174 HYPRE_Int HYPRE_AssumedPartitionCheck(); 175 176 /*-------------------------------------------------------------------------- 177 * HYPRE memory location 178 *--------------------------------------------------------------------------*/ 179 180 typedef enum _HYPRE_MemoryLocation 181 { 182 HYPRE_MEMORY_UNDEFINED = -1, 183 HYPRE_MEMORY_HOST , 184 HYPRE_MEMORY_DEVICE 185 } HYPRE_MemoryLocation; 186 187 HYPRE_Int HYPRE_SetMemoryLocation(HYPRE_MemoryLocation memory_location); 188 HYPRE_Int HYPRE_GetMemoryLocation(HYPRE_MemoryLocation *memory_location); 189 190 #include <stdlib.h> 191 192 /*-------------------------------------------------------------------------- 193 * HYPRE execution policy 194 *--------------------------------------------------------------------------*/ 195 196 typedef enum _HYPRE_ExecutionPolicy 197 { 198 HYPRE_EXEC_UNDEFINED = -1, 199 HYPRE_EXEC_HOST , 200 HYPRE_EXEC_DEVICE 201 } HYPRE_ExecutionPolicy; 202 203 HYPRE_Int HYPRE_SetExecutionPolicy(HYPRE_ExecutionPolicy exec_policy); 204 HYPRE_Int HYPRE_GetExecutionPolicy(HYPRE_ExecutionPolicy *exec_policy); 205 HYPRE_Int HYPRE_SetStructExecutionPolicy(HYPRE_ExecutionPolicy exec_policy); 206 HYPRE_Int HYPRE_GetStructExecutionPolicy(HYPRE_ExecutionPolicy *exec_policy); 207 208 /*-------------------------------------------------------------------------- 209 * HYPRE UMPIRE 210 *--------------------------------------------------------------------------*/ 211 212 HYPRE_Int HYPRE_SetUmpireDevicePoolSize(size_t nbytes); 213 HYPRE_Int HYPRE_SetUmpireUMPoolSize(size_t nbytes); 214 HYPRE_Int HYPRE_SetUmpireHostPoolSize(size_t nbytes); 215 HYPRE_Int HYPRE_SetUmpirePinnedPoolSize(size_t nbytes); 216 HYPRE_Int HYPRE_SetUmpireDevicePoolName(const char *pool_name); 217 HYPRE_Int HYPRE_SetUmpireUMPoolName(const char *pool_name); 218 HYPRE_Int HYPRE_SetUmpireHostPoolName(const char *pool_name); 219 HYPRE_Int HYPRE_SetUmpirePinnedPoolName(const char *pool_name); 220 221 /*-------------------------------------------------------------------------- 222 * HYPRE GPU memory pool 223 *--------------------------------------------------------------------------*/ 224 225 HYPRE_Int HYPRE_SetGPUMemoryPoolSize(HYPRE_Int bin_growth, HYPRE_Int min_bin, HYPRE_Int max_bin, size_t max_cached_bytes); 226 227 /*-------------------------------------------------------------------------- 228 * HYPRE handle 229 *--------------------------------------------------------------------------*/ 230 231 HYPRE_Int HYPRE_SetSpGemmUseCusparse( HYPRE_Int use_cusparse ); 232 HYPRE_Int HYPRE_SetUseGpuRand( HYPRE_Int use_curand ); 233 234 #ifdef __cplusplus 235 } 236 #endif 237 238 #endif 239