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 176 Notes: 177 For MPI calls that require datatypes, use MPIU_REAL as the datatype for PetscScalar and MPIU_SUM, MPIU_MAX, etc. for operations. 178 They will automatically work correctly regardless of the size of PetscReal. 179 180 See PetscScalar for details on how to ./configure the size of PetscReal. 181 182 Level: beginner 183 184 .seealso: PetscScalar, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT 185 M*/ 186 187 #if defined(PETSC_USE_REAL_SINGLE) 188 typedef float PetscReal; 189 #elif defined(PETSC_USE_REAL_DOUBLE) 190 typedef double PetscReal; 191 #elif defined(PETSC_USE_REAL___FLOAT128) 192 # if defined(__cplusplus) 193 extern "C" { 194 # endif 195 # include <quadmath.h> 196 # if defined(__cplusplus) 197 } 198 # endif 199 typedef __float128 PetscReal; 200 #elif defined(PETSC_USE_REAL___FP16) 201 typedef __fp16 PetscReal; 202 #endif /* PETSC_USE_REAL_* */ 203 204 /*MC 205 PetscComplex - PETSc type that represents a complex number with precision matching that of PetscReal. 206 207 Synopsis: 208 #include <petscsys.h> 209 PetscComplex number = 1. + 2.*PETSC_i; 210 211 Notes: 212 For MPI calls that require datatypes, use MPIU_COMPLEX as the datatype for PetscComplex and MPIU_SUM etc for operations. 213 They will automatically work correctly regardless of the size of PetscComplex. 214 215 See PetscScalar for details on how to ./configure the size of PetscReal 216 217 Complex numbers are automatically available if PETSc was able to find a working complex implementation 218 219 Level: beginner 220 221 .seealso: PetscReal, PetscScalar, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT, PETSC_i 222 M*/ 223 #if !defined(PETSC_SKIP_COMPLEX) 224 # if defined(PETSC_CLANGUAGE_CXX) 225 # if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128) 226 # if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */ 227 # define PETSC_HAVE_COMPLEX 1 228 # elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */ 229 # define PETSC_HAVE_COMPLEX 1 230 # endif 231 # endif 232 # else /* !PETSC_CLANGUAGE_CXX */ 233 # if !defined(PETSC_USE_REAL___FP16) 234 # if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */ 235 # define PETSC_HAVE_COMPLEX 1 236 # elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */ 237 # define PETSC_HAVE_COMPLEX 1 238 # endif 239 # endif 240 # endif /* PETSC_CLANGUAGE_CXX */ 241 #endif /* !PETSC_SKIP_COMPLEX */ 242 243 #if defined(PETSC_HAVE_COMPLEX) 244 #if defined(__cplusplus) /* C++ complex support */ 245 /* Locate a C++ complex template library */ 246 #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */ 247 #define petsccomplexlib Kokkos 248 #include <Kokkos_Complex.hpp> 249 #elif defined(PETSC_HAVE_CUDA) 250 #define petsccomplexlib thrust 251 #include <thrust/complex.h> 252 #else 253 #define petsccomplexlib std 254 #include <complex> 255 #endif 256 257 /* Define PetscComplex based on the precision */ 258 #if defined(PETSC_USE_REAL_SINGLE) 259 typedef petsccomplexlib::complex<float> PetscComplex; 260 #elif defined(PETSC_USE_REAL_DOUBLE) 261 typedef petsccomplexlib::complex<double> PetscComplex; 262 #elif defined(PETSC_USE_REAL___FLOAT128) 263 typedef petsccomplexlib::complex<__float128> PetscComplex; /* Notstandard and not expected to work, use __complex128 */ 264 #endif 265 266 #if !defined(PETSC_SKIP_CXX_COMPLEX_FIX) 267 #include <petsccxxcomplexfix.h> 268 #endif 269 #else /* c99 complex support */ 270 #include <complex.h> 271 #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16) 272 typedef float _Complex PetscComplex; 273 #elif defined(PETSC_USE_REAL_DOUBLE) 274 typedef double _Complex PetscComplex; 275 #elif defined(PETSC_USE_REAL___FLOAT128) 276 typedef __complex128 PetscComplex; 277 #endif /* PETSC_USE_REAL_* */ 278 #endif /* !__cplusplus */ 279 #endif /* PETSC_HAVE_COMPLEX */ 280 281 /*MC 282 PetscScalar - PETSc type that represents either a double precision real number, a double precision 283 complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured 284 with --with-scalar-type=real,complex --with-precision=single,double,__float128,__fp16 285 286 Notes: 287 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. 288 289 Level: beginner 290 291 .seealso: PetscReal, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX, MPIU_INT, PetscRealPart(), PetscImaginaryPart() 292 M*/ 293 294 #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX) 295 typedef PetscComplex PetscScalar; 296 #else /* PETSC_USE_COMPLEX */ 297 typedef PetscReal PetscScalar; 298 #endif /* PETSC_USE_COMPLEX */ 299 300 /*E 301 PetscCopyMode - Determines how an array or PetscObject passed to certain functions is copied or retained by the aggregate PetscObject 302 303 Level: beginner 304 305 For the array input: 306 $ PETSC_COPY_VALUES - the array values are copied into new space, the user is free to reuse or delete the passed in array 307 $ 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 308 $ delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran. 309 $ 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 310 $ the array but the user must delete the array after the object is destroyed. 311 312 For the PetscObject input: 313 $ 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. 314 $ 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.) 315 For either case above, the input PetscObject should be destroyed by the user when no longer needed (the aggregate object increases its reference count). 316 $ PETSC_USE_POINTER - invalid for PetscObject inputs. 317 318 E*/ 319 typedef enum {PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER} PetscCopyMode; 320 321 /*MC 322 PETSC_FALSE - False value of PetscBool 323 324 Level: beginner 325 326 Note: 327 Zero integer 328 329 .seealso: PetscBool, PETSC_TRUE 330 M*/ 331 332 /*MC 333 PETSC_TRUE - True value of PetscBool 334 335 Level: beginner 336 337 Note: 338 Nonzero integer 339 340 .seealso: PetscBool, PETSC_FALSE 341 M*/ 342 343 /*MC 344 PetscLogDouble - Used for logging times 345 346 Notes: 347 Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc. 348 349 Level: developer 350 351 M*/ 352 typedef double PetscLogDouble; 353 354 /*E 355 PetscDataType - Used for handling different basic data types. 356 357 Level: beginner 358 359 Notes: 360 Use of this should be avoided if one can directly use MPI_Datatype instead. 361 362 PETSC_INT is the datatype for a PetscInt, regardless of whether it is 4 or 8 bytes. 363 PETSC_REAL, PETSC_COMPLEX and PETSC_SCALAR are the datatypes for PetscReal, PetscComplex and PetscScalar, regardless of their sizes. 364 365 Developer comment: 366 It would be nice if we could always just use MPI Datatypes, why can we not? 367 368 If you change any values in PetscDatatype make sure you update their usage in 369 share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m 370 371 TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM 372 373 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(), 374 PetscDataTypeGetSize() 375 376 E*/ 377 typedef enum {PETSC_DATATYPE_UNKNOWN = 0, 378 PETSC_DOUBLE = 1, PETSC_COMPLEX = 2, PETSC_LONG = 3, PETSC_SHORT = 4, PETSC_FLOAT = 5, 379 PETSC_CHAR = 6, PETSC_BIT_LOGICAL = 7, PETSC_ENUM = 8, PETSC_BOOL = 9, PETSC___FLOAT128 = 10, 380 PETSC_OBJECT = 11, PETSC_FUNCTION = 12, PETSC_STRING = 13, PETSC___FP16 = 14, PETSC_STRUCT = 15, 381 PETSC_INT = 16, PETSC_INT64 = 17} PetscDataType; 382 383 #if defined(PETSC_USE_REAL_SINGLE) 384 # define PETSC_REAL PETSC_FLOAT 385 #elif defined(PETSC_USE_REAL_DOUBLE) 386 # define PETSC_REAL PETSC_DOUBLE 387 #elif defined(PETSC_USE_REAL___FLOAT128) 388 # define PETSC_REAL PETSC___FLOAT128 389 #elif defined(PETSC_USE_REAL___FP16) 390 # define PETSC_REAL PETSC___FP16 391 #else 392 # define PETSC_REAL PETSC_DOUBLE 393 #endif 394 395 #if defined(PETSC_USE_COMPLEX) 396 # define PETSC_SCALAR PETSC_COMPLEX 397 #else 398 # define PETSC_SCALAR PETSC_REAL 399 #endif 400 401 #define PETSC_FORTRANADDR PETSC_LONG 402 403 /*S 404 PetscToken - 'Token' used for managing tokenizing strings 405 406 Level: intermediate 407 408 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy() 409 S*/ 410 typedef struct _p_PetscToken* PetscToken; 411 412 /*S 413 PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc 414 415 Level: beginner 416 417 Note: 418 This is the base class from which all PETSc objects are derived from. 419 420 .seealso: PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName(), PetscObjectReference(), PetscObjectDereference() 421 S*/ 422 typedef struct _p_PetscObject* PetscObject; 423 424 /*MC 425 PetscObjectId - unique integer Id for a PetscObject 426 427 Level: developer 428 429 Notes: 430 Unlike pointer values, object ids are never reused. 431 432 .seealso: PetscObjectState, PetscObjectGetId() 433 M*/ 434 typedef PetscInt64 PetscObjectId; 435 436 /*MC 437 PetscObjectState - integer state for a PetscObject 438 439 Level: developer 440 441 Notes: 442 Object state is always-increasing and (for objects that track state) can be used to determine if an object has 443 changed since the last time you interacted with it. It is 64-bit so that it will not overflow for a very long time. 444 445 .seealso: PetscObjectId, PetscObjectStateGet(), PetscObjectStateIncrease(), PetscObjectStateSet() 446 M*/ 447 typedef PetscInt64 PetscObjectState; 448 449 /*S 450 PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed 451 by string name 452 453 Level: advanced 454 455 .seealso: PetscFunctionListAdd(), PetscFunctionListDestroy() 456 S*/ 457 typedef struct _n_PetscFunctionList *PetscFunctionList; 458 459 /*E 460 PetscFileMode - Access mode for a file. 461 462 Level: beginner 463 464 $ FILE_MODE_UNDEFINED - initial invalid value 465 $ FILE_MODE_READ - open a file at its beginning for reading 466 $ FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist) 467 $ FILE_MODE_APPEND - open a file at end for writing 468 $ FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing 469 $ FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end 470 471 .seealso: PetscViewerFileSetMode() 472 E*/ 473 typedef enum {FILE_MODE_UNDEFINED=-1, FILE_MODE_READ=0, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode; 474 475 typedef void* PetscDLHandle; 476 typedef enum {PETSC_DL_DECIDE=0,PETSC_DL_NOW=1,PETSC_DL_LOCAL=2} PetscDLMode; 477 478 /*S 479 PetscObjectList - Linked list of PETSc objects, each accessible by string name 480 481 Level: developer 482 483 Notes: 484 Used by PetscObjectCompose() and PetscObjectQuery() 485 486 .seealso: PetscObjectListAdd(), PetscObjectListDestroy(), PetscObjectListFind(), PetscObjectCompose(), PetscObjectQuery(), PetscFunctionList 487 S*/ 488 typedef struct _n_PetscObjectList *PetscObjectList; 489 490 /*S 491 PetscDLLibrary - Linked list of dynamics libraries to search for functions 492 493 Level: advanced 494 495 .seealso: PetscDLLibraryOpen() 496 S*/ 497 typedef struct _n_PetscDLLibrary *PetscDLLibrary; 498 499 /*S 500 PetscContainer - Simple PETSc object that contains a pointer to any required data 501 502 Level: advanced 503 504 .seealso: PetscObject, PetscContainerCreate() 505 S*/ 506 typedef struct _p_PetscContainer* PetscContainer; 507 508 /*S 509 PetscRandom - Abstract PETSc object that manages generating random numbers 510 511 Level: intermediate 512 513 .seealso: PetscRandomCreate(), PetscRandomGetValue(), PetscRandomType 514 S*/ 515 typedef struct _p_PetscRandom* PetscRandom; 516 517 /* 518 In binary files variables are stored using the following lengths, 519 regardless of how they are stored in memory on any one particular 520 machine. Use these rather then sizeof() in computing sizes for 521 PetscBinarySeek(). 522 */ 523 #define PETSC_BINARY_INT_SIZE (32/8) 524 #define PETSC_BINARY_FLOAT_SIZE (32/8) 525 #define PETSC_BINARY_CHAR_SIZE (8/8) 526 #define PETSC_BINARY_SHORT_SIZE (16/8) 527 #define PETSC_BINARY_DOUBLE_SIZE (64/8) 528 #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar) 529 530 /*E 531 PetscBinarySeekType - argument to PetscBinarySeek() 532 533 Level: advanced 534 535 .seealso: PetscBinarySeek(), PetscBinarySynchronizedSeek() 536 E*/ 537 typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType; 538 539 /*E 540 PetscBuildTwoSidedType - algorithm for setting up two-sided communication 541 542 $ PETSC_BUILDTWOSIDED_ALLREDUCE - classical algorithm using an MPI_Allreduce with 543 $ a buffer of length equal to the communicator size. Not memory-scalable due to 544 $ the large reduction size. Requires only MPI-1. 545 $ PETSC_BUILDTWOSIDED_IBARRIER - nonblocking algorithm based on MPI_Issend and MPI_Ibarrier. 546 $ Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires MPI-3. 547 $ PETSC_BUILDTWOSIDED_REDSCATTER - similar to above, but use more optimized function 548 $ that only communicates the part of the reduction that is necessary. Requires MPI-2. 549 550 Level: developer 551 552 .seealso: PetscCommBuildTwoSided(), PetscCommBuildTwoSidedSetType(), PetscCommBuildTwoSidedGetType() 553 E*/ 554 typedef enum { 555 PETSC_BUILDTWOSIDED_NOTSET = -1, 556 PETSC_BUILDTWOSIDED_ALLREDUCE = 0, 557 PETSC_BUILDTWOSIDED_IBARRIER = 1, 558 PETSC_BUILDTWOSIDED_REDSCATTER = 2 559 /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */ 560 } PetscBuildTwoSidedType; 561 562 /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */ 563 /*E 564 InsertMode - Whether entries are inserted or added into vectors or matrices 565 566 Level: beginner 567 568 .seealso: VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 569 VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), 570 MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd() 571 E*/ 572 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; 573 574 /*MC 575 INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value 576 577 Level: beginner 578 579 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 580 VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES, 581 MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd(), MAX_VALUES 582 583 M*/ 584 585 /*MC 586 ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the 587 value into that location 588 589 Level: beginner 590 591 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 592 VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), INSERT_VALUES, 593 MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd(), MAX_VALUES 594 595 M*/ 596 597 /*MC 598 MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location 599 600 Level: beginner 601 602 .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES 603 604 M*/ 605 606 /*MC 607 MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location 608 609 Level: beginner 610 611 .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES 612 613 M*/ 614 615 616 /*S 617 PetscSubcomm - A decomposition of an MPI communicator into subcommunicators 618 619 Notes: 620 After a call to PetscSubcommSetType(), PetscSubcommSetTypeGeneral(), or PetscSubcommSetFromOptions() one may call 621 $ PetscSubcommChild() returns the associated subcommunicator on this process 622 $ PetscSubcommContiguousParent() returns a parent communitor but with all child of the same subcommunicator having contiguous rank 623 624 Sample Usage: 625 PetscSubcommCreate() 626 PetscSubcommSetNumber() 627 PetscSubcommSetType(PETSC_SUBCOMM_INTERLACED); 628 ccomm = PetscSubcommChild() 629 PetscSubcommDestroy() 630 631 Level: advanced 632 633 Notes: 634 $ 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 635 $ PETSC_SUBCOMM_CONTIGUOUS - each new communicator contains a set of process with contiguous ranks in the original MPI communicator 636 $ PETSC_SUBCOMM_INTERLACED - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator 637 638 Example: Consider a communicator with six processes split into 3 subcommunicators. 639 $ 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 640 $ PETSC_SUBCOMM_INTERLACED - the first communicator contains rank 0,3, the second 1,4 and the third 2,5 641 642 Developer Notes: 643 This is used in objects such as PCREDUNDANT to manage the subcommunicators on which the redundant computations 644 are performed. 645 646 647 .seealso: PetscSubcommCreate(), PetscSubcommSetNumber(), PetscSubcommSetType(), PetscSubcommView(), PetscSubcommSetFromOptions() 648 649 S*/ 650 typedef struct _n_PetscSubcomm* PetscSubcomm; 651 typedef enum {PETSC_SUBCOMM_GENERAL=0,PETSC_SUBCOMM_CONTIGUOUS=1,PETSC_SUBCOMM_INTERLACED=2} PetscSubcommType; 652 653 /*S 654 PetscHeap - A simple class for managing heaps 655 656 Level: intermediate 657 658 .seealso: PetscHeapCreate(), PetscHeapAdd(), PetscHeapPop(), PetscHeapPeek(), PetscHeapStash(), PetscHeapUnstash(), PetscHeapView(), PetscHeapDestroy() 659 S*/ 660 typedef struct _PetscHeap *PetscHeap; 661 662 typedef struct _n_PetscShmComm* PetscShmComm; 663 typedef struct _n_PetscOmpCtrl* PetscOmpCtrl; 664 665 /*S 666 PetscSegBuffer - a segmented extendable buffer 667 668 Level: developer 669 670 .seealso: PetscSegBufferCreate(), PetscSegBufferGet(), PetscSegBufferExtract(), PetscSegBufferDestroy() 671 S*/ 672 typedef struct _n_PetscSegBuffer *PetscSegBuffer; 673 674 typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted; 675 676 /*E 677 PetscMemType - Memory type of a pointer 678 679 Level: beginner 680 681 Developer Note: 682 Encoding of the bitmask in binary: xxxxyyyz 683 z = 0: Host memory 684 z = 1: Device memory 685 yyy = 000: CUDA-related memory 686 yyy = 001: HIP-related memory 687 xxxxyyy1 = 0000,0001: CUDA memory 688 xxxxyyy1 = 0001,0001: CUDA NVSHMEM memory 689 xxxxyyy1 = 0000,0011: HIP memory 690 691 Other types of memory, e.g., CUDA managed memory, can be added when needed. 692 693 .seealso: VecGetArrayAndMemType(), PetscSFBcastWithMemTypeBegin(), PetscSFReduceWithMemTypeBegin() 694 E*/ 695 typedef enum {PETSC_MEMTYPE_HOST=0, PETSC_MEMTYPE_DEVICE=0x01, PETSC_MEMTYPE_CUDA=0x01, PETSC_MEMTYPE_NVSHMEM=0x11,PETSC_MEMTYPE_HIP=0x03} PetscMemType; 696 697 #define PetscMemTypeHost(m) (((m) & 0x1) == PETSC_MEMTYPE_HOST) 698 #define PetscMemTypeDevice(m) (((m) & 0x1) == PETSC_MEMTYPE_DEVICE) 699 #define PetscMemTypeCUDA(m) (((m) & 0xF) == PETSC_MEMTYPE_CUDA) 700 #define PetscMemTypeHIP(m) (((m) & 0xF) == PETSC_MEMTYPE_HIP) 701 #define PetscMemTypeNVSHMEM(m) ((m) == PETSC_MEMTYPE_NVSHMEM) 702 703 #endif 704