Actual source code: petscsystypes.h

  1: /* Portions of this code are under:
  2:    Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
  3: */

  5: #pragma once

  7: #include <petscconf.h>
  8: #include <petscconf_poison.h>
  9: #include <petscfix.h>
 10: #include <petscmacros.h>
 11: #include <stddef.h>

 13: /* SUBMANSEC = Sys */

 15: #include <limits.h> // INT_MIN, INT_MAX, CHAR_BIT

 17: #if defined(__clang__) || (PETSC_CPP_VERSION >= 17)
 18:   // clang allows both [[nodiscard]] and __attribute__((warn_unused_result)) on type
 19:   // definitions. GCC, however, does not, so check that we are using C++17 [[nodiscard]]
 20:   // instead of __attribute__((warn_unused_result))
 21:   #define PETSC_ERROR_CODE_NODISCARD PETSC_NODISCARD
 22: #else
 23:   #define PETSC_ERROR_CODE_NODISCARD
 24: #endif

 26: #ifdef PETSC_CLANG_STATIC_ANALYZER
 27:   #undef PETSC_USE_STRICT_PETSCERRORCODE
 28: #endif

 30: #ifdef PETSC_USE_STRICT_PETSCERRORCODE
 31:   #define PETSC_ERROR_CODE_TYPEDEF   typedef
 32:   #define PETSC_ERROR_CODE_ENUM_NAME PetscErrorCode
 33: #else
 34:   #define PETSC_ERROR_CODE_TYPEDEF
 35:   #define PETSC_ERROR_CODE_ENUM_NAME
 36: #endif

 38: /*E
 39:   PetscErrorCode - Datatype used to return PETSc error codes.

 41:   Level: beginner

 43:   Notes:
 44:   Virtually all PETSc functions return an error code. It is the callers responsibility to check
 45:   the value of the returned error code after each PETSc call to determine if any errors
 46:   occurred. A set of convenience macros (e.g. `PetscCall()`, `PetscCallVoid()`) are provided
 47:   for this purpose. Failing to properly check for errors is not supported, as errors may leave
 48:   PETSc in an undetermined state.

 50:   One can retrieve the error string corresponding to a particular error code using
 51:   `PetscErrorMessage()`.

 53:   The user can also configure PETSc with the `--with-strict-petscerrorcode` option to enable
 54:   compiler warnings when the returned error codes are not captured and checked. Users are
 55:   *heavily* encouraged to opt-in to this option, as it will become enabled by default in a
 56:   future release.

 58:   Developer Notes:

 60:   These are the generic error codes. These error codes are used in many different places in the
 61:   PETSc source code. The C-string versions are at defined in `PetscErrorStrings[]` in
 62:   `src/sys/error/err.c`, while the Fortran versions are defined in
 63:   `src/sys/f90-mod/petscerror.h`. Any changes here must also be made in both locations.

 65: .seealso: `PetscErrorMessage()`, `PetscCall()`, `SETERRQ()`
 66: E*/
 67: PETSC_ERROR_CODE_TYPEDEF enum PETSC_ERROR_CODE_NODISCARD {
 68:   PETSC_SUCCESS                   = 0,
 69:   PETSC_ERR_BOOLEAN_MACRO_FAILURE = 1, /* do not use */

 71:   PETSC_ERR_MIN_VALUE = 54, /* should always be one less then the smallest value */

 73:   PETSC_ERR_MEM            = 55, /* unable to allocate requested memory */
 74:   PETSC_ERR_SUP            = 56, /* no support for requested operation */
 75:   PETSC_ERR_SUP_SYS        = 57, /* no support for requested operation on this computer system */
 76:   PETSC_ERR_ORDER          = 58, /* operation done in wrong order */
 77:   PETSC_ERR_SIG            = 59, /* signal received */
 78:   PETSC_ERR_FP             = 72, /* floating point exception */
 79:   PETSC_ERR_COR            = 74, /* corrupted PETSc object */
 80:   PETSC_ERR_LIB            = 76, /* error in library called by PETSc */
 81:   PETSC_ERR_PLIB           = 77, /* PETSc library generated inconsistent data */
 82:   PETSC_ERR_MEMC           = 78, /* memory corruption */
 83:   PETSC_ERR_CONV_FAILED    = 82, /* iterative method (KSP or SNES) failed */
 84:   PETSC_ERR_USER           = 83, /* user has not provided needed function */
 85:   PETSC_ERR_SYS            = 88, /* error in system call */
 86:   PETSC_ERR_POINTER        = 70, /* pointer does not point to valid address */
 87:   PETSC_ERR_MPI_LIB_INCOMP = 87, /* MPI library at runtime is not compatible with MPI user compiled with */

 89:   PETSC_ERR_ARG_SIZ          = 60, /* nonconforming object sizes used in operation */
 90:   PETSC_ERR_ARG_IDN          = 61, /* two arguments not allowed to be the same */
 91:   PETSC_ERR_ARG_WRONG        = 62, /* wrong argument (but object probably ok) */
 92:   PETSC_ERR_ARG_CORRUPT      = 64, /* null or corrupted PETSc object as argument */
 93:   PETSC_ERR_ARG_OUTOFRANGE   = 63, /* input argument, out of range */
 94:   PETSC_ERR_ARG_BADPTR       = 68, /* invalid pointer argument */
 95:   PETSC_ERR_ARG_NOTSAMETYPE  = 69, /* two args must be same object type */
 96:   PETSC_ERR_ARG_NOTSAMECOMM  = 80, /* two args must be same communicators */
 97:   PETSC_ERR_ARG_WRONGSTATE   = 73, /* object in argument is in wrong state, e.g. unassembled mat */
 98:   PETSC_ERR_ARG_TYPENOTSET   = 89, /* the type of the object has not yet been set */
 99:   PETSC_ERR_ARG_INCOMP       = 75, /* two arguments are incompatible */
100:   PETSC_ERR_ARG_NULL         = 85, /* argument is null that should not be */
101:   PETSC_ERR_ARG_UNKNOWN_TYPE = 86, /* type name doesn't match any registered type */

103:   PETSC_ERR_FILE_OPEN       = 65, /* unable to open file */
104:   PETSC_ERR_FILE_READ       = 66, /* unable to read from file */
105:   PETSC_ERR_FILE_WRITE      = 67, /* unable to write to file */
106:   PETSC_ERR_FILE_UNEXPECTED = 79, /* unexpected data in file */

108:   PETSC_ERR_MAT_LU_ZRPVT = 71, /* detected a zero pivot during LU factorization */
109:   PETSC_ERR_MAT_CH_ZRPVT = 81, /* detected a zero pivot during Cholesky factorization */

111:   PETSC_ERR_INT_OVERFLOW   = 84,
112:   PETSC_ERR_FLOP_COUNT     = 90,
113:   PETSC_ERR_NOT_CONVERGED  = 91,  /* solver did not converge */
114:   PETSC_ERR_MISSING_FACTOR = 92,  /* MatGetFactor() failed */
115:   PETSC_ERR_OPT_OVERWRITE  = 93,  /* attempted to over write options which should not be changed */
116:   PETSC_ERR_WRONG_MPI_SIZE = 94,  /* example/application run with number of MPI ranks it does not support */
117:   PETSC_ERR_USER_INPUT     = 95,  /* missing or incorrect user input */
118:   PETSC_ERR_GPU_RESOURCE   = 96,  /* unable to load a GPU resource, for example cuBLAS */
119:   PETSC_ERR_GPU            = 97,  /* An error from a GPU call, this may be due to lack of resources on the GPU or a true error in the call */
120:   PETSC_ERR_MPI            = 98,  /* general MPI error */
121:   PETSC_ERR_RETURN         = 99,  /* PetscError() incorrectly returned an error code of 0 */
122:   PETSC_ERR_MEM_LEAK       = 100, /* memory alloc/free imbalance */
123:   PETSC_ERR_MAX_VALUE      = 101, /* this is always the one more than the largest error code */

125:   /*
126:     do not use, exist purely to make the enum bounds equal that of a regular int (so conversion
127:     to int in main() is not undefined behavior)
128:   */
129:   PETSC_ERR_MIN_SIGNED_BOUND_DO_NOT_USE = INT_MIN,
130:   PETSC_ERR_MAX_SIGNED_BOUND_DO_NOT_USE = INT_MAX
131: } PETSC_ERROR_CODE_ENUM_NAME;

