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