xref: /petsc/include/petscpartitioner.h (revision 237137dc2c36cd704ae82eca1d03b531ce3d02f9)
1 #pragma once
2 
3 #include <petscsection.h>
4 
5 /* MANSEC = Mat */
6 /* SUBMANSEC = MatGraphOperations */
7 
8 /*S
9   PetscPartitioner - PETSc object that manages a graph partitioner
10 
11   Level: intermediate
12 
13   Note:
14   Also consider `MatPartitioning` which provides an alternative API for partitioning.
15 
16 .seealso: `PetscPartitionerCreate()`, `PetscPartitionerSetType()`, `PetscPartitionerType`, `MatPartitioning`, `MatPartitioningCreate()`
17 S*/
18 typedef struct _p_PetscPartitioner *PetscPartitioner;
19 
20 PETSC_EXTERN PetscClassId   PETSCPARTITIONER_CLASSID;
21 PETSC_EXTERN PetscErrorCode PetscPartitionerInitializePackage(void);
22 PETSC_EXTERN PetscErrorCode PetscPartitionerFinalizePackage(void);
23 
24 /*J
25   PetscPartitionerType - String with the name of a PETSc graph partitioner
26 
27   Level: beginner
28 
29 .seealso: `PetscPartitionerSetType()`, `PetscPartitioner`
30 J*/
31 typedef const char *PetscPartitionerType;
32 #define PETSCPARTITIONERPARMETIS   "parmetis"
33 #define PETSCPARTITIONERPTSCOTCH   "ptscotch"
34 #define PETSCPARTITIONERCHACO      "chaco"
35 #define PETSCPARTITIONERSIMPLE     "simple"
36 #define PETSCPARTITIONERSHELL      "shell"
37 #define PETSCPARTITIONERGATHER     "gather"
38 #define PETSCPARTITIONERMULTISTAGE "multistage"
39 
40 PETSC_EXTERN PetscFunctionList PetscPartitionerList;
41 PETSC_EXTERN PetscErrorCode    PetscPartitionerRegister(const char[], PetscErrorCode (*)(PetscPartitioner));
42 
43 PETSC_EXTERN PetscErrorCode PetscPartitionerCreate(MPI_Comm, PetscPartitioner *);
44 PETSC_EXTERN PetscErrorCode PetscPartitionerDestroy(PetscPartitioner *);
45 PETSC_EXTERN PetscErrorCode PetscPartitionerSetType(PetscPartitioner, PetscPartitionerType);
46 PETSC_EXTERN PetscErrorCode PetscPartitionerGetType(PetscPartitioner, PetscPartitionerType *);
47 PETSC_EXTERN PetscErrorCode PetscPartitionerSetUp(PetscPartitioner);
48 PETSC_EXTERN PetscErrorCode PetscPartitionerReset(PetscPartitioner);
49 PETSC_EXTERN PetscErrorCode PetscPartitionerSetFromOptions(PetscPartitioner);
50 PETSC_EXTERN PetscErrorCode PetscPartitionerViewFromOptions(PetscPartitioner, PetscObject, const char[]);
51 PETSC_EXTERN PetscErrorCode PetscPartitionerView(PetscPartitioner, PetscViewer);
52 PETSC_EXTERN PetscErrorCode PetscPartitionerPartition(PetscPartitioner, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscSection, PetscSection, PetscSection, PetscSection, IS *);
53 
54 PETSC_EXTERN PetscErrorCode PetscPartitionerShellSetPartition(PetscPartitioner, PetscInt, const PetscInt[], const PetscInt[]);
55 PETSC_EXTERN PetscErrorCode PetscPartitionerShellSetRandom(PetscPartitioner, PetscBool);
56 PETSC_EXTERN PetscErrorCode PetscPartitionerShellGetRandom(PetscPartitioner, PetscBool *);
57 
58 /*E
59     PetscPartitionerMultistageStrategy - indicates what type of strategy to use
60 
61     Values:
62 +  `PETSCPARTITIONER_MS_STRATEGY_NODE` - Use node-aware stages
63 -  `PETSCPARTITIONER_MS_STRATEGY_MSECTION` - Use recursive m-sections
64 
65     Level: intermediate
66 
67 .seealso: `PetscPartitionerSetType()`, `PetscPartitioner`, `PETSCPARTITIONERMULTISTAGE`
68 E*/
69 typedef enum {
70   PETSCPARTITIONER_MS_STRATEGY_NODE,
71   PETSCPARTITIONER_MS_STRATEGY_MSECTION
72 } PetscPartitionerMultistageStrategy;
73 PETSC_EXTERN const char *const PetscPartitionerMultistageStrategyList[];
74 
75 PetscErrorCode PetscPartitionerMultistageSetStages(PetscPartitioner, PetscInt, MPI_Group[]);
76 
77 /* We should implement PetscPartitioner with MatPartitioning */
78 #include <petscmat.h>
79 #define PETSCPARTITIONERMATPARTITIONING "matpartitioning"
80 PETSC_EXTERN PetscErrorCode PetscPartitionerMatPartitioningGetMatPartitioning(PetscPartitioner, MatPartitioning *);
81