133: #ifndef PETSC_USE_STRICT_PETSCERRORCODE
134: typedef int PetscErrorCode;

136:   /*
137:   Needed so that C++ lambdas can deduce the return type as PetscErrorCode from
138:   PetscFunctionReturn(PETSC_SUCCESS). Otherwise we get

140:   error: return type '(unnamed enum at include/petscsystypes.h:50:1)' must match previous
141:   return type 'int' when lambda expression has unspecified explicit return type
142:   PetscFunctionReturn(PETSC_SUCCESS);
143:   ^
144: */
145:   #define PETSC_SUCCESS ((PetscErrorCode)0)
146: #endif

148: #undef PETSC_ERROR_CODE_NODISCARD
149: #undef PETSC_ERROR_CODE_TYPEDEF
150: #undef PETSC_ERROR_CODE_ENUM_NAME

152: /*MC
153:     PetscClassId - A unique id used to identify each PETSc class.

155:     Level: developer

157:     Note:
158:     Use `PetscClassIdRegister()` to obtain a new value for a new class being created. Usually
159:          XXXInitializePackage() calls it for each class it defines.

161:     Developer Note:
162:     Internal integer stored in the `_p_PetscObject` data structure. These are all computed by an offset from the lowest one, `PETSC_SMALLEST_CLASSID`.

164: .seealso: `PetscClassIdRegister()`, `PetscLogEventRegister()`, `PetscHeaderCreate()`
165: M*/
166: typedef int PetscClassId;

168: /*MC
169:     PetscMPIInt - datatype used to represent 'int' parameters to MPI functions.

171:     Level: intermediate

173:     Notes:
174:     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
175:            standard C/Fortran integers are 32-bit then this is NOT the same as `PetscInt`; it remains 32-bit.

177:     `PetscMPIIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscMPIInt`, if not it
178:       generates a `PETSC_ERR_ARG_OUTOFRANGE` error.

180: .seealso: `PetscBLASInt`, `PetscInt`, `PetscMPIIntCast()`
181: M*/
182: typedef int PetscMPIInt;

184: /* Limit MPI to 32-bits */
185: enum {
186:   PETSC_MPI_INT_MIN = INT_MIN,
187:   PETSC_MPI_INT_MAX = INT_MAX
188: };

190: /*MC
191:     PetscSizeT - datatype used to represent sizes in memory (like `size_t`)

193:     Level: intermediate

195:     Notes:
196:     This is equivalent to `size_t`, but defined for consistency with Fortran, which lacks a native equivalent of `size_t`.

198: .seealso: `PetscInt`, `PetscInt64`, `PetscCount`
199: M*/
200: typedef size_t PetscSizeT;

