147d993e7Ssuyashtn /* Portions of this code are under: 247d993e7Ssuyashtn Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 347d993e7Ssuyashtn */ 447d993e7Ssuyashtn 56524c165SJacob Faibussowitsch #ifndef PETSCSYSTYPES_H 626bd1501SBarry Smith #define PETSCSYSTYPES_H 7df4397b0SStefano Zampini 8df4397b0SStefano Zampini #include <petscconf.h> 9e1bf4ed2SJacob Faibussowitsch #include <petscconf_poison.h> 10df4397b0SStefano Zampini #include <petscfix.h> 11bf491261SJacob Faibussowitsch #include <petscmacros.h> 123edda6a2SJed Brown #include <stddef.h> 13df4397b0SStefano Zampini 14ac09b921SBarry Smith /* SUBMANSEC = Sys */ 15ac09b921SBarry Smith 16df4397b0SStefano Zampini /*MC 17df4397b0SStefano Zampini PetscErrorCode - datatype used for return error code from almost all PETSc functions 18df4397b0SStefano Zampini 19df4397b0SStefano Zampini Level: beginner 20df4397b0SStefano Zampini 21db781477SPatrick Sanan .seealso: `PetscCall()`, `SETERRQ()` 22df4397b0SStefano Zampini M*/ 23df4397b0SStefano Zampini typedef int PetscErrorCode; 24df4397b0SStefano Zampini 25df4397b0SStefano Zampini /*MC 26df4397b0SStefano Zampini 27df4397b0SStefano Zampini PetscClassId - A unique id used to identify each PETSc class. 28df4397b0SStefano Zampini 29df4397b0SStefano Zampini Notes: 3087497f52SBarry Smith Use `PetscClassIdRegister()` to obtain a new value for a new class being created. Usually 31df4397b0SStefano Zampini XXXInitializePackage() calls it for each class it defines. 32df4397b0SStefano Zampini 33df4397b0SStefano Zampini Developer Notes: 3487497f52SBarry Smith Internal integer stored in the `_p_PetscObject` data structure. 3587497f52SBarry Smith These are all computed by an offset from the lowest one, `PETSC_SMALLEST_CLASSID`. 36df4397b0SStefano Zampini 37df4397b0SStefano Zampini Level: developer 38df4397b0SStefano Zampini 39db781477SPatrick Sanan .seealso: `PetscClassIdRegister()`, `PetscLogEventRegister()`, `PetscHeaderCreate()` 40df4397b0SStefano Zampini M*/ 41df4397b0SStefano Zampini typedef int PetscClassId; 42df4397b0SStefano Zampini 43df4397b0SStefano Zampini /*MC 44df4397b0SStefano Zampini PetscMPIInt - datatype used to represent 'int' parameters to MPI functions. 45df4397b0SStefano Zampini 46df4397b0SStefano Zampini Level: intermediate 47df4397b0SStefano Zampini 48df4397b0SStefano Zampini Notes: 4987497f52SBarry Smith This is always a 32 bit integer, sometimes it is the same as `PetscInt`, but if PETSc was built with --with-64-bit-indices but 5087497f52SBarry Smith standard C/Fortran integers are 32 bit then this is NOT the same as `PetscInt`; it remains 32 bit. 51df4397b0SStefano Zampini 5287497f52SBarry Smith `PetscMPIIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscMPIInt`, if not it 5387497f52SBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error. 54df4397b0SStefano Zampini 55db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscInt`, `PetscMPIIntCast()` 56df4397b0SStefano Zampini 57df4397b0SStefano Zampini M*/ 58df4397b0SStefano Zampini typedef int PetscMPIInt; 59df4397b0SStefano Zampini 60bf491261SJacob Faibussowitsch #include <limits.h> 61bf491261SJacob Faibussowitsch 62bf491261SJacob Faibussowitsch /* Limit MPI to 32-bits */ 63bf491261SJacob Faibussowitsch enum { 64bf491261SJacob Faibussowitsch PETSC_MPI_INT_MIN = INT_MIN, 65bf491261SJacob Faibussowitsch PETSC_MPI_INT_MAX = INT_MAX 66bf491261SJacob Faibussowitsch }; 67bf491261SJacob Faibussowitsch 68df4397b0SStefano Zampini /*MC 693edda6a2SJed Brown PetscSizeT - datatype used to represent sizes in memory (like size_t) 703edda6a2SJed Brown 713edda6a2SJed Brown Level: intermediate 723edda6a2SJed Brown 733edda6a2SJed Brown Notes: 743edda6a2SJed Brown This is equivalent to size_t, but defined for consistency with Fortran, which lacks a native equivalent of size_t. 753edda6a2SJed Brown 76db781477SPatrick Sanan .seealso: `PetscInt`, `PetscInt64`, `PetscCount` 773edda6a2SJed Brown 783edda6a2SJed Brown M*/ 793edda6a2SJed Brown typedef size_t PetscSizeT; 803edda6a2SJed Brown 813edda6a2SJed Brown /*MC 8282a78a4eSJed Brown PetscCount - signed datatype used to represent counts 8382a78a4eSJed Brown 8482a78a4eSJed Brown Level: intermediate 8582a78a4eSJed Brown 8682a78a4eSJed Brown Notes: 8782a78a4eSJed Brown This is equivalent to ptrdiff_t, but defined for consistency with Fortran, which lacks a native equivalent of ptrdiff_t. 8882a78a4eSJed Brown 8987497f52SBarry Smith Use `PetscCount_FMT` to format with `PetscPrintf()`, `printf()`, and related functions. 9082a78a4eSJed Brown 91db781477SPatrick Sanan .seealso: `PetscInt`, `PetscInt64`, `PetscSizeT` 9282a78a4eSJed Brown 9382a78a4eSJed Brown M*/ 9482a78a4eSJed Brown typedef ptrdiff_t PetscCount; 9563a3b9bcSJacob Faibussowitsch #define PetscCount_FMT "td" 9682a78a4eSJed Brown 9782a78a4eSJed Brown /*MC 98df4397b0SStefano Zampini PetscEnum - datatype used to pass enum types within PETSc functions. 99df4397b0SStefano Zampini 100df4397b0SStefano Zampini Level: intermediate 101df4397b0SStefano Zampini 102db781477SPatrick Sanan .seealso: `PetscOptionsGetEnum()`, `PetscOptionsEnum()`, `PetscBagRegisterEnum()` 103df4397b0SStefano Zampini M*/ 1049371c9d4SSatish Balay typedef enum { 1059371c9d4SSatish Balay ENUM_DUMMY 1069371c9d4SSatish Balay } PetscEnum; 107df4397b0SStefano Zampini 108df4397b0SStefano Zampini typedef short PetscShort; 109df4397b0SStefano Zampini typedef char PetscChar; 110df4397b0SStefano Zampini typedef float PetscFloat; 111df4397b0SStefano Zampini 112df4397b0SStefano Zampini /*MC 113df4397b0SStefano Zampini PetscInt - PETSc type that represents an integer, used primarily to 114df4397b0SStefano 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. 115df4397b0SStefano Zampini 116df4397b0SStefano Zampini Notes: 11787497f52SBarry Smith 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. 118df4397b0SStefano Zampini 119df4397b0SStefano Zampini Level: beginner 120df4397b0SStefano Zampini 121db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT` 122df4397b0SStefano Zampini M*/ 123df4397b0SStefano Zampini 124df4397b0SStefano Zampini #if defined(PETSC_HAVE_STDINT_H) 125df4397b0SStefano Zampini #include <stdint.h> 126df4397b0SStefano Zampini #endif 127df4397b0SStefano Zampini #if defined(PETSC_HAVE_INTTYPES_H) 128df4397b0SStefano Zampini #if !defined(__STDC_FORMAT_MACROS) 129df4397b0SStefano Zampini #define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */ 130df4397b0SStefano Zampini #endif 131df4397b0SStefano Zampini #include <inttypes.h> 132df4397b0SStefano Zampini #if !defined(PRId64) 133df4397b0SStefano Zampini #define PRId64 "ld" 134df4397b0SStefano Zampini #endif 135df4397b0SStefano Zampini #endif 136df4397b0SStefano Zampini 137df4397b0SStefano 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 */ 138df4397b0SStefano Zampini typedef int64_t PetscInt64; 139bf491261SJacob Faibussowitsch 140bf491261SJacob Faibussowitsch #define PETSC_INT64_MIN INT64_MIN 141bf491261SJacob Faibussowitsch #define PETSC_INT64_MAX INT64_MAX 142bf491261SJacob Faibussowitsch 143df4397b0SStefano Zampini #elif (PETSC_SIZEOF_LONG_LONG == 8) 144df4397b0SStefano Zampini typedef long long PetscInt64; 145bf491261SJacob Faibussowitsch 146bf491261SJacob Faibussowitsch #define PETSC_INT64_MIN LLONG_MIN 147bf491261SJacob Faibussowitsch #define PETSC_INT64_MAX LLONG_MAX 148bf491261SJacob Faibussowitsch 149df4397b0SStefano Zampini #elif defined(PETSC_HAVE___INT64) 150df4397b0SStefano Zampini typedef __int64 PetscInt64; 151bf491261SJacob Faibussowitsch 152bf491261SJacob Faibussowitsch #define PETSC_INT64_MIN INT64_MIN 153bf491261SJacob Faibussowitsch #define PETSC_INT64_MAX INT64_MAX 154bf491261SJacob Faibussowitsch 155df4397b0SStefano Zampini #else 156df4397b0SStefano Zampini #error "cannot determine PetscInt64 type" 157df4397b0SStefano Zampini #endif 158df4397b0SStefano Zampini 159df4397b0SStefano Zampini #if defined(PETSC_USE_64BIT_INDICES) 160df4397b0SStefano Zampini typedef PetscInt64 PetscInt; 161bf491261SJacob Faibussowitsch 162bf491261SJacob Faibussowitsch #define PETSC_INT_MIN PETSC_INT64_MIN 163bf491261SJacob Faibussowitsch #define PETSC_INT_MAX PETSC_INT64_MAX 164bf491261SJacob Faibussowitsch #define PetscInt_FMT PetscInt64_FMT 165df4397b0SStefano Zampini #else 166df4397b0SStefano Zampini typedef int PetscInt; 167bf491261SJacob Faibussowitsch 168bf491261SJacob Faibussowitsch enum { 169bf491261SJacob Faibussowitsch PETSC_INT_MIN = INT_MIN, 170bf491261SJacob Faibussowitsch PETSC_INT_MAX = INT_MAX 171bf491261SJacob Faibussowitsch }; 172bf491261SJacob Faibussowitsch 173bf491261SJacob Faibussowitsch #define PetscInt_FMT "d" 174df4397b0SStefano Zampini #endif 175df4397b0SStefano Zampini 176bf491261SJacob Faibussowitsch #define PETSC_MIN_INT PETSC_INT_MIN 177bf491261SJacob Faibussowitsch #define PETSC_MAX_INT PETSC_INT_MAX 178bf491261SJacob Faibussowitsch #define PETSC_MAX_UINT16 65535 179bf491261SJacob Faibussowitsch 180c93fae50SJacob Faibussowitsch #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 */ 181c93fae50SJacob Faibussowitsch #define MPIU_INT64 MPI_INT64_T 182c93fae50SJacob Faibussowitsch #define PetscInt64_FMT PRId64 183c93fae50SJacob Faibussowitsch #elif (PETSC_SIZEOF_LONG_LONG == 8) 184c93fae50SJacob Faibussowitsch #define MPIU_INT64 MPI_LONG_LONG_INT 185c93fae50SJacob Faibussowitsch #define PetscInt64_FMT "lld" 186c93fae50SJacob Faibussowitsch #elif defined(PETSC_HAVE___INT64) 187c93fae50SJacob Faibussowitsch #define MPIU_INT64 MPI_INT64_T 188c93fae50SJacob Faibussowitsch #define PetscInt64_FMT "ld" 189c93fae50SJacob Faibussowitsch #else 190c93fae50SJacob Faibussowitsch #error "cannot determine PetscInt64 type" 191c93fae50SJacob Faibussowitsch #endif 192c93fae50SJacob Faibussowitsch 193df4397b0SStefano Zampini /*MC 194df4397b0SStefano Zampini PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions. 195df4397b0SStefano Zampini 196df4397b0SStefano Zampini Notes: 19787497f52SBarry Smith Usually this is the same as `PetscIn`t, but if PETSc was built with --with-64-bit-indices but 19887497f52SBarry Smith standard C/Fortran integers are 32 bit then this may not be the same as `PetscInt`, 19987497f52SBarry Smith except on some BLAS/LAPACK implementations that support 64 bit integers see the notes below. 200df4397b0SStefano Zampini 20187497f52SBarry Smith `PetscErrorCode` `PetscBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscBLASInt`, if not it 20287497f52SBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error 203df4397b0SStefano Zampini 204df4397b0SStefano Zampini Installation Notes: 205cdc6ee08SBarry Smith ./configure automatically determines the size of the integers used by BLAS/LAPACK except when --with-batch is used 206cdc6ee08SBarry 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 207cdc6ee08SBarry Smith 208cdc6ee08SBarry Smith MATLAB ships with BLAS and LAPACK that use 64 bit integers, for example if you run ./configure with, the option 209df4397b0SStefano Zampini --with-blaslapack-lib=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib] 210df4397b0SStefano Zampini 211cdc6ee08SBarry 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 212cdc6ee08SBarry Smith against the 64 bit version, otherwise it use the 32 bit version 213df4397b0SStefano Zampini 214cdc6ee08SBarry 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 215df4397b0SStefano Zampini 216df4397b0SStefano Zampini External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64 bit integers to BLAS/LAPACK so cannot 217cdc6ee08SBarry 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 218cdc6ee08SBarry Smith these external libraries while using 64 bit integer BLAS/LAPACK. 219df4397b0SStefano Zampini 220df4397b0SStefano Zampini Level: intermediate 221df4397b0SStefano Zampini 222db781477SPatrick Sanan .seealso: `PetscMPIInt`, `PetscInt`, `PetscBLASIntCast()` 223df4397b0SStefano Zampini 224df4397b0SStefano Zampini M*/ 225df4397b0SStefano Zampini #if defined(PETSC_HAVE_64BIT_BLAS_INDICES) 226df4397b0SStefano Zampini typedef PetscInt64 PetscBLASInt; 227bf491261SJacob Faibussowitsch 228bf491261SJacob Faibussowitsch #define PETSC_BLAS_INT_MIN PETSC_INT64_MIN 229bf491261SJacob Faibussowitsch #define PETSC_BLAS_INT_MAX PETSC_INT64_MAX 230bf491261SJacob Faibussowitsch #define PetscBLASInt_FMT PetscInt64_FMT 231df4397b0SStefano Zampini #else 232df4397b0SStefano Zampini typedef int PetscBLASInt; 233bf491261SJacob Faibussowitsch 234bf491261SJacob Faibussowitsch enum { 235bf491261SJacob Faibussowitsch PETSC_BLAS_INT_MIN = INT_MIN, 236bf491261SJacob Faibussowitsch PETSC_BLAS_INT_MAX = INT_MAX 237bf491261SJacob Faibussowitsch }; 238bf491261SJacob Faibussowitsch 239bf491261SJacob Faibussowitsch #define PetscBLASInt_FMT "d" 240df4397b0SStefano Zampini #endif 241df4397b0SStefano Zampini 242eee0c0a6SToby Isaac /*MC 243eee0c0a6SToby Isaac PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions. 244eee0c0a6SToby Isaac 245eee0c0a6SToby Isaac Notes: 246eee0c0a6SToby Isaac As of this writing PetscCuBLASInt is always the system `int`. 247eee0c0a6SToby Isaac 24887497f52SBarry Smith `PetscErrorCode` `PetscCuBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscCuBLASInt`, if not it 24987497f52SBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error 250eee0c0a6SToby Isaac 251eee0c0a6SToby Isaac Level: intermediate 252eee0c0a6SToby Isaac 253db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscCuBLASIntCast()` 254eee0c0a6SToby Isaac 255eee0c0a6SToby Isaac M*/ 256eee0c0a6SToby Isaac typedef int PetscCuBLASInt; 257eee0c0a6SToby Isaac 258bf491261SJacob Faibussowitsch enum { 259bf491261SJacob Faibussowitsch PETSC_CUBLAS_INT_MIN = INT_MIN, 260bf491261SJacob Faibussowitsch PETSC_CUBLAS_INT_MAX = INT_MAX 261bf491261SJacob Faibussowitsch }; 262bf491261SJacob Faibussowitsch 26347d993e7Ssuyashtn /*MC 26447d993e7Ssuyashtn PetscHipBLASInt - datatype used to represent 'int' parameters to hipBLAS/hipSOLVER functions. 26547d993e7Ssuyashtn 26647d993e7Ssuyashtn Notes: 26747d993e7Ssuyashtn As of this writing PetscHipBLASInt is always the system `int`. 26847d993e7Ssuyashtn 26947d993e7Ssuyashtn PetscErrorCode PetscHipBLASIntCast(a,&b) checks if the given PetscInt a will fit in a PetscHipBLASInt, if not it 27047d993e7Ssuyashtn generates a PETSC_ERR_ARG_OUTOFRANGE error 27147d993e7Ssuyashtn 27247d993e7Ssuyashtn Level: intermediate 27347d993e7Ssuyashtn 27447d993e7Ssuyashtn .seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscHipBLASIntCast() 27547d993e7Ssuyashtn 27647d993e7Ssuyashtn M*/ 27747d993e7Ssuyashtn typedef int PetscHipBLASInt; 27847d993e7Ssuyashtn 279bf491261SJacob Faibussowitsch enum { 280bf491261SJacob Faibussowitsch PETSC_HIPBLAS_INT_MIN = INT_MIN, 281bf491261SJacob Faibussowitsch PETSC_HIPBLAS_INT_MAX = INT_MAX 282bf491261SJacob Faibussowitsch }; 283bf491261SJacob Faibussowitsch 284df4397b0SStefano Zampini /*E 285b94d7dedSBarry Smith PetscBool - Logical variable. Actually an enum in C and a logical in Fortran. 286df4397b0SStefano Zampini 287df4397b0SStefano Zampini Level: beginner 288df4397b0SStefano Zampini 289df4397b0SStefano Zampini Developer Note: 29087497f52SBarry Smith 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 291df4397b0SStefano Zampini boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms. 292df4397b0SStefano Zampini 293b94d7dedSBarry Smith .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PetscBool3` 294df4397b0SStefano Zampini E*/ 2959371c9d4SSatish Balay typedef enum { 2969371c9d4SSatish Balay PETSC_FALSE, 2979371c9d4SSatish Balay PETSC_TRUE 2989371c9d4SSatish Balay } PetscBool; 299*3b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscBools[]; 300df4397b0SStefano Zampini 301b94d7dedSBarry Smith /*E 302b94d7dedSBarry Smith PetscBool3 - Ternary logical variable. Actually an enum in C and a 4 byte integer in Fortran. 303b94d7dedSBarry Smith 304b94d7dedSBarry Smith Level: beginner 305b94d7dedSBarry Smith 30687497f52SBarry Smith Note: 307b94d7dedSBarry Smith Should not be used with the if (flg) or if (!flg) syntax. 308b94d7dedSBarry Smith 30990dd7910SPierre Jolivet .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PETSC_BOOL3_TRUE`, `PETSC_BOOL3_FALSE`, `PETSC_BOOL3_UNKNOWN` 310b94d7dedSBarry Smith E*/ 3119371c9d4SSatish Balay typedef enum { 3129371c9d4SSatish Balay PETSC_BOOL3_FALSE, 3139371c9d4SSatish Balay PETSC_BOOL3_TRUE, 3149371c9d4SSatish Balay PETSC_BOOL3_UNKNOWN = -1 3159371c9d4SSatish Balay } PetscBool3; 316b94d7dedSBarry Smith 317b94d7dedSBarry Smith #define PetscBool3ToBool(a) ((a) == PETSC_BOOL3_TRUE ? PETSC_TRUE : PETSC_FALSE) 318b94d7dedSBarry Smith #define PetscBoolToBool3(a) ((a) == PETSC_TRUE ? PETSC_BOOL3_TRUE : PETSC_BOOL3_FALSE) 319b94d7dedSBarry Smith 320df4397b0SStefano Zampini /*MC 32187497f52SBarry Smith PetscReal - PETSc type that represents a real number version of `PetscScalar` 322df4397b0SStefano Zampini 323df4397b0SStefano Zampini Notes: 32487497f52SBarry Smith For MPI calls that require datatypes, use `MPIU_REAL` as the datatype for `PetscReal` and `MPIU_SUM`, `MPIU_MAX`, etc. for operations. 32587497f52SBarry Smith They will automatically work correctly regardless of the size of `PetscReal`. 326df4397b0SStefano Zampini 32787497f52SBarry Smith See `PetscScalar` for details on how to ./configure the size of `PetscReal`. 328df4397b0SStefano Zampini 329df4397b0SStefano Zampini Level: beginner 330df4397b0SStefano Zampini 331db781477SPatrick Sanan .seealso: `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT` 332df4397b0SStefano Zampini M*/ 333df4397b0SStefano Zampini 334df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 335df4397b0SStefano Zampini typedef float PetscReal; 336df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 337df4397b0SStefano Zampini typedef double PetscReal; 338df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 339df4397b0SStefano Zampini #if defined(__cplusplus) 340df4397b0SStefano Zampini extern "C" { 341df4397b0SStefano Zampini #endif 342df4397b0SStefano Zampini #include <quadmath.h> 343df4397b0SStefano Zampini #if defined(__cplusplus) 344df4397b0SStefano Zampini } 345df4397b0SStefano Zampini #endif 346df4397b0SStefano Zampini typedef __float128 PetscReal; 347df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 348df4397b0SStefano Zampini typedef __fp16 PetscReal; 349df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 350df4397b0SStefano Zampini 351df4397b0SStefano Zampini /*MC 35287497f52SBarry Smith PetscComplex - PETSc type that represents a complex number with precision matching that of `PetscReal`. 353df4397b0SStefano Zampini 354df4397b0SStefano Zampini Synopsis: 355df4397b0SStefano Zampini #include <petscsys.h> 356df4397b0SStefano Zampini PetscComplex number = 1. + 2.*PETSC_i; 357df4397b0SStefano Zampini 358df4397b0SStefano Zampini Notes: 35987497f52SBarry Smith For MPI calls that require datatypes, use `MPIU_COMPLEX` as the datatype for `PetscComplex` and `MPIU_SUM` etc for operations. 36087497f52SBarry Smith They will automatically work correctly regardless of the size of `PetscComplex`. 361df4397b0SStefano Zampini 36287497f52SBarry Smith See PetscScalar for details on how to ./configure the size of `PetscReal` 363df4397b0SStefano Zampini 364df4397b0SStefano Zampini Complex numbers are automatically available if PETSc was able to find a working complex implementation 365df4397b0SStefano Zampini 36687497f52SBarry Smith Petsc has a 'fix' for complex numbers to support expressions such as std::complex<PetscReal> + `PetscInt`, which are not supported by the standard 367a966371cSJunchao Zhang C++ library, but are convenient for petsc users. If the C++ compiler is able to compile code in petsccxxcomplexfix.h (This is checked by 368a966371cSJunchao Zhang configure), we include petsccxxcomplexfix.h to provide this convenience. 369a966371cSJunchao Zhang 37087497f52SBarry Smith If the fix causes conflicts, or one really does not want this fix for a particular C++ file, one can define `PETSC_SKIP_CXX_COMPLEX_FIX` 371a966371cSJunchao Zhang at the beginning of the C++ file to skip the fix. 372a966371cSJunchao Zhang 373df4397b0SStefano Zampini Level: beginner 374df4397b0SStefano Zampini 375db781477SPatrick Sanan .seealso: `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i` 376df4397b0SStefano Zampini M*/ 377df4397b0SStefano Zampini #if !defined(PETSC_SKIP_COMPLEX) 3787a19d461SSatish Balay #if defined(PETSC_CLANGUAGE_CXX) 3797a19d461SSatish Balay #if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128) 3807a19d461SSatish Balay #if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */ 381df4397b0SStefano Zampini #define PETSC_HAVE_COMPLEX 1 382d5b43468SJose E. Roman #elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */ 3837a19d461SSatish Balay #define PETSC_HAVE_COMPLEX 1 3847a19d461SSatish Balay #endif 385450fc7c9SSatish Balay #elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX) 386450fc7c9SSatish Balay #define PETSC_HAVE_COMPLEX 1 3877a19d461SSatish Balay #endif 3887a19d461SSatish Balay #else /* !PETSC_CLANGUAGE_CXX */ 3897a19d461SSatish Balay #if !defined(PETSC_USE_REAL___FP16) 3907a19d461SSatish Balay #if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */ 3917a19d461SSatish Balay #define PETSC_HAVE_COMPLEX 1 392d5b43468SJose E. Roman #elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */ 3937a19d461SSatish Balay #define PETSC_HAVE_COMPLEX 1 3947a19d461SSatish Balay #endif 3957a19d461SSatish Balay #endif 3967a19d461SSatish Balay #endif /* PETSC_CLANGUAGE_CXX */ 3977a19d461SSatish Balay #endif /* !PETSC_SKIP_COMPLEX */ 3987a19d461SSatish Balay 3997a19d461SSatish Balay #if defined(PETSC_HAVE_COMPLEX) 4007a19d461SSatish Balay #if defined(__cplusplus) /* C++ complex support */ 40111d22bbfSJunchao Zhang /* Locate a C++ complex template library */ 40211d22bbfSJunchao Zhang #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */ 40311d22bbfSJunchao Zhang #define petsccomplexlib Kokkos 40411d22bbfSJunchao Zhang #include <Kokkos_Complex.hpp> 405022afdc5SJed Brown #elif defined(__CUDACC__) || defined(__HIPCC__) 406df4397b0SStefano Zampini #define petsccomplexlib thrust 407df4397b0SStefano Zampini #include <thrust/complex.h> 408450fc7c9SSatish Balay #elif defined(PETSC_USE_REAL___FLOAT128) 409450fc7c9SSatish Balay #include <complex.h> 410df4397b0SStefano Zampini #else 411df4397b0SStefano Zampini #define petsccomplexlib std 412df4397b0SStefano Zampini #include <complex> 413df4397b0SStefano Zampini #endif 41411d22bbfSJunchao Zhang 41511d22bbfSJunchao Zhang /* Define PetscComplex based on the precision */ 416df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 417df4397b0SStefano Zampini typedef petsccomplexlib::complex<float> PetscComplex; 418df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 419df4397b0SStefano Zampini typedef petsccomplexlib::complex<double> PetscComplex; 420df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 421450fc7c9SSatish Balay typedef __complex128 PetscComplex; 42211d22bbfSJunchao Zhang #endif 42311d22bbfSJunchao Zhang 424a966371cSJunchao Zhang /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */ 425a966371cSJunchao Zhang #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX) 42639829747SLisandro Dalcin #include <petsccxxcomplexfix.h> 42711d22bbfSJunchao Zhang #endif 4287a19d461SSatish Balay #else /* c99 complex support */ 429df4397b0SStefano Zampini #include <complex.h> 430df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16) 431df4397b0SStefano Zampini typedef float _Complex PetscComplex; 432df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 433df4397b0SStefano Zampini typedef double _Complex PetscComplex; 434df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 435df4397b0SStefano Zampini typedef __complex128 PetscComplex; 436df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 4377a19d461SSatish Balay #endif /* !__cplusplus */ 4387a19d461SSatish Balay #endif /* PETSC_HAVE_COMPLEX */ 439df4397b0SStefano Zampini 440df4397b0SStefano Zampini /*MC 441df4397b0SStefano Zampini PetscScalar - PETSc type that represents either a double precision real number, a double precision 442df4397b0SStefano Zampini complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured 443df4397b0SStefano Zampini with --with-scalar-type=real,complex --with-precision=single,double,__float128,__fp16 444df4397b0SStefano Zampini 445df4397b0SStefano Zampini Notes: 44687497f52SBarry Smith For MPI calls that require datatypes, use `MPIU_SCALAR` as the datatype for `PetscScalar` and `MPIU_SUM`, etc for operations. They will automatically work correctly regardless of the size of `PetscScalar`. 447df4397b0SStefano Zampini 448df4397b0SStefano Zampini Level: beginner 449df4397b0SStefano Zampini 450db781477SPatrick Sanan .seealso: `PetscReal`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscRealPart()`, `PetscImaginaryPart()` 451df4397b0SStefano Zampini M*/ 452df4397b0SStefano Zampini 4537a19d461SSatish Balay #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX) 454df4397b0SStefano Zampini typedef PetscComplex PetscScalar; 455df4397b0SStefano Zampini #else /* PETSC_USE_COMPLEX */ 456df4397b0SStefano Zampini typedef PetscReal PetscScalar; 457df4397b0SStefano Zampini #endif /* PETSC_USE_COMPLEX */ 458df4397b0SStefano Zampini 459df4397b0SStefano Zampini /*E 46087497f52SBarry Smith PetscCopyMode - Determines how an array or `PetscObject` passed to certain functions is copied or retained by the aggregate `PetscObject` 461df4397b0SStefano Zampini 462df4397b0SStefano Zampini Level: beginner 463df4397b0SStefano Zampini 4645d80c0bfSVaclav Hapla For the array input: 46587497f52SBarry Smith $ `PETSC_COPY_VALUES` - the array values are copied into new space, the user is free to reuse or delete the passed in array 46687497f52SBarry Smith $ `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 467df4397b0SStefano Zampini $ delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran. 46887497f52SBarry Smith $ `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 4695d80c0bfSVaclav Hapla $ the array but the user must delete the array after the object is destroyed. 4705d80c0bfSVaclav Hapla 4715d80c0bfSVaclav Hapla For the PetscObject input: 47287497f52SBarry Smith $ `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. 47387497f52SBarry Smith $ `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.) 47487497f52SBarry Smith For either case above, the input `PetscObject` should be destroyed by the user when no longer needed (the aggregate object increases its reference count). 47587497f52SBarry Smith $ `PETSC_USE_POINTER` - invalid for `PetscObject` inputs. 476df4397b0SStefano Zampini 477df4397b0SStefano Zampini E*/ 4789371c9d4SSatish Balay typedef enum { 4799371c9d4SSatish Balay PETSC_COPY_VALUES, 4809371c9d4SSatish Balay PETSC_OWN_POINTER, 4819371c9d4SSatish Balay PETSC_USE_POINTER 4829371c9d4SSatish Balay } PetscCopyMode; 483*3b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscCopyModes[]; 484df4397b0SStefano Zampini 485df4397b0SStefano Zampini /*MC 48687497f52SBarry Smith PETSC_FALSE - False value of `PetscBool` 487df4397b0SStefano Zampini 488df4397b0SStefano Zampini Level: beginner 489df4397b0SStefano Zampini 490df4397b0SStefano Zampini Note: 491df4397b0SStefano Zampini Zero integer 492df4397b0SStefano Zampini 49387497f52SBarry Smith .seealso: `PetscBool`, `PetscBool3`, `PETSC_TRUE` 494df4397b0SStefano Zampini M*/ 495df4397b0SStefano Zampini 496df4397b0SStefano Zampini /*MC 49787497f52SBarry Smith PETSC_TRUE - True value of `PetscBool` 498df4397b0SStefano Zampini 499df4397b0SStefano Zampini Level: beginner 500df4397b0SStefano Zampini 501df4397b0SStefano Zampini Note: 502df4397b0SStefano Zampini Nonzero integer 503df4397b0SStefano Zampini 50487497f52SBarry Smith .seealso: `PetscBool`, `PetscBool3`, `PETSC_FALSE` 505df4397b0SStefano Zampini M*/ 506df4397b0SStefano Zampini 507df4397b0SStefano Zampini /*MC 508df4397b0SStefano Zampini PetscLogDouble - Used for logging times 509df4397b0SStefano Zampini 510df4397b0SStefano Zampini Notes: 511df4397b0SStefano Zampini Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc. 512df4397b0SStefano Zampini 5136b3bf505SPatrick Sanan Level: developer 5146b3bf505SPatrick Sanan 515df4397b0SStefano Zampini M*/ 516df4397b0SStefano Zampini typedef double PetscLogDouble; 517df4397b0SStefano Zampini 518df4397b0SStefano Zampini /*E 519df4397b0SStefano Zampini PetscDataType - Used for handling different basic data types. 520df4397b0SStefano Zampini 521df4397b0SStefano Zampini Level: beginner 522df4397b0SStefano Zampini 523df4397b0SStefano Zampini Notes: 52487497f52SBarry Smith Use of this should be avoided if one can directly use `MPI_Datatype` instead. 525df4397b0SStefano Zampini 52687497f52SBarry Smith `PETSC_INT` is the datatype for a `PetscInt`, regardless of whether it is 4 or 8 bytes. 52787497f52SBarry Smith `PETSC_REAL`, `PETSC_COMPLEX` and `PETSC_SCALAR` are the datatypes for `PetscReal`, `PetscComplex` and `PetscScalar`, regardless of their sizes. 528277f51e8SBarry Smith 52987497f52SBarry Smith Developer Notes: 530df4397b0SStefano Zampini It would be nice if we could always just use MPI Datatypes, why can we not? 531df4397b0SStefano Zampini 53287497f52SBarry Smith If you change any values in `PetscDatatype` make sure you update their usage in 533fa131761SBarry Smith share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m 53491e29162SBarry Smith 535277f51e8SBarry Smith TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM 536277f51e8SBarry Smith 537db781477SPatrick Sanan .seealso: `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`, 538db781477SPatrick Sanan `PetscDataTypeGetSize()` 539df4397b0SStefano Zampini 540df4397b0SStefano Zampini E*/ 5419371c9d4SSatish Balay typedef enum { 5429371c9d4SSatish Balay PETSC_DATATYPE_UNKNOWN = 0, 5439371c9d4SSatish Balay PETSC_DOUBLE = 1, 5449371c9d4SSatish Balay PETSC_COMPLEX = 2, 5459371c9d4SSatish Balay PETSC_LONG = 3, 5469371c9d4SSatish Balay PETSC_SHORT = 4, 5479371c9d4SSatish Balay PETSC_FLOAT = 5, 5489371c9d4SSatish Balay PETSC_CHAR = 6, 5499371c9d4SSatish Balay PETSC_BIT_LOGICAL = 7, 5509371c9d4SSatish Balay PETSC_ENUM = 8, 5519371c9d4SSatish Balay PETSC_BOOL = 9, 5529371c9d4SSatish Balay PETSC___FLOAT128 = 10, 5539371c9d4SSatish Balay PETSC_OBJECT = 11, 5549371c9d4SSatish Balay PETSC_FUNCTION = 12, 5559371c9d4SSatish Balay PETSC_STRING = 13, 5569371c9d4SSatish Balay PETSC___FP16 = 14, 5579371c9d4SSatish Balay PETSC_STRUCT = 15, 5589371c9d4SSatish Balay PETSC_INT = 16, 55962e5d2d2SJDBetteridge PETSC_INT64 = 17, 56062e5d2d2SJDBetteridge PETSC_COUNT = 18 5619371c9d4SSatish Balay } PetscDataType; 562*3b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscDataTypes[]; 563df4397b0SStefano Zampini 564df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 565df4397b0SStefano Zampini #define PETSC_REAL PETSC_FLOAT 5665117d392SLisandro Dalcin #elif defined(PETSC_USE_REAL_DOUBLE) 5675117d392SLisandro Dalcin #define PETSC_REAL PETSC_DOUBLE 568df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 569df4397b0SStefano Zampini #define PETSC_REAL PETSC___FLOAT128 570df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 571df4397b0SStefano Zampini #define PETSC_REAL PETSC___FP16 572df4397b0SStefano Zampini #else 573df4397b0SStefano Zampini #define PETSC_REAL PETSC_DOUBLE 574df4397b0SStefano Zampini #endif 5755117d392SLisandro Dalcin 5765117d392SLisandro Dalcin #if defined(PETSC_USE_COMPLEX) 5775117d392SLisandro Dalcin #define PETSC_SCALAR PETSC_COMPLEX 5785117d392SLisandro Dalcin #else 5795117d392SLisandro Dalcin #define PETSC_SCALAR PETSC_REAL 5805117d392SLisandro Dalcin #endif 5815117d392SLisandro Dalcin 582df4397b0SStefano Zampini #define PETSC_FORTRANADDR PETSC_LONG 583df4397b0SStefano Zampini 584df4397b0SStefano Zampini /*S 585df4397b0SStefano Zampini PetscToken - 'Token' used for managing tokenizing strings 586df4397b0SStefano Zampini 587df4397b0SStefano Zampini Level: intermediate 588df4397b0SStefano Zampini 589db781477SPatrick Sanan .seealso: `PetscTokenCreate()`, `PetscTokenFind()`, `PetscTokenDestroy()` 590df4397b0SStefano Zampini S*/ 591df4397b0SStefano Zampini typedef struct _p_PetscToken *PetscToken; 592df4397b0SStefano Zampini 593df4397b0SStefano Zampini /*S 59487497f52SBarry Smith PetscObject - any PETSc object, `PetscViewer`, `Mat`, `Vec`, `KSP` etc 595df4397b0SStefano Zampini 596df4397b0SStefano Zampini Level: beginner 597df4397b0SStefano Zampini 59887497f52SBarry Smith Notes: 599df4397b0SStefano Zampini This is the base class from which all PETSc objects are derived from. 600df4397b0SStefano Zampini 60187497f52SBarry Smith In certain situations one can cast an object, for example a `Vec`, to a `PetscObject` with (`PetscObject`)vec 60287497f52SBarry Smith 603db781477SPatrick Sanan .seealso: `PetscObjectDestroy()`, `PetscObjectView()`, `PetscObjectGetName()`, `PetscObjectSetName()`, `PetscObjectReference()`, `PetscObjectDereference()` 604df4397b0SStefano Zampini S*/ 605df4397b0SStefano Zampini typedef struct _p_PetscObject *PetscObject; 606df4397b0SStefano Zampini 607df4397b0SStefano Zampini /*MC 60887497f52SBarry Smith PetscObjectId - unique integer Id for a `PetscObject` 609df4397b0SStefano Zampini 610df4397b0SStefano Zampini Level: developer 611df4397b0SStefano Zampini 61287497f52SBarry Smith Note: 61387497f52SBarry Smith Unlike pointer values, object ids are never reused so one may save a `PetscObjectId` and compare it to one obtained later from a `PetscObject` to determine 61487497f52SBarry Smith if the objects are the same. Never compare two object pointer values. 615df4397b0SStefano Zampini 616db781477SPatrick Sanan .seealso: `PetscObjectState`, `PetscObjectGetId()` 617df4397b0SStefano Zampini M*/ 618df4397b0SStefano Zampini typedef PetscInt64 PetscObjectId; 619df4397b0SStefano Zampini 620df4397b0SStefano Zampini /*MC 62187497f52SBarry Smith PetscObjectState - integer state for a `PetscObject` 622df4397b0SStefano Zampini 623df4397b0SStefano Zampini Level: developer 624df4397b0SStefano Zampini 625df4397b0SStefano Zampini Notes: 626df4397b0SStefano Zampini Object state is always-increasing and (for objects that track state) can be used to determine if an object has 627df4397b0SStefano 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. 628df4397b0SStefano Zampini 629db781477SPatrick Sanan .seealso: `PetscObjectId`, `PetscObjectStateGet()`, `PetscObjectStateIncrease()`, `PetscObjectStateSet()` 630df4397b0SStefano Zampini M*/ 631df4397b0SStefano Zampini typedef PetscInt64 PetscObjectState; 632df4397b0SStefano Zampini 633df4397b0SStefano Zampini /*S 634df4397b0SStefano Zampini PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed 635df4397b0SStefano Zampini by string name 636df4397b0SStefano Zampini 637df4397b0SStefano Zampini Level: advanced 638df4397b0SStefano Zampini 639db781477SPatrick Sanan .seealso: `PetscFunctionListAdd()`, `PetscFunctionListDestroy()` 640df4397b0SStefano Zampini S*/ 641df4397b0SStefano Zampini typedef struct _n_PetscFunctionList *PetscFunctionList; 642df4397b0SStefano Zampini 643df4397b0SStefano Zampini /*E 644df4397b0SStefano Zampini PetscFileMode - Access mode for a file. 645df4397b0SStefano Zampini 646df4397b0SStefano Zampini Level: beginner 647df4397b0SStefano Zampini 64887497f52SBarry Smith $ `FILE_MODE_UNDEFINED` - initial invalid value 64987497f52SBarry Smith $ `FILE_MODE_READ` - open a file at its beginning for reading 65087497f52SBarry Smith $ `FILE_MODE_WRITE` - open a file at its beginning for writing (will create if the file does not exist) 65187497f52SBarry Smith $ `FILE_MODE_APPEND` - open a file at end for writing 65287497f52SBarry Smith $ `FILE_MODE_UPDATE` - open a file for updating, meaning for reading and writing 65387497f52SBarry Smith $ `FILE_MODE_APPEND_UPDATE` - open a file for updating, meaning for reading and writing, at the end 654df4397b0SStefano Zampini 655db781477SPatrick Sanan .seealso: `PetscViewerFileSetMode()` 656df4397b0SStefano Zampini E*/ 6579371c9d4SSatish Balay typedef enum { 6589371c9d4SSatish Balay FILE_MODE_UNDEFINED = -1, 6599371c9d4SSatish Balay FILE_MODE_READ = 0, 6609371c9d4SSatish Balay FILE_MODE_WRITE, 6619371c9d4SSatish Balay FILE_MODE_APPEND, 6629371c9d4SSatish Balay FILE_MODE_UPDATE, 6639371c9d4SSatish Balay FILE_MODE_APPEND_UPDATE 6649371c9d4SSatish Balay } PetscFileMode; 665*3b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscFileModes[]; 666df4397b0SStefano Zampini 667df4397b0SStefano Zampini typedef void *PetscDLHandle; 6689371c9d4SSatish Balay typedef enum { 6699371c9d4SSatish Balay PETSC_DL_DECIDE = 0, 6709371c9d4SSatish Balay PETSC_DL_NOW = 1, 6719371c9d4SSatish Balay PETSC_DL_LOCAL = 2 6729371c9d4SSatish Balay } PetscDLMode; 673df4397b0SStefano Zampini 674df4397b0SStefano Zampini /*S 6757243573dSPierre Jolivet PetscObjectList - Linked list of PETSc objects, each accessible by string name 676df4397b0SStefano Zampini 677df4397b0SStefano Zampini Level: developer 678df4397b0SStefano Zampini 67987497f52SBarry Smith Note: 68087497f52SBarry Smith Used by `PetscObjectCompose()` and `PetscObjectQuery()` 681df4397b0SStefano Zampini 682db781477SPatrick Sanan .seealso: `PetscObjectListAdd()`, `PetscObjectListDestroy()`, `PetscObjectListFind()`, `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscFunctionList` 683df4397b0SStefano Zampini S*/ 684df4397b0SStefano Zampini typedef struct _n_PetscObjectList *PetscObjectList; 685df4397b0SStefano Zampini 686df4397b0SStefano Zampini /*S 687df4397b0SStefano Zampini PetscDLLibrary - Linked list of dynamics libraries to search for functions 688df4397b0SStefano Zampini 689df4397b0SStefano Zampini Level: advanced 690df4397b0SStefano Zampini 691db781477SPatrick Sanan .seealso: `PetscDLLibraryOpen()` 692df4397b0SStefano Zampini S*/ 693df4397b0SStefano Zampini typedef struct _n_PetscDLLibrary *PetscDLLibrary; 694df4397b0SStefano Zampini 695df4397b0SStefano Zampini /*S 696df4397b0SStefano Zampini PetscContainer - Simple PETSc object that contains a pointer to any required data 697df4397b0SStefano Zampini 698df4397b0SStefano Zampini Level: advanced 699df4397b0SStefano Zampini 70087497f52SBarry Smith Note: 70187497f52SBarry Smith This is useful to attach arbitrary data to a `PetscObject` with `PetscObjectCompose()` and `PetscObjectQuery()` 70287497f52SBarry Smith 70387497f52SBarry Smith .seealso: `PetscObject`, `PetscContainerCreate()`, `PetscObjectCompose()`, `PetscObjectQuery()` 704df4397b0SStefano Zampini S*/ 705df4397b0SStefano Zampini typedef struct _p_PetscContainer *PetscContainer; 706df4397b0SStefano Zampini 707df4397b0SStefano Zampini /*S 708df4397b0SStefano Zampini PetscRandom - Abstract PETSc object that manages generating random numbers 709df4397b0SStefano Zampini 710df4397b0SStefano Zampini Level: intermediate 711df4397b0SStefano Zampini 712db781477SPatrick Sanan .seealso: `PetscRandomCreate()`, `PetscRandomGetValue()`, `PetscRandomType` 713df4397b0SStefano Zampini S*/ 714df4397b0SStefano Zampini typedef struct _p_PetscRandom *PetscRandom; 715df4397b0SStefano Zampini 716df4397b0SStefano Zampini /* 717df4397b0SStefano Zampini In binary files variables are stored using the following lengths, 718df4397b0SStefano Zampini regardless of how they are stored in memory on any one particular 719df4397b0SStefano Zampini machine. Use these rather then sizeof() in computing sizes for 720df4397b0SStefano Zampini PetscBinarySeek(). 721df4397b0SStefano Zampini */ 722df4397b0SStefano Zampini #define PETSC_BINARY_INT_SIZE (32 / 8) 723df4397b0SStefano Zampini #define PETSC_BINARY_FLOAT_SIZE (32 / 8) 724df4397b0SStefano Zampini #define PETSC_BINARY_CHAR_SIZE (8 / 8) 725df4397b0SStefano Zampini #define PETSC_BINARY_SHORT_SIZE (16 / 8) 726df4397b0SStefano Zampini #define PETSC_BINARY_DOUBLE_SIZE (64 / 8) 727df4397b0SStefano Zampini #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar) 728df4397b0SStefano Zampini 729df4397b0SStefano Zampini /*E 73087497f52SBarry Smith PetscBinarySeekType - argument to `PetscBinarySeek()` 731df4397b0SStefano Zampini 732df4397b0SStefano Zampini Level: advanced 733df4397b0SStefano Zampini 734db781477SPatrick Sanan .seealso: `PetscBinarySeek()`, `PetscBinarySynchronizedSeek()` 735df4397b0SStefano Zampini E*/ 7369371c9d4SSatish Balay typedef enum { 7379371c9d4SSatish Balay PETSC_BINARY_SEEK_SET = 0, 7389371c9d4SSatish Balay PETSC_BINARY_SEEK_CUR = 1, 7399371c9d4SSatish Balay PETSC_BINARY_SEEK_END = 2 7409371c9d4SSatish Balay } PetscBinarySeekType; 741df4397b0SStefano Zampini 742df4397b0SStefano Zampini /*E 743df4397b0SStefano Zampini PetscBuildTwoSidedType - algorithm for setting up two-sided communication 744df4397b0SStefano Zampini 74587497f52SBarry Smith $ `PETSC_BUILDTWOSIDED_ALLREDUCE` - classical algorithm using an MPI_Allreduce with 746df4397b0SStefano Zampini $ a buffer of length equal to the communicator size. Not memory-scalable due to 747df4397b0SStefano Zampini $ the large reduction size. Requires only MPI-1. 74887497f52SBarry Smith $ `PETSC_BUILDTWOSIDED_IBARRIER` - nonblocking algorithm based on MPI_Issend and MPI_Ibarrier. 749df4397b0SStefano Zampini $ Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires MPI-3. 75087497f52SBarry Smith $ `PETSC_BUILDTWOSIDED_REDSCATTER` - similar to above, but use more optimized function 751df4397b0SStefano Zampini $ that only communicates the part of the reduction that is necessary. Requires MPI-2. 752df4397b0SStefano Zampini 753df4397b0SStefano Zampini Level: developer 754df4397b0SStefano Zampini 755db781477SPatrick Sanan .seealso: `PetscCommBuildTwoSided()`, `PetscCommBuildTwoSidedSetType()`, `PetscCommBuildTwoSidedGetType()` 756df4397b0SStefano Zampini E*/ 757df4397b0SStefano Zampini typedef enum { 758df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_NOTSET = -1, 759df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_ALLREDUCE = 0, 760df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_IBARRIER = 1, 761df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_REDSCATTER = 2 762df4397b0SStefano Zampini /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */ 763df4397b0SStefano Zampini } PetscBuildTwoSidedType; 764*3b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscBuildTwoSidedTypes[]; 765df4397b0SStefano Zampini 766aa2d33c1SMatthew G. Knepley /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */ 767df4397b0SStefano Zampini /*E 768df4397b0SStefano Zampini InsertMode - Whether entries are inserted or added into vectors or matrices 769df4397b0SStefano Zampini 770df4397b0SStefano Zampini Level: beginner 771df4397b0SStefano Zampini 772db781477SPatrick Sanan .seealso: `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 773db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, 774db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()` 775df4397b0SStefano Zampini E*/ 7769371c9d4SSatish Balay typedef enum { 7779371c9d4SSatish Balay NOT_SET_VALUES, 7789371c9d4SSatish Balay INSERT_VALUES, 7799371c9d4SSatish Balay ADD_VALUES, 7809371c9d4SSatish Balay MAX_VALUES, 7819371c9d4SSatish Balay MIN_VALUES, 7829371c9d4SSatish Balay INSERT_ALL_VALUES, 7839371c9d4SSatish Balay ADD_ALL_VALUES, 7849371c9d4SSatish Balay INSERT_BC_VALUES, 7859371c9d4SSatish Balay ADD_BC_VALUES 7869371c9d4SSatish Balay } InsertMode; 787df4397b0SStefano Zampini 788df4397b0SStefano Zampini /*MC 789df4397b0SStefano Zampini INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value 790df4397b0SStefano Zampini 791df4397b0SStefano Zampini Level: beginner 792df4397b0SStefano Zampini 793db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 794db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `ADD_VALUES`, 795db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 796df4397b0SStefano Zampini 797df4397b0SStefano Zampini M*/ 798df4397b0SStefano Zampini 799df4397b0SStefano Zampini /*MC 800df4397b0SStefano Zampini ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the 801df4397b0SStefano Zampini value into that location 802df4397b0SStefano Zampini 803df4397b0SStefano Zampini Level: beginner 804df4397b0SStefano Zampini 805db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 806db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `INSERT_VALUES`, 807db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 808df4397b0SStefano Zampini 809df4397b0SStefano Zampini M*/ 810df4397b0SStefano Zampini 811df4397b0SStefano Zampini /*MC 812df4397b0SStefano Zampini MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location 813df4397b0SStefano Zampini 814df4397b0SStefano Zampini Level: beginner 815df4397b0SStefano Zampini 816db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 817df4397b0SStefano Zampini 818df4397b0SStefano Zampini M*/ 819df4397b0SStefano Zampini 820421aa1e7SJunchao Zhang /*MC 821421aa1e7SJunchao Zhang MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location 822421aa1e7SJunchao Zhang 823421aa1e7SJunchao Zhang Level: beginner 824421aa1e7SJunchao Zhang 825db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 826421aa1e7SJunchao Zhang 827421aa1e7SJunchao Zhang M*/ 828421aa1e7SJunchao Zhang 829df4397b0SStefano Zampini /*S 830df4397b0SStefano Zampini PetscSubcomm - A decomposition of an MPI communicator into subcommunicators 831df4397b0SStefano Zampini 832df4397b0SStefano Zampini Notes: 83387497f52SBarry Smith After a call to `PetscSubcommSetType()`, `PetscSubcommSetTypeGeneral()`, or `PetscSubcommSetFromOptions()` one may call 83487497f52SBarry Smith $ `PetscSubcommChild()` returns the associated subcommunicator on this process 83587497f52SBarry Smith $ `PetscSubcommContiguousParent()` returns a parent communitor but with all child of the same subcommunicator having contiguous rank 836df4397b0SStefano Zampini 837df4397b0SStefano Zampini Sample Usage: 83887497f52SBarry Smith .vb 83987497f52SBarry Smith `PetscSubcommCreate()` 84087497f52SBarry Smith `PetscSubcommSetNumber()` 84187497f52SBarry Smith `PetscSubcommSetType`(`PETSC_SUBCOMM_INTERLACED`); 84287497f52SBarry Smith ccomm = `PetscSubcommChild()` 84387497f52SBarry Smith `PetscSubcommDestroy()` 84487497f52SBarry Smith .ve 845df4397b0SStefano Zampini 846df4397b0SStefano Zampini Level: advanced 847df4397b0SStefano Zampini 848df4397b0SStefano Zampini Notes: 84987497f52SBarry Smith $ `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 85087497f52SBarry Smith $ `PETSC_SUBCOMM_CONTIGUOUS` - each new communicator contains a set of process with contiguous ranks in the original MPI communicator 85187497f52SBarry Smith $ `PETSC_SUBCOMM_INTERLACED` - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator 852df4397b0SStefano Zampini 853df4397b0SStefano Zampini Example: Consider a communicator with six processes split into 3 subcommunicators. 85487497f52SBarry Smith $ `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 85587497f52SBarry Smith $ `PETSC_SUBCOMM_INTERLACED` - the first communicator contains rank 0,3, the second 1,4 and the third 2,5 856df4397b0SStefano Zampini 85787497f52SBarry Smith Developer Note: 85887497f52SBarry Smith This is used in objects such as `PCREDUNDANT` to manage the subcommunicators on which the redundant computations 859df4397b0SStefano Zampini are performed. 860df4397b0SStefano Zampini 861db781477SPatrick Sanan .seealso: `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()` 862df4397b0SStefano Zampini 863df4397b0SStefano Zampini S*/ 864df4397b0SStefano Zampini typedef struct _n_PetscSubcomm *PetscSubcomm; 8659371c9d4SSatish Balay typedef enum { 8669371c9d4SSatish Balay PETSC_SUBCOMM_GENERAL = 0, 8679371c9d4SSatish Balay PETSC_SUBCOMM_CONTIGUOUS = 1, 8689371c9d4SSatish Balay PETSC_SUBCOMM_INTERLACED = 2 8699371c9d4SSatish Balay } PetscSubcommType; 870*3b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscSubcommTypes[]; 871df4397b0SStefano Zampini 872df4397b0SStefano Zampini /*S 873df4397b0SStefano Zampini PetscHeap - A simple class for managing heaps 874df4397b0SStefano Zampini 875df4397b0SStefano Zampini Level: intermediate 876df4397b0SStefano Zampini 877db781477SPatrick Sanan .seealso: `PetscHeapCreate()`, `PetscHeapAdd()`, `PetscHeapPop()`, `PetscHeapPeek()`, `PetscHeapStash()`, `PetscHeapUnstash()`, `PetscHeapView()`, `PetscHeapDestroy()` 878df4397b0SStefano Zampini S*/ 879df4397b0SStefano Zampini typedef struct _PetscHeap *PetscHeap; 880df4397b0SStefano Zampini 881df4397b0SStefano Zampini typedef struct _n_PetscShmComm *PetscShmComm; 882df4397b0SStefano Zampini typedef struct _n_PetscOmpCtrl *PetscOmpCtrl; 883df4397b0SStefano Zampini 884df4397b0SStefano Zampini /*S 885df4397b0SStefano Zampini PetscSegBuffer - a segmented extendable buffer 886df4397b0SStefano Zampini 887df4397b0SStefano Zampini Level: developer 888df4397b0SStefano Zampini 889db781477SPatrick Sanan .seealso: `PetscSegBufferCreate()`, `PetscSegBufferGet()`, `PetscSegBufferExtract()`, `PetscSegBufferDestroy()` 890df4397b0SStefano Zampini S*/ 891df4397b0SStefano Zampini typedef struct _n_PetscSegBuffer *PetscSegBuffer; 892df4397b0SStefano Zampini 893df4397b0SStefano Zampini typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted; 894df4397b0SStefano Zampini #endif 895