xref: /petsc/include/petscsystypes.h (revision eee954682a6abb1a7ac141dbd0723ecb4ff6b1e5)
1 #if !defined(PETSCSYSTYPES_H)
2 #define PETSCSYSTYPES_H
3 
4 #include <petscconf.h>
5 #include <petscfix.h>
6 #include <stddef.h>
7 
8 /*MC
9     PetscErrorCode - datatype used for return error code from almost all PETSc functions
10 
11     Level: beginner
12 
13 .seealso: CHKERRQ, SETERRQ
14 M*/
15 typedef int PetscErrorCode;
16 
17 /*MC
18 
19     PetscClassId - A unique id used to identify each PETSc class.
20 
21     Notes:
22     Use PetscClassIdRegister() to obtain a new value for a new class being created. Usually
23          XXXInitializePackage() calls it for each class it defines.
24 
25     Developer Notes:
26     Internal integer stored in the _p_PetscObject data structure.
27          These are all computed by an offset from the lowest one, PETSC_SMALLEST_CLASSID.
28 
29     Level: developer
30 
31 .seealso: PetscClassIdRegister(), PetscLogEventRegister(), PetscHeaderCreate()
32 M*/
33 typedef int PetscClassId;
34 
35 /*MC
36     PetscMPIInt - datatype used to represent 'int' parameters to MPI functions.
37 
38     Level: intermediate
39 
40     Notes:
41     usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but
42            standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt; it remains 32 bit.
43 
44     PetscMPIIntCast(a,&b) checks if the given PetscInt a will fit in a PetscMPIInt, if not it
45       generates a PETSC_ERR_ARG_OUTOFRANGE error.
46 
47 .seealso: PetscBLASInt, PetscInt, PetscMPIIntCast()
48 
49 M*/
50 typedef int PetscMPIInt;
51 
52 /*MC
53     PetscSizeT - datatype used to represent sizes in memory (like size_t)
54 
55     Level: intermediate
56 
57     Notes:
58     This is equivalent to size_t, but defined for consistency with Fortran, which lacks a native equivalent of size_t.
59 
60 .seealso: PetscInt, PetscInt64, PetscCount
61 
62 M*/
63 typedef size_t PetscSizeT;
64 
65 /*MC
66     PetscCount - signed datatype used to represent counts
67 
68     Level: intermediate
69 
70     Notes:
71     This is equivalent to ptrdiff_t, but defined for consistency with Fortran, which lacks a native equivalent of ptrdiff_t.
72 
73     Use PetscCount_FMT to format with PetscPrintf(), printf(), and related functions.
74 
75 .seealso: PetscInt, PetscInt64, PetscSizeT
76 
77 M*/
78 typedef ptrdiff_t PetscCount;
79 
80 /*MC
81     PetscEnum - datatype used to pass enum types within PETSc functions.
82 
83     Level: intermediate
84 
85 .seealso: PetscOptionsGetEnum(), PetscOptionsEnum(), PetscBagRegisterEnum()
86 M*/
87 typedef enum { ENUM_DUMMY } PetscEnum;
88 
89 typedef short PetscShort;
90 typedef char  PetscChar;
91 typedef float PetscFloat;
92 
93 /*MC
94   PetscInt - PETSc type that represents an integer, used primarily to
95       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.
96 
97   Notes:
98   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.
99 
100   Level: beginner
101 
102 .seealso: PetscBLASInt, PetscMPIInt, PetscReal, PetscScalar, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT
103 M*/
104 
105 #if defined(PETSC_HAVE_STDINT_H)
106 #  include <stdint.h>
107 #endif
108 #if defined (PETSC_HAVE_INTTYPES_H)
109 #  if !defined(__STDC_FORMAT_MACROS)
110 #    define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */
111 #  endif
112 #  include <inttypes.h>
113 #  if !defined(PRId64)
114 #    define PRId64 "ld"
115 #  endif
116 #endif
117 
118 #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 */
119    typedef int64_t PetscInt64;
120 #elif (PETSC_SIZEOF_LONG_LONG == 8)
121    typedef long long PetscInt64;
122 #elif defined(PETSC_HAVE___INT64)
123    typedef __int64 PetscInt64;
124 #else
125 #  error "cannot determine PetscInt64 type"
126 #endif
127 
128 #if defined(PETSC_USE_64BIT_INDICES)
129    typedef PetscInt64 PetscInt;
130 #else
131    typedef int PetscInt;
132 #endif
133 
134 #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 */
135 #  define MPIU_INT64     MPI_INT64_T
136 #  define PetscInt64_FMT PRId64
137 #elif (PETSC_SIZEOF_LONG_LONG == 8)
138 #  define MPIU_INT64     MPI_LONG_LONG_INT
139 #  define PetscInt64_FMT "lld"
140 #elif defined(PETSC_HAVE___INT64)
141 #  define MPIU_INT64     MPI_INT64_T
142 #  define PetscInt64_FMT "ld"
143 #else
144 #  error "cannot determine PetscInt64 type"
145 #endif
146 
147 #if PETSC_SIZEOF_SIZE_T == 8
148 #  define PetscCount_FMT PetscInt64_FMT
149 #else
150 #  define PetscCount_FMT "d"
151 #endif
152 
153 /*MC
154    PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions.
155 
156    Notes:
157     Usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but
158            standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt it remains 32 bit
159            (except on very rare BLAS/LAPACK implementations that support 64 bit integers see the notes below).
160 
161     PetscErrorCode PetscBLASIntCast(a,&b) checks if the given PetscInt a will fit in a PetscBLASInt, if not it
162       generates a PETSC_ERR_ARG_OUTOFRANGE error
163 
164    Installation Notes:
165     ./configure automatically determines the size of the integers used by BLAS/LAPACK except when --with-batch is used
166     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
167 
168     MATLAB ships with BLAS and LAPACK that use 64 bit integers, for example if you run ./configure with, the option
169      --with-blaslapack-lib=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib]
170 
171     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
172     against the 64 bit version, otherwise it use the 32 bit version
173 
174     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
175 
176     External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64 bit integers to BLAS/LAPACK so cannot
177     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
178     these external libraries while using 64 bit integer BLAS/LAPACK.
179 
180    Level: intermediate
181 
182 .seealso: PetscMPIInt, PetscInt, PetscBLASIntCast()
183 
184 M*/
185 #if defined(PETSC_HAVE_64BIT_BLAS_INDICES)
186 #  define PetscBLASInt_FMT PetscInt64_FMT
187    typedef PetscInt64 PetscBLASInt;
188 #else
189 #  define PetscBLASInt_FMT "d"
190    typedef int PetscBLASInt;
191 #endif
192 
193 /*MC
194    PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions.
195 
196    Notes:
197     As of this writing PetscCuBLASInt is always the system `int`.
198 
199     PetscErrorCode PetscCuBLASIntCast(a,&b) checks if the given PetscInt a will fit in a PetscCuBLASInt, if not it
200       generates a PETSC_ERR_ARG_OUTOFRANGE error
201 
202    Level: intermediate
203 
204 .seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscCuBLASIntCast()
205 
206 M*/
207 typedef int PetscCuBLASInt;
208 
209 /*E
210     PetscBool  - Logical variable. Actually an int in C and a logical in Fortran.
211 
212    Level: beginner
213 
214    Developer Note:
215    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
216       boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms.
217 
218 .seealso: PETSC_TRUE, PETSC_FALSE, PetscNot()
219 E*/
220 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscBool;
221 
222 /*MC
223    PetscReal - PETSc type that represents a real number version of PetscScalar
224 
225    Notes:
226    For MPI calls that require datatypes, use MPIU_REAL as the datatype for PetscScalar and MPIU_SUM, MPIU_MAX, etc. for operations.
227           They will automatically work correctly regardless of the size of PetscReal.
228 
229           See PetscScalar for details on how to ./configure the size of PetscReal.
230 
231    Level: beginner
232 
233 .seealso: PetscScalar, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT
234 M*/
235 
236 #if defined(PETSC_USE_REAL_SINGLE)
237    typedef float PetscReal;
238 #elif defined(PETSC_USE_REAL_DOUBLE)
239    typedef double PetscReal;
240 #elif defined(PETSC_USE_REAL___FLOAT128)
241 #  if defined(__cplusplus)
242      extern "C" {
243 #  endif
244 #  include <quadmath.h>
245 #  if defined(__cplusplus)
246      }
247 #  endif
248    typedef __float128 PetscReal;
249 #elif defined(PETSC_USE_REAL___FP16)
250    typedef __fp16 PetscReal;
251 #endif /* PETSC_USE_REAL_* */
252 
253 /*MC
254    PetscComplex - PETSc type that represents a complex number with precision matching that of PetscReal.
255 
256    Synopsis:
257    #include <petscsys.h>
258    PetscComplex number = 1. + 2.*PETSC_i;
259 
260    Notes:
261    For MPI calls that require datatypes, use MPIU_COMPLEX as the datatype for PetscComplex and MPIU_SUM etc for operations.
262           They will automatically work correctly regardless of the size of PetscComplex.
263 
264           See PetscScalar for details on how to ./configure the size of PetscReal
265 
266           Complex numbers are automatically available if PETSc was able to find a working complex implementation
267 
268     Petsc has a 'fix' for complex numbers to support expressions such as std::complex<PetscReal> + PetscInt, which are not supported by the standard
269     C++ library, but are convenient for petsc users. If the C++ compiler is able to compile code in petsccxxcomplexfix.h (This is checked by
270     configure), we include petsccxxcomplexfix.h to provide this convenience.
271 
272     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
273     at the beginning of the C++ file to skip the fix.
274 
275    Level: beginner
276 
277 .seealso: PetscReal, PetscScalar, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT, PETSC_i
278 M*/
279 #if !defined(PETSC_SKIP_COMPLEX)
280 #  if defined(PETSC_CLANGUAGE_CXX)
281 #    if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128)
282 #      if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX)  /* enable complex for library code */
283 #        define PETSC_HAVE_COMPLEX 1
284 #      elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX)  /* User code only - conditional on libary code complex support */
285 #        define PETSC_HAVE_COMPLEX 1
286 #      endif
287 #    elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX)
288 #        define PETSC_HAVE_COMPLEX 1
289 #    endif
290 #  else /* !PETSC_CLANGUAGE_CXX */
291 #    if !defined(PETSC_USE_REAL___FP16)
292 #      if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */
293 #        define PETSC_HAVE_COMPLEX 1
294 #      elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX)  /* User code only - conditional on libary code complex support */
295 #        define PETSC_HAVE_COMPLEX 1
296 #      endif
297 #    endif
298 #  endif /* PETSC_CLANGUAGE_CXX */
299 #endif /* !PETSC_SKIP_COMPLEX */
300 
301 #if defined(PETSC_HAVE_COMPLEX)
302   #if defined(__cplusplus)  /* C++ complex support */
303     /* Locate a C++ complex template library */
304     #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */
305       #define petsccomplexlib Kokkos
306       #include <Kokkos_Complex.hpp>
307     #elif defined(__CUDACC__) || defined(__HIPCC__)
308       #define petsccomplexlib thrust
309       #include <thrust/complex.h>
310     #elif defined(PETSC_USE_REAL___FLOAT128)
311       #include <complex.h>
312     #else
313       #define petsccomplexlib std
314       #include <complex>
315     #endif
316 
317     /* Define PetscComplex based on the precision */
318     #if defined(PETSC_USE_REAL_SINGLE)
319       typedef petsccomplexlib::complex<float> PetscComplex;
320     #elif defined(PETSC_USE_REAL_DOUBLE)
321       typedef petsccomplexlib::complex<double> PetscComplex;
322     #elif defined(PETSC_USE_REAL___FLOAT128)
323       typedef __complex128 PetscComplex;
324     #endif
325 
326     /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */
327     #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX)
328       #include <petsccxxcomplexfix.h>
329     #endif
330   #else /* c99 complex support */
331     #include <complex.h>
332     #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16)
333       typedef float _Complex PetscComplex;
334     #elif defined(PETSC_USE_REAL_DOUBLE)
335       typedef double _Complex PetscComplex;
336     #elif defined(PETSC_USE_REAL___FLOAT128)
337       typedef __complex128 PetscComplex;
338     #endif /* PETSC_USE_REAL_* */
339   #endif /* !__cplusplus */
340 #endif /* PETSC_HAVE_COMPLEX */
341 
342 /*MC
343    PetscScalar - PETSc type that represents either a double precision real number, a double precision
344        complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured
345        with --with-scalar-type=real,complex --with-precision=single,double,__float128,__fp16
346 
347    Notes:
348    For MPI calls that require datatypes, use MPIU_SCALAR as the datatype for PetscScalar and MPIU_SUM, MPIU_MAX etc for operations. They will automatically work correctly regardless of the size of PetscScalar.
349 
350    Level: beginner
351 
352 .seealso: PetscReal, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT, PetscRealPart(), PetscImaginaryPart()
353 M*/
354 
355 #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX)
356    typedef PetscComplex PetscScalar;
357 #else /* PETSC_USE_COMPLEX */
358    typedef PetscReal PetscScalar;
359 #endif /* PETSC_USE_COMPLEX */
360 
361 /*E
362     PetscCopyMode  - Determines how an array or PetscObject passed to certain functions is copied or retained by the aggregate PetscObject
363 
364    Level: beginner
365 
366    For the array input:
367 $   PETSC_COPY_VALUES - the array values are copied into new space, the user is free to reuse or delete the passed in array
368 $   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
369 $                       delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran.
370 $   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
371 $                       the array but the user must delete the array after the object is destroyed.
372 
373    For the PetscObject input:
374 $   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.
375 $   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.)
376    For either case above, the input PetscObject should be destroyed by the user when no longer needed (the aggregate object increases its reference count).
377 $   PETSC_USE_POINTER - invalid for PetscObject inputs.
378 
379 E*/
380 typedef enum {PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER} PetscCopyMode;
381 
382 /*MC
383     PETSC_FALSE - False value of PetscBool
384 
385     Level: beginner
386 
387     Note:
388     Zero integer
389 
390 .seealso: PetscBool, PETSC_TRUE
391 M*/
392 
393 /*MC
394     PETSC_TRUE - True value of PetscBool
395 
396     Level: beginner
397 
398     Note:
399     Nonzero integer
400 
401 .seealso: PetscBool, PETSC_FALSE
402 M*/
403 
404 /*MC
405     PetscLogDouble - Used for logging times
406 
407   Notes:
408   Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc.
409 
410   Level: developer
411 
412 M*/
413 typedef double PetscLogDouble;
414 
415 /*E
416     PetscDataType - Used for handling different basic data types.
417 
418    Level: beginner
419 
420    Notes:
421    Use of this should be avoided if one can directly use MPI_Datatype instead.
422 
423    PETSC_INT is the datatype for a PetscInt, regardless of whether it is 4 or 8 bytes.
424    PETSC_REAL, PETSC_COMPLEX and PETSC_SCALAR are the datatypes for PetscReal, PetscComplex and PetscScalar, regardless of their sizes.
425 
426    Developer comment:
427    It would be nice if we could always just use MPI Datatypes, why can we not?
428 
429    If you change any values in PetscDatatype make sure you update their usage in
430    share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m
431 
432    TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM
433 
434 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(),
435           PetscDataTypeGetSize()
436 
437 E*/
438 typedef enum {PETSC_DATATYPE_UNKNOWN = 0,
439               PETSC_DOUBLE = 1, PETSC_COMPLEX = 2, PETSC_LONG = 3, PETSC_SHORT = 4, PETSC_FLOAT = 5,
440               PETSC_CHAR = 6, PETSC_BIT_LOGICAL = 7, PETSC_ENUM = 8, PETSC_BOOL = 9, PETSC___FLOAT128 = 10,
441               PETSC_OBJECT = 11, PETSC_FUNCTION = 12, PETSC_STRING = 13, PETSC___FP16 = 14, PETSC_STRUCT = 15,
442               PETSC_INT = 16, PETSC_INT64 = 17} PetscDataType;
443 
444 #if defined(PETSC_USE_REAL_SINGLE)
445 #  define PETSC_REAL PETSC_FLOAT
446 #elif defined(PETSC_USE_REAL_DOUBLE)
447 #  define PETSC_REAL PETSC_DOUBLE
448 #elif defined(PETSC_USE_REAL___FLOAT128)
449 #  define PETSC_REAL PETSC___FLOAT128
450 #elif defined(PETSC_USE_REAL___FP16)
451 #  define PETSC_REAL PETSC___FP16
452 #else
453 #  define PETSC_REAL PETSC_DOUBLE
454 #endif
455 
456 #if defined(PETSC_USE_COMPLEX)
457 #  define PETSC_SCALAR PETSC_COMPLEX
458 #else
459 #  define PETSC_SCALAR PETSC_REAL
460 #endif
461 
462 #define PETSC_FORTRANADDR PETSC_LONG
463 
464 /*S
465     PetscToken - 'Token' used for managing tokenizing strings
466 
467   Level: intermediate
468 
469 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy()
470 S*/
471 typedef struct _p_PetscToken* PetscToken;
472 
473 /*S
474      PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc
475 
476    Level: beginner
477 
478    Note:
479    This is the base class from which all PETSc objects are derived from.
480 
481 .seealso:  PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName(), PetscObjectReference(), PetscObjectDereference()
482 S*/
483 typedef struct _p_PetscObject* PetscObject;
484 
485 /*MC
486     PetscObjectId - unique integer Id for a PetscObject
487 
488     Level: developer
489 
490     Notes:
491     Unlike pointer values, object ids are never reused.
492 
493 .seealso: PetscObjectState, PetscObjectGetId()
494 M*/
495 typedef PetscInt64 PetscObjectId;
496 
497 /*MC
498     PetscObjectState - integer state for a PetscObject
499 
500     Level: developer
501 
502     Notes:
503     Object state is always-increasing and (for objects that track state) can be used to determine if an object has
504     changed since the last time you interacted with it.  It is 64-bit so that it will not overflow for a very long time.
505 
506 .seealso: PetscObjectId, PetscObjectStateGet(), PetscObjectStateIncrease(), PetscObjectStateSet()
507 M*/
508 typedef PetscInt64 PetscObjectState;
509 
510 /*S
511      PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed
512       by string name
513 
514    Level: advanced
515 
516 .seealso:  PetscFunctionListAdd(), PetscFunctionListDestroy()
517 S*/
518 typedef struct _n_PetscFunctionList *PetscFunctionList;
519 
520 /*E
521   PetscFileMode - Access mode for a file.
522 
523   Level: beginner
524 
525 $  FILE_MODE_UNDEFINED - initial invalid value
526 $  FILE_MODE_READ - open a file at its beginning for reading
527 $  FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist)
528 $  FILE_MODE_APPEND - open a file at end for writing
529 $  FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing
530 $  FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end
531 
532 .seealso: PetscViewerFileSetMode()
533 E*/
534 typedef enum {FILE_MODE_UNDEFINED=-1, FILE_MODE_READ=0, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode;
535 
536 typedef void* PetscDLHandle;
537 typedef enum {PETSC_DL_DECIDE=0,PETSC_DL_NOW=1,PETSC_DL_LOCAL=2} PetscDLMode;
538 
539 /*S
540      PetscObjectList - Linked list of PETSc objects, each accessible by string name
541 
542    Level: developer
543 
544    Notes:
545    Used by PetscObjectCompose() and PetscObjectQuery()
546 
547 .seealso:  PetscObjectListAdd(), PetscObjectListDestroy(), PetscObjectListFind(), PetscObjectCompose(), PetscObjectQuery(), PetscFunctionList
548 S*/
549 typedef struct _n_PetscObjectList *PetscObjectList;
550 
551 /*S
552      PetscDLLibrary - Linked list of dynamics libraries to search for functions
553 
554    Level: advanced
555 
556 .seealso:  PetscDLLibraryOpen()
557 S*/
558 typedef struct _n_PetscDLLibrary *PetscDLLibrary;
559 
560 /*S
561      PetscContainer - Simple PETSc object that contains a pointer to any required data
562 
563    Level: advanced
564 
565 .seealso:  PetscObject, PetscContainerCreate()
566 S*/
567 typedef struct _p_PetscContainer*  PetscContainer;
568 
569 /*S
570      PetscRandom - Abstract PETSc object that manages generating random numbers
571 
572    Level: intermediate
573 
574 .seealso:  PetscRandomCreate(), PetscRandomGetValue(), PetscRandomType
575 S*/
576 typedef struct _p_PetscRandom*   PetscRandom;
577 
578 /*
579    In binary files variables are stored using the following lengths,
580   regardless of how they are stored in memory on any one particular
581   machine. Use these rather then sizeof() in computing sizes for
582   PetscBinarySeek().
583 */
584 #define PETSC_BINARY_INT_SIZE    (32/8)
585 #define PETSC_BINARY_FLOAT_SIZE  (32/8)
586 #define PETSC_BINARY_CHAR_SIZE   (8/8)
587 #define PETSC_BINARY_SHORT_SIZE  (16/8)
588 #define PETSC_BINARY_DOUBLE_SIZE (64/8)
589 #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar)
590 
591 /*E
592   PetscBinarySeekType - argument to PetscBinarySeek()
593 
594   Level: advanced
595 
596 .seealso: PetscBinarySeek(), PetscBinarySynchronizedSeek()
597 E*/
598 typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType;
599 
600 /*E
601     PetscBuildTwoSidedType - algorithm for setting up two-sided communication
602 
603 $  PETSC_BUILDTWOSIDED_ALLREDUCE - classical algorithm using an MPI_Allreduce with
604 $      a buffer of length equal to the communicator size. Not memory-scalable due to
605 $      the large reduction size. Requires only MPI-1.
606 $  PETSC_BUILDTWOSIDED_IBARRIER - nonblocking algorithm based on MPI_Issend and MPI_Ibarrier.
607 $      Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires MPI-3.
608 $  PETSC_BUILDTWOSIDED_REDSCATTER - similar to above, but use more optimized function
609 $      that only communicates the part of the reduction that is necessary.  Requires MPI-2.
610 
611    Level: developer
612 
613 .seealso: PetscCommBuildTwoSided(), PetscCommBuildTwoSidedSetType(), PetscCommBuildTwoSidedGetType()
614 E*/
615 typedef enum {
616   PETSC_BUILDTWOSIDED_NOTSET = -1,
617   PETSC_BUILDTWOSIDED_ALLREDUCE = 0,
618   PETSC_BUILDTWOSIDED_IBARRIER = 1,
619   PETSC_BUILDTWOSIDED_REDSCATTER = 2
620   /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */
621 } PetscBuildTwoSidedType;
622 
623 /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */
624 /*E
625   InsertMode - Whether entries are inserted or added into vectors or matrices
626 
627   Level: beginner
628 
629 .seealso: VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(),
630           VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(),
631           MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd()
632 E*/
633  typedef enum {NOT_SET_VALUES, INSERT_VALUES, ADD_VALUES, MAX_VALUES, MIN_VALUES, INSERT_ALL_VALUES, ADD_ALL_VALUES, INSERT_BC_VALUES, ADD_BC_VALUES} InsertMode;
634 
635 /*MC
636     INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value
637 
638     Level: beginner
639 
640 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(),
641           VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES,
642           MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd(), MAX_VALUES
643 
644 M*/
645 
646 /*MC
647     ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the
648                 value into that location
649 
650     Level: beginner
651 
652 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(),
653           VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), INSERT_VALUES,
654           MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd(), MAX_VALUES
655 
656 M*/
657 
658 /*MC
659     MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location
660 
661     Level: beginner
662 
663 .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES
664 
665 M*/
666 
667 /*MC
668     MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location
669 
670     Level: beginner
671 
672 .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES
673 
674 M*/
675 
676 /*S
677    PetscSubcomm - A decomposition of an MPI communicator into subcommunicators
678 
679    Notes:
680    After a call to PetscSubcommSetType(), PetscSubcommSetTypeGeneral(), or PetscSubcommSetFromOptions() one may call
681 $     PetscSubcommChild() returns the associated subcommunicator on this process
682 $     PetscSubcommContiguousParent() returns a parent communitor but with all child of the same subcommunicator having contiguous rank
683 
684    Sample Usage:
685        PetscSubcommCreate()
686        PetscSubcommSetNumber()
687        PetscSubcommSetType(PETSC_SUBCOMM_INTERLACED);
688        ccomm = PetscSubcommChild()
689        PetscSubcommDestroy()
690 
691    Level: advanced
692 
693    Notes:
694 $   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
695 $   PETSC_SUBCOMM_CONTIGUOUS - each new communicator contains a set of process with contiguous ranks in the original MPI communicator
696 $   PETSC_SUBCOMM_INTERLACED - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator
697 
698    Example: Consider a communicator with six processes split into 3 subcommunicators.
699 $     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
700 $     PETSC_SUBCOMM_INTERLACED - the first communicator contains rank 0,3, the second 1,4 and the third 2,5
701 
702    Developer Notes:
703    This is used in objects such as PCREDUNDANT to manage the subcommunicators on which the redundant computations
704       are performed.
705 
706 .seealso: PetscSubcommCreate(), PetscSubcommSetNumber(), PetscSubcommSetType(), PetscSubcommView(), PetscSubcommSetFromOptions()
707 
708 S*/
709 typedef struct _n_PetscSubcomm* PetscSubcomm;
710 typedef enum {PETSC_SUBCOMM_GENERAL=0,PETSC_SUBCOMM_CONTIGUOUS=1,PETSC_SUBCOMM_INTERLACED=2} PetscSubcommType;
711 
712 /*S
713      PetscHeap - A simple class for managing heaps
714 
715    Level: intermediate
716 
717 .seealso:  PetscHeapCreate(), PetscHeapAdd(), PetscHeapPop(), PetscHeapPeek(), PetscHeapStash(), PetscHeapUnstash(), PetscHeapView(), PetscHeapDestroy()
718 S*/
719 typedef struct _PetscHeap *PetscHeap;
720 
721 typedef struct _n_PetscShmComm* PetscShmComm;
722 typedef struct _n_PetscOmpCtrl* PetscOmpCtrl;
723 
724 /*S
725    PetscSegBuffer - a segmented extendable buffer
726 
727    Level: developer
728 
729 .seealso: PetscSegBufferCreate(), PetscSegBufferGet(), PetscSegBufferExtract(), PetscSegBufferDestroy()
730 S*/
731 typedef struct _n_PetscSegBuffer *PetscSegBuffer;
732 
733 typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted;
734 #endif
735