202: /*MC
203:     PetscCount - signed datatype used to represent counts

205:     Level: intermediate

207:     Notes:
208:     This is equivalent to `ptrdiff_t`, but defined for consistency with Fortran, which lacks a native equivalent of `ptrdiff_t`.

210:     Use `PetscCount_FMT` to format with `PetscPrintf()`, `printf()`, and related functions.

212: .seealso: `PetscInt`, `PetscInt64`, `PetscSizeT`
213: M*/
214: typedef ptrdiff_t PetscCount;
215: #define PetscCount_FMT "td"

217: /*MC
218:     PetscEnum - datatype used to pass enum types within PETSc functions.

220:     Level: intermediate

222: .seealso: `PetscOptionsGetEnum()`, `PetscOptionsEnum()`, `PetscBagRegisterEnum()`
223: M*/
224: typedef enum {
225:   ENUM_DUMMY
226: } PetscEnum;

228: typedef short PetscShort;
229: typedef char  PetscChar;
230: typedef float PetscFloat;

232: /*MC
233:   PetscInt - PETSc type that represents an integer, used primarily to
234:       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.

236:   Level: beginner

238:   Notes:
239:   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`.

241: .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscIntCast()`
242: M*/

244: #if defined(PETSC_HAVE_STDINT_H)
245:   #include <stdint.h>
246: #endif
247: #if defined(PETSC_HAVE_INTTYPES_H)
250:   #endif
251:   #include <inttypes.h>
252:   #if !defined(PRId64)
253:     #define PRId64 "ld"
254:   #endif
255: #endif

257: #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 */
258: typedef int64_t PetscInt64;

260:   #define PETSC_INT64_MIN INT64_MIN
261:   #define PETSC_INT64_MAX INT64_MAX

263: #elif (PETSC_SIZEOF_LONG_LONG == 8)
264: typedef long long PetscInt64;

266:   #define PETSC_INT64_MIN LLONG_MIN
267:   #define PETSC_INT64_MAX LLONG_MAX

269: #elif defined(PETSC_HAVE___INT64)
270: typedef __int64 PetscInt64;

272:   #define PETSC_INT64_MIN INT64_MIN
273:   #define PETSC_INT64_MAX INT64_MAX

275: #else
276:   #error "cannot determine PetscInt64 type"
277: #endif

279: typedef int32_t PetscInt32;
280: #define PETSC_INT32_MIN INT32_MIN
281: #define PETSC_INT32_MAX INT32_MAX

283: #if defined(PETSC_USE_64BIT_INDICES)
284: typedef PetscInt64 PetscInt;

286:   #define PETSC_INT_MIN PETSC_INT64_MIN
287:   #define PETSC_INT_MAX PETSC_INT64_MAX
288:   #define PetscInt_FMT  PetscInt64_FMT
289: #else
290: typedef int       PetscInt;

292: enum {
293:   PETSC_INT_MIN = INT_MIN,
294:   PETSC_INT_MAX = INT_MAX
295: };

297:   #define PetscInt_FMT "d"
298: #endif

300: #define PETSC_MIN_INT    PETSC_INT_MIN
301: #define PETSC_MAX_INT    PETSC_INT_MAX
302: #define PETSC_MAX_UINT16 65535

304: #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 */
305:   #define MPIU_INT64     MPI_INT64_T
306:   #define PetscInt64_FMT PRId64
307: #elif (PETSC_SIZEOF_LONG_LONG == 8)
308:   #define MPIU_INT64     MPI_LONG_LONG_INT
309:   #define PetscInt64_FMT "lld"
310: #elif defined(PETSC_HAVE___INT64)
311:   #define MPIU_INT64     MPI_INT64_T
312:   #define PetscInt64_FMT "ld"
313: #else
314:   #error "cannot determine PetscInt64 type"
315: #endif

317: #define MPIU_INT32     MPI_INT32_T
318: #define PetscInt32_FMT PRId32

320: /*MC
321:    PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions.

323:    Level: intermediate

325:    Notes:
326:    Usually this is the same as `PetscInt`, but if PETSc was built with `--with-64-bit-indices` but
327:    standard C/Fortran integers are 32-bit then this may not be the same as `PetscInt`,
328:    except on some BLAS/LAPACK implementations that support 64-bit integers see the notes below.

330:    `PetscErrorCode` `PetscBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscBLASInt`, if not it
331:     generates a `PETSC_ERR_ARG_OUTOFRANGE` error

333:    Installation Notes:
334:     ./configure automatically determines the size of the integers used by BLAS/LAPACK except when `--with-batch` is used
335:     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-indices`

337:     MATLAB ships with BLAS and LAPACK that use 64-bit integers, for example if you run ./configure with, the option
338:      `--with-blaslapack-lib`=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib]

340:     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
341:     against the 64-bit version, otherwise it uses the 32-bit version

343:     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

345:     External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64-bit integers to BLAS/LAPACK so cannot
346:     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
347:     these external libraries while using 64-bit integer BLAS/LAPACK.

349: .seealso: `PetscMPIInt`, `PetscInt`, `PetscBLASIntCast()`
350: M*/
351: #if defined(PETSC_HAVE_64BIT_BLAS_INDICES)
352: typedef PetscInt64 PetscBLASInt;

354:   #define PETSC_BLAS_INT_MIN PETSC_INT64_MIN
355:   #define PETSC_BLAS_INT_MAX PETSC_INT64_MAX
356:   #define PetscBLASInt_FMT   PetscInt64_FMT
357: #else
358: typedef int PetscBLASInt;

