xref: /petsc/include/petscsystypes.h (revision a4e35b1925eceef64945ea472b84f2bf06a67b5e)
1 /* Portions of this code are under:
2    Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
3 */
4 
5 #ifndef PETSCSYSTYPES_H
6 #define PETSCSYSTYPES_H
7 
8 #include <petscconf.h>
9 #include <petscconf_poison.h>
10 #include <petscfix.h>
11 #include <petscmacros.h> // PETSC_NODISCARD, PETSC_CPP_VERSION
12 #include <stddef.h>
13 
14 /* SUBMANSEC = Sys */
15 
16 #include <limits.h> // INT_MIN, INT_MAX, CHAR_BIT
17 
18 #if defined(__clang__) || (PETSC_CPP_VERSION >= 17)
19   // clang allows both [[nodiscard]] and __attribute__((warn_unused_result)) on type
20   // definitions. GCC, however, does not, so check that we are using C++17 [[nodiscard]]
21   // instead of __attribute__((warn_unused_result))
22   #define PETSC_ERROR_CODE_NODISCARD PETSC_NODISCARD
23 #else
24   #define PETSC_ERROR_CODE_NODISCARD
25 #endif
26 
27 #ifdef PETSC_CLANG_STATIC_ANALYZER
28   #undef PETSC_USE_STRICT_PETSCERRORCODE
29 #endif
30 
31 #ifdef PETSC_USE_STRICT_PETSCERRORCODE
32   #define PETSC_ERROR_CODE_TYPEDEF   typedef
33   #define PETSC_ERROR_CODE_ENUM_NAME PetscErrorCode
34 #else
35   #define PETSC_ERROR_CODE_TYPEDEF
36   #define PETSC_ERROR_CODE_ENUM_NAME
37 #endif
38 
39 /*E
40   PetscErrorCode - Datatype used to return PETSc error codes.
41 
42   Level: beginner
43 
44   Notes:
45   Virtually all PETSc functions return an error code. It is the callers responsibility to check
46   the value of the returned error code after each PETSc call to determine if any errors
47   occurred. A set of convenience macros (e.g. `PetscCall()`, `PetscCallVoid()`) are provided
48   for this purpose. Failing to properly check for errors is not supported, as errors may leave
49   PETSc in an undetermined state.
50 
51   One can retrieve the error string corresponding to a particular error code using
52   `PetscErrorMessage()`.
53 
54   The user can also configure PETSc with the `--with-strict-petscerrorcode` option to enable
55   compiler warnings when the returned error codes are not captured and checked. Users are
56   *heavily* encouraged to opt-in to this option, as it will become enabled by default in a
57   future release.
58 
59   Developer Notes:
60 
61   These are the generic error codes. These error codes are used in many different places in the
62   PETSc source code. The C-string versions are at defined in `PetscErrorStrings[]` in
63   `src/sys/error/err.c`, while the Fortran versions are defined in
64   `src/sys/f90-mod/petscerror.h`. Any changes here must also be made in both locations.
65 
66 .seealso: `PetscErrorMessage()`, `PetscCall()`, `SETERRQ()`
67 E*/
68 PETSC_ERROR_CODE_TYPEDEF enum PETSC_ERROR_CODE_NODISCARD {
69   PETSC_SUCCESS                   = 0,
70   PETSC_ERR_BOOLEAN_MACRO_FAILURE = 1, /* do not use */
71 
72   PETSC_ERR_MIN_VALUE = 54, /* should always be one less then the smallest value */
73 
74   PETSC_ERR_MEM            = 55, /* unable to allocate requested memory */
75   PETSC_ERR_SUP            = 56, /* no support for requested operation */
76   PETSC_ERR_SUP_SYS        = 57, /* no support for requested operation on this computer system */
77   PETSC_ERR_ORDER          = 58, /* operation done in wrong order */
78   PETSC_ERR_SIG            = 59, /* signal received */
79   PETSC_ERR_FP             = 72, /* floating point exception */
80   PETSC_ERR_COR            = 74, /* corrupted PETSc object */
81   PETSC_ERR_LIB            = 76, /* error in library called by PETSc */
82   PETSC_ERR_PLIB           = 77, /* PETSc library generated inconsistent data */
83   PETSC_ERR_MEMC           = 78, /* memory corruption */
84   PETSC_ERR_CONV_FAILED    = 82, /* iterative method (KSP or SNES) failed */
85   PETSC_ERR_USER           = 83, /* user has not provided needed function */
86   PETSC_ERR_SYS            = 88, /* error in system call */
87   PETSC_ERR_POINTER        = 70, /* pointer does not point to valid address */
88   PETSC_ERR_MPI_LIB_INCOMP = 87, /* MPI library at runtime is not compatible with MPI user compiled with */
89 
90   PETSC_ERR_ARG_SIZ          = 60, /* nonconforming object sizes used in operation */
91   PETSC_ERR_ARG_IDN          = 61, /* two arguments not allowed to be the same */
92   PETSC_ERR_ARG_WRONG        = 62, /* wrong argument (but object probably ok) */
93   PETSC_ERR_ARG_CORRUPT      = 64, /* null or corrupted PETSc object as argument */
94   PETSC_ERR_ARG_OUTOFRANGE   = 63, /* input argument, out of range */
95   PETSC_ERR_ARG_BADPTR       = 68, /* invalid pointer argument */
96   PETSC_ERR_ARG_NOTSAMETYPE  = 69, /* two args must be same object type */
97   PETSC_ERR_ARG_NOTSAMECOMM  = 80, /* two args must be same communicators */
98   PETSC_ERR_ARG_WRONGSTATE   = 73, /* object in argument is in wrong state, e.g. unassembled mat */
99   PETSC_ERR_ARG_TYPENOTSET   = 89, /* the type of the object has not yet been set */
100   PETSC_ERR_ARG_INCOMP       = 75, /* two arguments are incompatible */
101   PETSC_ERR_ARG_NULL         = 85, /* argument is null that should not be */
102   PETSC_ERR_ARG_UNKNOWN_TYPE = 86, /* type name doesn't match any registered type */
103 
104   PETSC_ERR_FILE_OPEN       = 65, /* unable to open file */
105   PETSC_ERR_FILE_READ       = 66, /* unable to read from file */
106   PETSC_ERR_FILE_WRITE      = 67, /* unable to write to file */
107   PETSC_ERR_FILE_UNEXPECTED = 79, /* unexpected data in file */
108 
109   PETSC_ERR_MAT_LU_ZRPVT = 71, /* detected a zero pivot during LU factorization */
110   PETSC_ERR_MAT_CH_ZRPVT = 81, /* detected a zero pivot during Cholesky factorization */
111 
112   PETSC_ERR_INT_OVERFLOW   = 84,
113   PETSC_ERR_FLOP_COUNT     = 90,
114   PETSC_ERR_NOT_CONVERGED  = 91,  /* solver did not converge */
115   PETSC_ERR_MISSING_FACTOR = 92,  /* MatGetFactor() failed */
116   PETSC_ERR_OPT_OVERWRITE  = 93,  /* attempted to over write options which should not be changed */
117   PETSC_ERR_WRONG_MPI_SIZE = 94,  /* example/application run with number of MPI ranks it does not support */
118   PETSC_ERR_USER_INPUT     = 95,  /* missing or incorrect user input */
119   PETSC_ERR_GPU_RESOURCE   = 96,  /* unable to load a GPU resource, for example cuBLAS */
120   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 */
121   PETSC_ERR_MPI            = 98,  /* general MPI error */
122   PETSC_ERR_RETURN         = 99,  /* PetscError() incorrectly returned an error code of 0 */
123   PETSC_ERR_MEM_LEAK       = 100, /* memory alloc/free imbalance */
124   PETSC_ERR_MAX_VALUE      = 101, /* this is always the one more than the largest error code */
125 
126   /*
127     do not use, exist purely to make the enum bounds equal that of a regular int (so conversion
128     to int in main() is not undefined behavior)
129   */
130   PETSC_ERR_MIN_SIGNED_BOUND_DO_NOT_USE = INT_MIN,
131   PETSC_ERR_MAX_SIGNED_BOUND_DO_NOT_USE = INT_MAX
132 } PETSC_ERROR_CODE_ENUM_NAME;
133 
134 #ifndef PETSC_USE_STRICT_PETSCERRORCODE
135 typedef int PetscErrorCode;
136 
137   /*
138   Needed so that C++ lambdas can deduce the return type as PetscErrorCode from
139   PetscFunctionReturn(PETSC_SUCCESS). Otherwise we get
140 
141   error: return type '(unnamed enum at include/petscsystypes.h:50:1)' must match previous
142   return type 'int' when lambda expression has unspecified explicit return type
143   PetscFunctionReturn(PETSC_SUCCESS);
144   ^
145 */
146   #define PETSC_SUCCESS ((PetscErrorCode)0)
147 #endif
148 
149 #undef PETSC_ERROR_CODE_NODISCARD
150 #undef PETSC_ERROR_CODE_TYPEDEF
151 #undef PETSC_ERROR_CODE_ENUM_NAME
152 
153 /*MC
154     PetscClassId - A unique id used to identify each PETSc class.
155 
156     Level: developer
157 
158     Note:
159     Use `PetscClassIdRegister()` to obtain a new value for a new class being created. Usually
160          XXXInitializePackage() calls it for each class it defines.
161 
162     Developer Note:
163     Internal integer stored in the `_p_PetscObject` data structure. These are all computed by an offset from the lowest one, `PETSC_SMALLEST_CLASSID`.
164 
165 .seealso: `PetscClassIdRegister()`, `PetscLogEventRegister()`, `PetscHeaderCreate()`
166 M*/
167 typedef int PetscClassId;
168 
169 /*MC
170     PetscMPIInt - datatype used to represent 'int' parameters to MPI functions.
171 
172     Level: intermediate
173 
174     Notes:
175     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
176            standard C/Fortran integers are 32-bit then this is NOT the same as `PetscInt`; it remains 32-bit.
177 
178     `PetscMPIIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscMPIInt`, if not it
179       generates a `PETSC_ERR_ARG_OUTOFRANGE` error.
180 
181 .seealso: `PetscBLASInt`, `PetscInt`, `PetscMPIIntCast()`
182 M*/
183 typedef int PetscMPIInt;
184 
185 /* Limit MPI to 32-bits */
186 enum {
187   PETSC_MPI_INT_MIN = INT_MIN,
188   PETSC_MPI_INT_MAX = INT_MAX
189 };
190 
191 /*MC
192     PetscSizeT - datatype used to represent sizes in memory (like `size_t`)
193 
194     Level: intermediate
195 
196     Notes:
197     This is equivalent to `size_t`, but defined for consistency with Fortran, which lacks a native equivalent of `size_t`.
198 
199 .seealso: `PetscInt`, `PetscInt64`, `PetscCount`
200 M*/
201 typedef size_t PetscSizeT;
202 
203 /*MC
204     PetscCount - signed datatype used to represent counts
205 
206     Level: intermediate
207 
208     Notes:
209     This is equivalent to `ptrdiff_t`, but defined for consistency with Fortran, which lacks a native equivalent of `ptrdiff_t`.
210 
211     Use `PetscCount_FMT` to format with `PetscPrintf()`, `printf()`, and related functions.
212 
213 .seealso: `PetscInt`, `PetscInt64`, `PetscSizeT`
214 M*/
215 typedef ptrdiff_t PetscCount;
216 #define PetscCount_FMT "td"
217 
218 /*MC
219     PetscEnum - datatype used to pass enum types within PETSc functions.
220 
221     Level: intermediate
222 
223 .seealso: `PetscOptionsGetEnum()`, `PetscOptionsEnum()`, `PetscBagRegisterEnum()`
224 M*/
225 typedef enum {
226   ENUM_DUMMY
227 } PetscEnum;
228 
229 typedef short PetscShort;
230 typedef char  PetscChar;
231 typedef float PetscFloat;
232 
233 /*MC
234   PetscInt - PETSc type that represents an integer, used primarily to
235       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 
237   Level: beginner
238 
239   Notes:
240   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 
242 .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscIntCast()`
243 M*/
244 
245 #if defined(PETSC_HAVE_STDINT_H)
246   #include <stdint.h>
247 #endif
248 #if defined(PETSC_HAVE_INTTYPES_H)
249   #if !defined(__STDC_FORMAT_MACROS)
250     #define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */
251   #endif
252   #include <inttypes.h>
253   #if !defined(PRId64)
254     #define PRId64 "ld"
255   #endif
256 #endif
257 
258 #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 */
259 typedef int64_t PetscInt64;
260 
261   #define PETSC_INT64_MIN INT64_MIN
262   #define PETSC_INT64_MAX INT64_MAX
263 
264 #elif (PETSC_SIZEOF_LONG_LONG == 8)
265 typedef long long PetscInt64;
266 
267   #define PETSC_INT64_MIN LLONG_MIN
268   #define PETSC_INT64_MAX LLONG_MAX
269 
270 #elif defined(PETSC_HAVE___INT64)
271 typedef __int64 PetscInt64;
272 
273   #define PETSC_INT64_MIN INT64_MIN
274   #define PETSC_INT64_MAX INT64_MAX
275 
276 #else
277   #error "cannot determine PetscInt64 type"
278 #endif
279 
280 typedef int32_t PetscInt32;
281 #define PETSC_INT32_MIN INT32_MIN
282 #define PETSC_INT32_MAX INT32_MAX
283 
284 #if defined(PETSC_USE_64BIT_INDICES)
285 typedef PetscInt64 PetscInt;
286 
287   #define PETSC_INT_MIN PETSC_INT64_MIN
288   #define PETSC_INT_MAX PETSC_INT64_MAX
289   #define PetscInt_FMT  PetscInt64_FMT
290 #else
291 typedef int       PetscInt;
292 
293 enum {
294   PETSC_INT_MIN = INT_MIN,
295   PETSC_INT_MAX = INT_MAX
296 };
297 
298   #define PetscInt_FMT "d"
299 #endif
300 
301 #define PETSC_MIN_INT    PETSC_INT_MIN
302 #define PETSC_MAX_INT    PETSC_INT_MAX
303 #define PETSC_MAX_UINT16 65535
304 
305 #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 */
306   #define MPIU_INT64     MPI_INT64_T
307   #define PetscInt64_FMT PRId64
308 #elif (PETSC_SIZEOF_LONG_LONG == 8)
309   #define MPIU_INT64     MPI_LONG_LONG_INT
310   #define PetscInt64_FMT "lld"
311 #elif defined(PETSC_HAVE___INT64)
312   #define MPIU_INT64     MPI_INT64_T
313   #define PetscInt64_FMT "ld"
314 #else
315   #error "cannot determine PetscInt64 type"
316 #endif
317 
318 #define MPIU_INT32     MPI_INT32_T
319 #define PetscInt32_FMT PRId32
320 
321 /*MC
322    PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions.
323 
324    Level: intermediate
325 
326    Notes:
327    Usually this is the same as `PetscInt`, but if PETSc was built with `--with-64-bit-indices` but
328    standard C/Fortran integers are 32-bit then this may not be the same as `PetscInt`,
329    except on some BLAS/LAPACK implementations that support 64-bit integers see the notes below.
330 
331    `PetscErrorCode` `PetscBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscBLASInt`, if not it
332     generates a `PETSC_ERR_ARG_OUTOFRANGE` error
333 
334    Installation Notes:
335     ./configure automatically determines the size of the integers used by BLAS/LAPACK except when `--with-batch` is used
336     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 
338     MATLAB ships with BLAS and LAPACK that use 64-bit integers, for example if you run ./configure with, the option
339      `--with-blaslapack-lib`=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib]
340 
341     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
342     against the 64-bit version, otherwise it uses the 32-bit version
343 
344     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 
346     External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64-bit integers to BLAS/LAPACK so cannot
347     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
348     these external libraries while using 64-bit integer BLAS/LAPACK.
349 
350 .seealso: `PetscMPIInt`, `PetscInt`, `PetscBLASIntCast()`
351 M*/
352 #if defined(PETSC_HAVE_64BIT_BLAS_INDICES)
353 typedef PetscInt64 PetscBLASInt;
354 
355   #define PETSC_BLAS_INT_MIN PETSC_INT64_MIN
356   #define PETSC_BLAS_INT_MAX PETSC_INT64_MAX
357   #define PetscBLASInt_FMT   PetscInt64_FMT
358 #else
359 typedef int PetscBLASInt;
360 
361 enum {
362   PETSC_BLAS_INT_MIN = INT_MIN,
363   PETSC_BLAS_INT_MAX = INT_MAX
364 };
365 
366   #define PetscBLASInt_FMT "d"
367 #endif
368 
369 /*MC
370    PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions.
371 
372    Level: intermediate
373 
374    Notes:
375    As of this writing `PetscCuBLASInt` is always the system `int`.
376 
377   `PetscErrorCode` `PetscCuBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscCuBLASInt`, if not it
378    generates a `PETSC_ERR_ARG_OUTOFRANGE` error
379 
380 .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscCuBLASIntCast()`
381 M*/
382 typedef int PetscCuBLASInt;
383 
384 enum {
385   PETSC_CUBLAS_INT_MIN = INT_MIN,
386   PETSC_CUBLAS_INT_MAX = INT_MAX
387 };
388 
389 /*MC
390    PetscHipBLASInt - datatype used to represent 'int' parameters to hipBLAS/hipSOLVER functions.
391 
392    Level: intermediate
393 
394    Notes:
395    As of this writing `PetscHipBLASInt` is always the system `int`.
396 
397    `PetscErrorCode` `PetscHipBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscHipBLASInt`, if not it
398    generates a `PETSC_ERR_ARG_OUTOFRANGE` error
399 
400 .seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscHipBLASIntCast()
401 M*/
402 typedef int PetscHipBLASInt;
403 
404 enum {
405   PETSC_HIPBLAS_INT_MIN = INT_MIN,
406   PETSC_HIPBLAS_INT_MAX = INT_MAX
407 };
408 
409 /*E
410     PetscBool  - Logical variable. Actually an enum in C and a logical in Fortran.
411 
412    Level: beginner
413 
414    Developer Note:
415    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
416       boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms.
417 
418 .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PetscBool3`
419 E*/
420 typedef enum {
421   PETSC_FALSE,
422   PETSC_TRUE
423 } PetscBool;
424 PETSC_EXTERN const char *const PetscBools[];
425 
426 /*E
427     PetscBool3  - Ternary logical variable. Actually an enum in C and a 4 byte integer in Fortran.
428 
429    Level: beginner
430 
431    Note:
432    Should not be used with the if (flg) or if (!flg) syntax.
433 
434 .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PETSC_BOOL3_TRUE`, `PETSC_BOOL3_FALSE`, `PETSC_BOOL3_UNKNOWN`
435 E*/
436 typedef enum {
437   PETSC_BOOL3_FALSE,
438   PETSC_BOOL3_TRUE,
439   PETSC_BOOL3_UNKNOWN = -1
440 } PetscBool3;
441 
442 #define PetscBool3ToBool(a) ((a) == PETSC_BOOL3_TRUE ? PETSC_TRUE : PETSC_FALSE)
443 #define PetscBoolToBool3(a) ((a) == PETSC_TRUE ? PETSC_BOOL3_TRUE : PETSC_BOOL3_FALSE)
444 
445 /*MC
446    PetscReal - PETSc type that represents a real number version of `PetscScalar`
447 
448    Level: beginner
449 
450    Notes:
451    For MPI calls that require datatypes, use `MPIU_REAL` as the datatype for `PetscReal` and `MPIU_SUM`, `MPIU_MAX`, etc. for operations.
452    They will automatically work correctly regardless of the size of `PetscReal`.
453 
454    See `PetscScalar` for details on how to ./configure the size of `PetscReal`.
455 
456 .seealso: `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`
457 M*/
458 
459 #if defined(PETSC_USE_REAL_SINGLE)
460 typedef float PetscReal;
461 #elif defined(PETSC_USE_REAL_DOUBLE)
462 typedef double    PetscReal;
463 #elif defined(PETSC_USE_REAL___FLOAT128)
464   #if defined(__cplusplus)
465 extern "C" {
466   #endif
467   #include <quadmath.h>
468   #if defined(__cplusplus)
469 }
470   #endif
471 typedef __float128 PetscReal;
472 #elif defined(PETSC_USE_REAL___FP16)
473 typedef __fp16 PetscReal;
474 #endif /* PETSC_USE_REAL_* */
475 
476 /*MC
477    PetscComplex - PETSc type that represents a complex number with precision matching that of `PetscReal`.
478 
479    Synopsis:
480    #include <petscsys.h>
481    PetscComplex number = 1. + 2.*PETSC_i;
482 
483    Level: beginner
484 
485    Notes:
486    For MPI calls that require datatypes, use `MPIU_COMPLEX` as the datatype for `PetscComplex` and `MPIU_SUM` etc for operations.
487           They will automatically work correctly regardless of the size of `PetscComplex`.
488 
489           See `PetscScalar` for details on how to ./configure the size of `PetscReal`
490 
491           Complex numbers are automatically available if PETSc was able to find a working complex implementation
492 
493     PETSc has a 'fix' for complex numbers to support expressions such as `std::complex<PetscReal>` + `PetscInt`, which are not supported by the standard
494     C++ library, but are convenient for petsc users. If the C++ compiler is able to compile code in `petsccxxcomplexfix.h` (This is checked by
495     configure), we include `petsccxxcomplexfix.h` to provide this convenience.
496 
497     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`
498     at the beginning of the C++ file to skip the fix.
499 
500 .seealso: `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i`
501 M*/
502 #if !defined(PETSC_SKIP_COMPLEX)
503   #if defined(PETSC_CLANGUAGE_CXX)
504     #if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128)
505       #if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */
506         #define PETSC_HAVE_COMPLEX 1
507       #elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */
508         #define PETSC_HAVE_COMPLEX 1
509       #endif
510     #elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX)
511       #define PETSC_HAVE_COMPLEX 1
512     #endif
513   #else /* !PETSC_CLANGUAGE_CXX */
514     #if !defined(PETSC_USE_REAL___FP16)
515       #if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */
516         #define PETSC_HAVE_COMPLEX 1
517       #elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */
518         #define PETSC_HAVE_COMPLEX 1
519       #endif
520     #endif
521   #endif /* PETSC_CLANGUAGE_CXX */
522 #endif   /* !PETSC_SKIP_COMPLEX */
523 
524 #if defined(PETSC_HAVE_COMPLEX)
525   #if defined(__cplusplus) /* C++ complex support */
526     /* Locate a C++ complex template library */
527     #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */
528       #define petsccomplexlib Kokkos
529       #include <Kokkos_Complex.hpp>
530     #elif defined(__CUDACC__) || defined(__HIPCC__)
531       #define petsccomplexlib thrust
532       #include <thrust/complex.h>
533     #elif defined(PETSC_USE_REAL___FLOAT128)
534       #include <complex.h>
535     #else
536       #define petsccomplexlib std
537       #include <complex>
538     #endif
539 
540     /* Define PetscComplex based on the precision */
541     #if defined(PETSC_USE_REAL_SINGLE)
542 typedef petsccomplexlib::complex<float> PetscComplex;
543     #elif defined(PETSC_USE_REAL_DOUBLE)
544 typedef petsccomplexlib::complex<double> PetscComplex;
545     #elif defined(PETSC_USE_REAL___FLOAT128)
546 typedef __complex128 PetscComplex;
547     #endif
548 
549     /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */
550     #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX)
551       #include <petsccxxcomplexfix.h>
552     #endif
553   #else /* c99 complex support */
554     #include <complex.h>
555     #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16)
556 typedef float _Complex PetscComplex;
557     #elif defined(PETSC_USE_REAL_DOUBLE)
558 typedef double _Complex PetscComplex;
559     #elif defined(PETSC_USE_REAL___FLOAT128)
560 typedef __complex128 PetscComplex;
561     #endif /* PETSC_USE_REAL_* */
562   #endif   /* !__cplusplus */
563 #endif     /* PETSC_HAVE_COMPLEX */
564 
565 /*MC
566    PetscScalar - PETSc type that represents either a double precision real number, a double precision
567        complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured
568        with `--with-scalar-type`=real,complex `--with-precision`=single,double,__float128,__fp16
569 
570    Level: beginner
571 
572    Note:
573    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 
575 .seealso: `PetscReal`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscRealPart()`, `PetscImaginaryPart()`
576 M*/
577 
578 #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX)
579 typedef PetscComplex PetscScalar;
580 #else  /* PETSC_USE_COMPLEX */
581 typedef PetscReal PetscScalar;
582 #endif /* PETSC_USE_COMPLEX */
583 
584 /*E
585     PetscCopyMode  - Determines how an array or `PetscObject` passed to certain functions is copied or retained by the aggregate `PetscObject`
586 
587    Level: beginner
588 
589    Values for array input:
590 +   `PETSC_COPY_VALUES` - the array values are copied into new space, the user is free to reuse or delete the passed in array
591 .   `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
592                           delete the array. The array MUST have been obtained with `PetscMalloc()`. Hence this mode cannot be used in Fortran.
593 -   `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
594                           the array but the user must delete the array after the object is destroyed.
595 
596    Values for PetscObject:
597 +   `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.
598 .   `PETSC_OWN_POINTER` - the input `PetscObject` is referenced by pointer (with reference count), thus should not be modified by the user.
599                           increases its reference count).
600 -   `PETSC_USE_POINTER` - invalid for `PetscObject` inputs.
601 
602 .seealso: `PetscInsertMode`
603 E*/
604 typedef enum {
605   PETSC_COPY_VALUES,
606   PETSC_OWN_POINTER,
607   PETSC_USE_POINTER
608 } PetscCopyMode;
609 PETSC_EXTERN const char *const PetscCopyModes[];
610 
611 /*MC
612     PETSC_FALSE - False value of `PetscBool`
613 
614     Level: beginner
615 
616     Note:
617     Zero integer
618 
619 .seealso: `PetscBool`, `PetscBool3`, `PETSC_TRUE`
620 M*/
621 
622 /*MC
623     PETSC_TRUE - True value of `PetscBool`
624 
625     Level: beginner
626 
627     Note:
628     Nonzero integer
629 
630 .seealso: `PetscBool`, `PetscBool3`, `PETSC_FALSE`
631 M*/
632 
633 /*MC
634     PetscLogDouble - Used for logging times
635 
636   Level: developer
637 
638   Note:
639   Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc.
640 
641 .seealso: `PetscBool`, `PetscDataType`
642 M*/
643 typedef double PetscLogDouble;
644 
645 /*E
646     PetscDataType - Used for handling different basic data types.
647 
648    Level: beginner
649 
650    Notes:
651    Use of this should be avoided if one can directly use `MPI_Datatype` instead.
652 
653    `PETSC_INT` is the datatype for a `PetscInt`, regardless of whether it is 4 or 8 bytes.
654    `PETSC_REAL`, `PETSC_COMPLEX` and `PETSC_SCALAR` are the datatypes for `PetscReal`, `PetscComplex` and `PetscScalar`, regardless of their sizes.
655 
656    Developer Notes:
657    It would be nice if we could always just use MPI Datatypes, why can we not?
658 
659    If you change any values in `PetscDatatype` make sure you update their usage in
660    share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m
661 
662    TODO:
663    Remove use of improper `PETSC_ENUM`
664 
665 .seealso: `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`,
666           `PetscDataTypeGetSize()`
667 E*/
668 typedef enum {
669   PETSC_DATATYPE_UNKNOWN = 0,
670   PETSC_DOUBLE           = 1,
671   PETSC_COMPLEX          = 2,
672   PETSC_LONG             = 3,
673   PETSC_SHORT            = 4,
674   PETSC_FLOAT            = 5,
675   PETSC_CHAR             = 6,
676   PETSC_BIT_LOGICAL      = 7,
677   PETSC_ENUM             = 8,
678   PETSC_BOOL             = 9,
679   PETSC___FLOAT128       = 10,
680   PETSC_OBJECT           = 11,
681   PETSC_FUNCTION         = 12,
682   PETSC_STRING           = 13,
683   PETSC___FP16           = 14,
684   PETSC_STRUCT           = 15,
685   PETSC_INT              = 16,
686   PETSC_INT64            = 17,
687   PETSC_COUNT            = 18,
688   PETSC_INT32            = 19,
689 } PetscDataType;
690 PETSC_EXTERN const char *const PetscDataTypes[];
691 
692 #if defined(PETSC_USE_REAL_SINGLE)
693   #define PETSC_REAL PETSC_FLOAT
694 #elif defined(PETSC_USE_REAL_DOUBLE)
695   #define PETSC_REAL PETSC_DOUBLE
696 #elif defined(PETSC_USE_REAL___FLOAT128)
697   #define PETSC_REAL PETSC___FLOAT128
698 #elif defined(PETSC_USE_REAL___FP16)
699   #define PETSC_REAL PETSC___FP16
700 #else
701   #define PETSC_REAL PETSC_DOUBLE
702 #endif
703 
704 #if defined(PETSC_USE_COMPLEX)
705   #define PETSC_SCALAR PETSC_COMPLEX
706 #else
707   #define PETSC_SCALAR PETSC_REAL
708 #endif
709 
710 #define PETSC_FORTRANADDR PETSC_LONG
711 
712 /*S
713     PetscToken - 'Token' used for managing tokenizing strings
714 
715   Level: intermediate
716 
717 .seealso: `PetscTokenCreate()`, `PetscTokenFind()`, `PetscTokenDestroy()`
718 S*/
719 typedef struct _p_PetscToken *PetscToken;
720 
721 /*S
722      PetscObject - any PETSc object, `PetscViewer`, `Mat`, `Vec`, `KSP` etc
723 
724    Level: beginner
725 
726    Notes:
727    This is the base class from which all PETSc objects are derived from.
728 
729    In certain situations one can cast an object, for example a `Vec`, to a `PetscObject` with (`PetscObject`)vec
730 
731 .seealso: `PetscObjectDestroy()`, `PetscObjectView()`, `PetscObjectGetName()`, `PetscObjectSetName()`, `PetscObjectReference()`, `PetscObjectDereference()`
732 S*/
733 typedef struct _p_PetscObject *PetscObject;
734 
735 /*MC
736     PetscObjectId - unique integer Id for a `PetscObject`
737 
738     Level: developer
739 
740     Note:
741     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
742     if the objects are the same. Never compare two object pointer values.
743 
744 .seealso: `PetscObjectState`, `PetscObjectGetId()`
745 M*/
746 typedef PetscInt64 PetscObjectId;
747 
748 /*MC
749     PetscObjectState - integer state for a `PetscObject`
750 
751     Level: developer
752 
753     Notes:
754     Object state is always-increasing and (for objects that track state) can be used to determine if an object has
755     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 
757 .seealso: `PetscObjectId`, `PetscObjectStateGet()`, `PetscObjectStateIncrease()`, `PetscObjectStateSet()`
758 M*/
759 typedef PetscInt64 PetscObjectState;
760 
761 /*S
762      PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed
763       by string name
764 
765    Level: advanced
766 
767 .seealso: `PetscFunctionListAdd()`, `PetscFunctionListDestroy()`
768 S*/
769 typedef struct _n_PetscFunctionList *PetscFunctionList;
770 
771 /*E
772   PetscFileMode - Access mode for a file.
773 
774   Values:
775 +  `FILE_MODE_UNDEFINED` - initial invalid value
776 .  `FILE_MODE_READ` - open a file at its beginning for reading
777 .  `FILE_MODE_WRITE` - open a file at its beginning for writing (will create if the file does not exist)
778 .  `FILE_MODE_APPEND` - open a file at end for writing
779 .  `FILE_MODE_UPDATE` - open a file for updating, meaning for reading and writing
780 -  `FILE_MODE_APPEND_UPDATE` - open a file for updating, meaning for reading and writing, at the end
781 
782   Level: beginner
783 
784 .seealso: `PetscViewerFileSetMode()`
785 E*/
786 typedef enum {
787   FILE_MODE_UNDEFINED = -1,
788   FILE_MODE_READ      = 0,
789   FILE_MODE_WRITE,
790   FILE_MODE_APPEND,
791   FILE_MODE_UPDATE,
792   FILE_MODE_APPEND_UPDATE
793 } PetscFileMode;
794 PETSC_EXTERN const char *const PetscFileModes[];
795 
796 typedef void *PetscDLHandle;
797 typedef enum {
798   PETSC_DL_DECIDE = 0,
799   PETSC_DL_NOW    = 1,
800   PETSC_DL_LOCAL  = 2
801 } PetscDLMode;
802 
803 /*S
804      PetscObjectList - Linked list of PETSc objects, each accessible by string name
805 
806    Level: developer
807 
808    Note:
809    Used by `PetscObjectCompose()` and `PetscObjectQuery()`
810 
811 .seealso: `PetscObjectListAdd()`, `PetscObjectListDestroy()`, `PetscObjectListFind()`, `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscFunctionList`
812 S*/
813 typedef struct _n_PetscObjectList *PetscObjectList;
814 
815 /*S
816      PetscDLLibrary - Linked list of dynamic libraries to search for functions
817 
818    Level: developer
819 
820 .seealso: `PetscDLLibraryOpen()`
821 S*/
822 typedef struct _n_PetscDLLibrary *PetscDLLibrary;
823 
824 /*S
825      PetscContainer - Simple PETSc object that contains a pointer to any required data
826 
827    Level: advanced
828 
829    Note:
830    This is useful to attach arbitrary data to a `PetscObject` with `PetscObjectCompose()` and `PetscObjectQuery()`
831 
832 .seealso: `PetscObject`, `PetscContainerCreate()`, `PetscObjectCompose()`, `PetscObjectQuery()`
833 S*/
834 typedef struct _p_PetscContainer *PetscContainer;
835 
836 /*S
837      PetscRandom - Abstract PETSc object that manages generating random numbers
838 
839    Level: intermediate
840 
841 .seealso: `PetscRandomCreate()`, `PetscRandomGetValue()`, `PetscRandomType`
842 S*/
843 typedef struct _p_PetscRandom *PetscRandom;
844 
845 /*
846    In binary files variables are stored using the following lengths,
847   regardless of how they are stored in memory on any one particular
848   machine. Use these rather then sizeof() in computing sizes for
849   PetscBinarySeek().
850 */
851 #define PETSC_BINARY_INT_SIZE    (32 / 8)
852 #define PETSC_BINARY_FLOAT_SIZE  (32 / 8)
853 #define PETSC_BINARY_CHAR_SIZE   (8 / 8)
854 #define PETSC_BINARY_SHORT_SIZE  (16 / 8)
855 #define PETSC_BINARY_DOUBLE_SIZE (64 / 8)
856 #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar)
857 
858 /*E
859   PetscBinarySeekType - argument to `PetscBinarySeek()`
860 
861   Values:
862 +  `PETSC_BINARY_SEEK_SET` - offset is an absolute location in the file
863 .  `PETSC_BINARY_SEEK_CUR` - offset is an offset from the current location of the file pointer
864 -  `PETSC_BINARY_SEEK_END` - offset is an offset from the end of the file
865 
866   Level: advanced
867 
868 .seealso: `PetscBinarySeek()`, `PetscBinarySynchronizedSeek()`
869 E*/
870 typedef enum {
871   PETSC_BINARY_SEEK_SET = 0,
872   PETSC_BINARY_SEEK_CUR = 1,
873   PETSC_BINARY_SEEK_END = 2
874 } PetscBinarySeekType;
875 
876 /*E
877     PetscBuildTwoSidedType - algorithm for setting up two-sided communication for use with `PetscSF`
878 
879    Values:
880 +  `PETSC_BUILDTWOSIDED_ALLREDUCE` - classical algorithm using an `MPI_Allreduce()` with
881       a buffer of length equal to the communicator size. Not memory-scalable due to
882       the large reduction size. Requires only an MPI-1 implementation.
883 .  `PETSC_BUILDTWOSIDED_IBARRIER` - nonblocking algorithm based on `MPI_Issend()` and `MPI_Ibarrier()`.
884       Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires an MPI-3 implementation.
885 -  `PETSC_BUILDTWOSIDED_REDSCATTER` - similar to above, but use more optimized function
886       that only communicates the part of the reduction that is necessary.  Requires an MPI-2 implementation.
887 
888    Level: developer
889 
890 .seealso: `PetscCommBuildTwoSided()`, `PetscCommBuildTwoSidedSetType()`, `PetscCommBuildTwoSidedGetType()`
891 E*/
892 typedef enum {
893   PETSC_BUILDTWOSIDED_NOTSET     = -1,
894   PETSC_BUILDTWOSIDED_ALLREDUCE  = 0,
895   PETSC_BUILDTWOSIDED_IBARRIER   = 1,
896   PETSC_BUILDTWOSIDED_REDSCATTER = 2
897   /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */
898 } PetscBuildTwoSidedType;
899 PETSC_EXTERN const char *const PetscBuildTwoSidedTypes[];
900 
901 /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */
902 /*E
903   InsertMode - How the entries are combined with the current values in the vectors or matrices
904 
905   Values:
906 +  `NOT_SET_VALUES` - do not actually use the values
907 .  `INSERT_VALUES` - replace the current values with the provided values, unless the index is marked as constrained by the `PetscSection`
908 .  `ADD_VALUES` - add the values to the current values, unless the index is marked as constrained by the `PetscSection`
909 .  `MAX_VALUES` - use the maximum of each current value and provided value
910 .  `MIN_VALUES` - use the minimum of each current value and provided value
911 .  `INSERT_ALL_VALUES` - insert, even if indices that are not marked as constrained by the `PetscSection`
912 .  `ADD_ALL_VALUES` - add, even if indices that are not marked as constrained by the `PetscSection`
913 .  `INSERT_BC_VALUES` - insert, but ignore indices that are not marked as constrained by the `PetscSection`
914 -  `ADD_BC_VALUES` - add, but ignore indices that are not marked as constrained by the `PetscSection`
915 
916   Level: beginner
917 
918   Note:
919   The `PetscSection` that determines the effects of the `InsertMode` values can be obtained by the `Vec` object with `VecGetDM()`
920   and `DMGetLocalSection()`.
921 
922   Not all options are supported for all operations or PETSc object types.
923 
924 .seealso: `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
925           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`,
926           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`
927 E*/
928 typedef enum {
929   NOT_SET_VALUES,
930   INSERT_VALUES,
931   ADD_VALUES,
932   MAX_VALUES,
933   MIN_VALUES,
934   INSERT_ALL_VALUES,
935   ADD_ALL_VALUES,
936   INSERT_BC_VALUES,
937   ADD_BC_VALUES
938 } InsertMode;
939 
940 /*MC
941     INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value
942 
943     Level: beginner
944 
945 .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
946           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `ADD_VALUES`,
947           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES`
948 M*/
949 
950 /*MC
951     ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the
952                 value into that location
953 
954     Level: beginner
955 
956 .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
957           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `INSERT_VALUES`,
958           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES`
959 M*/
960 
961 /*MC
962     MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location
963 
964     Level: beginner
965 
966 .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES`
967 M*/
968 
969 /*MC
970     MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location
971 
972     Level: beginner
973 
974 .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES`
975 M*/
976 
977 /*S
978    PetscSubcomm - A decomposition of an MPI communicator into subcommunicators
979 
980    Values:
981 +   `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
982 .   `PETSC_SUBCOMM_CONTIGUOUS` - each new communicator contains a set of process with contiguous ranks in the original MPI communicator
983 -   `PETSC_SUBCOMM_INTERLACED` - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator
984 
985    Sample Usage:
986 .vb
987        PetscSubcommCreate()
988        PetscSubcommSetNumber()
989        PetscSubcommSetType(PETSC_SUBCOMM_INTERLACED);
990        ccomm = PetscSubcommChild()
991        PetscSubcommDestroy()
992 .ve
993 
994    Example:
995    Consider a communicator with six processes split into 3 subcommunicators.
996 .vb
997    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
998    PETSC_SUBCOMM_INTERLACED - the first communicator contains rank 0,3, the second 1,4 and the third 2,5
999 .ve
1000 
1001    Level: advanced
1002 
1003    Note:
1004    After a call to `PetscSubcommSetType()`, `PetscSubcommSetTypeGeneral()`, or `PetscSubcommSetFromOptions()` one may call
1005 .vb
1006      PetscSubcommChild() returns the associated subcommunicator on this process
1007      PetscSubcommContiguousParent() returns a parent communitor but with all child of the same subcommunicator having contiguous rank
1008 .ve
1009 
1010    Developer Note:
1011    This is used in objects such as `PCREDUNDANT` to manage the subcommunicators on which the redundant computations
1012    are performed.
1013 
1014 .seealso: `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()`
1015 S*/
1016 typedef struct _n_PetscSubcomm *PetscSubcomm;
1017 typedef enum {
1018   PETSC_SUBCOMM_GENERAL    = 0,
1019   PETSC_SUBCOMM_CONTIGUOUS = 1,
1020   PETSC_SUBCOMM_INTERLACED = 2
1021 } PetscSubcommType;
1022 PETSC_EXTERN const char *const PetscSubcommTypes[];
1023 
1024 /*S
1025      PetscHeap - A simple class for managing heaps
1026 
1027    Level: intermediate
1028 
1029 .seealso: `PetscHeapCreate()`, `PetscHeapAdd()`, `PetscHeapPop()`, `PetscHeapPeek()`, `PetscHeapStash()`, `PetscHeapUnstash()`, `PetscHeapView()`, `PetscHeapDestroy()`
1030 S*/
1031 typedef struct _PetscHeap *PetscHeap;
1032 
1033 typedef struct _n_PetscShmComm *PetscShmComm;
1034 typedef struct _n_PetscOmpCtrl *PetscOmpCtrl;
1035 
1036 /*S
1037    PetscSegBuffer - a segmented extendable buffer
1038 
1039    Level: developer
1040 
1041 .seealso: `PetscSegBufferCreate()`, `PetscSegBufferGet()`, `PetscSegBufferExtract()`, `PetscSegBufferDestroy()`
1042 S*/
1043 typedef struct _n_PetscSegBuffer *PetscSegBuffer;
1044 
1045 typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted;
1046 
1047 /*S
1048      PetscBT - PETSc bitarrays, efficient storage of arrays of boolean values
1049 
1050      Level: advanced
1051 
1052      Notes:
1053      The following routines do not have their own manual pages
1054 
1055 .vb
1056      PetscBTCreate(m,&bt)         - creates a bit array with enough room to hold m values
1057      PetscBTDestroy(&bt)          - destroys the bit array
1058      PetscBTMemzero(m,bt)         - zeros the entire bit array (sets all values to false)
1059      PetscBTSet(bt,index)         - sets a particular entry as true
1060      PetscBTClear(bt,index)       - sets a particular entry as false
1061      PetscBTLookup(bt,index)      - returns the value
1062      PetscBTLookupSet(bt,index)   - returns the value and then sets it true
1063      PetscBTLookupClear(bt,index) - returns the value and then sets it false
1064      PetscBTLength(m)             - returns number of bytes in array with m bits
1065      PetscBTView(m,bt,viewer)     - prints all the entries in a bit array
1066 .ve
1067 
1068     PETSc does not check error flags on `PetscBTLookup()`, `PetcBTLookupSet()`, `PetscBTLength()` because error checking
1069     would cost hundreds more cycles then the operation.
1070 
1071 S*/
1072 typedef char *PetscBT;
1073 
1074 /* The number of bits in a byte */
1075 #define PETSC_BITS_PER_BYTE CHAR_BIT
1076 
1077 #endif
1078