126bd1501SBarry Smith #if !defined(PETSCSYSTYPES_H) 226bd1501SBarry Smith #define PETSCSYSTYPES_H 3df4397b0SStefano Zampini 4df4397b0SStefano Zampini #include <petscconf.h> 5df4397b0SStefano Zampini #include <petscfix.h> 6df4397b0SStefano Zampini 7df4397b0SStefano Zampini /*MC 8df4397b0SStefano Zampini PetscErrorCode - datatype used for return error code from almost all PETSc functions 9df4397b0SStefano Zampini 10df4397b0SStefano Zampini Level: beginner 11df4397b0SStefano Zampini 12df4397b0SStefano Zampini .seealso: CHKERRQ, SETERRQ 13df4397b0SStefano Zampini M*/ 14df4397b0SStefano Zampini typedef int PetscErrorCode; 15df4397b0SStefano Zampini 16df4397b0SStefano Zampini /*MC 17df4397b0SStefano Zampini 18df4397b0SStefano Zampini PetscClassId - A unique id used to identify each PETSc class. 19df4397b0SStefano Zampini 20df4397b0SStefano Zampini Notes: 21df4397b0SStefano Zampini Use PetscClassIdRegister() to obtain a new value for a new class being created. Usually 22df4397b0SStefano Zampini XXXInitializePackage() calls it for each class it defines. 23df4397b0SStefano Zampini 24df4397b0SStefano Zampini Developer Notes: 25df4397b0SStefano Zampini Internal integer stored in the _p_PetscObject data structure. 26df4397b0SStefano Zampini These are all computed by an offset from the lowest one, PETSC_SMALLEST_CLASSID. 27df4397b0SStefano Zampini 28df4397b0SStefano Zampini Level: developer 29df4397b0SStefano Zampini 30df4397b0SStefano Zampini .seealso: PetscClassIdRegister(), PetscLogEventRegister(), PetscHeaderCreate() 31df4397b0SStefano Zampini M*/ 32df4397b0SStefano Zampini typedef int PetscClassId; 33df4397b0SStefano Zampini 34df4397b0SStefano Zampini /*MC 35df4397b0SStefano Zampini PetscMPIInt - datatype used to represent 'int' parameters to MPI functions. 36df4397b0SStefano Zampini 37df4397b0SStefano Zampini Level: intermediate 38df4397b0SStefano Zampini 39df4397b0SStefano Zampini Notes: 40df4397b0SStefano Zampini usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but 41df4397b0SStefano Zampini standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt; it remains 32 bit. 42df4397b0SStefano Zampini 43df4397b0SStefano Zampini PetscMPIIntCast(a,&b) checks if the given PetscInt a will fit in a PetscMPIInt, if not it 44df4397b0SStefano Zampini generates a PETSC_ERR_ARG_OUTOFRANGE error. 45df4397b0SStefano Zampini 46df4397b0SStefano Zampini .seealso: PetscBLASInt, PetscInt, PetscMPIIntCast() 47df4397b0SStefano Zampini 48df4397b0SStefano Zampini M*/ 49df4397b0SStefano Zampini typedef int PetscMPIInt; 50df4397b0SStefano Zampini 51df4397b0SStefano Zampini /*MC 52df4397b0SStefano Zampini PetscEnum - datatype used to pass enum types within PETSc functions. 53df4397b0SStefano Zampini 54df4397b0SStefano Zampini Level: intermediate 55df4397b0SStefano Zampini 56df4397b0SStefano Zampini .seealso: PetscOptionsGetEnum(), PetscOptionsEnum(), PetscBagRegisterEnum() 57df4397b0SStefano Zampini M*/ 58df4397b0SStefano Zampini typedef enum { ENUM_DUMMY } PetscEnum; 59df4397b0SStefano Zampini 60df4397b0SStefano Zampini typedef short PetscShort; 61df4397b0SStefano Zampini typedef char PetscChar; 62df4397b0SStefano Zampini typedef float PetscFloat; 63df4397b0SStefano Zampini 64df4397b0SStefano Zampini /*MC 65df4397b0SStefano Zampini PetscInt - PETSc type that represents an integer, used primarily to 66df4397b0SStefano Zampini represent size of arrays and indexing into arrays. Its size can be configured with the option --with-64-bit-indices to be either 32-bit (default) or 64-bit. 67df4397b0SStefano Zampini 68df4397b0SStefano Zampini Notes: 69df4397b0SStefano Zampini For MPI calls that require datatypes, use MPIU_INT as the datatype for PetscInt. It will automatically work correctly regardless of the size of PetscInt. 70df4397b0SStefano Zampini 71df4397b0SStefano Zampini Level: beginner 72df4397b0SStefano Zampini 73df4397b0SStefano Zampini .seealso: PetscBLASInt, PetscMPIInt, PetscReal, PetscScalar, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT 74df4397b0SStefano Zampini M*/ 75df4397b0SStefano Zampini 76df4397b0SStefano Zampini #if defined(PETSC_HAVE_STDINT_H) 77df4397b0SStefano Zampini # include <stdint.h> 78df4397b0SStefano Zampini #endif 79df4397b0SStefano Zampini #if defined (PETSC_HAVE_INTTYPES_H) 80df4397b0SStefano Zampini # if !defined(__STDC_FORMAT_MACROS) 81df4397b0SStefano Zampini # define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */ 82df4397b0SStefano Zampini # endif 83df4397b0SStefano Zampini # include <inttypes.h> 84df4397b0SStefano Zampini # if !defined(PRId64) 85df4397b0SStefano Zampini # define PRId64 "ld" 86df4397b0SStefano Zampini # endif 87df4397b0SStefano Zampini #endif 88df4397b0SStefano Zampini 89df4397b0SStefano Zampini #if defined(PETSC_HAVE_STDINT_H) && defined(PETSC_HAVE_INTTYPES_H) && defined(PETSC_HAVE_MPI_INT64_T) /* MPI_INT64_T is not guaranteed to be a macro */ 90df4397b0SStefano Zampini typedef int64_t PetscInt64; 91df4397b0SStefano Zampini #elif (PETSC_SIZEOF_LONG_LONG == 8) 92df4397b0SStefano Zampini typedef long long PetscInt64; 93df4397b0SStefano Zampini #elif defined(PETSC_HAVE___INT64) 94df4397b0SStefano Zampini typedef __int64 PetscInt64; 95df4397b0SStefano Zampini #else 96df4397b0SStefano Zampini # error "cannot determine PetscInt64 type" 97df4397b0SStefano Zampini #endif 98df4397b0SStefano Zampini 99df4397b0SStefano Zampini #if defined(PETSC_USE_64BIT_INDICES) 100df4397b0SStefano Zampini typedef PetscInt64 PetscInt; 101df4397b0SStefano Zampini #else 102df4397b0SStefano Zampini typedef int PetscInt; 103df4397b0SStefano Zampini #endif 104df4397b0SStefano Zampini 105df4397b0SStefano Zampini /*MC 106df4397b0SStefano Zampini PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions. 107df4397b0SStefano Zampini 108df4397b0SStefano Zampini Notes: 109df4397b0SStefano Zampini Usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but 110df4397b0SStefano Zampini standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt it remains 32 bit 111cdc6ee08SBarry Smith (except on very rare BLAS/LAPACK implementations that support 64 bit integers see the notes below). 112df4397b0SStefano Zampini 113df4397b0SStefano Zampini PetscErrorCode PetscBLASIntCast(a,&b) checks if the given PetscInt a will fit in a PetscBLASInt, if not it 114df4397b0SStefano Zampini generates a PETSC_ERR_ARG_OUTOFRANGE error 115df4397b0SStefano Zampini 116df4397b0SStefano Zampini Installation Notes: 117cdc6ee08SBarry Smith ./configure automatically determines the size of the integers used by BLAS/LAPACK except when --with-batch is used 118cdc6ee08SBarry Smith in that situation one must know (by some other means) if the integers used by BLAS/LAPACK are 64 bit and if so pass the flag --known-64-bit-blas-indice 119cdc6ee08SBarry Smith 120cdc6ee08SBarry Smith MATLAB ships with BLAS and LAPACK that use 64 bit integers, for example if you run ./configure with, the option 121df4397b0SStefano Zampini --with-blaslapack-lib=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib] 122df4397b0SStefano Zampini 123cdc6ee08SBarry Smith MKL ships with both 32 and 64 bit integer versions of the BLAS and LAPACK. If you pass the flag -with-64-bit-blas-indices PETSc will link 124cdc6ee08SBarry Smith against the 64 bit version, otherwise it use the 32 bit version 125df4397b0SStefano Zampini 126cdc6ee08SBarry Smith OpenBLAS can be built to use 64 bit integers. The ./configure options --download-openblas -with-64-bit-blas-indices will build a 64 bit integer version 127df4397b0SStefano Zampini 128df4397b0SStefano Zampini External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64 bit integers to BLAS/LAPACK so cannot 129cdc6ee08SBarry Smith be used with PETSc when PETSc links against 64 bit integer BLAS/LAPACK. ./configure will generate an error if you attempt to link PETSc against any of 130cdc6ee08SBarry Smith these external libraries while using 64 bit integer BLAS/LAPACK. 131df4397b0SStefano Zampini 132df4397b0SStefano Zampini Level: intermediate 133df4397b0SStefano Zampini 134df4397b0SStefano Zampini .seealso: PetscMPIInt, PetscInt, PetscBLASIntCast() 135df4397b0SStefano Zampini 136df4397b0SStefano Zampini M*/ 137df4397b0SStefano Zampini #if defined(PETSC_HAVE_64BIT_BLAS_INDICES) 138df4397b0SStefano Zampini typedef PetscInt64 PetscBLASInt; 139df4397b0SStefano Zampini #else 140df4397b0SStefano Zampini typedef int PetscBLASInt; 141df4397b0SStefano Zampini #endif 142df4397b0SStefano Zampini 143df4397b0SStefano Zampini /*E 144df4397b0SStefano Zampini PetscBool - Logical variable. Actually an int in C and a logical in Fortran. 145df4397b0SStefano Zampini 146df4397b0SStefano Zampini Level: beginner 147df4397b0SStefano Zampini 148df4397b0SStefano Zampini Developer Note: 149df4397b0SStefano Zampini Why have PetscBool , why not use bool in C? The problem is that K and R C, C99 and C++ all have different mechanisms for 150df4397b0SStefano Zampini boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms. 151df4397b0SStefano Zampini 152df4397b0SStefano Zampini .seealso: PETSC_TRUE, PETSC_FALSE, PetscNot() 153df4397b0SStefano Zampini E*/ 154df4397b0SStefano Zampini typedef enum { PETSC_FALSE,PETSC_TRUE } PetscBool; 155df4397b0SStefano Zampini 156df4397b0SStefano Zampini /*MC 157df4397b0SStefano Zampini PetscReal - PETSc type that represents a real number version of PetscScalar 158df4397b0SStefano Zampini 159df4397b0SStefano Zampini 160df4397b0SStefano Zampini Notes: 161df4397b0SStefano Zampini For MPI calls that require datatypes, use MPIU_REAL as the datatype for PetscScalar and MPIU_SUM, MPIU_MAX, etc. for operations. 162df4397b0SStefano Zampini They will automatically work correctly regardless of the size of PetscReal. 163df4397b0SStefano Zampini 164df4397b0SStefano Zampini See PetscScalar for details on how to ./configure the size of PetscReal. 165df4397b0SStefano Zampini 166df4397b0SStefano Zampini Level: beginner 167df4397b0SStefano Zampini 168df4397b0SStefano Zampini .seealso: PetscScalar, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT 169df4397b0SStefano Zampini M*/ 170df4397b0SStefano Zampini 171df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 172df4397b0SStefano Zampini typedef float PetscReal; 173df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 174df4397b0SStefano Zampini typedef double PetscReal; 175df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 176df4397b0SStefano Zampini # if defined(__cplusplus) 177df4397b0SStefano Zampini extern "C" { 178df4397b0SStefano Zampini # endif 179df4397b0SStefano Zampini # include <quadmath.h> 180df4397b0SStefano Zampini # if defined(__cplusplus) 181df4397b0SStefano Zampini } 182df4397b0SStefano Zampini # endif 183df4397b0SStefano Zampini typedef __float128 PetscReal; 184df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 185df4397b0SStefano Zampini typedef __fp16 PetscReal; 186df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 187df4397b0SStefano Zampini 188df4397b0SStefano Zampini /*MC 189df4397b0SStefano Zampini PetscComplex - PETSc type that represents a complex number with precision matching that of PetscReal. 190df4397b0SStefano Zampini 191df4397b0SStefano Zampini Synopsis: 192df4397b0SStefano Zampini #include <petscsys.h> 193df4397b0SStefano Zampini PetscComplex number = 1. + 2.*PETSC_i; 194df4397b0SStefano Zampini 195df4397b0SStefano Zampini Notes: 196df4397b0SStefano Zampini For MPI calls that require datatypes, use MPIU_COMPLEX as the datatype for PetscComplex and MPIU_SUM etc for operations. 197df4397b0SStefano Zampini They will automatically work correctly regardless of the size of PetscComplex. 198df4397b0SStefano Zampini 199df4397b0SStefano Zampini See PetscScalar for details on how to ./configure the size of PetscReal 200df4397b0SStefano Zampini 201df4397b0SStefano Zampini Complex numbers are automatically available if PETSc was able to find a working complex implementation 202df4397b0SStefano Zampini 203df4397b0SStefano Zampini Level: beginner 204df4397b0SStefano Zampini 205df4397b0SStefano Zampini .seealso: PetscReal, PetscScalar, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT, PETSC_i 206df4397b0SStefano Zampini M*/ 207df4397b0SStefano Zampini #if !defined(PETSC_SKIP_COMPLEX) 2087a19d461SSatish Balay # if defined(PETSC_CLANGUAGE_CXX) 2097a19d461SSatish Balay # if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128) 2107a19d461SSatish Balay # if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */ 211df4397b0SStefano Zampini # define PETSC_HAVE_COMPLEX 1 2127a19d461SSatish Balay # elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */ 2137a19d461SSatish Balay # define PETSC_HAVE_COMPLEX 1 2147a19d461SSatish Balay # endif 2157a19d461SSatish Balay # endif 2167a19d461SSatish Balay # else /* !PETSC_CLANGUAGE_CXX */ 2177a19d461SSatish Balay # if !defined(PETSC_USE_REAL___FP16) 2187a19d461SSatish Balay # if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */ 2197a19d461SSatish Balay # define PETSC_HAVE_COMPLEX 1 2207a19d461SSatish Balay # elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */ 2217a19d461SSatish Balay # define PETSC_HAVE_COMPLEX 1 2227a19d461SSatish Balay # endif 2237a19d461SSatish Balay # endif 2247a19d461SSatish Balay # endif /* PETSC_CLANGUAGE_CXX */ 2257a19d461SSatish Balay #endif /* !PETSC_SKIP_COMPLEX */ 2267a19d461SSatish Balay 2277a19d461SSatish Balay #if defined(PETSC_HAVE_COMPLEX) 2287a19d461SSatish Balay #if defined(__cplusplus) /* C++ complex support */ 229*11d22bbfSJunchao Zhang /* Locate a C++ complex template library */ 230*11d22bbfSJunchao Zhang #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */ 231*11d22bbfSJunchao Zhang #define petsccomplexlib Kokkos 232*11d22bbfSJunchao Zhang #include <Kokkos_Complex.hpp> 233*11d22bbfSJunchao Zhang #elif defined(PETSC_HAVE_CUDA) 234df4397b0SStefano Zampini #define petsccomplexlib thrust 235df4397b0SStefano Zampini #include <thrust/complex.h> 236df4397b0SStefano Zampini #else 237df4397b0SStefano Zampini #define petsccomplexlib std 238df4397b0SStefano Zampini #include <complex> 239df4397b0SStefano Zampini #endif 240*11d22bbfSJunchao Zhang 241*11d22bbfSJunchao Zhang /* Define PetscComplex based on the precision */ 242df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 243df4397b0SStefano Zampini typedef petsccomplexlib::complex<float> PetscComplex; 244df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 245df4397b0SStefano Zampini typedef petsccomplexlib::complex<double> PetscComplex; 246df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 247df4397b0SStefano Zampini typedef petsccomplexlib::complex<__float128> PetscComplex; /* Notstandard and not expected to work, use __complex128 */ 248*11d22bbfSJunchao Zhang #endif 249*11d22bbfSJunchao Zhang 25039829747SLisandro Dalcin #if !defined(PETSC_SKIP_CXX_COMPLEX_FIX) 25139829747SLisandro Dalcin #include <petsccxxcomplexfix.h> 252*11d22bbfSJunchao Zhang #endif 2537a19d461SSatish Balay #else /* c99 complex support */ 254df4397b0SStefano Zampini #include <complex.h> 255df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16) 256df4397b0SStefano Zampini typedef float _Complex PetscComplex; 257df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 258df4397b0SStefano Zampini typedef double _Complex PetscComplex; 259df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 260df4397b0SStefano Zampini typedef __complex128 PetscComplex; 261df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 2627a19d461SSatish Balay #endif /* !__cplusplus */ 2637a19d461SSatish Balay #endif /* PETSC_HAVE_COMPLEX */ 264df4397b0SStefano Zampini 265df4397b0SStefano Zampini /*MC 266df4397b0SStefano Zampini PetscScalar - PETSc type that represents either a double precision real number, a double precision 267df4397b0SStefano Zampini complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured 268df4397b0SStefano Zampini with --with-scalar-type=real,complex --with-precision=single,double,__float128,__fp16 269df4397b0SStefano Zampini 270df4397b0SStefano Zampini Notes: 271df4397b0SStefano Zampini For MPI calls that require datatypes, use MPIU_SCALAR as the datatype for PetscScalar and MPIU_SUM, MPIU_MAX etc for operations. They will automatically work correctly regardless of the size of PetscScalar. 272df4397b0SStefano Zampini 273df4397b0SStefano Zampini Level: beginner 274df4397b0SStefano Zampini 275df4397b0SStefano Zampini .seealso: PetscReal, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT, PetscRealPart(), PetscImaginaryPart() 276df4397b0SStefano Zampini M*/ 277df4397b0SStefano Zampini 2787a19d461SSatish Balay #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX) 279df4397b0SStefano Zampini typedef PetscComplex PetscScalar; 280df4397b0SStefano Zampini #else /* PETSC_USE_COMPLEX */ 281df4397b0SStefano Zampini typedef PetscReal PetscScalar; 282df4397b0SStefano Zampini #endif /* PETSC_USE_COMPLEX */ 283df4397b0SStefano Zampini 284df4397b0SStefano Zampini /*E 2855d80c0bfSVaclav Hapla PetscCopyMode - Determines how an array or PetscObject passed to certain functions is copied or retained by the aggregate PetscObject 286df4397b0SStefano Zampini 287df4397b0SStefano Zampini Level: beginner 288df4397b0SStefano Zampini 2895d80c0bfSVaclav Hapla For the array input: 290df4397b0SStefano Zampini $ PETSC_COPY_VALUES - the array values are copied into new space, the user is free to reuse or delete the passed in array 291df4397b0SStefano Zampini $ PETSC_OWN_POINTER - the array values are NOT copied, the object takes ownership of the array and will free it later, the user cannot change or 292df4397b0SStefano Zampini $ delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran. 293df4397b0SStefano Zampini $ PETSC_USE_POINTER - the array values are NOT copied, the object uses the array but does NOT take ownership of the array. The user cannot use 2945d80c0bfSVaclav Hapla $ the array but the user must delete the array after the object is destroyed. 2955d80c0bfSVaclav Hapla 2965d80c0bfSVaclav Hapla For the PetscObject input: 2975d80c0bfSVaclav Hapla $ PETSC_COPY_VALUES - the input PetscObject is cloned into the aggregate PetscObject; the user is free to reuse/modify the input PetscObject without side effects. 2985d80c0bfSVaclav Hapla $ PETSC_OWN_POINTER - the input PetscObject is referenced by pointer (with reference count), thus should not be modified by the user. (Modification may cause errors or unintended side-effects in this or a future version of PETSc.) 2995d80c0bfSVaclav Hapla For either case above, the input PetscObject should be destroyed by the user when no longer needed (the aggregate object increases its reference count). 3005d80c0bfSVaclav Hapla $ PETSC_USE_POINTER - invalid for PetscObject inputs. 301df4397b0SStefano Zampini 302df4397b0SStefano Zampini E*/ 303df4397b0SStefano Zampini typedef enum {PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER} PetscCopyMode; 304df4397b0SStefano Zampini 305df4397b0SStefano Zampini /*MC 306df4397b0SStefano Zampini PETSC_FALSE - False value of PetscBool 307df4397b0SStefano Zampini 308df4397b0SStefano Zampini Level: beginner 309df4397b0SStefano Zampini 310df4397b0SStefano Zampini Note: 311df4397b0SStefano Zampini Zero integer 312df4397b0SStefano Zampini 313df4397b0SStefano Zampini .seealso: PetscBool, PETSC_TRUE 314df4397b0SStefano Zampini M*/ 315df4397b0SStefano Zampini 316df4397b0SStefano Zampini /*MC 317df4397b0SStefano Zampini PETSC_TRUE - True value of PetscBool 318df4397b0SStefano Zampini 319df4397b0SStefano Zampini Level: beginner 320df4397b0SStefano Zampini 321df4397b0SStefano Zampini Note: 322df4397b0SStefano Zampini Nonzero integer 323df4397b0SStefano Zampini 324df4397b0SStefano Zampini .seealso: PetscBool, PETSC_FALSE 325df4397b0SStefano Zampini M*/ 326df4397b0SStefano Zampini 327df4397b0SStefano Zampini /*MC 328df4397b0SStefano Zampini PetscLogDouble - Used for logging times 329df4397b0SStefano Zampini 330df4397b0SStefano Zampini Notes: 331df4397b0SStefano Zampini Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc. 332df4397b0SStefano Zampini 3336b3bf505SPatrick Sanan Level: developer 3346b3bf505SPatrick Sanan 335df4397b0SStefano Zampini M*/ 336df4397b0SStefano Zampini typedef double PetscLogDouble; 337df4397b0SStefano Zampini 338df4397b0SStefano Zampini /*E 339df4397b0SStefano Zampini PetscDataType - Used for handling different basic data types. 340df4397b0SStefano Zampini 341df4397b0SStefano Zampini Level: beginner 342df4397b0SStefano Zampini 343df4397b0SStefano Zampini Notes: 344df4397b0SStefano Zampini Use of this should be avoided if one can directly use MPI_Datatype instead. 345df4397b0SStefano Zampini 346277f51e8SBarry Smith PETSC_INT is the datatype for a PetscInt, regardless of whether it is 4 or 8 bytes. 347277f51e8SBarry Smith PETSC_REAL, PETSC_COMPLEX and PETSC_SCALAR are the datatypes for PetscReal, PetscComplex and PetscScalar, regardless of their sizes. 348277f51e8SBarry Smith 349df4397b0SStefano Zampini Developer comment: 350df4397b0SStefano Zampini It would be nice if we could always just use MPI Datatypes, why can we not? 351df4397b0SStefano Zampini 35291e29162SBarry Smith If you change any values in PetscDatatype make sure you update their usage in 353fa131761SBarry Smith share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m 35491e29162SBarry Smith 355277f51e8SBarry Smith TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM 356277f51e8SBarry Smith 357df4397b0SStefano Zampini .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(), 358df4397b0SStefano Zampini PetscDataTypeGetSize() 359df4397b0SStefano Zampini 360df4397b0SStefano Zampini E*/ 3612ebc710fSVaclav Hapla typedef enum {PETSC_DATATYPE_UNKNOWN = 0, 3622ebc710fSVaclav Hapla PETSC_DOUBLE = 1, PETSC_COMPLEX = 2, PETSC_LONG = 3, PETSC_SHORT = 4, PETSC_FLOAT = 5, 36349de050aSVaclav Hapla PETSC_CHAR = 6, PETSC_BIT_LOGICAL = 7, PETSC_ENUM = 8, PETSC_BOOL = 9, PETSC___FLOAT128 = 10, 364ea127267SVaclav Hapla PETSC_OBJECT = 11, PETSC_FUNCTION = 12, PETSC_STRING = 13, PETSC___FP16 = 14, PETSC_STRUCT = 15, 3659e3e4c22SLisandro Dalcin PETSC_INT = 16, PETSC_INT64 = 17} PetscDataType; 366df4397b0SStefano Zampini 367df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 368df4397b0SStefano Zampini # define PETSC_REAL PETSC_FLOAT 3695117d392SLisandro Dalcin #elif defined(PETSC_USE_REAL_DOUBLE) 3705117d392SLisandro Dalcin # define PETSC_REAL PETSC_DOUBLE 371df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 372df4397b0SStefano Zampini # define PETSC_REAL PETSC___FLOAT128 373df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 374df4397b0SStefano Zampini # define PETSC_REAL PETSC___FP16 375df4397b0SStefano Zampini #else 376df4397b0SStefano Zampini # define PETSC_REAL PETSC_DOUBLE 377df4397b0SStefano Zampini #endif 3785117d392SLisandro Dalcin 3795117d392SLisandro Dalcin #if defined(PETSC_USE_COMPLEX) 3805117d392SLisandro Dalcin # define PETSC_SCALAR PETSC_COMPLEX 3815117d392SLisandro Dalcin #else 3825117d392SLisandro Dalcin # define PETSC_SCALAR PETSC_REAL 3835117d392SLisandro Dalcin #endif 3845117d392SLisandro Dalcin 385df4397b0SStefano Zampini #define PETSC_FORTRANADDR PETSC_LONG 386df4397b0SStefano Zampini 387df4397b0SStefano Zampini /*S 388df4397b0SStefano Zampini PetscToken - 'Token' used for managing tokenizing strings 389df4397b0SStefano Zampini 390df4397b0SStefano Zampini Level: intermediate 391df4397b0SStefano Zampini 392df4397b0SStefano Zampini .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy() 393df4397b0SStefano Zampini S*/ 394df4397b0SStefano Zampini typedef struct _p_PetscToken* PetscToken; 395df4397b0SStefano Zampini 396df4397b0SStefano Zampini /*S 397df4397b0SStefano Zampini PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc 398df4397b0SStefano Zampini 399df4397b0SStefano Zampini Level: beginner 400df4397b0SStefano Zampini 401df4397b0SStefano Zampini Note: 402df4397b0SStefano Zampini This is the base class from which all PETSc objects are derived from. 403df4397b0SStefano Zampini 404df4397b0SStefano Zampini .seealso: PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName(), PetscObjectReference(), PetscObjectDereference() 405df4397b0SStefano Zampini S*/ 406df4397b0SStefano Zampini typedef struct _p_PetscObject* PetscObject; 407df4397b0SStefano Zampini 408df4397b0SStefano Zampini /*MC 409df4397b0SStefano Zampini PetscObjectId - unique integer Id for a PetscObject 410df4397b0SStefano Zampini 411df4397b0SStefano Zampini Level: developer 412df4397b0SStefano Zampini 413df4397b0SStefano Zampini Notes: 414df4397b0SStefano Zampini Unlike pointer values, object ids are never reused. 415df4397b0SStefano Zampini 416df4397b0SStefano Zampini .seealso: PetscObjectState, PetscObjectGetId() 417df4397b0SStefano Zampini M*/ 418df4397b0SStefano Zampini typedef PetscInt64 PetscObjectId; 419df4397b0SStefano Zampini 420df4397b0SStefano Zampini /*MC 421df4397b0SStefano Zampini PetscObjectState - integer state for a PetscObject 422df4397b0SStefano Zampini 423df4397b0SStefano Zampini Level: developer 424df4397b0SStefano Zampini 425df4397b0SStefano Zampini Notes: 426df4397b0SStefano Zampini Object state is always-increasing and (for objects that track state) can be used to determine if an object has 427df4397b0SStefano Zampini changed since the last time you interacted with it. It is 64-bit so that it will not overflow for a very long time. 428df4397b0SStefano Zampini 429df4397b0SStefano Zampini .seealso: PetscObjectId, PetscObjectStateGet(), PetscObjectStateIncrease(), PetscObjectStateSet() 430df4397b0SStefano Zampini M*/ 431df4397b0SStefano Zampini typedef PetscInt64 PetscObjectState; 432df4397b0SStefano Zampini 433df4397b0SStefano Zampini /*S 434df4397b0SStefano Zampini PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed 435df4397b0SStefano Zampini by string name 436df4397b0SStefano Zampini 437df4397b0SStefano Zampini Level: advanced 438df4397b0SStefano Zampini 4397243573dSPierre Jolivet .seealso: PetscFunctionListAdd(), PetscFunctionListDestroy() 440df4397b0SStefano Zampini S*/ 441df4397b0SStefano Zampini typedef struct _n_PetscFunctionList *PetscFunctionList; 442df4397b0SStefano Zampini 443df4397b0SStefano Zampini /*E 444df4397b0SStefano Zampini PetscFileMode - Access mode for a file. 445df4397b0SStefano Zampini 446df4397b0SStefano Zampini Level: beginner 447df4397b0SStefano Zampini 4487e4fd573SVaclav Hapla $ FILE_MODE_UNDEFINED - initial invalid value 449df4397b0SStefano Zampini $ FILE_MODE_READ - open a file at its beginning for reading 450df4397b0SStefano Zampini $ FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist) 451df4397b0SStefano Zampini $ FILE_MODE_APPEND - open a file at end for writing 452df4397b0SStefano Zampini $ FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing 453df4397b0SStefano Zampini $ FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end 454df4397b0SStefano Zampini 455df4397b0SStefano Zampini .seealso: PetscViewerFileSetMode() 456df4397b0SStefano Zampini E*/ 4577e4fd573SVaclav Hapla typedef enum {FILE_MODE_UNDEFINED=-1, FILE_MODE_READ=0, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode; 458df4397b0SStefano Zampini 459df4397b0SStefano Zampini typedef void* PetscDLHandle; 460df4397b0SStefano Zampini typedef enum {PETSC_DL_DECIDE=0,PETSC_DL_NOW=1,PETSC_DL_LOCAL=2} PetscDLMode; 461df4397b0SStefano Zampini 462df4397b0SStefano Zampini /*S 4637243573dSPierre Jolivet PetscObjectList - Linked list of PETSc objects, each accessible by string name 464df4397b0SStefano Zampini 465df4397b0SStefano Zampini Level: developer 466df4397b0SStefano Zampini 467df4397b0SStefano Zampini Notes: 468df4397b0SStefano Zampini Used by PetscObjectCompose() and PetscObjectQuery() 469df4397b0SStefano Zampini 470df4397b0SStefano Zampini .seealso: PetscObjectListAdd(), PetscObjectListDestroy(), PetscObjectListFind(), PetscObjectCompose(), PetscObjectQuery(), PetscFunctionList 471df4397b0SStefano Zampini S*/ 472df4397b0SStefano Zampini typedef struct _n_PetscObjectList *PetscObjectList; 473df4397b0SStefano Zampini 474df4397b0SStefano Zampini /*S 475df4397b0SStefano Zampini PetscDLLibrary - Linked list of dynamics libraries to search for functions 476df4397b0SStefano Zampini 477df4397b0SStefano Zampini Level: advanced 478df4397b0SStefano Zampini 479df4397b0SStefano Zampini .seealso: PetscDLLibraryOpen() 480df4397b0SStefano Zampini S*/ 481df4397b0SStefano Zampini typedef struct _n_PetscDLLibrary *PetscDLLibrary; 482df4397b0SStefano Zampini 483df4397b0SStefano Zampini /*S 484df4397b0SStefano Zampini PetscContainer - Simple PETSc object that contains a pointer to any required data 485df4397b0SStefano Zampini 486df4397b0SStefano Zampini Level: advanced 487df4397b0SStefano Zampini 488df4397b0SStefano Zampini .seealso: PetscObject, PetscContainerCreate() 489df4397b0SStefano Zampini S*/ 490df4397b0SStefano Zampini typedef struct _p_PetscContainer* PetscContainer; 491df4397b0SStefano Zampini 492df4397b0SStefano Zampini /*S 493df4397b0SStefano Zampini PetscRandom - Abstract PETSc object that manages generating random numbers 494df4397b0SStefano Zampini 495df4397b0SStefano Zampini Level: intermediate 496df4397b0SStefano Zampini 497df4397b0SStefano Zampini .seealso: PetscRandomCreate(), PetscRandomGetValue(), PetscRandomType 498df4397b0SStefano Zampini S*/ 499df4397b0SStefano Zampini typedef struct _p_PetscRandom* PetscRandom; 500df4397b0SStefano Zampini 501df4397b0SStefano Zampini /* 502df4397b0SStefano Zampini In binary files variables are stored using the following lengths, 503df4397b0SStefano Zampini regardless of how they are stored in memory on any one particular 504df4397b0SStefano Zampini machine. Use these rather then sizeof() in computing sizes for 505df4397b0SStefano Zampini PetscBinarySeek(). 506df4397b0SStefano Zampini */ 507df4397b0SStefano Zampini #define PETSC_BINARY_INT_SIZE (32/8) 508df4397b0SStefano Zampini #define PETSC_BINARY_FLOAT_SIZE (32/8) 509df4397b0SStefano Zampini #define PETSC_BINARY_CHAR_SIZE (8/8) 510df4397b0SStefano Zampini #define PETSC_BINARY_SHORT_SIZE (16/8) 511df4397b0SStefano Zampini #define PETSC_BINARY_DOUBLE_SIZE (64/8) 512df4397b0SStefano Zampini #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar) 513df4397b0SStefano Zampini 514df4397b0SStefano Zampini /*E 515df4397b0SStefano Zampini PetscBinarySeekType - argument to PetscBinarySeek() 516df4397b0SStefano Zampini 517df4397b0SStefano Zampini Level: advanced 518df4397b0SStefano Zampini 519df4397b0SStefano Zampini .seealso: PetscBinarySeek(), PetscBinarySynchronizedSeek() 520df4397b0SStefano Zampini E*/ 521df4397b0SStefano Zampini typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType; 522df4397b0SStefano Zampini 523df4397b0SStefano Zampini /*E 524df4397b0SStefano Zampini PetscBuildTwoSidedType - algorithm for setting up two-sided communication 525df4397b0SStefano Zampini 526df4397b0SStefano Zampini $ PETSC_BUILDTWOSIDED_ALLREDUCE - classical algorithm using an MPI_Allreduce with 527df4397b0SStefano Zampini $ a buffer of length equal to the communicator size. Not memory-scalable due to 528df4397b0SStefano Zampini $ the large reduction size. Requires only MPI-1. 529df4397b0SStefano Zampini $ PETSC_BUILDTWOSIDED_IBARRIER - nonblocking algorithm based on MPI_Issend and MPI_Ibarrier. 530df4397b0SStefano Zampini $ Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires MPI-3. 531df4397b0SStefano Zampini $ PETSC_BUILDTWOSIDED_REDSCATTER - similar to above, but use more optimized function 532df4397b0SStefano Zampini $ that only communicates the part of the reduction that is necessary. Requires MPI-2. 533df4397b0SStefano Zampini 534df4397b0SStefano Zampini Level: developer 535df4397b0SStefano Zampini 536df4397b0SStefano Zampini .seealso: PetscCommBuildTwoSided(), PetscCommBuildTwoSidedSetType(), PetscCommBuildTwoSidedGetType() 537df4397b0SStefano Zampini E*/ 538df4397b0SStefano Zampini typedef enum { 539df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_NOTSET = -1, 540df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_ALLREDUCE = 0, 541df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_IBARRIER = 1, 542df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_REDSCATTER = 2 543df4397b0SStefano Zampini /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */ 544df4397b0SStefano Zampini } PetscBuildTwoSidedType; 545df4397b0SStefano Zampini 546aa2d33c1SMatthew G. Knepley /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */ 547df4397b0SStefano Zampini /*E 548df4397b0SStefano Zampini InsertMode - Whether entries are inserted or added into vectors or matrices 549df4397b0SStefano Zampini 550df4397b0SStefano Zampini Level: beginner 551df4397b0SStefano Zampini 552df4397b0SStefano Zampini .seealso: VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 553df4397b0SStefano Zampini VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), 554df4397b0SStefano Zampini MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd() 555df4397b0SStefano Zampini E*/ 5560c91829fSJunchao Zhang typedef enum {NOT_SET_VALUES, INSERT_VALUES, ADD_VALUES, MAX_VALUES, MIN_VALUES, INSERT_ALL_VALUES, ADD_ALL_VALUES, INSERT_BC_VALUES, ADD_BC_VALUES} InsertMode; 557df4397b0SStefano Zampini 558df4397b0SStefano Zampini /*MC 559df4397b0SStefano Zampini INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value 560df4397b0SStefano Zampini 561df4397b0SStefano Zampini Level: beginner 562df4397b0SStefano Zampini 563df4397b0SStefano Zampini .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 564df4397b0SStefano Zampini VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES, 565df4397b0SStefano Zampini MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd(), MAX_VALUES 566df4397b0SStefano Zampini 567df4397b0SStefano Zampini M*/ 568df4397b0SStefano Zampini 569df4397b0SStefano Zampini /*MC 570df4397b0SStefano Zampini ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the 571df4397b0SStefano Zampini value into that location 572df4397b0SStefano Zampini 573df4397b0SStefano Zampini Level: beginner 574df4397b0SStefano Zampini 575df4397b0SStefano Zampini .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 576df4397b0SStefano Zampini VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), INSERT_VALUES, 577df4397b0SStefano Zampini MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd(), MAX_VALUES 578df4397b0SStefano Zampini 579df4397b0SStefano Zampini M*/ 580df4397b0SStefano Zampini 581df4397b0SStefano Zampini /*MC 582df4397b0SStefano Zampini MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location 583df4397b0SStefano Zampini 584df4397b0SStefano Zampini Level: beginner 585df4397b0SStefano Zampini 586df4397b0SStefano Zampini .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES 587df4397b0SStefano Zampini 588df4397b0SStefano Zampini M*/ 589df4397b0SStefano Zampini 590421aa1e7SJunchao Zhang /*MC 591421aa1e7SJunchao Zhang MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location 592421aa1e7SJunchao Zhang 593421aa1e7SJunchao Zhang Level: beginner 594421aa1e7SJunchao Zhang 595421aa1e7SJunchao Zhang .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES 596421aa1e7SJunchao Zhang 597421aa1e7SJunchao Zhang M*/ 598421aa1e7SJunchao Zhang 599421aa1e7SJunchao Zhang 600df4397b0SStefano Zampini /*S 601df4397b0SStefano Zampini PetscSubcomm - A decomposition of an MPI communicator into subcommunicators 602df4397b0SStefano Zampini 603df4397b0SStefano Zampini Notes: 604df4397b0SStefano Zampini After a call to PetscSubcommSetType(), PetscSubcommSetTypeGeneral(), or PetscSubcommSetFromOptions() one may call 605df4397b0SStefano Zampini $ PetscSubcommChild() returns the associated subcommunicator on this process 606df4397b0SStefano Zampini $ PetscSubcommContiguousParent() returns a parent communitor but with all child of the same subcommunicator having contiguous rank 607df4397b0SStefano Zampini 608df4397b0SStefano Zampini Sample Usage: 609df4397b0SStefano Zampini PetscSubcommCreate() 610df4397b0SStefano Zampini PetscSubcommSetNumber() 611df4397b0SStefano Zampini PetscSubcommSetType(PETSC_SUBCOMM_INTERLACED); 612df4397b0SStefano Zampini ccomm = PetscSubcommChild() 613df4397b0SStefano Zampini PetscSubcommDestroy() 614df4397b0SStefano Zampini 615df4397b0SStefano Zampini Level: advanced 616df4397b0SStefano Zampini 617df4397b0SStefano Zampini Notes: 618df4397b0SStefano Zampini $ PETSC_SUBCOMM_GENERAL - similar to MPI_Comm_split() each process sets the new communicator (color) they will belong to and the order within that communicator 619df4397b0SStefano Zampini $ PETSC_SUBCOMM_CONTIGUOUS - each new communicator contains a set of process with contiguous ranks in the original MPI communicator 620df4397b0SStefano Zampini $ PETSC_SUBCOMM_INTERLACED - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator 621df4397b0SStefano Zampini 622df4397b0SStefano Zampini Example: Consider a communicator with six processes split into 3 subcommunicators. 623df4397b0SStefano Zampini $ PETSC_SUBCOMM_CONTIGUOUS - the first communicator contains rank 0,1 the second rank 2,3 and the third rank 4,5 in the original ordering of the original communicator 624df4397b0SStefano Zampini $ PETSC_SUBCOMM_INTERLACED - the first communicator contains rank 0,3, the second 1,4 and the third 2,5 625df4397b0SStefano Zampini 626df4397b0SStefano Zampini Developer Notes: 627df4397b0SStefano Zampini This is used in objects such as PCREDUNDANT to manage the subcommunicators on which the redundant computations 628df4397b0SStefano Zampini are performed. 629df4397b0SStefano Zampini 630df4397b0SStefano Zampini 631df4397b0SStefano Zampini .seealso: PetscSubcommCreate(), PetscSubcommSetNumber(), PetscSubcommSetType(), PetscSubcommView(), PetscSubcommSetFromOptions() 632df4397b0SStefano Zampini 633df4397b0SStefano Zampini S*/ 634df4397b0SStefano Zampini typedef struct _n_PetscSubcomm* PetscSubcomm; 635df4397b0SStefano Zampini typedef enum {PETSC_SUBCOMM_GENERAL=0,PETSC_SUBCOMM_CONTIGUOUS=1,PETSC_SUBCOMM_INTERLACED=2} PetscSubcommType; 636df4397b0SStefano Zampini 637df4397b0SStefano Zampini /*S 638df4397b0SStefano Zampini PetscHeap - A simple class for managing heaps 639df4397b0SStefano Zampini 640df4397b0SStefano Zampini Level: intermediate 641df4397b0SStefano Zampini 642df4397b0SStefano Zampini .seealso: PetscHeapCreate(), PetscHeapAdd(), PetscHeapPop(), PetscHeapPeek(), PetscHeapStash(), PetscHeapUnstash(), PetscHeapView(), PetscHeapDestroy() 643df4397b0SStefano Zampini S*/ 644df4397b0SStefano Zampini typedef struct _PetscHeap *PetscHeap; 645df4397b0SStefano Zampini 646df4397b0SStefano Zampini typedef struct _n_PetscShmComm* PetscShmComm; 647df4397b0SStefano Zampini typedef struct _n_PetscOmpCtrl* PetscOmpCtrl; 648df4397b0SStefano Zampini 649df4397b0SStefano Zampini /*S 650df4397b0SStefano Zampini PetscSegBuffer - a segmented extendable buffer 651df4397b0SStefano Zampini 652df4397b0SStefano Zampini Level: developer 653df4397b0SStefano Zampini 654df4397b0SStefano Zampini .seealso: PetscSegBufferCreate(), PetscSegBufferGet(), PetscSegBufferExtract(), PetscSegBufferDestroy() 655df4397b0SStefano Zampini S*/ 656df4397b0SStefano Zampini typedef struct _n_PetscSegBuffer *PetscSegBuffer; 657df4397b0SStefano Zampini 658df4397b0SStefano Zampini typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted; 659df4397b0SStefano Zampini 660d0295fc0SJunchao Zhang /*E 661d0295fc0SJunchao Zhang PetscMemType - Memory type of a pointer 662d0295fc0SJunchao Zhang 663d0295fc0SJunchao Zhang Level: beginner 664d0295fc0SJunchao Zhang 665a247e58cSJunchao Zhang Developer Note: 66671438e86SJunchao Zhang Encoding of the bitmask in binary: xxxxyyyz 66771438e86SJunchao Zhang z = 0: Host memory 66871438e86SJunchao Zhang z = 1: Device memory 66971438e86SJunchao Zhang yyy = 000: CUDA-related memory 67071438e86SJunchao Zhang yyy = 001: HIP-related memory 67171438e86SJunchao Zhang xxxxyyy1 = 0000,0001: CUDA memory 67271438e86SJunchao Zhang xxxxyyy1 = 0001,0001: CUDA NVSHMEM memory 67371438e86SJunchao Zhang xxxxyyy1 = 0000,0011: HIP memory 67471438e86SJunchao Zhang 67571438e86SJunchao Zhang Other types of memory, e.g., CUDA managed memory, can be added when needed. 676a247e58cSJunchao Zhang 677ad227feaSJunchao Zhang .seealso: VecGetArrayAndMemType(), PetscSFBcastWithMemTypeBegin(), PetscSFReduceWithMemTypeBegin() 678d0295fc0SJunchao Zhang E*/ 67971438e86SJunchao Zhang typedef enum {PETSC_MEMTYPE_HOST=0, PETSC_MEMTYPE_DEVICE=0x01, PETSC_MEMTYPE_CUDA=0x01, PETSC_MEMTYPE_NVSHMEM=0x11,PETSC_MEMTYPE_HIP=0x03} PetscMemType; 680a247e58cSJunchao Zhang 681a247e58cSJunchao Zhang #define PetscMemTypeHost(m) (((m) & 0x1) == PETSC_MEMTYPE_HOST) 682a247e58cSJunchao Zhang #define PetscMemTypeDevice(m) (((m) & 0x1) == PETSC_MEMTYPE_DEVICE) 68371438e86SJunchao Zhang #define PetscMemTypeCUDA(m) (((m) & 0xF) == PETSC_MEMTYPE_CUDA) 68471438e86SJunchao Zhang #define PetscMemTypeHIP(m) (((m) & 0xF) == PETSC_MEMTYPE_HIP) 68571438e86SJunchao Zhang #define PetscMemTypeNVSHMEM(m) ((m) == PETSC_MEMTYPE_NVSHMEM) 686a247e58cSJunchao Zhang 687df4397b0SStefano Zampini #endif 688