360: enum {
361:   PETSC_BLAS_INT_MIN = INT_MIN,
362:   PETSC_BLAS_INT_MAX = INT_MAX
363: };

365:   #define PetscBLASInt_FMT "d"
366: #endif

368: /*MC
369:    PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions.

371:    Level: intermediate

373:    Notes:
374:    As of this writing `PetscCuBLASInt` is always the system `int`.

376:   `PetscErrorCode` `PetscCuBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscCuBLASInt`, if not it
377:    generates a `PETSC_ERR_ARG_OUTOFRANGE` error

379: .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscCuBLASIntCast()`
380: M*/
381: typedef int PetscCuBLASInt;

383: enum {
384:   PETSC_CUBLAS_INT_MIN = INT_MIN,
385:   PETSC_CUBLAS_INT_MAX = INT_MAX
386: };

388: /*MC
389:    PetscHipBLASInt - datatype used to represent 'int' parameters to hipBLAS/hipSOLVER functions.

391:    Level: intermediate

393:    Notes:
394:    As of this writing `PetscHipBLASInt` is always the system `int`.

396:    `PetscErrorCode` `PetscHipBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscHipBLASInt`, if not it
397:    generates a `PETSC_ERR_ARG_OUTOFRANGE` error

399: .seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscHipBLASIntCast()
400: M*/
401: typedef int PetscHipBLASInt;

403: enum {
404:   PETSC_HIPBLAS_INT_MIN = INT_MIN,
405:   PETSC_HIPBLAS_INT_MAX = INT_MAX
406: };

408: /*E
409:     PetscBool  - Logical variable. Actually an enum in C and a logical in Fortran.

411:    Level: beginner

413:    Developer Note:
414:    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
415:       boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms.

417: .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PetscBool3`
418: E*/
419: typedef enum {
420:   PETSC_FALSE,
421:   PETSC_TRUE
422: } PetscBool;
423: PETSC_EXTERN const char *const PetscBools[];

425: /*E
426:     PetscBool3  - Ternary logical variable. Actually an enum in C and a 4 byte integer in Fortran.

428:    Level: beginner

430:    Note:
431:    Should not be used with the if (flg) or if (!flg) syntax.

433: .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PETSC_BOOL3_TRUE`, `PETSC_BOOL3_FALSE`, `PETSC_BOOL3_UNKNOWN`
434: E*/
435: typedef enum {
436:   PETSC_BOOL3_FALSE,
437:   PETSC_BOOL3_TRUE,
438:   PETSC_BOOL3_UNKNOWN = -1
439: } PetscBool3;

441: #define PetscBool3ToBool(a) ((a) == PETSC_BOOL3_TRUE ? PETSC_TRUE : PETSC_FALSE)
442: #define PetscBoolToBool3(a) ((a) == PETSC_TRUE ? PETSC_BOOL3_TRUE : PETSC_BOOL3_FALSE)

444: /*MC
445:    PetscReal - PETSc type that represents a real number version of `PetscScalar`

447:    Level: beginner

449:    Notes:
450:    For MPI calls that require datatypes, use `MPIU_REAL` as the datatype for `PetscReal` and `MPIU_SUM`, `MPIU_MAX`, etc. for operations.
451:    They will automatically work correctly regardless of the size of `PetscReal`.

453:    See `PetscScalar` for details on how to ./configure the size of `PetscReal`.

455: .seealso: `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`
456: M*/

458: #if defined(PETSC_USE_REAL_SINGLE)
459: typedef float PetscReal;
460: #elif defined(PETSC_USE_REAL_DOUBLE)
461: typedef double    PetscReal;
462: #elif defined(PETSC_USE_REAL___FLOAT128)
463:   #if defined(__cplusplus)
464: extern "C" {
465:   #endif
466:   #include <quadmath.h>
467:   #if defined(__cplusplus)
468: }
469:   #endif
470: typedef __float128 PetscReal;
471: #elif defined(PETSC_USE_REAL___FP16)
472: typedef __fp16 PetscReal;
473: #endif /* PETSC_USE_REAL_* */

475: /*MC
476:    PetscComplex - PETSc type that represents a complex number with precision matching that of `PetscReal`.

478:    Synopsis:
479: #include <petscsys.h>
480:    PetscComplex number = 1. + 2.*PETSC_i;

482:    Level: beginner

484:    Notes:
485:    For MPI calls that require datatypes, use `MPIU_COMPLEX` as the datatype for `PetscComplex` and `MPIU_SUM` etc for operations.
486:           They will automatically work correctly regardless of the size of `PetscComplex`.

488:           See `PetscScalar` for details on how to ./configure the size of `PetscReal`

490:           Complex numbers are automatically available if PETSc was able to find a working complex implementation

492:     PETSc has a 'fix' for complex numbers to support expressions such as `std::complex<PetscReal>` + `PetscInt`, which are not supported by the standard
493:     C++ library, but are convenient for petsc users. If the C++ compiler is able to compile code in `petsccxxcomplexfix.h` (This is checked by
494:     configure), we include `petsccxxcomplexfix.h` to provide this convenience.

496:     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`
497:     at the beginning of the C++ file to skip the fix.

499: .seealso: `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i`
500: M*/
501: #if !defined(PETSC_SKIP_COMPLEX)
502:   #if defined(PETSC_CLANGUAGE_CXX)
503:     #if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128)
504:       #if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */
505:         #define PETSC_HAVE_COMPLEX 1
506:       #elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */
507:         #define PETSC_HAVE_COMPLEX 1
508:       #endif
509:     #elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX)
510:       #define PETSC_HAVE_COMPLEX 1
511:     #endif
512:   #else /* !PETSC_CLANGUAGE_CXX */
513:     #if !defined(PETSC_USE_REAL___FP16)
515:         #define PETSC_HAVE_COMPLEX 1
516:       #elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */
517:         #define PETSC_HAVE_COMPLEX 1
518:       #endif
519:     #endif
520:   #endif /* PETSC_CLANGUAGE_CXX */
521: #endif   /* !PETSC_SKIP_COMPLEX */

