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