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> 113edda6a2SJed Brown #include <stddef.h> 12df4397b0SStefano Zampini 13ac09b921SBarry Smith /* SUBMANSEC = Sys */ 14ac09b921SBarry Smith 15df4397b0SStefano Zampini /*MC 16df4397b0SStefano Zampini PetscErrorCode - datatype used for return error code from almost all PETSc functions 17df4397b0SStefano Zampini 18df4397b0SStefano Zampini Level: beginner 19df4397b0SStefano Zampini 20db781477SPatrick Sanan .seealso: `PetscCall()`, `SETERRQ()` 21df4397b0SStefano Zampini M*/ 22df4397b0SStefano Zampini typedef int PetscErrorCode; 23df4397b0SStefano Zampini 24df4397b0SStefano Zampini /*MC 25df4397b0SStefano Zampini 26df4397b0SStefano Zampini PetscClassId - A unique id used to identify each PETSc class. 27df4397b0SStefano Zampini 28df4397b0SStefano Zampini Notes: 2987497f52SBarry Smith Use `PetscClassIdRegister()` to obtain a new value for a new class being created. Usually 30df4397b0SStefano Zampini XXXInitializePackage() calls it for each class it defines. 31df4397b0SStefano Zampini 32df4397b0SStefano Zampini Developer Notes: 3387497f52SBarry Smith Internal integer stored in the `_p_PetscObject` data structure. 3487497f52SBarry Smith These are all computed by an offset from the lowest one, `PETSC_SMALLEST_CLASSID`. 35df4397b0SStefano Zampini 36df4397b0SStefano Zampini Level: developer 37df4397b0SStefano Zampini 38db781477SPatrick Sanan .seealso: `PetscClassIdRegister()`, `PetscLogEventRegister()`, `PetscHeaderCreate()` 39df4397b0SStefano Zampini M*/ 40df4397b0SStefano Zampini typedef int PetscClassId; 41df4397b0SStefano Zampini 42df4397b0SStefano Zampini /*MC 43df4397b0SStefano Zampini PetscMPIInt - datatype used to represent 'int' parameters to MPI functions. 44df4397b0SStefano Zampini 45df4397b0SStefano Zampini Level: intermediate 46df4397b0SStefano Zampini 47df4397b0SStefano Zampini Notes: 4887497f52SBarry 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 4987497f52SBarry Smith standard C/Fortran integers are 32 bit then this is NOT the same as `PetscInt`; it remains 32 bit. 50df4397b0SStefano Zampini 5187497f52SBarry Smith `PetscMPIIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscMPIInt`, if not it 5287497f52SBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error. 53df4397b0SStefano Zampini 54db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscInt`, `PetscMPIIntCast()` 55df4397b0SStefano Zampini 56df4397b0SStefano Zampini M*/ 57df4397b0SStefano Zampini typedef int PetscMPIInt; 58df4397b0SStefano Zampini 59df4397b0SStefano Zampini /*MC 603edda6a2SJed Brown PetscSizeT - datatype used to represent sizes in memory (like size_t) 613edda6a2SJed Brown 623edda6a2SJed Brown Level: intermediate 633edda6a2SJed Brown 643edda6a2SJed Brown Notes: 653edda6a2SJed Brown This is equivalent to size_t, but defined for consistency with Fortran, which lacks a native equivalent of size_t. 663edda6a2SJed Brown 67db781477SPatrick Sanan .seealso: `PetscInt`, `PetscInt64`, `PetscCount` 683edda6a2SJed Brown 693edda6a2SJed Brown M*/ 703edda6a2SJed Brown typedef size_t PetscSizeT; 713edda6a2SJed Brown 723edda6a2SJed Brown /*MC 7382a78a4eSJed Brown PetscCount - signed datatype used to represent counts 7482a78a4eSJed Brown 7582a78a4eSJed Brown Level: intermediate 7682a78a4eSJed Brown 7782a78a4eSJed Brown Notes: 7882a78a4eSJed Brown This is equivalent to ptrdiff_t, but defined for consistency with Fortran, which lacks a native equivalent of ptrdiff_t. 7982a78a4eSJed Brown 8087497f52SBarry Smith Use `PetscCount_FMT` to format with `PetscPrintf()`, `printf()`, and related functions. 8182a78a4eSJed Brown 82db781477SPatrick Sanan .seealso: `PetscInt`, `PetscInt64`, `PetscSizeT` 8382a78a4eSJed Brown 8482a78a4eSJed Brown M*/ 8582a78a4eSJed Brown typedef ptrdiff_t PetscCount; 8663a3b9bcSJacob Faibussowitsch #define PetscCount_FMT "td" 8782a78a4eSJed Brown 8882a78a4eSJed Brown /*MC 89df4397b0SStefano Zampini PetscEnum - datatype used to pass enum types within PETSc functions. 90df4397b0SStefano Zampini 91df4397b0SStefano Zampini Level: intermediate 92df4397b0SStefano Zampini 93db781477SPatrick Sanan .seealso: `PetscOptionsGetEnum()`, `PetscOptionsEnum()`, `PetscBagRegisterEnum()` 94df4397b0SStefano Zampini M*/ 959371c9d4SSatish Balay typedef enum { 969371c9d4SSatish Balay ENUM_DUMMY 979371c9d4SSatish Balay } PetscEnum; 98df4397b0SStefano Zampini 99df4397b0SStefano Zampini typedef short PetscShort; 100df4397b0SStefano Zampini typedef char PetscChar; 101df4397b0SStefano Zampini typedef float PetscFloat; 102df4397b0SStefano Zampini 103df4397b0SStefano Zampini /*MC 104df4397b0SStefano Zampini PetscInt - PETSc type that represents an integer, used primarily to 105df4397b0SStefano 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. 106df4397b0SStefano Zampini 107df4397b0SStefano Zampini Notes: 10887497f52SBarry 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. 109df4397b0SStefano Zampini 110df4397b0SStefano Zampini Level: beginner 111df4397b0SStefano Zampini 112db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT` 113df4397b0SStefano Zampini M*/ 114df4397b0SStefano Zampini 115df4397b0SStefano Zampini #if defined(PETSC_HAVE_STDINT_H) 116df4397b0SStefano Zampini #include <stdint.h> 117df4397b0SStefano Zampini #endif 118df4397b0SStefano Zampini #if defined(PETSC_HAVE_INTTYPES_H) 119df4397b0SStefano Zampini #if !defined(__STDC_FORMAT_MACROS) 120df4397b0SStefano Zampini #define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */ 121df4397b0SStefano Zampini #endif 122df4397b0SStefano Zampini #include <inttypes.h> 123df4397b0SStefano Zampini #if !defined(PRId64) 124df4397b0SStefano Zampini #define PRId64 "ld" 125df4397b0SStefano Zampini #endif 126df4397b0SStefano Zampini #endif 127df4397b0SStefano Zampini 128df4397b0SStefano 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 */ 129df4397b0SStefano Zampini typedef int64_t PetscInt64; 130df4397b0SStefano Zampini #elif (PETSC_SIZEOF_LONG_LONG == 8) 131df4397b0SStefano Zampini typedef long long PetscInt64; 132df4397b0SStefano Zampini #elif defined(PETSC_HAVE___INT64) 133df4397b0SStefano Zampini typedef __int64 PetscInt64; 134df4397b0SStefano Zampini #else 135df4397b0SStefano Zampini #error "cannot determine PetscInt64 type" 136df4397b0SStefano Zampini #endif 137df4397b0SStefano Zampini 138df4397b0SStefano Zampini #if defined(PETSC_USE_64BIT_INDICES) 139df4397b0SStefano Zampini typedef PetscInt64 PetscInt; 140df4397b0SStefano Zampini #else 141df4397b0SStefano Zampini typedef int PetscInt; 142df4397b0SStefano Zampini #endif 143df4397b0SStefano Zampini 144c93fae50SJacob 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 */ 145c93fae50SJacob Faibussowitsch #define MPIU_INT64 MPI_INT64_T 146c93fae50SJacob Faibussowitsch #define PetscInt64_FMT PRId64 147c93fae50SJacob Faibussowitsch #elif (PETSC_SIZEOF_LONG_LONG == 8) 148c93fae50SJacob Faibussowitsch #define MPIU_INT64 MPI_LONG_LONG_INT 149c93fae50SJacob Faibussowitsch #define PetscInt64_FMT "lld" 150c93fae50SJacob Faibussowitsch #elif defined(PETSC_HAVE___INT64) 151c93fae50SJacob Faibussowitsch #define MPIU_INT64 MPI_INT64_T 152c93fae50SJacob Faibussowitsch #define PetscInt64_FMT "ld" 153c93fae50SJacob Faibussowitsch #else 154c93fae50SJacob Faibussowitsch #error "cannot determine PetscInt64 type" 155c93fae50SJacob Faibussowitsch #endif 156c93fae50SJacob Faibussowitsch 157df4397b0SStefano Zampini /*MC 158df4397b0SStefano Zampini PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions. 159df4397b0SStefano Zampini 160df4397b0SStefano Zampini Notes: 16187497f52SBarry Smith Usually this is the same as `PetscIn`t, but if PETSc was built with --with-64-bit-indices but 16287497f52SBarry Smith standard C/Fortran integers are 32 bit then this may not be the same as `PetscInt`, 16387497f52SBarry Smith except on some BLAS/LAPACK implementations that support 64 bit integers see the notes below. 164df4397b0SStefano Zampini 16587497f52SBarry Smith `PetscErrorCode` `PetscBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscBLASInt`, if not it 16687497f52SBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error 167df4397b0SStefano Zampini 168df4397b0SStefano Zampini Installation Notes: 169cdc6ee08SBarry Smith ./configure automatically determines the size of the integers used by BLAS/LAPACK except when --with-batch is used 170cdc6ee08SBarry 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 171cdc6ee08SBarry Smith 172cdc6ee08SBarry Smith MATLAB ships with BLAS and LAPACK that use 64 bit integers, for example if you run ./configure with, the option 173df4397b0SStefano Zampini --with-blaslapack-lib=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib] 174df4397b0SStefano Zampini 175cdc6ee08SBarry 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 176cdc6ee08SBarry Smith against the 64 bit version, otherwise it use the 32 bit version 177df4397b0SStefano Zampini 178cdc6ee08SBarry 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 179df4397b0SStefano Zampini 180df4397b0SStefano Zampini External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64 bit integers to BLAS/LAPACK so cannot 181cdc6ee08SBarry 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 182cdc6ee08SBarry Smith these external libraries while using 64 bit integer BLAS/LAPACK. 183df4397b0SStefano Zampini 184df4397b0SStefano Zampini Level: intermediate 185df4397b0SStefano Zampini 186db781477SPatrick Sanan .seealso: `PetscMPIInt`, `PetscInt`, `PetscBLASIntCast()` 187df4397b0SStefano Zampini 188df4397b0SStefano Zampini M*/ 189df4397b0SStefano Zampini #if defined(PETSC_HAVE_64BIT_BLAS_INDICES) 190c93fae50SJacob Faibussowitsch #define PetscBLASInt_FMT PetscInt64_FMT 191df4397b0SStefano Zampini typedef PetscInt64 PetscBLASInt; 192df4397b0SStefano Zampini #else 193c93fae50SJacob Faibussowitsch #define PetscBLASInt_FMT "d" 194df4397b0SStefano Zampini typedef int PetscBLASInt; 195df4397b0SStefano Zampini #endif 196df4397b0SStefano Zampini 197eee0c0a6SToby Isaac /*MC 198eee0c0a6SToby Isaac PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions. 199eee0c0a6SToby Isaac 200eee0c0a6SToby Isaac Notes: 201eee0c0a6SToby Isaac As of this writing PetscCuBLASInt is always the system `int`. 202eee0c0a6SToby Isaac 20387497f52SBarry Smith `PetscErrorCode` `PetscCuBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscCuBLASInt`, if not it 20487497f52SBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error 205eee0c0a6SToby Isaac 206eee0c0a6SToby Isaac Level: intermediate 207eee0c0a6SToby Isaac 208db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscCuBLASIntCast()` 209eee0c0a6SToby Isaac 210eee0c0a6SToby Isaac M*/ 211eee0c0a6SToby Isaac typedef int PetscCuBLASInt; 212eee0c0a6SToby Isaac 21347d993e7Ssuyashtn /*MC 21447d993e7Ssuyashtn PetscHipBLASInt - datatype used to represent 'int' parameters to hipBLAS/hipSOLVER functions. 21547d993e7Ssuyashtn 21647d993e7Ssuyashtn Notes: 21747d993e7Ssuyashtn As of this writing PetscHipBLASInt is always the system `int`. 21847d993e7Ssuyashtn 21947d993e7Ssuyashtn PetscErrorCode PetscHipBLASIntCast(a,&b) checks if the given PetscInt a will fit in a PetscHipBLASInt, if not it 22047d993e7Ssuyashtn generates a PETSC_ERR_ARG_OUTOFRANGE error 22147d993e7Ssuyashtn 22247d993e7Ssuyashtn Level: intermediate 22347d993e7Ssuyashtn 22447d993e7Ssuyashtn .seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscHipBLASIntCast() 22547d993e7Ssuyashtn 22647d993e7Ssuyashtn M*/ 22747d993e7Ssuyashtn typedef int PetscHipBLASInt; 22847d993e7Ssuyashtn 229df4397b0SStefano Zampini /*E 230b94d7dedSBarry Smith PetscBool - Logical variable. Actually an enum in C and a logical in Fortran. 231df4397b0SStefano Zampini 232df4397b0SStefano Zampini Level: beginner 233df4397b0SStefano Zampini 234df4397b0SStefano Zampini Developer Note: 23587497f52SBarry 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 236df4397b0SStefano Zampini boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms. 237df4397b0SStefano Zampini 238b94d7dedSBarry Smith .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PetscBool3` 239df4397b0SStefano Zampini E*/ 2409371c9d4SSatish Balay typedef enum { 2419371c9d4SSatish Balay PETSC_FALSE, 2429371c9d4SSatish Balay PETSC_TRUE 2439371c9d4SSatish Balay } PetscBool; 244df4397b0SStefano Zampini 245b94d7dedSBarry Smith /*E 246b94d7dedSBarry Smith PetscBool3 - Ternary logical variable. Actually an enum in C and a 4 byte integer in Fortran. 247b94d7dedSBarry Smith 248b94d7dedSBarry Smith Level: beginner 249b94d7dedSBarry Smith 25087497f52SBarry Smith Note: 251b94d7dedSBarry Smith Should not be used with the if (flg) or if (!flg) syntax. 252b94d7dedSBarry Smith 253b94d7dedSBarry Smith .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PETSC_BOOL3_TRUE`, `PETSC_BOOL3_FALSE`, `PETSC_BOOL3_UKNOWN` 254b94d7dedSBarry Smith E*/ 2559371c9d4SSatish Balay typedef enum { 2569371c9d4SSatish Balay PETSC_BOOL3_FALSE, 2579371c9d4SSatish Balay PETSC_BOOL3_TRUE, 2589371c9d4SSatish Balay PETSC_BOOL3_UNKNOWN = -1 2599371c9d4SSatish Balay } PetscBool3; 260b94d7dedSBarry Smith 261b94d7dedSBarry Smith #define PetscBool3ToBool(a) ((a) == PETSC_BOOL3_TRUE ? PETSC_TRUE : PETSC_FALSE) 262b94d7dedSBarry Smith #define PetscBoolToBool3(a) ((a) == PETSC_TRUE ? PETSC_BOOL3_TRUE : PETSC_BOOL3_FALSE) 263b94d7dedSBarry Smith 264df4397b0SStefano Zampini /*MC 26587497f52SBarry Smith PetscReal - PETSc type that represents a real number version of `PetscScalar` 266df4397b0SStefano Zampini 267df4397b0SStefano Zampini Notes: 26887497f52SBarry Smith For MPI calls that require datatypes, use `MPIU_REAL` as the datatype for `PetscReal` and `MPIU_SUM`, `MPIU_MAX`, etc. for operations. 26987497f52SBarry Smith They will automatically work correctly regardless of the size of `PetscReal`. 270df4397b0SStefano Zampini 27187497f52SBarry Smith See `PetscScalar` for details on how to ./configure the size of `PetscReal`. 272df4397b0SStefano Zampini 273df4397b0SStefano Zampini Level: beginner 274df4397b0SStefano Zampini 275db781477SPatrick Sanan .seealso: `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT` 276df4397b0SStefano Zampini M*/ 277df4397b0SStefano Zampini 278df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 279df4397b0SStefano Zampini typedef float PetscReal; 280df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 281df4397b0SStefano Zampini typedef double PetscReal; 282df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 283df4397b0SStefano Zampini #if defined(__cplusplus) 284df4397b0SStefano Zampini extern "C" { 285df4397b0SStefano Zampini #endif 286df4397b0SStefano Zampini #include <quadmath.h> 287df4397b0SStefano Zampini #if defined(__cplusplus) 288df4397b0SStefano Zampini } 289df4397b0SStefano Zampini #endif 290df4397b0SStefano Zampini typedef __float128 PetscReal; 291df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 292df4397b0SStefano Zampini typedef __fp16 PetscReal; 293df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 294df4397b0SStefano Zampini 295df4397b0SStefano Zampini /*MC 29687497f52SBarry Smith PetscComplex - PETSc type that represents a complex number with precision matching that of `PetscReal`. 297df4397b0SStefano Zampini 298df4397b0SStefano Zampini Synopsis: 299df4397b0SStefano Zampini #include <petscsys.h> 300df4397b0SStefano Zampini PetscComplex number = 1. + 2.*PETSC_i; 301df4397b0SStefano Zampini 302df4397b0SStefano Zampini Notes: 30387497f52SBarry Smith For MPI calls that require datatypes, use `MPIU_COMPLEX` as the datatype for `PetscComplex` and `MPIU_SUM` etc for operations. 30487497f52SBarry Smith They will automatically work correctly regardless of the size of `PetscComplex`. 305df4397b0SStefano Zampini 30687497f52SBarry Smith See PetscScalar for details on how to ./configure the size of `PetscReal` 307df4397b0SStefano Zampini 308df4397b0SStefano Zampini Complex numbers are automatically available if PETSc was able to find a working complex implementation 309df4397b0SStefano Zampini 31087497f52SBarry Smith Petsc has a 'fix' for complex numbers to support expressions such as std::complex<PetscReal> + `PetscInt`, which are not supported by the standard 311a966371cSJunchao 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 312a966371cSJunchao Zhang configure), we include petsccxxcomplexfix.h to provide this convenience. 313a966371cSJunchao Zhang 31487497f52SBarry 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` 315a966371cSJunchao Zhang at the beginning of the C++ file to skip the fix. 316a966371cSJunchao Zhang 317df4397b0SStefano Zampini Level: beginner 318df4397b0SStefano Zampini 319db781477SPatrick Sanan .seealso: `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i` 320df4397b0SStefano Zampini M*/ 321df4397b0SStefano Zampini #if !defined(PETSC_SKIP_COMPLEX) 3227a19d461SSatish Balay #if defined(PETSC_CLANGUAGE_CXX) 3237a19d461SSatish Balay #if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128) 3247a19d461SSatish Balay #if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */ 325df4397b0SStefano Zampini #define PETSC_HAVE_COMPLEX 1 326*d5b43468SJose E. Roman #elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */ 3277a19d461SSatish Balay #define PETSC_HAVE_COMPLEX 1 3287a19d461SSatish Balay #endif 329450fc7c9SSatish Balay #elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX) 330450fc7c9SSatish Balay #define PETSC_HAVE_COMPLEX 1 3317a19d461SSatish Balay #endif 3327a19d461SSatish Balay #else /* !PETSC_CLANGUAGE_CXX */ 3337a19d461SSatish Balay #if !defined(PETSC_USE_REAL___FP16) 3347a19d461SSatish Balay #if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */ 3357a19d461SSatish Balay #define PETSC_HAVE_COMPLEX 1 336*d5b43468SJose E. Roman #elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */ 3377a19d461SSatish Balay #define PETSC_HAVE_COMPLEX 1 3387a19d461SSatish Balay #endif 3397a19d461SSatish Balay #endif 3407a19d461SSatish Balay #endif /* PETSC_CLANGUAGE_CXX */ 3417a19d461SSatish Balay #endif /* !PETSC_SKIP_COMPLEX */ 3427a19d461SSatish Balay 3437a19d461SSatish Balay #if defined(PETSC_HAVE_COMPLEX) 3447a19d461SSatish Balay #if defined(__cplusplus) /* C++ complex support */ 34511d22bbfSJunchao Zhang /* Locate a C++ complex template library */ 34611d22bbfSJunchao Zhang #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */ 34711d22bbfSJunchao Zhang #define petsccomplexlib Kokkos 34811d22bbfSJunchao Zhang #include <Kokkos_Complex.hpp> 349022afdc5SJed Brown #elif defined(__CUDACC__) || defined(__HIPCC__) 350df4397b0SStefano Zampini #define petsccomplexlib thrust 351df4397b0SStefano Zampini #include <thrust/complex.h> 352450fc7c9SSatish Balay #elif defined(PETSC_USE_REAL___FLOAT128) 353450fc7c9SSatish Balay #include <complex.h> 354df4397b0SStefano Zampini #else 355df4397b0SStefano Zampini #define petsccomplexlib std 356df4397b0SStefano Zampini #include <complex> 357df4397b0SStefano Zampini #endif 35811d22bbfSJunchao Zhang 35911d22bbfSJunchao Zhang /* Define PetscComplex based on the precision */ 360df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 361df4397b0SStefano Zampini typedef petsccomplexlib::complex<float> PetscComplex; 362df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 363df4397b0SStefano Zampini typedef petsccomplexlib::complex<double> PetscComplex; 364df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 365450fc7c9SSatish Balay typedef __complex128 PetscComplex; 36611d22bbfSJunchao Zhang #endif 36711d22bbfSJunchao Zhang 368a966371cSJunchao Zhang /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */ 369a966371cSJunchao Zhang #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX) 37039829747SLisandro Dalcin #include <petsccxxcomplexfix.h> 37111d22bbfSJunchao Zhang #endif 3727a19d461SSatish Balay #else /* c99 complex support */ 373df4397b0SStefano Zampini #include <complex.h> 374df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16) 375df4397b0SStefano Zampini typedef float _Complex PetscComplex; 376df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 377df4397b0SStefano Zampini typedef double _Complex PetscComplex; 378df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 379df4397b0SStefano Zampini typedef __complex128 PetscComplex; 380df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 3817a19d461SSatish Balay #endif /* !__cplusplus */ 3827a19d461SSatish Balay #endif /* PETSC_HAVE_COMPLEX */ 383df4397b0SStefano Zampini 384df4397b0SStefano Zampini /*MC 385df4397b0SStefano Zampini PetscScalar - PETSc type that represents either a double precision real number, a double precision 386df4397b0SStefano Zampini complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured 387df4397b0SStefano Zampini with --with-scalar-type=real,complex --with-precision=single,double,__float128,__fp16 388df4397b0SStefano Zampini 389df4397b0SStefano Zampini Notes: 39087497f52SBarry 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`. 391df4397b0SStefano Zampini 392df4397b0SStefano Zampini Level: beginner 393df4397b0SStefano Zampini 394db781477SPatrick Sanan .seealso: `PetscReal`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscRealPart()`, `PetscImaginaryPart()` 395df4397b0SStefano Zampini M*/ 396df4397b0SStefano Zampini 3977a19d461SSatish Balay #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX) 398df4397b0SStefano Zampini typedef PetscComplex PetscScalar; 399df4397b0SStefano Zampini #else /* PETSC_USE_COMPLEX */ 400df4397b0SStefano Zampini typedef PetscReal PetscScalar; 401df4397b0SStefano Zampini #endif /* PETSC_USE_COMPLEX */ 402df4397b0SStefano Zampini 403df4397b0SStefano Zampini /*E 40487497f52SBarry Smith PetscCopyMode - Determines how an array or `PetscObject` passed to certain functions is copied or retained by the aggregate `PetscObject` 405df4397b0SStefano Zampini 406df4397b0SStefano Zampini Level: beginner 407df4397b0SStefano Zampini 4085d80c0bfSVaclav Hapla For the array input: 40987497f52SBarry Smith $ `PETSC_COPY_VALUES` - the array values are copied into new space, the user is free to reuse or delete the passed in array 41087497f52SBarry 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 411df4397b0SStefano Zampini $ delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran. 41287497f52SBarry 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 4135d80c0bfSVaclav Hapla $ the array but the user must delete the array after the object is destroyed. 4145d80c0bfSVaclav Hapla 4155d80c0bfSVaclav Hapla For the PetscObject input: 41687497f52SBarry 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. 41787497f52SBarry 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.) 41887497f52SBarry 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). 41987497f52SBarry Smith $ `PETSC_USE_POINTER` - invalid for `PetscObject` inputs. 420df4397b0SStefano Zampini 421df4397b0SStefano Zampini E*/ 4229371c9d4SSatish Balay typedef enum { 4239371c9d4SSatish Balay PETSC_COPY_VALUES, 4249371c9d4SSatish Balay PETSC_OWN_POINTER, 4259371c9d4SSatish Balay PETSC_USE_POINTER 4269371c9d4SSatish Balay } PetscCopyMode; 427df4397b0SStefano Zampini 428df4397b0SStefano Zampini /*MC 42987497f52SBarry Smith PETSC_FALSE - False value of `PetscBool` 430df4397b0SStefano Zampini 431df4397b0SStefano Zampini Level: beginner 432df4397b0SStefano Zampini 433df4397b0SStefano Zampini Note: 434df4397b0SStefano Zampini Zero integer 435df4397b0SStefano Zampini 43687497f52SBarry Smith .seealso: `PetscBool`, `PetscBool3`, `PETSC_TRUE` 437df4397b0SStefano Zampini M*/ 438df4397b0SStefano Zampini 439df4397b0SStefano Zampini /*MC 44087497f52SBarry Smith PETSC_TRUE - True value of `PetscBool` 441df4397b0SStefano Zampini 442df4397b0SStefano Zampini Level: beginner 443df4397b0SStefano Zampini 444df4397b0SStefano Zampini Note: 445df4397b0SStefano Zampini Nonzero integer 446df4397b0SStefano Zampini 44787497f52SBarry Smith .seealso: `PetscBool`, `PetscBool3`, `PETSC_FALSE` 448df4397b0SStefano Zampini M*/ 449df4397b0SStefano Zampini 450df4397b0SStefano Zampini /*MC 451df4397b0SStefano Zampini PetscLogDouble - Used for logging times 452df4397b0SStefano Zampini 453df4397b0SStefano Zampini Notes: 454df4397b0SStefano Zampini Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc. 455df4397b0SStefano Zampini 4566b3bf505SPatrick Sanan Level: developer 4576b3bf505SPatrick Sanan 458df4397b0SStefano Zampini M*/ 459df4397b0SStefano Zampini typedef double PetscLogDouble; 460df4397b0SStefano Zampini 461df4397b0SStefano Zampini /*E 462df4397b0SStefano Zampini PetscDataType - Used for handling different basic data types. 463df4397b0SStefano Zampini 464df4397b0SStefano Zampini Level: beginner 465df4397b0SStefano Zampini 466df4397b0SStefano Zampini Notes: 46787497f52SBarry Smith Use of this should be avoided if one can directly use `MPI_Datatype` instead. 468df4397b0SStefano Zampini 46987497f52SBarry Smith `PETSC_INT` is the datatype for a `PetscInt`, regardless of whether it is 4 or 8 bytes. 47087497f52SBarry Smith `PETSC_REAL`, `PETSC_COMPLEX` and `PETSC_SCALAR` are the datatypes for `PetscReal`, `PetscComplex` and `PetscScalar`, regardless of their sizes. 471277f51e8SBarry Smith 47287497f52SBarry Smith Developer Notes: 473df4397b0SStefano Zampini It would be nice if we could always just use MPI Datatypes, why can we not? 474df4397b0SStefano Zampini 47587497f52SBarry Smith If you change any values in `PetscDatatype` make sure you update their usage in 476fa131761SBarry Smith share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m 47791e29162SBarry Smith 478277f51e8SBarry Smith TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM 479277f51e8SBarry Smith 480db781477SPatrick Sanan .seealso: `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`, 481db781477SPatrick Sanan `PetscDataTypeGetSize()` 482df4397b0SStefano Zampini 483df4397b0SStefano Zampini E*/ 4849371c9d4SSatish Balay typedef enum { 4859371c9d4SSatish Balay PETSC_DATATYPE_UNKNOWN = 0, 4869371c9d4SSatish Balay PETSC_DOUBLE = 1, 4879371c9d4SSatish Balay PETSC_COMPLEX = 2, 4889371c9d4SSatish Balay PETSC_LONG = 3, 4899371c9d4SSatish Balay PETSC_SHORT = 4, 4909371c9d4SSatish Balay PETSC_FLOAT = 5, 4919371c9d4SSatish Balay PETSC_CHAR = 6, 4929371c9d4SSatish Balay PETSC_BIT_LOGICAL = 7, 4939371c9d4SSatish Balay PETSC_ENUM = 8, 4949371c9d4SSatish Balay PETSC_BOOL = 9, 4959371c9d4SSatish Balay PETSC___FLOAT128 = 10, 4969371c9d4SSatish Balay PETSC_OBJECT = 11, 4979371c9d4SSatish Balay PETSC_FUNCTION = 12, 4989371c9d4SSatish Balay PETSC_STRING = 13, 4999371c9d4SSatish Balay PETSC___FP16 = 14, 5009371c9d4SSatish Balay PETSC_STRUCT = 15, 5019371c9d4SSatish Balay PETSC_INT = 16, 50262e5d2d2SJDBetteridge PETSC_INT64 = 17, 50362e5d2d2SJDBetteridge PETSC_COUNT = 18 5049371c9d4SSatish Balay } PetscDataType; 505df4397b0SStefano Zampini 506df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 507df4397b0SStefano Zampini #define PETSC_REAL PETSC_FLOAT 5085117d392SLisandro Dalcin #elif defined(PETSC_USE_REAL_DOUBLE) 5095117d392SLisandro Dalcin #define PETSC_REAL PETSC_DOUBLE 510df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 511df4397b0SStefano Zampini #define PETSC_REAL PETSC___FLOAT128 512df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 513df4397b0SStefano Zampini #define PETSC_REAL PETSC___FP16 514df4397b0SStefano Zampini #else 515df4397b0SStefano Zampini #define PETSC_REAL PETSC_DOUBLE 516df4397b0SStefano Zampini #endif 5175117d392SLisandro Dalcin 5185117d392SLisandro Dalcin #if defined(PETSC_USE_COMPLEX) 5195117d392SLisandro Dalcin #define PETSC_SCALAR PETSC_COMPLEX 5205117d392SLisandro Dalcin #else 5215117d392SLisandro Dalcin #define PETSC_SCALAR PETSC_REAL 5225117d392SLisandro Dalcin #endif 5235117d392SLisandro Dalcin 524df4397b0SStefano Zampini #define PETSC_FORTRANADDR PETSC_LONG 525df4397b0SStefano Zampini 526df4397b0SStefano Zampini /*S 527df4397b0SStefano Zampini PetscToken - 'Token' used for managing tokenizing strings 528df4397b0SStefano Zampini 529df4397b0SStefano Zampini Level: intermediate 530df4397b0SStefano Zampini 531db781477SPatrick Sanan .seealso: `PetscTokenCreate()`, `PetscTokenFind()`, `PetscTokenDestroy()` 532df4397b0SStefano Zampini S*/ 533df4397b0SStefano Zampini typedef struct _p_PetscToken *PetscToken; 534df4397b0SStefano Zampini 535df4397b0SStefano Zampini /*S 53687497f52SBarry Smith PetscObject - any PETSc object, `PetscViewer`, `Mat`, `Vec`, `KSP` etc 537df4397b0SStefano Zampini 538df4397b0SStefano Zampini Level: beginner 539df4397b0SStefano Zampini 54087497f52SBarry Smith Notes: 541df4397b0SStefano Zampini This is the base class from which all PETSc objects are derived from. 542df4397b0SStefano Zampini 54387497f52SBarry Smith In certain situations one can cast an object, for example a `Vec`, to a `PetscObject` with (`PetscObject`)vec 54487497f52SBarry Smith 545db781477SPatrick Sanan .seealso: `PetscObjectDestroy()`, `PetscObjectView()`, `PetscObjectGetName()`, `PetscObjectSetName()`, `PetscObjectReference()`, `PetscObjectDereference()` 546df4397b0SStefano Zampini S*/ 547df4397b0SStefano Zampini typedef struct _p_PetscObject *PetscObject; 548df4397b0SStefano Zampini 549df4397b0SStefano Zampini /*MC 55087497f52SBarry Smith PetscObjectId - unique integer Id for a `PetscObject` 551df4397b0SStefano Zampini 552df4397b0SStefano Zampini Level: developer 553df4397b0SStefano Zampini 55487497f52SBarry Smith Note: 55587497f52SBarry 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 55687497f52SBarry Smith if the objects are the same. Never compare two object pointer values. 557df4397b0SStefano Zampini 558db781477SPatrick Sanan .seealso: `PetscObjectState`, `PetscObjectGetId()` 559df4397b0SStefano Zampini M*/ 560df4397b0SStefano Zampini typedef PetscInt64 PetscObjectId; 561df4397b0SStefano Zampini 562df4397b0SStefano Zampini /*MC 56387497f52SBarry Smith PetscObjectState - integer state for a `PetscObject` 564df4397b0SStefano Zampini 565df4397b0SStefano Zampini Level: developer 566df4397b0SStefano Zampini 567df4397b0SStefano Zampini Notes: 568df4397b0SStefano Zampini Object state is always-increasing and (for objects that track state) can be used to determine if an object has 569df4397b0SStefano 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. 570df4397b0SStefano Zampini 571db781477SPatrick Sanan .seealso: `PetscObjectId`, `PetscObjectStateGet()`, `PetscObjectStateIncrease()`, `PetscObjectStateSet()` 572df4397b0SStefano Zampini M*/ 573df4397b0SStefano Zampini typedef PetscInt64 PetscObjectState; 574df4397b0SStefano Zampini 575df4397b0SStefano Zampini /*S 576df4397b0SStefano Zampini PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed 577df4397b0SStefano Zampini by string name 578df4397b0SStefano Zampini 579df4397b0SStefano Zampini Level: advanced 580df4397b0SStefano Zampini 581db781477SPatrick Sanan .seealso: `PetscFunctionListAdd()`, `PetscFunctionListDestroy()` 582df4397b0SStefano Zampini S*/ 583df4397b0SStefano Zampini typedef struct _n_PetscFunctionList *PetscFunctionList; 584df4397b0SStefano Zampini 585df4397b0SStefano Zampini /*E 586df4397b0SStefano Zampini PetscFileMode - Access mode for a file. 587df4397b0SStefano Zampini 588df4397b0SStefano Zampini Level: beginner 589df4397b0SStefano Zampini 59087497f52SBarry Smith $ `FILE_MODE_UNDEFINED` - initial invalid value 59187497f52SBarry Smith $ `FILE_MODE_READ` - open a file at its beginning for reading 59287497f52SBarry Smith $ `FILE_MODE_WRITE` - open a file at its beginning for writing (will create if the file does not exist) 59387497f52SBarry Smith $ `FILE_MODE_APPEND` - open a file at end for writing 59487497f52SBarry Smith $ `FILE_MODE_UPDATE` - open a file for updating, meaning for reading and writing 59587497f52SBarry Smith $ `FILE_MODE_APPEND_UPDATE` - open a file for updating, meaning for reading and writing, at the end 596df4397b0SStefano Zampini 597db781477SPatrick Sanan .seealso: `PetscViewerFileSetMode()` 598df4397b0SStefano Zampini E*/ 5999371c9d4SSatish Balay typedef enum { 6009371c9d4SSatish Balay FILE_MODE_UNDEFINED = -1, 6019371c9d4SSatish Balay FILE_MODE_READ = 0, 6029371c9d4SSatish Balay FILE_MODE_WRITE, 6039371c9d4SSatish Balay FILE_MODE_APPEND, 6049371c9d4SSatish Balay FILE_MODE_UPDATE, 6059371c9d4SSatish Balay FILE_MODE_APPEND_UPDATE 6069371c9d4SSatish Balay } PetscFileMode; 607df4397b0SStefano Zampini 608df4397b0SStefano Zampini typedef void *PetscDLHandle; 6099371c9d4SSatish Balay typedef enum { 6109371c9d4SSatish Balay PETSC_DL_DECIDE = 0, 6119371c9d4SSatish Balay PETSC_DL_NOW = 1, 6129371c9d4SSatish Balay PETSC_DL_LOCAL = 2 6139371c9d4SSatish Balay } PetscDLMode; 614df4397b0SStefano Zampini 615df4397b0SStefano Zampini /*S 6167243573dSPierre Jolivet PetscObjectList - Linked list of PETSc objects, each accessible by string name 617df4397b0SStefano Zampini 618df4397b0SStefano Zampini Level: developer 619df4397b0SStefano Zampini 62087497f52SBarry Smith Note: 62187497f52SBarry Smith Used by `PetscObjectCompose()` and `PetscObjectQuery()` 622df4397b0SStefano Zampini 623db781477SPatrick Sanan .seealso: `PetscObjectListAdd()`, `PetscObjectListDestroy()`, `PetscObjectListFind()`, `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscFunctionList` 624df4397b0SStefano Zampini S*/ 625df4397b0SStefano Zampini typedef struct _n_PetscObjectList *PetscObjectList; 626df4397b0SStefano Zampini 627df4397b0SStefano Zampini /*S 628df4397b0SStefano Zampini PetscDLLibrary - Linked list of dynamics libraries to search for functions 629df4397b0SStefano Zampini 630df4397b0SStefano Zampini Level: advanced 631df4397b0SStefano Zampini 632db781477SPatrick Sanan .seealso: `PetscDLLibraryOpen()` 633df4397b0SStefano Zampini S*/ 634df4397b0SStefano Zampini typedef struct _n_PetscDLLibrary *PetscDLLibrary; 635df4397b0SStefano Zampini 636df4397b0SStefano Zampini /*S 637df4397b0SStefano Zampini PetscContainer - Simple PETSc object that contains a pointer to any required data 638df4397b0SStefano Zampini 639df4397b0SStefano Zampini Level: advanced 640df4397b0SStefano Zampini 64187497f52SBarry Smith Note: 64287497f52SBarry Smith This is useful to attach arbitrary data to a `PetscObject` with `PetscObjectCompose()` and `PetscObjectQuery()` 64387497f52SBarry Smith 64487497f52SBarry Smith .seealso: `PetscObject`, `PetscContainerCreate()`, `PetscObjectCompose()`, `PetscObjectQuery()` 645df4397b0SStefano Zampini S*/ 646df4397b0SStefano Zampini typedef struct _p_PetscContainer *PetscContainer; 647df4397b0SStefano Zampini 648df4397b0SStefano Zampini /*S 649df4397b0SStefano Zampini PetscRandom - Abstract PETSc object that manages generating random numbers 650df4397b0SStefano Zampini 651df4397b0SStefano Zampini Level: intermediate 652df4397b0SStefano Zampini 653db781477SPatrick Sanan .seealso: `PetscRandomCreate()`, `PetscRandomGetValue()`, `PetscRandomType` 654df4397b0SStefano Zampini S*/ 655df4397b0SStefano Zampini typedef struct _p_PetscRandom *PetscRandom; 656df4397b0SStefano Zampini 657df4397b0SStefano Zampini /* 658df4397b0SStefano Zampini In binary files variables are stored using the following lengths, 659df4397b0SStefano Zampini regardless of how they are stored in memory on any one particular 660df4397b0SStefano Zampini machine. Use these rather then sizeof() in computing sizes for 661df4397b0SStefano Zampini PetscBinarySeek(). 662df4397b0SStefano Zampini */ 663df4397b0SStefano Zampini #define PETSC_BINARY_INT_SIZE (32 / 8) 664df4397b0SStefano Zampini #define PETSC_BINARY_FLOAT_SIZE (32 / 8) 665df4397b0SStefano Zampini #define PETSC_BINARY_CHAR_SIZE (8 / 8) 666df4397b0SStefano Zampini #define PETSC_BINARY_SHORT_SIZE (16 / 8) 667df4397b0SStefano Zampini #define PETSC_BINARY_DOUBLE_SIZE (64 / 8) 668df4397b0SStefano Zampini #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar) 669df4397b0SStefano Zampini 670df4397b0SStefano Zampini /*E 67187497f52SBarry Smith PetscBinarySeekType - argument to `PetscBinarySeek()` 672df4397b0SStefano Zampini 673df4397b0SStefano Zampini Level: advanced 674df4397b0SStefano Zampini 675db781477SPatrick Sanan .seealso: `PetscBinarySeek()`, `PetscBinarySynchronizedSeek()` 676df4397b0SStefano Zampini E*/ 6779371c9d4SSatish Balay typedef enum { 6789371c9d4SSatish Balay PETSC_BINARY_SEEK_SET = 0, 6799371c9d4SSatish Balay PETSC_BINARY_SEEK_CUR = 1, 6809371c9d4SSatish Balay PETSC_BINARY_SEEK_END = 2 6819371c9d4SSatish Balay } PetscBinarySeekType; 682df4397b0SStefano Zampini 683df4397b0SStefano Zampini /*E 684df4397b0SStefano Zampini PetscBuildTwoSidedType - algorithm for setting up two-sided communication 685df4397b0SStefano Zampini 68687497f52SBarry Smith $ `PETSC_BUILDTWOSIDED_ALLREDUCE` - classical algorithm using an MPI_Allreduce with 687df4397b0SStefano Zampini $ a buffer of length equal to the communicator size. Not memory-scalable due to 688df4397b0SStefano Zampini $ the large reduction size. Requires only MPI-1. 68987497f52SBarry Smith $ `PETSC_BUILDTWOSIDED_IBARRIER` - nonblocking algorithm based on MPI_Issend and MPI_Ibarrier. 690df4397b0SStefano Zampini $ Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires MPI-3. 69187497f52SBarry Smith $ `PETSC_BUILDTWOSIDED_REDSCATTER` - similar to above, but use more optimized function 692df4397b0SStefano Zampini $ that only communicates the part of the reduction that is necessary. Requires MPI-2. 693df4397b0SStefano Zampini 694df4397b0SStefano Zampini Level: developer 695df4397b0SStefano Zampini 696db781477SPatrick Sanan .seealso: `PetscCommBuildTwoSided()`, `PetscCommBuildTwoSidedSetType()`, `PetscCommBuildTwoSidedGetType()` 697df4397b0SStefano Zampini E*/ 698df4397b0SStefano Zampini typedef enum { 699df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_NOTSET = -1, 700df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_ALLREDUCE = 0, 701df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_IBARRIER = 1, 702df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_REDSCATTER = 2 703df4397b0SStefano Zampini /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */ 704df4397b0SStefano Zampini } PetscBuildTwoSidedType; 705df4397b0SStefano Zampini 706aa2d33c1SMatthew G. Knepley /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */ 707df4397b0SStefano Zampini /*E 708df4397b0SStefano Zampini InsertMode - Whether entries are inserted or added into vectors or matrices 709df4397b0SStefano Zampini 710df4397b0SStefano Zampini Level: beginner 711df4397b0SStefano Zampini 712db781477SPatrick Sanan .seealso: `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 713db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, 714db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()` 715df4397b0SStefano Zampini E*/ 7169371c9d4SSatish Balay typedef enum { 7179371c9d4SSatish Balay NOT_SET_VALUES, 7189371c9d4SSatish Balay INSERT_VALUES, 7199371c9d4SSatish Balay ADD_VALUES, 7209371c9d4SSatish Balay MAX_VALUES, 7219371c9d4SSatish Balay MIN_VALUES, 7229371c9d4SSatish Balay INSERT_ALL_VALUES, 7239371c9d4SSatish Balay ADD_ALL_VALUES, 7249371c9d4SSatish Balay INSERT_BC_VALUES, 7259371c9d4SSatish Balay ADD_BC_VALUES 7269371c9d4SSatish Balay } InsertMode; 727df4397b0SStefano Zampini 728df4397b0SStefano Zampini /*MC 729df4397b0SStefano Zampini INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value 730df4397b0SStefano Zampini 731df4397b0SStefano Zampini Level: beginner 732df4397b0SStefano Zampini 733db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 734db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `ADD_VALUES`, 735db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 736df4397b0SStefano Zampini 737df4397b0SStefano Zampini M*/ 738df4397b0SStefano Zampini 739df4397b0SStefano Zampini /*MC 740df4397b0SStefano Zampini ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the 741df4397b0SStefano Zampini value into that location 742df4397b0SStefano Zampini 743df4397b0SStefano Zampini Level: beginner 744df4397b0SStefano Zampini 745db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 746db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `INSERT_VALUES`, 747db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 748df4397b0SStefano Zampini 749df4397b0SStefano Zampini M*/ 750df4397b0SStefano Zampini 751df4397b0SStefano Zampini /*MC 752df4397b0SStefano Zampini MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location 753df4397b0SStefano Zampini 754df4397b0SStefano Zampini Level: beginner 755df4397b0SStefano Zampini 756db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 757df4397b0SStefano Zampini 758df4397b0SStefano Zampini M*/ 759df4397b0SStefano Zampini 760421aa1e7SJunchao Zhang /*MC 761421aa1e7SJunchao Zhang MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location 762421aa1e7SJunchao Zhang 763421aa1e7SJunchao Zhang Level: beginner 764421aa1e7SJunchao Zhang 765db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 766421aa1e7SJunchao Zhang 767421aa1e7SJunchao Zhang M*/ 768421aa1e7SJunchao Zhang 769df4397b0SStefano Zampini /*S 770df4397b0SStefano Zampini PetscSubcomm - A decomposition of an MPI communicator into subcommunicators 771df4397b0SStefano Zampini 772df4397b0SStefano Zampini Notes: 77387497f52SBarry Smith After a call to `PetscSubcommSetType()`, `PetscSubcommSetTypeGeneral()`, or `PetscSubcommSetFromOptions()` one may call 77487497f52SBarry Smith $ `PetscSubcommChild()` returns the associated subcommunicator on this process 77587497f52SBarry Smith $ `PetscSubcommContiguousParent()` returns a parent communitor but with all child of the same subcommunicator having contiguous rank 776df4397b0SStefano Zampini 777df4397b0SStefano Zampini Sample Usage: 77887497f52SBarry Smith .vb 77987497f52SBarry Smith `PetscSubcommCreate()` 78087497f52SBarry Smith `PetscSubcommSetNumber()` 78187497f52SBarry Smith `PetscSubcommSetType`(`PETSC_SUBCOMM_INTERLACED`); 78287497f52SBarry Smith ccomm = `PetscSubcommChild()` 78387497f52SBarry Smith `PetscSubcommDestroy()` 78487497f52SBarry Smith .ve 785df4397b0SStefano Zampini 786df4397b0SStefano Zampini Level: advanced 787df4397b0SStefano Zampini 788df4397b0SStefano Zampini Notes: 78987497f52SBarry 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 79087497f52SBarry Smith $ `PETSC_SUBCOMM_CONTIGUOUS` - each new communicator contains a set of process with contiguous ranks in the original MPI communicator 79187497f52SBarry Smith $ `PETSC_SUBCOMM_INTERLACED` - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator 792df4397b0SStefano Zampini 793df4397b0SStefano Zampini Example: Consider a communicator with six processes split into 3 subcommunicators. 79487497f52SBarry 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 79587497f52SBarry Smith $ `PETSC_SUBCOMM_INTERLACED` - the first communicator contains rank 0,3, the second 1,4 and the third 2,5 796df4397b0SStefano Zampini 79787497f52SBarry Smith Developer Note: 79887497f52SBarry Smith This is used in objects such as `PCREDUNDANT` to manage the subcommunicators on which the redundant computations 799df4397b0SStefano Zampini are performed. 800df4397b0SStefano Zampini 801db781477SPatrick Sanan .seealso: `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()` 802df4397b0SStefano Zampini 803df4397b0SStefano Zampini S*/ 804df4397b0SStefano Zampini typedef struct _n_PetscSubcomm *PetscSubcomm; 8059371c9d4SSatish Balay typedef enum { 8069371c9d4SSatish Balay PETSC_SUBCOMM_GENERAL = 0, 8079371c9d4SSatish Balay PETSC_SUBCOMM_CONTIGUOUS = 1, 8089371c9d4SSatish Balay PETSC_SUBCOMM_INTERLACED = 2 8099371c9d4SSatish Balay } PetscSubcommType; 810df4397b0SStefano Zampini 811df4397b0SStefano Zampini /*S 812df4397b0SStefano Zampini PetscHeap - A simple class for managing heaps 813df4397b0SStefano Zampini 814df4397b0SStefano Zampini Level: intermediate 815df4397b0SStefano Zampini 816db781477SPatrick Sanan .seealso: `PetscHeapCreate()`, `PetscHeapAdd()`, `PetscHeapPop()`, `PetscHeapPeek()`, `PetscHeapStash()`, `PetscHeapUnstash()`, `PetscHeapView()`, `PetscHeapDestroy()` 817df4397b0SStefano Zampini S*/ 818df4397b0SStefano Zampini typedef struct _PetscHeap *PetscHeap; 819df4397b0SStefano Zampini 820df4397b0SStefano Zampini typedef struct _n_PetscShmComm *PetscShmComm; 821df4397b0SStefano Zampini typedef struct _n_PetscOmpCtrl *PetscOmpCtrl; 822df4397b0SStefano Zampini 823df4397b0SStefano Zampini /*S 824df4397b0SStefano Zampini PetscSegBuffer - a segmented extendable buffer 825df4397b0SStefano Zampini 826df4397b0SStefano Zampini Level: developer 827df4397b0SStefano Zampini 828db781477SPatrick Sanan .seealso: `PetscSegBufferCreate()`, `PetscSegBufferGet()`, `PetscSegBufferExtract()`, `PetscSegBufferDestroy()` 829df4397b0SStefano Zampini S*/ 830df4397b0SStefano Zampini typedef struct _n_PetscSegBuffer *PetscSegBuffer; 831df4397b0SStefano Zampini 832df4397b0SStefano Zampini typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted; 833df4397b0SStefano Zampini #endif 834