523: #if defined(PETSC_HAVE_COMPLEX)
524:   #if defined(__cplusplus) /* C++ complex support */
525:     /* Locate a C++ complex template library */
526:     #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */
527:       #define petsccomplexlib Kokkos
528:       #include <Kokkos_Complex.hpp>
529:     #elif defined(__CUDACC__) || defined(__HIPCC__)
530:       #define petsccomplexlib thrust
531:       #include <thrust/complex.h>
532:     #elif defined(PETSC_USE_REAL___FLOAT128)
533:       #include <complex.h>
534:     #else
535:       #define petsccomplexlib std
536:       #include <complex>
537:     #endif

539:     /* Define PetscComplex based on the precision */
540:     #if defined(PETSC_USE_REAL_SINGLE)
541: typedef petsccomplexlib::complex<float> PetscComplex;
542:     #elif defined(PETSC_USE_REAL_DOUBLE)
543: typedef petsccomplexlib::complex<double> PetscComplex;
544:     #elif defined(PETSC_USE_REAL___FLOAT128)
545: typedef __complex128 PetscComplex;
546:     #endif

548:     /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */
549:     #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX)
550: #include <petsccxxcomplexfix.h>
551:     #endif
552:   #else /* c99 complex support */
553:     #include <complex.h>
554:     #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16)
555: typedef float _Complex PetscComplex;
556:     #elif defined(PETSC_USE_REAL_DOUBLE)
557: typedef double _Complex PetscComplex;
558:     #elif defined(PETSC_USE_REAL___FLOAT128)
559: typedef __complex128 PetscComplex;
560:     #endif /* PETSC_USE_REAL_* */
561:   #endif   /* !__cplusplus */
562: #endif     /* PETSC_HAVE_COMPLEX */

564: /*MC
565:    PetscScalar - PETSc type that represents either a double precision real number, a double precision
566:        complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured
567:        with `--with-scalar-type`=real,complex `--with-precision`=single,double,__float128,__fp16

569:    Level: beginner

571:    Note:
572:    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`.

574: .seealso: `PetscReal`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscRealPart()`, `PetscImaginaryPart()`
575: M*/

577: #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX)
578: typedef PetscComplex PetscScalar;
579: #else  /* PETSC_USE_COMPLEX */
580: typedef PetscReal PetscScalar;
581: #endif /* PETSC_USE_COMPLEX */

583: /*E
584:     PetscCopyMode  - Determines how an array or `PetscObject` passed to certain functions is copied or retained by the aggregate `PetscObject`

586:    Level: beginner

588:    Values for array input:
589: +   `PETSC_COPY_VALUES` - the array values are copied into new space, the user is free to reuse or delete the passed in array
590: .   `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
591:                           delete the array. The array MUST have been obtained with `PetscMalloc()`. Hence this mode cannot be used in Fortran.
592: -   `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
593:                           the array but the user must delete the array after the object is destroyed.

595:    Values for PetscObject:
596: +   `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.
597: .   `PETSC_OWN_POINTER` - the input `PetscObject` is referenced by pointer (with reference count), thus should not be modified by the user.
598:                           increases its reference count).
599: -   `PETSC_USE_POINTER` - invalid for `PetscObject` inputs.

601: .seealso: `PetscInsertMode`
602: E*/
603: typedef enum {
604:   PETSC_COPY_VALUES,
605:   PETSC_OWN_POINTER,
606:   PETSC_USE_POINTER
607: } PetscCopyMode;
608: PETSC_EXTERN const char *const PetscCopyModes[];

610: /*MC
611:     PETSC_FALSE - False value of `PetscBool`

613:     Level: beginner

615:     Note:
616:     Zero integer

618: .seealso: `PetscBool`, `PetscBool3`, `PETSC_TRUE`
619: M*/

621: /*MC
622:     PETSC_TRUE - True value of `PetscBool`

624:     Level: beginner

626:     Note:
627:     Nonzero integer

629: .seealso: `PetscBool`, `PetscBool3`, `PETSC_FALSE`
630: M*/

632: /*MC
633:     PetscLogDouble - Used for logging times

635:   Level: developer

637:   Note:
638:   Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc.

640: .seealso: `PetscBool`, `PetscDataType`
641: M*/
642: typedef double PetscLogDouble;

644: /*E
645:     PetscDataType - Used for handling different basic data types.

647:    Level: beginner

649:    Notes:
650:    Use of this should be avoided if one can directly use `MPI_Datatype` instead.

652:    `PETSC_INT` is the datatype for a `PetscInt`, regardless of whether it is 4 or 8 bytes.
653:    `PETSC_REAL`, `PETSC_COMPLEX` and `PETSC_SCALAR` are the datatypes for `PetscReal`, `PetscComplex` and `PetscScalar`, regardless of their sizes.

655:    Developer Notes:
656:    It would be nice if we could always just use MPI Datatypes, why can we not?

658:    If you change any values in `PetscDatatype` make sure you update their usage in
659:    share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m

661:    TODO:
662:    Remove use of improper `PETSC_ENUM`

664: .seealso: `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`,
665:           `PetscDataTypeGetSize()`
666: E*/
667: typedef enum {
668:   PETSC_DATATYPE_UNKNOWN = 0,
669:   PETSC_DOUBLE           = 1,
670:   PETSC_COMPLEX          = 2,
671:   PETSC_LONG             = 3,
672:   PETSC_SHORT            = 4,
673:   PETSC_FLOAT            = 5,
674:   PETSC_CHAR             = 6,
675:   PETSC_BIT_LOGICAL      = 7,
676:   PETSC_ENUM             = 8,
677:   PETSC_BOOL             = 9,
678:   PETSC___FLOAT128       = 10,
679:   PETSC_OBJECT           = 11,
680:   PETSC_FUNCTION         = 12,
681:   PETSC_STRING           = 13,
682:   PETSC___FP16           = 14,
683:   PETSC_STRUCT           = 15,
684:   PETSC_INT              = 16,
685:   PETSC_INT64            = 17,
686:   PETSC_COUNT            = 18,
687:   PETSC_INT32            = 19,
688: } PetscDataType;
689: PETSC_EXTERN const char *const PetscDataTypes[];

691: #if defined(PETSC_USE_REAL_SINGLE)
692:   #define PETSC_REAL PETSC_FLOAT
693: #elif defined(PETSC_USE_REAL_DOUBLE)
694:   #define PETSC_REAL PETSC_DOUBLE
695: #elif defined(PETSC_USE_REAL___FLOAT128)
696:   #define PETSC_REAL PETSC___FLOAT128
697: #elif defined(PETSC_USE_REAL___FP16)
698:   #define PETSC_REAL PETSC___FP16
699: #else
700:   #define PETSC_REAL PETSC_DOUBLE
701: #endif

703: #if defined(PETSC_USE_COMPLEX)
704:   #define PETSC_SCALAR PETSC_COMPLEX
705: #else
706:   #define PETSC_SCALAR PETSC_REAL
707: #endif

709: #define PETSC_FORTRANADDR PETSC_LONG

711: /*S
712:     PetscToken - 'Token' used for managing tokenizing strings

714:   Level: intermediate

716: .seealso: `PetscTokenCreate()`, `PetscTokenFind()`, `PetscTokenDestroy()`
717: S*/
718: typedef struct _p_PetscToken *PetscToken;

720: /*S
721:      PetscObject - any PETSc object, `PetscViewer`, `Mat`, `Vec`, `KSP` etc

723:    Level: beginner

725:    Notes:
726:    This is the base class from which all PETSc objects are derived from.

728:    In certain situations one can cast an object, for example a `Vec`, to a `PetscObject` with (`PetscObject`)vec

730: .seealso: `PetscObjectDestroy()`, `PetscObjectView()`, `PetscObjectGetName()`, `PetscObjectSetName()`, `PetscObjectReference()`, `PetscObjectDereference()`
731: S*/
732: typedef struct _p_PetscObject *PetscObject;

734: /*MC
735:     PetscObjectId - unique integer Id for a `PetscObject`

737:     Level: developer

739:     Note:
740:     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
741:     if the objects are the same. Never compare two object pointer values.

743: .seealso: `PetscObjectState`, `PetscObjectGetId()`
744: M*/
745: typedef PetscInt64 PetscObjectId;

747: /*MC
748:     PetscObjectState - integer state for a `PetscObject`

750:     Level: developer

752:     Notes:
753:     Object state is always-increasing and (for objects that track state) can be used to determine if an object has
754:     changed since the last time you interacted with it.  It is 64-bit so that it will not overflow for a very long time.

756: .seealso: `PetscObjectId`, `PetscObjectStateGet()`, `PetscObjectStateIncrease()`, `PetscObjectStateSet()`
757: M*/
758: typedef PetscInt64 PetscObjectState;

760: /*S
761:      PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed
762:       by string name

764:    Level: advanced

766: .seealso: `PetscFunctionListAdd()`, `PetscFunctionListDestroy()`
767: S*/
768: typedef struct _n_PetscFunctionList *PetscFunctionList;

770: /*E
771:   PetscFileMode - Access mode for a file.

773:   Values:
774: +  `FILE_MODE_UNDEFINED` - initial invalid value
775: .  `FILE_MODE_READ` - open a file at its beginning for reading
776: .  `FILE_MODE_WRITE` - open a file at its beginning for writing (will create if the file does not exist)
777: .  `FILE_MODE_APPEND` - open a file at end for writing
778: .  `FILE_MODE_UPDATE` - open a file for updating, meaning for reading and writing
779: -  `FILE_MODE_APPEND_UPDATE` - open a file for updating, meaning for reading and writing, at the end

781:   Level: beginner

783: .seealso: `PetscViewerFileSetMode()`
784: E*/
785: typedef enum {
786:   FILE_MODE_UNDEFINED = -1,
787:   FILE_MODE_READ      = 0,
788:   FILE_MODE_WRITE,
789:   FILE_MODE_APPEND,
790:   FILE_MODE_UPDATE,
791:   FILE_MODE_APPEND_UPDATE
792: } PetscFileMode;
793: PETSC_EXTERN const char *const PetscFileModes[];

795: typedef void *PetscDLHandle;
796: typedef enum {
797:   PETSC_DL_DECIDE = 0,
798:   PETSC_DL_NOW    = 1,
799:   PETSC_DL_LOCAL  = 2
800: } PetscDLMode;

802: /*S
803:      PetscObjectList - Linked list of PETSc objects, each accessible by string name

805:    Level: developer

807:    Note:
808:    Used by `PetscObjectCompose()` and `PetscObjectQuery()`

810: .seealso: `PetscObjectListAdd()`, `PetscObjectListDestroy()`, `PetscObjectListFind()`, `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscFunctionList`
811: S*/
812: typedef struct _n_PetscObjectList *PetscObjectList;

814: /*S
815:      PetscDLLibrary - Linked list of dynamic libraries to search for functions

817:    Level: developer

819: .seealso: `PetscDLLibraryOpen()`
820: S*/
821: typedef struct _n_PetscDLLibrary *PetscDLLibrary;

823: /*S
824:      PetscContainer - Simple PETSc object that contains a pointer to any required data

826:    Level: advanced

828:    Note:
829:    This is useful to attach arbitrary data to a `PetscObject` with `PetscObjectCompose()` and `PetscObjectQuery()`

831: .seealso: `PetscObject`, `PetscContainerCreate()`, `PetscObjectCompose()`, `PetscObjectQuery()`
832: S*/
833: typedef struct _p_PetscContainer *PetscContainer;

835: /*S
836:      PetscRandom - Abstract PETSc object that manages generating random numbers

838:    Level: intermediate

840: .seealso: `PetscRandomCreate()`, `PetscRandomGetValue()`, `PetscRandomType`
841: S*/
842: typedef struct _p_PetscRandom *PetscRandom;

844: /*
845:    In binary files variables are stored using the following lengths,
846:   regardless of how they are stored in memory on any one particular
847:   machine. Use these rather then sizeof() in computing sizes for
848:   PetscBinarySeek().
849: */
850: #define PETSC_BINARY_INT_SIZE    (32 / 8)
851: #define PETSC_BINARY_FLOAT_SIZE  (32 / 8)
852: #define PETSC_BINARY_CHAR_SIZE   (8 / 8)
853: #define PETSC_BINARY_SHORT_SIZE  (16 / 8)
854: #define PETSC_BINARY_DOUBLE_SIZE (64 / 8)
855: #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar)

857: /*E
858:   PetscBinarySeekType - argument to `PetscBinarySeek()`

860:   Values:
861: +  `PETSC_BINARY_SEEK_SET` - offset is an absolute location in the file
862: .  `PETSC_BINARY_SEEK_CUR` - offset is an offset from the current location of the file pointer
863: -  `PETSC_BINARY_SEEK_END` - offset is an offset from the end of the file

865:   Level: advanced

867: .seealso: `PetscBinarySeek()`, `PetscBinarySynchronizedSeek()`
868: E*/
869: typedef enum {
870:   PETSC_BINARY_SEEK_SET = 0,
871:   PETSC_BINARY_SEEK_CUR = 1,
872:   PETSC_BINARY_SEEK_END = 2
873: } PetscBinarySeekType;

875: /*E
876:     PetscBuildTwoSidedType - algorithm for setting up two-sided communication for use with `PetscSF`

878:    Values:
879: +  `PETSC_BUILDTWOSIDED_ALLREDUCE` - classical algorithm using an `MPI_Allreduce()` with
880:       a buffer of length equal to the communicator size. Not memory-scalable due to
881:       the large reduction size. Requires only an MPI-1 implementation.
882: .  `PETSC_BUILDTWOSIDED_IBARRIER` - nonblocking algorithm based on `MPI_Issend()` and `MPI_Ibarrier()`.
883:       Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires an MPI-3 implementation.
884: -  `PETSC_BUILDTWOSIDED_REDSCATTER` - similar to above, but use more optimized function
885:       that only communicates the part of the reduction that is necessary.  Requires an MPI-2 implementation.

887:    Level: developer

889: .seealso: `PetscCommBuildTwoSided()`, `PetscCommBuildTwoSidedSetType()`, `PetscCommBuildTwoSidedGetType()`
890: E*/
891: typedef enum {
892:   PETSC_BUILDTWOSIDED_NOTSET     = -1,
893:   PETSC_BUILDTWOSIDED_ALLREDUCE  = 0,
894:   PETSC_BUILDTWOSIDED_IBARRIER   = 1,
895:   PETSC_BUILDTWOSIDED_REDSCATTER = 2
896:   /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */
897: } PetscBuildTwoSidedType;
898: PETSC_EXTERN const char *const PetscBuildTwoSidedTypes[];

900: /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */
901: /*E
902:   InsertMode - How the entries are combined with the current values in the vectors or matrices

904:   Values:
905: +  `NOT_SET_VALUES` - do not actually use the values
906: .  `INSERT_VALUES` - replace the current values with the provided values, unless the index is marked as constrained by the `PetscSection`
907: .  `ADD_VALUES` - add the values to the current values, unless the index is marked as constrained by the `PetscSection`
908: .  `MAX_VALUES` - use the maximum of each current value and provided value
909: .  `MIN_VALUES` - use the minimum of each current value and provided value
910: .  `INSERT_ALL_VALUES` - insert, even if indices that are not marked as constrained by the `PetscSection`
911: .  `ADD_ALL_VALUES` - add, even if indices that are not marked as constrained by the `PetscSection`
912: .  `INSERT_BC_VALUES` - insert, but ignore indices that are not marked as constrained by the `PetscSection`
913: -  `ADD_BC_VALUES` - add, but ignore indices that are not marked as constrained by the `PetscSection`

915:   Level: beginner

917:   Note:
918:   The `PetscSection` that determines the effects of the `InsertMode` values can be obtained by the `Vec` object with `VecGetDM()`
919:   and `DMGetLocalSection()`.

921:   Not all options are supported for all operations or PETSc object types.

923: .seealso: `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
924:           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`,
925:           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`
926: E*/
927: typedef enum {
928:   NOT_SET_VALUES,
929:   INSERT_VALUES,
930:   ADD_VALUES,
931:   MAX_VALUES,
932:   MIN_VALUES,
933:   INSERT_ALL_VALUES,
934:   ADD_ALL_VALUES,
935:   INSERT_BC_VALUES,
936:   ADD_BC_VALUES
937: } InsertMode;

939: /*MC
940:     INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value

942:     Level: beginner

944: .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
945:           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `ADD_VALUES`,
946:           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES`
947: M*/

949: /*MC
950:     ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the
951:                 value into that location

953:     Level: beginner

955: .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
956:           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `INSERT_VALUES`,
957:           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES`
958: M*/

960: /*MC
961:     MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location

963:     Level: beginner

965: .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES`
966: M*/

968: /*MC
969:     MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location

971:     Level: beginner

973: .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES`
974: M*/

976: /*S
977:    PetscSubcomm - A decomposition of an MPI communicator into subcommunicators

979:    Values:
980: +   `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
981: .   `PETSC_SUBCOMM_CONTIGUOUS` - each new communicator contains a set of process with contiguous ranks in the original MPI communicator
982: -   `PETSC_SUBCOMM_INTERLACED` - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator

984:    Sample Usage:
985: .vb
986:        PetscSubcommCreate()
987:        PetscSubcommSetNumber()
988:        PetscSubcommSetType(PETSC_SUBCOMM_INTERLACED);
989:        ccomm = PetscSubcommChild()
990:        PetscSubcommDestroy()
991: .ve

993:    Example:
994:    Consider a communicator with six processes split into 3 subcommunicators.
995: .vb
996:    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
997:    PETSC_SUBCOMM_INTERLACED - the first communicator contains rank 0,3, the second 1,4 and the third 2,5
998: .ve

1000:    Level: advanced

1002:    Note:
1003:    After a call to `PetscSubcommSetType()`, `PetscSubcommSetTypeGeneral()`, or `PetscSubcommSetFromOptions()` one may call
1004: .vb
1005:      PetscSubcommChild() returns the associated subcommunicator on this process
1006:      PetscSubcommContiguousParent() returns a parent communitor but with all child of the same subcommunicator having contiguous rank
1007: .ve

1009:    Developer Note:
1010:    This is used in objects such as `PCREDUNDANT` to manage the subcommunicators on which the redundant computations
1011:    are performed.

1013: .seealso: `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()`
1014: S*/
1015: typedef struct _n_PetscSubcomm *PetscSubcomm;
1016: typedef enum {
1017:   PETSC_SUBCOMM_GENERAL    = 0,
1018:   PETSC_SUBCOMM_CONTIGUOUS = 1,
1019:   PETSC_SUBCOMM_INTERLACED = 2
1020: } PetscSubcommType;
1021: PETSC_EXTERN const char *const PetscSubcommTypes[];

1023: /*S
1024:      PetscHeap - A simple class for managing heaps

1026:    Level: intermediate

1028: .seealso: `PetscHeapCreate()`, `PetscHeapAdd()`, `PetscHeapPop()`, `PetscHeapPeek()`, `PetscHeapStash()`, `PetscHeapUnstash()`, `PetscHeapView()`, `PetscHeapDestroy()`
1029: S*/
1030: typedef struct _PetscHeap *PetscHeap;

1032: typedef struct _n_PetscShmComm *PetscShmComm;
1033: typedef struct _n_PetscOmpCtrl *PetscOmpCtrl;

1035: /*S
1036:    PetscSegBuffer - a segmented extendable buffer

1038:    Level: developer

1040: .seealso: `PetscSegBufferCreate()`, `PetscSegBufferGet()`, `PetscSegBufferExtract()`, `PetscSegBufferDestroy()`
1041: S*/
1042: typedef struct _n_PetscSegBuffer *PetscSegBuffer;

1044: typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted;

1046: /*S
1047:      PetscBT - PETSc bitarrays, efficient storage of arrays of boolean values

1049:      Level: advanced

1051:      Notes:
1052:      The following routines do not have their own manual pages

1054: .vb
1055:      PetscBTCreate(m,&bt)         - creates a bit array with enough room to hold m values
1056:      PetscBTDestroy(&bt)          - destroys the bit array
1057:      PetscBTMemzero(m,bt)         - zeros the entire bit array (sets all values to false)
1058:      PetscBTSet(bt,index)         - sets a particular entry as true
1059:      PetscBTClear(bt,index)       - sets a particular entry as false
1060:      PetscBTLookup(bt,index)      - returns the value
1061:      PetscBTLookupSet(bt,index)   - returns the value and then sets it true
1062:      PetscBTLookupClear(bt,index) - returns the value and then sets it false
1063:      PetscBTLength(m)             - returns number of bytes in array with m bits
1064:      PetscBTView(m,bt,viewer)     - prints all the entries in a bit array
1065: .ve

1067:     PETSc does not check error flags on `PetscBTLookup()`, `PetcBTLookupSet()`, `PetscBTLength()` because error checking
1068:     would cost hundreds more cycles then the operation.

1070: S*/
1071: typedef char *PetscBT;

1073: /* The number of bits in a byte */
1074: #define PETSC_BITS_PER_BYTE CHAR_BIT