Bug Summary

File:ksp/pc/impls/redundant/redundant.c
Warning:line 2342, column 76
Access to field 'child' results in a dereference of a null pointer (loaded from variable 'scomm')

Annotated Source Code

[?] Use j/k keys for keyboard navigation

/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c

1
2/*
3 This file defines a "solve the problem redundantly on each subgroup of processor" preconditioner.
4*/
5#include <petsc/private/pcimpl.h>
6#include <petscksp.h> /*I "petscksp.h" I*/
7
8typedef struct {
9 KSP ksp;
10 PC pc; /* actual preconditioner used on each processor */
11 Vec xsub,ysub; /* vectors of a subcommunicator to hold parallel vectors of PetscObjectComm((PetscObject)pc) */
12 Vec xdup,ydup; /* parallel vector that congregates xsub or ysub facilitating vector scattering */
13 Mat pmats; /* matrix and optional preconditioner matrix belong to a subcommunicator */
14 VecScatter scatterin,scatterout; /* scatter used to move all values to each processor group (subcommunicator) */
15 PetscBool useparallelmat;
16 PetscSubcomm psubcomm;
17 PetscInt nsubcomm; /* num of data structure PetscSubcomm */
18 PetscBool shifttypeset;
19 MatFactorShiftType shifttype;
20} PC_Redundant;
21
22PetscErrorCode PCFactorSetShiftType_Redundant(PC pc,MatFactorShiftType shifttype)
23{
24 PC_Redundant *red = (PC_Redundant*)pc->data;
25 PetscErrorCode ierr;
26
27 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 27; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
28 if (red->ksp) {
29 PC pc;
30 ierr = KSPGetPC(red->ksp,&pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),30,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
31 ierr = PCFactorSetShiftType(pc,shifttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),31,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
32 } else {
33 red->shifttypeset = PETSC_TRUE;
34 red->shifttype = shifttype;
35 }
36 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
37}
38
39static PetscErrorCode PCView_Redundant(PC pc,PetscViewer viewer)
40{
41 PC_Redundant *red = (PC_Redundant*)pc->data;
42 PetscErrorCode ierr;
43 PetscBool iascii,isstring;
44 PetscViewer subviewer;
45
46 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 46; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
47 ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII"ascii",&iascii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),47,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
48 ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERSTRING"string",&isstring);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),48,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
49 if (iascii) {
50 if (!red->psubcomm) {
51 ierr = PetscViewerASCIIPrintf(viewer," Not yet setup\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),51,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
52 } else {
53 ierr = PetscViewerASCIIPrintf(viewer," First (color=0) of %D PCs follows\n",red->nsubcomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),53,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
54 ierr = PetscViewerGetSubViewer(viewer,((PetscObject)red->pc)->comm,&subviewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),54,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
55 if (!red->psubcomm->color) { /* only view first redundant pc */
56 ierr = PetscViewerASCIIPushTab(subviewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),56,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
57 ierr = KSPView(red->ksp,subviewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),57,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
58 ierr = PetscViewerASCIIPopTab(subviewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),58,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
59 }
60 ierr = PetscViewerRestoreSubViewer(viewer,((PetscObject)red->pc)->comm,&subviewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),60,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
61 }
62 } else if (isstring) {
63 ierr = PetscViewerStringSPrintf(viewer," Redundant solver preconditioner");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),63,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
64 }
65 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
66}
67
68#include <../src/mat/impls/aij/mpi/mpiaij.h>
69static PetscErrorCode PCSetUp_Redundant(PC pc)
70{
71 PC_Redundant *red = (PC_Redundant*)pc->data;
72 PetscErrorCode ierr;
73 PetscInt mstart,mend,mlocal,M;
74 PetscMPIInt size;
75 MPI_Comm comm,subcomm;
76 Vec x;
77
78 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 78; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
79 ierr = PetscObjectGetComm((PetscObject)pc,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),79,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
80
81 /* if pmatrix set by user is sequential then we do not need to gather the parallel matrix */
82 ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),82,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
83 if (size == 1) red->useparallelmat = PETSC_FALSE;
1
Assuming 'size' is not equal to 1
2
Taking false branch
84
85 if (!pc->setupcalled) {
3
Assuming the condition is true
4
Taking true branch
86 PetscInt mloc_sub;
87 if (!red->psubcomm) { /* create red->psubcomm, new ksp and pc over subcomm */
5
Assuming pointer value is null
6
Taking true branch
88 KSP ksp;
89 ierr = PCRedundantGetKSP(pc,&ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),89,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
90 }
91 subcomm = PetscSubcommChild(red->psubcomm);
7
Passing null pointer value via 1st parameter 'scomm'
8
Calling 'PetscSubcommChild'
92
93 if (red->useparallelmat) {
94 /* grab the parallel matrix and put it into processors of a subcomminicator */
95 ierr = MatCreateRedundantMatrix(pc->pmat,red->psubcomm->n,subcomm,MAT_INITIAL_MATRIX,&red->pmats);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),95,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
96
97 ierr = MPI_Comm_size(subcomm,&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),97,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
98 if (size > 1) {
99 PetscBool foundpack;
100 ierr = MatGetFactorAvailable(red->pmats,NULL((void*)0),MAT_FACTOR_LU,&foundpack);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),100,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
101 if (!foundpack) { /* reset default ksp and pc */
102 ierr = KSPSetType(red->ksp,KSPGMRES"gmres");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),102,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
103 ierr = PCSetType(red->pc,PCBJACOBI"bjacobi");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),103,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
104 } else {
105 ierr = PCFactorSetMatSolverType(red->pc,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),105,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
106 }
107 }
108
109 ierr = KSPSetOperators(red->ksp,red->pmats,red->pmats);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),109,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
110
111 /* get working vectors xsub and ysub */
112 ierr = MatCreateVecs(red->pmats,&red->xsub,&red->ysub);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),112,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
113
114 /* create working vectors xdup and ydup.
115 xdup concatenates all xsub's contigously to form a mpi vector over dupcomm (see PetscSubcommCreate_interlaced())
116 ydup concatenates all ysub and has empty local arrays because ysub's arrays will be place into it.
117 Note: we use communicator dupcomm, not PetscObjectComm((PetscObject)pc)! */
118 ierr = MatGetLocalSize(red->pmats,&mloc_sub,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),118,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
119 ierr = VecCreateMPI(PetscSubcommContiguousParent(red->psubcomm),mloc_sub,PETSC_DECIDE-1,&red->xdup);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),119,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
120 ierr = VecCreateMPIWithArray(PetscSubcommContiguousParent(red->psubcomm),1,mloc_sub,PETSC_DECIDE-1,NULL((void*)0),&red->ydup);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),120,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
121
122 /* create vecscatters */
123 if (!red->scatterin) { /* efficiency of scatterin is independent from psubcomm_type! */
124 IS is1,is2;
125 PetscInt *idx1,*idx2,i,j,k;
126
127 ierr = MatCreateVecs(pc->pmat,&x,0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),127,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
128 ierr = VecGetSize(x,&M);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),128,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
129 ierr = VecGetOwnershipRange(x,&mstart,&mend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),129,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
130 mlocal = mend - mstart;
131 ierr = PetscMalloc2(red->psubcomm->n*mlocal,&idx1,red->psubcomm->n*mlocal,&idx2)PetscMallocA(2,PETSC_FALSE,131,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,(size_t)(red->psubcomm->n*mlocal)*sizeof(**(&idx1)
),(&idx1),(size_t)(red->psubcomm->n*mlocal)*sizeof(
**(&idx2)),(&idx2))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),131,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
132 j = 0;
133 for (k=0; k<red->psubcomm->n; k++) {
134 for (i=mstart; i<mend; i++) {
135 idx1[j] = i;
136 idx2[j++] = i + M*k;
137 }
138 }
139 ierr = ISCreateGeneral(comm,red->psubcomm->n*mlocal,idx1,PETSC_COPY_VALUES,&is1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),139,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
140 ierr = ISCreateGeneral(comm,red->psubcomm->n*mlocal,idx2,PETSC_COPY_VALUES,&is2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),140,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
141 ierr = VecScatterCreate(x,is1,red->xdup,is2,&red->scatterin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),141,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
142 ierr = ISDestroy(&is1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),142,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
143 ierr = ISDestroy(&is2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),143,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
144
145 /* Impl below is good for PETSC_SUBCOMM_INTERLACED (no inter-process communication) and PETSC_SUBCOMM_CONTIGUOUS (communication within subcomm) */
146 ierr = ISCreateStride(comm,mlocal,mstart+ red->psubcomm->color*M,1,&is1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),146,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
147 ierr = ISCreateStride(comm,mlocal,mstart,1,&is2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),147,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
148 ierr = VecScatterCreate(red->xdup,is1,x,is2,&red->scatterout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),148,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
149 ierr = ISDestroy(&is1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),149,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
150 ierr = ISDestroy(&is2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),150,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
151 ierr = PetscFree2(idx1,idx2)PetscFreeA(2,151,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,&(idx1),&(idx2))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),151,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
152 ierr = VecDestroy(&x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),152,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
153 }
154 } else { /* !red->useparallelmat */
155 ierr = KSPSetOperators(red->ksp,pc->mat,pc->pmat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),155,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
156 }
157 } else { /* pc->setupcalled */
158 if (red->useparallelmat) {
159 MatReuse reuse;
160 /* grab the parallel matrix and put it into processors of a subcomminicator */
161 /*--------------------------------------------------------------------------*/
162 if (pc->flag == DIFFERENT_NONZERO_PATTERN) {
163 /* destroy old matrices */
164 ierr = MatDestroy(&red->pmats);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),164,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
165 reuse = MAT_INITIAL_MATRIX;
166 } else {
167 reuse = MAT_REUSE_MATRIX;
168 }
169 ierr = MatCreateRedundantMatrix(pc->pmat,red->psubcomm->n,PetscSubcommChild(red->psubcomm),reuse,&red->pmats);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),169,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
170 ierr = KSPSetOperators(red->ksp,red->pmats,red->pmats);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),170,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
171 } else { /* !red->useparallelmat */
172 ierr = KSPSetOperators(red->ksp,pc->mat,pc->pmat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),172,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
173 }
174 }
175
176 if (pc->setfromoptionscalled) {
177 ierr = KSPSetFromOptions(red->ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),177,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
178 }
179 ierr = KSPSetUp(red->ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),179,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
180 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
181}
182
183static PetscErrorCode PCApply_Redundant(PC pc,Vec x,Vec y)
184{
185 PC_Redundant *red = (PC_Redundant*)pc->data;
186 PetscErrorCode ierr;
187 PetscScalar *array;
188
189 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 189; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
190 if (!red->useparallelmat) {
191 ierr = KSPSolve(red->ksp,x,y);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),191,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
192 ierr = KSPCheckSolve(red->ksp,pc,y);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),192,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
193 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
194 }
195
196 /* scatter x to xdup */
197 ierr = VecScatterBegin(red->scatterin,x,red->xdup,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),197,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
198 ierr = VecScatterEnd(red->scatterin,x,red->xdup,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),198,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
199
200 /* place xdup's local array into xsub */
201 ierr = VecGetArray(red->xdup,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),201,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
202 ierr = VecPlaceArray(red->xsub,(const PetscScalar*)array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),202,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
203
204 /* apply preconditioner on each processor */
205 ierr = KSPSolve(red->ksp,red->xsub,red->ysub);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),205,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
206 ierr = KSPCheckSolve(red->ksp,pc,red->ysub);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),206,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
207 ierr = VecResetArray(red->xsub);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),207,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
208 ierr = VecRestoreArray(red->xdup,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),208,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
209
210 /* place ysub's local array into ydup */
211 ierr = VecGetArray(red->ysub,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),211,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
212 ierr = VecPlaceArray(red->ydup,(const PetscScalar*)array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),212,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
213
214 /* scatter ydup to y */
215 ierr = VecScatterBegin(red->scatterout,red->ydup,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),215,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
216 ierr = VecScatterEnd(red->scatterout,red->ydup,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),216,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
217 ierr = VecResetArray(red->ydup);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),217,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
218 ierr = VecRestoreArray(red->ysub,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),218,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
219 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
220}
221
222static PetscErrorCode PCApplyTranspose_Redundant(PC pc,Vec x,Vec y)
223{
224 PC_Redundant *red = (PC_Redundant*)pc->data;
225 PetscErrorCode ierr;
226 PetscScalar *array;
227
228 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 228; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
229 if (!red->useparallelmat) {
230 ierr = KSPSolveTranspose(red->ksp,x,y);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),230,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
231 ierr = KSPCheckSolve(red->ksp,pc,y);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),231,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
232 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
233 }
234
235 /* scatter x to xdup */
236 ierr = VecScatterBegin(red->scatterin,x,red->xdup,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),236,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
237 ierr = VecScatterEnd(red->scatterin,x,red->xdup,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),237,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
238
239 /* place xdup's local array into xsub */
240 ierr = VecGetArray(red->xdup,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),240,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
241 ierr = VecPlaceArray(red->xsub,(const PetscScalar*)array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),241,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
242
243 /* apply preconditioner on each processor */
244 ierr = KSPSolveTranspose(red->ksp,red->xsub,red->ysub);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),244,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
245 ierr = KSPCheckSolve(red->ksp,pc,red->ysub);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),245,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
246 ierr = VecResetArray(red->xsub);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),246,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
247 ierr = VecRestoreArray(red->xdup,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),247,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
248
249 /* place ysub's local array into ydup */
250 ierr = VecGetArray(red->ysub,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),250,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
251 ierr = VecPlaceArray(red->ydup,(const PetscScalar*)array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),251,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
252
253 /* scatter ydup to y */
254 ierr = VecScatterBegin(red->scatterout,red->ydup,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),254,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
255 ierr = VecScatterEnd(red->scatterout,red->ydup,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),255,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
256 ierr = VecResetArray(red->ydup);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),256,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
257 ierr = VecRestoreArray(red->ysub,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),257,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
258 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
259}
260
261static PetscErrorCode PCReset_Redundant(PC pc)
262{
263 PC_Redundant *red = (PC_Redundant*)pc->data;
264 PetscErrorCode ierr;
265
266 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 266; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
267 if (red->useparallelmat) {
268 ierr = VecScatterDestroy(&red->scatterin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),268,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
269 ierr = VecScatterDestroy(&red->scatterout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),269,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
270 ierr = VecDestroy(&red->ysub);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),270,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
271 ierr = VecDestroy(&red->xsub);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),271,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
272 ierr = VecDestroy(&red->xdup);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),272,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
273 ierr = VecDestroy(&red->ydup);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),273,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
274 }
275 ierr = MatDestroy(&red->pmats);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),275,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
276 ierr = KSPReset(red->ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),276,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
277 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
278}
279
280static PetscErrorCode PCDestroy_Redundant(PC pc)
281{
282 PC_Redundant *red = (PC_Redundant*)pc->data;
283 PetscErrorCode ierr;
284
285 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 285; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
286 ierr = PCReset_Redundant(pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),286,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
287 ierr = KSPDestroy(&red->ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),287,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
288 ierr = PetscSubcommDestroy(&red->psubcomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),288,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
289 ierr = PetscFree(pc->data)((*PetscTrFree)((void*)(pc->data),289,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
) || ((pc->data) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),289,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
290 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
291}
292
293static PetscErrorCode PCSetFromOptions_Redundant(PetscOptionItems *PetscOptionsObject,PC pc)
294{
295 PetscErrorCode ierr;
296 PC_Redundant *red = (PC_Redundant*)pc->data;
297
298 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 298; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
299 ierr = PetscOptionsHead(PetscOptionsObject,"Redundant options");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),299,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
300 ierr = PetscOptionsInt("-pc_redundant_number","Number of redundant pc","PCRedundantSetNumber",red->nsubcomm,&red->nsubcomm,0)PetscOptionsInt_Private(PetscOptionsObject,"-pc_redundant_number"
,"Number of redundant pc","PCRedundantSetNumber",red->nsubcomm
,&red->nsubcomm,0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),300,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
301 ierr = PetscOptionsTail()0; {if (PetscOptionsObject->count != 1) do { do { ; if (petscstack
&& petscstack->currentsize > 0) { petscstack->
currentsize--; petscstack->function[petscstack->currentsize
] = 0; petscstack->file[petscstack->currentsize] = 0; petscstack
->line[petscstack->currentsize] = 0; petscstack->petscroutine
[petscstack->currentsize] = PETSC_FALSE; } if (petscstack)
{ petscstack->hotdepth = (((petscstack->hotdepth-1)<
(0)) ? (0) : (petscstack->hotdepth-1)); } ; } while (0); return
(0);} while (0);}
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),301,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
302 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
303}
304
305static PetscErrorCode PCRedundantSetNumber_Redundant(PC pc,PetscInt nreds)
306{
307 PC_Redundant *red = (PC_Redundant*)pc->data;
308
309 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 309; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
310 red->nsubcomm = nreds;
311 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
312}
313
314/*@
315 PCRedundantSetNumber - Sets the number of redundant preconditioner contexts.
316
317 Logically Collective on PC
318
319 Input Parameters:
320+ pc - the preconditioner context
321- nredundant - number of redundant preconditioner contexts; for example if you are using 64 MPI processes and
322 use an nredundant of 4 there will be 4 parallel solves each on 16 = 64/4 processes.
323
324 Level: advanced
325
326.keywords: PC, redundant solve
327@*/
328PetscErrorCode PCRedundantSetNumber(PC pc,PetscInt nredundant)
329{
330 PetscErrorCode ierr;
331
332 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 332; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
333 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),333,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(pc,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),333,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(pc))->classid != PC_CLASSID) { if (
((PetscObject)(pc))->classid == -1) return PetscError(((MPI_Comm
)0x44000001),333,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),333,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
334 if (nredundant <= 0) SETERRQ1(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONG, "num of redundant pc %D must be positive",nredundant)return PetscError(PetscObjectComm((PetscObject)pc),334,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,62,PETSC_ERROR_INITIAL,"num of redundant pc %D must be positive"
,nredundant)
;
335 ierr = PetscTryMethod(pc,"PCRedundantSetNumber_C",(PC,PetscInt),(pc,nredundant))0;{ PetscErrorCode (*f)(PC,PetscInt), __ierr; __ierr = PetscObjectQueryFunction_Private
(((PetscObject)pc),("PCRedundantSetNumber_C"),(PetscVoidFunction
*)(&f));do {if (__builtin_expect(!!(__ierr),0)) return PetscError
(((MPI_Comm)0x44000001),335,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (f) {__ierr =
(*f)(pc,nredundant);do {if (__builtin_expect(!!(__ierr),0)) return
PetscError(((MPI_Comm)0x44000001),335,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0);} }
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),335,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
336 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
337}
338
339static PetscErrorCode PCRedundantSetScatter_Redundant(PC pc,VecScatter in,VecScatter out)
340{
341 PC_Redundant *red = (PC_Redundant*)pc->data;
342 PetscErrorCode ierr;
343
344 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 344; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
345 ierr = PetscObjectReference((PetscObject)in);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),345,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
346 ierr = VecScatterDestroy(&red->scatterin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),346,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
347
348 red->scatterin = in;
349
350 ierr = PetscObjectReference((PetscObject)out);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),350,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
351 ierr = VecScatterDestroy(&red->scatterout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),351,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
352 red->scatterout = out;
353 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
354}
355
356/*@
357 PCRedundantSetScatter - Sets the scatter used to copy values into the
358 redundant local solve and the scatter to move them back into the global
359 vector.
360
361 Logically Collective on PC
362
363 Input Parameters:
364+ pc - the preconditioner context
365. in - the scatter to move the values in
366- out - the scatter to move them out
367
368 Level: advanced
369
370.keywords: PC, redundant solve
371@*/
372PetscErrorCode PCRedundantSetScatter(PC pc,VecScatter in,VecScatter out)
373{
374 PetscErrorCode ierr;
375
376 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 376; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
377 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),377,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(pc,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),377,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(pc))->classid != PC_CLASSID) { if (
((PetscObject)(pc))->classid == -1) return PetscError(((MPI_Comm
)0x44000001),377,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),377,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
378 PetscValidHeaderSpecific(in,VEC_SCATTER_CLASSID,2)do { if (!in) return PetscError(((MPI_Comm)0x44000001),378,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",2); if (
!PetscCheckPointer(in,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),378,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,2); if (((PetscObject)(in))->classid != VEC_SCATTER_CLASSID
) { if (((PetscObject)(in))->classid == -1) return PetscError
(((MPI_Comm)0x44000001),378,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,2); else return PetscError(((MPI_Comm)0x44000001),378,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,2); } } while (0)
;
379 PetscValidHeaderSpecific(out,VEC_SCATTER_CLASSID,3)do { if (!out) return PetscError(((MPI_Comm)0x44000001),379,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",3); if (
!PetscCheckPointer(out,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),379,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,3); if (((PetscObject)(out))->classid != VEC_SCATTER_CLASSID
) { if (((PetscObject)(out))->classid == -1) return PetscError
(((MPI_Comm)0x44000001),379,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,3); else return PetscError(((MPI_Comm)0x44000001),379,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,3); } } while (0)
;
380 ierr = PetscTryMethod(pc,"PCRedundantSetScatter_C",(PC,VecScatter,VecScatter),(pc,in,out))0;{ PetscErrorCode (*f)(PC,VecScatter,VecScatter), __ierr; __ierr
= PetscObjectQueryFunction_Private(((PetscObject)pc),("PCRedundantSetScatter_C"
),(PetscVoidFunction*)(&f));do {if (__builtin_expect(!!(__ierr
),0)) return PetscError(((MPI_Comm)0x44000001),380,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (f) {__ierr =
(*f)(pc,in,out);do {if (__builtin_expect(!!(__ierr),0)) return
PetscError(((MPI_Comm)0x44000001),380,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0);} }
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),380,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
381 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
382}
383
384static PetscErrorCode PCRedundantGetKSP_Redundant(PC pc,KSP *innerksp)
385{
386 PetscErrorCode ierr;
387 PC_Redundant *red = (PC_Redundant*)pc->data;
388 MPI_Comm comm,subcomm;
389 const char *prefix;
390
391 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 391; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
392 if (!red->psubcomm) {
393 ierr = PCGetOptionsPrefix(pc,&prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),393,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
394
395 ierr = PetscObjectGetComm((PetscObject)pc,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),395,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
396 ierr = PetscSubcommCreate(comm,&red->psubcomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),396,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
397 ierr = PetscSubcommSetNumber(red->psubcomm,red->nsubcomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),397,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
398 ierr = PetscSubcommSetType(red->psubcomm,PETSC_SUBCOMM_CONTIGUOUS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),398,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
399
400 ierr = PetscSubcommSetOptionsPrefix(red->psubcomm,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),400,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
401 ierr = PetscSubcommSetFromOptions(red->psubcomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),401,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
402 ierr = PetscLogObjectMemory((PetscObject)pc,sizeof(PetscSubcomm));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),402,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
403
404 /* create a new PC that processors in each subcomm have copy of */
405 subcomm = PetscSubcommChild(red->psubcomm);
406
407 ierr = KSPCreate(subcomm,&red->ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),407,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
408 ierr = KSPSetErrorIfNotConverged(red->ksp,pc->erroriffailure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),408,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
409 ierr = PetscObjectIncrementTabLevel((PetscObject)red->ksp,(PetscObject)pc,1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),409,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
410 ierr = PetscLogObjectParent((PetscObject)pc,(PetscObject)red->ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),410,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
411 ierr = KSPSetType(red->ksp,KSPPREONLY"preonly");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),411,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
412 ierr = KSPGetPC(red->ksp,&red->pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),412,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
413 ierr = PCSetType(red->pc,PCLU"lu");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),413,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
414 if (red->shifttypeset) {
415 ierr = PCFactorSetShiftType(red->pc,red->shifttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),415,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
416 red->shifttypeset = PETSC_FALSE;
417 }
418 ierr = KSPSetOptionsPrefix(red->ksp,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),418,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
419 ierr = KSPAppendOptionsPrefix(red->ksp,"redundant_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),419,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
420 }
421 *innerksp = red->ksp;
422 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
423}
424
425/*@
426 PCRedundantGetKSP - Gets the less parallel KSP created by the redundant PC.
427
428 Not Collective
429
430 Input Parameter:
431. pc - the preconditioner context
432
433 Output Parameter:
434. innerksp - the KSP on the smaller set of processes
435
436 Level: advanced
437
438.keywords: PC, redundant solve
439@*/
440PetscErrorCode PCRedundantGetKSP(PC pc,KSP *innerksp)
441{
442 PetscErrorCode ierr;
443
444 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 444; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
445 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),445,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(pc,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),445,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(pc))->classid != PC_CLASSID) { if (
((PetscObject)(pc))->classid == -1) return PetscError(((MPI_Comm
)0x44000001),445,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),445,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
446 PetscValidPointer(innerksp,2)do { if (!innerksp) return PetscError(((MPI_Comm)0x44000001),
446,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(innerksp,PETSC_CHAR)) return PetscError(
((MPI_Comm)0x44000001),446,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
447 ierr = PetscUseMethod(pc,"PCRedundantGetKSP_C",(PC,KSP*),(pc,innerksp))0;{ PetscErrorCode (*f)(PC,KSP*), __ierr; __ierr = PetscObjectQueryFunction_Private
(((PetscObject)pc),("PCRedundantGetKSP_C"),(PetscVoidFunction
*)(&f));do {if (__builtin_expect(!!(__ierr),0)) return PetscError
(((MPI_Comm)0x44000001),447,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (f) {__ierr =
(*f)(pc,innerksp);do {if (__builtin_expect(!!(__ierr),0)) return
PetscError(((MPI_Comm)0x44000001),447,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0);} else return PetscError
(PetscObjectComm((PetscObject)pc),447,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,56,PETSC_ERROR_INITIAL,"Cannot locate function %s in object"
,"PCRedundantGetKSP_C"); }
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),447,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
448 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
449}
450
451static PetscErrorCode PCRedundantGetOperators_Redundant(PC pc,Mat *mat,Mat *pmat)
452{
453 PC_Redundant *red = (PC_Redundant*)pc->data;
454
455 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 455; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
456 if (mat) *mat = red->pmats;
457 if (pmat) *pmat = red->pmats;
458 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
459}
460
461/*@
462 PCRedundantGetOperators - gets the sequential matrix and preconditioner matrix
463
464 Not Collective
465
466 Input Parameter:
467. pc - the preconditioner context
468
469 Output Parameters:
470+ mat - the matrix
471- pmat - the (possibly different) preconditioner matrix
472
473 Level: advanced
474
475.keywords: PC, redundant solve
476@*/
477PetscErrorCode PCRedundantGetOperators(PC pc,Mat *mat,Mat *pmat)
478{
479 PetscErrorCode ierr;
480
481 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 481; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
482 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),482,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(pc,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),482,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(pc))->classid != PC_CLASSID) { if (
((PetscObject)(pc))->classid == -1) return PetscError(((MPI_Comm
)0x44000001),482,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),482,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
483 if (mat) PetscValidPointer(mat,2)do { if (!mat) return PetscError(((MPI_Comm)0x44000001),483,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(mat,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),483,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
484 if (pmat) PetscValidPointer(pmat,3)do { if (!pmat) return PetscError(((MPI_Comm)0x44000001),484,
__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if
(!PetscCheckPointer(pmat,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),484,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3);
} while (0)
;
485 ierr = PetscUseMethod(pc,"PCRedundantGetOperators_C",(PC,Mat*,Mat*),(pc,mat,pmat))0;{ PetscErrorCode (*f)(PC,Mat*,Mat*), __ierr; __ierr = PetscObjectQueryFunction_Private
(((PetscObject)pc),("PCRedundantGetOperators_C"),(PetscVoidFunction
*)(&f));do {if (__builtin_expect(!!(__ierr),0)) return PetscError
(((MPI_Comm)0x44000001),485,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (f) {__ierr =
(*f)(pc,mat,pmat);do {if (__builtin_expect(!!(__ierr),0)) return
PetscError(((MPI_Comm)0x44000001),485,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0);} else return PetscError
(PetscObjectComm((PetscObject)pc),485,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,56,PETSC_ERROR_INITIAL,"Cannot locate function %s in object"
,"PCRedundantGetOperators_C"); }
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),485,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
486 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
487}
488
489/* -------------------------------------------------------------------------------------*/
490/*MC
491 PCREDUNDANT - Runs a KSP solver with preconditioner for the entire problem on subgroups of processors
492
493 Options for the redundant preconditioners can be set with -redundant_pc_xxx for the redundant KSP with -redundant_ksp_xxx
494
495 Options Database:
496. -pc_redundant_number <n> - number of redundant solves, for example if you are using 64 MPI processes and
497 use an n of 4 there will be 4 parallel solves each on 16 = 64/4 processes.
498
499 Level: intermediate
500
501 Notes:
502 The default KSP is preonly and the default PC is LU.
503
504 PCFactorSetShiftType() applied to this PC will convey they shift type into the inner PC if it is factorization based.
505
506 Developer Notes:
507 Note that PCSetInitialGuessNonzero() is not used by this class but likely should be.
508
509.seealso: PCCreate(), PCSetType(), PCType (for list of available types), PCRedundantSetScatter(),
510 PCRedundantGetKSP(), PCRedundantGetOperators(), PCRedundantSetNumber()
511M*/
512
513PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PCCreate_Redundant(PC pc)
514{
515 PetscErrorCode ierr;
516 PC_Redundant *red;
517 PetscMPIInt size;
518
519 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
; petscstack->line[petscstack->currentsize] = 519; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
520 ierr = PetscNewLog(pc,&red)(PetscMallocA(1,PETSC_TRUE,520,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,(size_t)(1)*sizeof(**(((&red)))),(((&red)))) || PetscLogObjectMemory
((PetscObject)pc,sizeof(**(&red))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),520,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
521 ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pc),&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),521,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
522
523 red->nsubcomm = size;
524 red->useparallelmat = PETSC_TRUE;
525 pc->data = (void*)red;
526
527 pc->ops->apply = PCApply_Redundant;
528 pc->ops->applytranspose = PCApplyTranspose_Redundant;
529 pc->ops->setup = PCSetUp_Redundant;
530 pc->ops->destroy = PCDestroy_Redundant;
531 pc->ops->reset = PCReset_Redundant;
532 pc->ops->setfromoptions = PCSetFromOptions_Redundant;
533 pc->ops->view = PCView_Redundant;
534
535 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCRedundantSetScatter_C",PCRedundantSetScatter_Redundant)PetscObjectComposeFunction_Private((PetscObject)pc,"PCRedundantSetScatter_C"
,(PetscVoidFunction)(PCRedundantSetScatter_Redundant))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),535,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
536 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCRedundantSetNumber_C",PCRedundantSetNumber_Redundant)PetscObjectComposeFunction_Private((PetscObject)pc,"PCRedundantSetNumber_C"
,(PetscVoidFunction)(PCRedundantSetNumber_Redundant))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),536,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
537 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCRedundantGetKSP_C",PCRedundantGetKSP_Redundant)PetscObjectComposeFunction_Private((PetscObject)pc,"PCRedundantGetKSP_C"
,(PetscVoidFunction)(PCRedundantGetKSP_Redundant))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),537,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
538 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCRedundantGetOperators_C",PCRedundantGetOperators_Redundant)PetscObjectComposeFunction_Private((PetscObject)pc,"PCRedundantGetOperators_C"
,(PetscVoidFunction)(PCRedundantGetOperators_Redundant))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),538,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
539 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetShiftType_C",PCFactorSetShiftType_Redundant)PetscObjectComposeFunction_Private((PetscObject)pc,"PCFactorSetShiftType_C"
,(PetscVoidFunction)(PCFactorSetShiftType_Redundant))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),539,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/redundant/redundant.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
540 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
541}
542

/sandbox/petsc/petsc.next-tmp/include/petscsys.h

1/*
2 This is the main PETSc include file (for C and C++). It is included by all
3 other PETSc include files, so it almost never has to be specifically included.
4*/
5#if !defined(PETSCSYS_H)
6#define PETSCSYS_H
7/* ========================================================================== */
8/*
9 petscconf.h is contained in ${PETSC_ARCH}/include/petscconf.h it is
10 found automatically by the compiler due to the -I${PETSC_DIR}/${PETSC_ARCH}/include.
11 For --prefix installs the ${PETSC_ARCH}/ does not exist and petscconf.h is in the same
12 directory as the other PETSc include files.
13*/
14#include <petscconf.h>
15#include <petscfix.h>
16
17#if defined(PETSC_DESIRE_FEATURE_TEST_MACROS)
18/*
19 Feature test macros must be included before headers defined by IEEE Std 1003.1-2001
20 We only turn these in PETSc source files that require them by setting PETSC_DESIRE_FEATURE_TEST_MACROS
21*/
22# if defined(PETSC__POSIX_C_SOURCE_200112L) && !defined(_POSIX_C_SOURCE200809L)
23# define _POSIX_C_SOURCE200809L 200112L
24# endif
25# if defined(PETSC__BSD_SOURCE1) && !defined(_BSD_SOURCE1)
26# define _BSD_SOURCE1
27# endif
28# if defined(PETSC__DEFAULT_SOURCE1) && !defined(_DEFAULT_SOURCE1)
29# define _DEFAULT_SOURCE1
30# endif
31# if defined(PETSC__GNU_SOURCE1) && !defined(_GNU_SOURCE)
32# define _GNU_SOURCE
33# endif
34#endif
35
36#include <petscsystypes.h>
37
38/* ========================================================================== */
39/*
40 This facilitates using the C version of PETSc from C++ and the C++ version from C.
41*/
42#if defined(__cplusplus)
43# define PETSC_FUNCTION_NAME__func__ PETSC_FUNCTION_NAME_CXX__func__
44#else
45# define PETSC_FUNCTION_NAME__func__ PETSC_FUNCTION_NAME_C__func__
46#endif
47
48/* ========================================================================== */
49/*
50 Since PETSc manages its own extern "C" handling users should never include PETSc include
51 files within extern "C". This will generate a compiler error if a user does put the include
52 file within an extern "C".
53*/
54#if defined(__cplusplus)
55void assert_never_put_petsc_headers_inside_an_extern_c(int); void assert_never_put_petsc_headers_inside_an_extern_c(double);
56#endif
57
58#if defined(__cplusplus)
59# define PETSC_RESTRICT__restrict PETSC_CXX_RESTRICT__restrict
60#else
61# define PETSC_RESTRICT__restrict PETSC_C_RESTRICT__restrict
62#endif
63
64#if defined(__cplusplus)
65# define PETSC_INLINEinline PETSC_CXX_INLINEinline
66#else
67# define PETSC_INLINEinline PETSC_C_INLINEinline
68#endif
69
70#define PETSC_STATIC_INLINEstatic inline static PETSC_INLINEinline
71
72#if defined(_WIN32) && defined(PETSC_USE_SHARED_LIBRARIES1) /* For Win32 shared libraries */
73# define PETSC_DLLEXPORT__attribute__((visibility ("default"))) __declspec(dllexport)
74# define PETSC_DLLIMPORT__attribute__((visibility ("default"))) __declspec(dllimport)
75# define PETSC_VISIBILITY_INTERNAL__attribute__((visibility ("hidden")))
76#elif defined(PETSC_USE_VISIBILITY_CXX1) && defined(__cplusplus)
77# define PETSC_DLLEXPORT__attribute__((visibility ("default"))) __attribute__((visibility ("default")))
78# define PETSC_DLLIMPORT__attribute__((visibility ("default"))) __attribute__((visibility ("default")))
79# define PETSC_VISIBILITY_INTERNAL__attribute__((visibility ("hidden"))) __attribute__((visibility ("hidden")))
80#elif defined(PETSC_USE_VISIBILITY_C1) && !defined(__cplusplus)
81# define PETSC_DLLEXPORT__attribute__((visibility ("default"))) __attribute__((visibility ("default")))
82# define PETSC_DLLIMPORT__attribute__((visibility ("default"))) __attribute__((visibility ("default")))
83# define PETSC_VISIBILITY_INTERNAL__attribute__((visibility ("hidden"))) __attribute__((visibility ("hidden")))
84#else
85# define PETSC_DLLEXPORT__attribute__((visibility ("default")))
86# define PETSC_DLLIMPORT__attribute__((visibility ("default")))
87# define PETSC_VISIBILITY_INTERNAL__attribute__((visibility ("hidden")))
88#endif
89
90#if defined(petsc_EXPORTS) /* CMake defines this when building the shared library */
91# define PETSC_VISIBILITY_PUBLIC__attribute__((visibility ("default"))) PETSC_DLLEXPORT__attribute__((visibility ("default")))
92#else /* Win32 users need this to import symbols from petsc.dll */
93# define PETSC_VISIBILITY_PUBLIC__attribute__((visibility ("default"))) PETSC_DLLIMPORT__attribute__((visibility ("default")))
94#endif
95
96/*
97 Functions tagged with PETSC_EXTERN in the header files are
98 always defined as extern "C" when compiled with C++ so they may be
99 used from C and are always visible in the shared libraries
100*/
101#if defined(__cplusplus)
102# define PETSC_EXTERNextern __attribute__((visibility ("default"))) extern "C" PETSC_VISIBILITY_PUBLIC__attribute__((visibility ("default")))
103# define PETSC_EXTERN_TYPEDEF extern "C"
104# define PETSC_INTERNextern __attribute__((visibility ("hidden"))) extern "C" PETSC_VISIBILITY_INTERNAL__attribute__((visibility ("hidden")))
105#else
106# define PETSC_EXTERNextern __attribute__((visibility ("default"))) extern PETSC_VISIBILITY_PUBLIC__attribute__((visibility ("default")))
107# define PETSC_EXTERN_TYPEDEF
108# define PETSC_INTERNextern __attribute__((visibility ("hidden"))) extern PETSC_VISIBILITY_INTERNAL__attribute__((visibility ("hidden")))
109#endif
110
111#include <petscversion.h>
112#define PETSC_AUTHOR_INFO" The PETSc Team\n [email protected]\n http://www.mcs.anl.gov/petsc/\n" " The PETSc Team\n [email protected]\n http://www.mcs.anl.gov/petsc/\n"
113
114/* ========================================================================== */
115
116/*
117 Defines the interface to MPI allowing the use of all MPI functions.
118
119 PETSc does not use the C++ binding of MPI at ALL. The following flag
120 makes sure the C++ bindings are not included. The C++ bindings REQUIRE
121 putting mpi.h before ANY C++ include files, we cannot control this
122 with all PETSc users. Users who want to use the MPI C++ bindings can include
123 mpicxx.h directly in their code
124*/
125#if !defined(MPICH_SKIP_MPICXX1)
126# define MPICH_SKIP_MPICXX1 1
127#endif
128#if !defined(OMPI_SKIP_MPICXX1)
129# define OMPI_SKIP_MPICXX1 1
130#endif
131#if defined(PETSC_HAVE_MPIUNI)
132# include <petsc/mpiuni/mpi.h>
133#else
134# include <mpi.h>
135#endif
136
137/*
138 Perform various sanity checks that the correct mpi.h is being included at compile time.
139 This usually happens because
140 * either an unexpected mpi.h is in the default compiler path (i.e. in /usr/include) or
141 * an extra include path -I/something (which contains the unexpected mpi.h) is being passed to the compiler
142*/
143#if defined(PETSC_HAVE_MPIUNI)
144# if !defined(MPIUNI_H)
145# error "PETSc was configured with --with-mpi=0 but now appears to be compiling using a different mpi.h"
146# endif
147#elif defined(PETSC_HAVE_I_MPI_NUMVERSION)
148# if !defined(I_MPI_NUMVERSION)
149# error "PETSc was configured with I_MPI but now appears to be compiling using a non-I_MPI mpi.h"
150# elif I_MPI_NUMVERSION != PETSC_HAVE_I_MPI_NUMVERSION
151# error "PETSc was configured with one I_MPI mpi.h version but now appears to be compiling using a different I_MPI mpi.h version"
152# endif
153#elif defined(PETSC_HAVE_MVAPICH2_NUMVERSION)
154# if !defined(MVAPICH2_NUMVERSION)
155# error "PETSc was configured with MVAPICH2 but now appears to be compiling using a non-MVAPICH2 mpi.h"
156# elif MVAPICH2_NUMVERSION != PETSC_HAVE_MVAPICH2_NUMVERSION
157# error "PETSc was configured with one MVAPICH2 mpi.h version but now appears to be compiling using a different MVAPICH2 mpi.h version"
158# endif
159#elif defined(PETSC_HAVE_MPICH_NUMVERSION30300101)
160# if !defined(MPICH_NUMVERSION30300101) || defined(MVAPICH2_NUMVERSION) || defined(I_MPI_NUMVERSION)
161# error "PETSc was configured with MPICH but now appears to be compiling using a non-MPICH mpi.h"
162# elif (MPICH_NUMVERSION30300101/100000 != PETSC_HAVE_MPICH_NUMVERSION30300101/100000) || (MPICH_NUMVERSION30300101%100000/1000 < PETSC_HAVE_MPICH_NUMVERSION30300101%100000/1000)
163# error "PETSc was configured with one MPICH mpi.h version but now appears to be compiling using a different MPICH mpi.h version"
164# endif
165#elif defined(PETSC_HAVE_OMPI_MAJOR_VERSION)
166# if !defined(OMPI_MAJOR_VERSION)
167# error "PETSc was configured with OpenMPI but now appears to be compiling using a non-OpenMPI mpi.h"
168# elif (OMPI_MAJOR_VERSION != PETSC_HAVE_OMPI_MAJOR_VERSION) || (OMPI_MINOR_VERSION != PETSC_HAVE_OMPI_MINOR_VERSION) || (OMPI_RELEASE_VERSION < PETSC_HAVE_OMPI_RELEASE_VERSION)
169# error "PETSc was configured with one OpenMPI mpi.h version but now appears to be compiling using a different OpenMPI mpi.h version"
170# endif
171#elif defined(OMPI_MAJOR_VERSION) || defined(MPICH_NUMVERSION30300101)
172# error "PETSc was configured with undetermined MPI - but now appears to be compiling using either of OpenMPI or a MPICH variant"
173#endif
174
175/*
176 Need to put stdio.h AFTER mpi.h for MPICH2 with C++ compiler
177 see the top of mpicxx.h in the MPICH2 distribution.
178*/
179#include <stdio.h>
180
181/* MSMPI on 32bit windows requires this yukky hack - that breaks MPI standard compliance */
182#if !defined(MPIAPI)
183#define MPIAPI
184#endif
185
186/*
187 Support for Clang (>=3.2) matching type tag arguments with void* buffer types.
188 This allows the compiler to detect cases where the MPI datatype argument passed to a MPI routine
189 does not match the actual type of the argument being passed in
190*/
191#if defined(__has_attribute)0 && defined(works_with_const_which_is_not_true)
192# if __has_attribute(argument_with_type_tag)1 && __has_attribute(pointer_with_type_tag)1 && __has_attribute(type_tag_for_datatype)1
193# define PetscAttrMPIPointerWithType(bufno,typeno) __attribute__((pointer_with_type_tag(MPI,bufno,typeno)))
194# define PetscAttrMPITypeTag(type) __attribute__((type_tag_for_datatype(MPI,type)))
195# define PetscAttrMPITypeTagLayoutCompatible(type) __attribute__((type_tag_for_datatype(MPI,type,layout_compatible)))
196# endif
197#endif
198#if !defined(PetscAttrMPIPointerWithType)
199# define PetscAttrMPIPointerWithType(bufno,typeno)
200# define PetscAttrMPITypeTag(type)
201# define PetscAttrMPITypeTagLayoutCompatible(type)
202#endif
203
204PETSC_EXTERNextern __attribute__((visibility ("default"))) MPI_Datatype MPIU_ENUM PetscAttrMPITypeTag(PetscEnum);
205PETSC_EXTERNextern __attribute__((visibility ("default"))) MPI_Datatype MPIU_BOOL PetscAttrMPITypeTag(PetscBool);
206
207/*MC
208 MPIU_INT - MPI datatype corresponding to PetscInt
209
210 Notes:
211 In MPI calls that require an MPI datatype that matches a PetscInt or array of PetscInt values, pass this value.
212
213 Level: beginner
214
215.seealso: PetscReal, PetscScalar, PetscComplex, PetscInt, MPIU_REAL, MPIU_SCALAR, MPIU_COMPLEX
216M*/
217
218#if defined(PETSC_HAVE_STDINT_H1) && defined(PETSC_HAVE_INTTYPES_H1) && defined(PETSC_HAVE_MPI_INT64_T1) /* MPI_INT64_T is not guaranteed to be a macro */
219# define MPIU_INT64((MPI_Datatype)0x4c00083a) MPI_INT64_T((MPI_Datatype)0x4c00083a)
220# define PetscInt64_FMT"l" "d" PRId64"l" "d"
221#elif (PETSC_SIZEOF_LONG_LONG8 == 8)
222# define MPIU_INT64((MPI_Datatype)0x4c00083a) MPI_LONG_LONG_INT((MPI_Datatype)0x4c000809)
223# define PetscInt64_FMT"l" "d" "lld"
224#elif defined(PETSC_HAVE___INT64)
225# define MPIU_INT64((MPI_Datatype)0x4c00083a) MPI_INT64_T((MPI_Datatype)0x4c00083a)
226# define PetscInt64_FMT"l" "d" "ld"
227#else
228# error "cannot determine PetscInt64 type"
229#endif
230
231#if PETSC_SIZEOF_VOID_P8 == 4
232# define MPIU_FORTRANADDR((MPI_Datatype)0x4c00083a) MPI_INT((MPI_Datatype)0x4c000405)
233#else
234# define MPIU_FORTRANADDR((MPI_Datatype)0x4c00083a) MPIU_INT64((MPI_Datatype)0x4c00083a)
235#endif
236
237#if defined(PETSC_USE_64BIT_INDICES)
238# define MPIU_INT((MPI_Datatype)0x4c000405) MPIU_INT64((MPI_Datatype)0x4c00083a)
239# define PetscInt_FMT"d" PetscInt64_FMT"l" "d"
240#else
241# define MPIU_INT((MPI_Datatype)0x4c000405) MPI_INT((MPI_Datatype)0x4c000405)
242# define PetscInt_FMT"d" "d"
243#endif
244
245/*
246 For the rare cases when one needs to send a size_t object with MPI
247*/
248#if (PETSC_SIZEOF_SIZE_T8) == (PETSC_SIZEOF_INT4)
249# define MPIU_SIZE_T((MPI_Datatype)0x4c000808) MPI_UNSIGNED((MPI_Datatype)0x4c000406)
250#elif (PETSC_SIZEOF_SIZE_T8) == (PETSC_SIZEOF_LONG8)
251# define MPIU_SIZE_T((MPI_Datatype)0x4c000808) MPI_UNSIGNED_LONG((MPI_Datatype)0x4c000808)
252#elif (PETSC_SIZEOF_SIZE_T8) == (PETSC_SIZEOF_LONG_LONG8)
253# define MPIU_SIZE_T((MPI_Datatype)0x4c000808) MPI_UNSIGNED_LONG_LONG((MPI_Datatype)0x4c000819)
254#else
255# error "Unknown size for size_t! Send us a bugreport at [email protected]"
256#endif
257
258/*
259 You can use PETSC_STDOUT as a replacement of stdout. You can also change
260 the value of PETSC_STDOUT to redirect all standard output elsewhere
261*/
262PETSC_EXTERNextern __attribute__((visibility ("default"))) FILE* PETSC_STDOUT;
263
264/*
265 You can use PETSC_STDERR as a replacement of stderr. You can also change
266 the value of PETSC_STDERR to redirect all standard error elsewhere
267*/
268PETSC_EXTERNextern __attribute__((visibility ("default"))) FILE* PETSC_STDERR;
269
270/*MC
271 PetscUnlikely - hints the compiler that the given condition is usually FALSE
272
273 Synopsis:
274 #include <petscsys.h>
275 PetscBool PetscUnlikely(PetscBool cond)
276
277 Not Collective
278
279 Input Parameters:
280. cond - condition or expression
281
282 Notes:
283 This returns the same truth value, it is only a hint to compilers that the resulting
284 branch is unlikely.
285
286 Level: advanced
287
288.seealso: PetscLikely(), CHKERRQ
289M*/
290
291/*MC
292 PetscLikely - hints the compiler that the given condition is usually TRUE
293
294 Synopsis:
295 #include <petscsys.h>
296 PetscBool PetscLikely(PetscBool cond)
297
298 Not Collective
299
300 Input Parameters:
301. cond - condition or expression
302
303 Notes:
304 This returns the same truth value, it is only a hint to compilers that the resulting
305 branch is likely.
306
307 Level: advanced
308
309.seealso: PetscUnlikely()
310M*/
311#if defined(PETSC_HAVE_BUILTIN_EXPECT1)
312# define PetscUnlikely(cond)__builtin_expect(!!(cond),0) __builtin_expect(!!(cond),0)
313# define PetscLikely(cond)__builtin_expect(!!(cond),1) __builtin_expect(!!(cond),1)
314#else
315# define PetscUnlikely(cond)__builtin_expect(!!(cond),0) (cond)
316# define PetscLikely(cond)__builtin_expect(!!(cond),1) (cond)
317#endif
318
319/*
320 Declare extern C stuff after including external header files
321*/
322
323PETSC_EXTERNextern __attribute__((visibility ("default"))) const char *const PetscBools[];
324
325/*
326 Defines elementary mathematics functions and constants.
327*/
328#include <petscmath.h>
329
330PETSC_EXTERNextern __attribute__((visibility ("default"))) const char *const PetscCopyModes[];
331
332/*MC
333 PETSC_IGNORE - same as NULL, means PETSc will ignore this argument
334
335 Level: beginner
336
337 Note:
338 Accepted by many PETSc functions to not set a parameter and instead use
339 some default
340
341 Fortran Notes:
342 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
343 PETSC_NULL_DOUBLE_PRECISION etc
344
345.seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_DETERMINE
346
347M*/
348#define PETSC_IGNORE((void*)0) NULL((void*)0)
349
350/* This is deprecated */
351#define PETSC_NULL((void*)0) NULL((void*)0)
352
353/*MC
354 PETSC_DECIDE - standard way of passing in integer or floating point parameter
355 where you wish PETSc to use the default.
356
357 Level: beginner
358
359.seealso: PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
360
361M*/
362#define PETSC_DECIDE-1 -1
363
364/*MC
365 PETSC_DETERMINE - standard way of passing in integer or floating point parameter
366 where you wish PETSc to compute the required value.
367
368 Level: beginner
369
370 Developer Note:
371 I would like to use const PetscInt PETSC_DETERMINE = PETSC_DECIDE; but for
372 some reason this is not allowed by the standard even though PETSC_DECIDE is a constant value.
373
374.seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, VecSetSizes()
375
376M*/
377#define PETSC_DETERMINE-1 PETSC_DECIDE-1
378
379/*MC
380 PETSC_DEFAULT - standard way of passing in integer or floating point parameter
381 where you wish PETSc to use the default.
382
383 Level: beginner
384
385 Fortran Notes:
386 You need to use PETSC_DEFAULT_INTEGER or PETSC_DEFAULT_REAL.
387
388.seealso: PETSC_DECIDE, PETSC_IGNORE, PETSC_DETERMINE
389
390M*/
391#define PETSC_DEFAULT-2 -2
392
393/*MC
394 PETSC_COMM_WORLD - the equivalent of the MPI_COMM_WORLD communicator which represents
395 all the processes that PETSc knows about.
396
397 Level: beginner
398
399 Notes:
400 By default PETSC_COMM_WORLD and MPI_COMM_WORLD are identical unless you wish to
401 run PETSc on ONLY a subset of MPI_COMM_WORLD. In that case create your new (smaller)
402 communicator, call it, say comm, and set PETSC_COMM_WORLD = comm BEFORE calling
403 PetscInitialize(), but after MPI_Init() has been called.
404
405 The value of PETSC_COMM_WORLD should never be USED/accessed before PetscInitialize()
406 is called because it may not have a valid value yet.
407
408.seealso: PETSC_COMM_SELF
409
410M*/
411PETSC_EXTERNextern __attribute__((visibility ("default"))) MPI_Comm PETSC_COMM_WORLD;
412
413/*MC
414 PETSC_COMM_SELF - This is always MPI_COMM_SELF
415
416 Level: beginner
417
418 Notes:
419 Do not USE/access or set this variable before PetscInitialize() has been called.
420
421.seealso: PETSC_COMM_WORLD
422
423M*/
424#define PETSC_COMM_SELF((MPI_Comm)0x44000001) MPI_COMM_SELF((MPI_Comm)0x44000001)
425
426PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscBool PetscBeganMPI;
427PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscBool PetscInitializeCalled;
428PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscBool PetscFinalizeCalled;
429PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscBool PetscViennaCLSynchronize;
430PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscBool PetscCUDASynchronize;
431
432PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm));
433PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*);
434PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscCommDestroy(MPI_Comm*);
435
436/*MC
437 PetscMalloc - Allocates memory, One should use PetscNew(), PetscMalloc1() or PetscCalloc1() usually instead of this
438
439 Synopsis:
440 #include <petscsys.h>
441 PetscErrorCode PetscMalloc(size_t m,void **result)
442
443 Not Collective
444
445 Input Parameter:
446. m - number of bytes to allocate
447
448 Output Parameter:
449. result - memory allocated
450
451 Level: beginner
452
453 Notes:
454 Memory is always allocated at least double aligned
455
456 It is safe to allocate size 0 and pass the resulting pointer (which may or may not be NULL) to PetscFree().
457
458.seealso: PetscFree(), PetscNew()
459
460 Concepts: memory allocation
461
462M*/
463#define PetscMalloc(a,b)((*PetscTrMalloc)((a),463,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(void**)(b)))
((*PetscTrMalloc)((a),__LINE__463,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(void**)(b)))
464
465/*MC
466 PetscRealloc - Rellocates memory
467
468 Synopsis:
469 #include <petscsys.h>
470 PetscErrorCode PetscRealloc(size_t m,void **result)
471
472 Not Collective
473
474 Input Parameters:
475+ m - number of bytes to allocate
476- result - initial memory allocated
477
478 Output Parameter:
479. result - new memory allocated
480
481 Level: developer
482
483 Notes:
484 Memory is always allocated at least double aligned
485
486.seealso: PetscMalloc(), PetscFree(), PetscNew()
487
488 Concepts: memory allocation
489
490M*/
491#define PetscRealloc(a,b)((*PetscTrRealloc)((a),491,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(void**)(b)))
((*PetscTrRealloc)((a),__LINE__491,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(void**)(b)))
492
493/*MC
494 PetscAddrAlign - Rounds up an address to PETSC_MEMALIGN alignment
495
496 Synopsis:
497 #include <petscsys.h>
498 void *PetscAddrAlign(void *addr)
499
500 Not Collective
501
502 Input Parameters:
503. addr - address to align (any pointer type)
504
505 Level: developer
506
507.seealso: PetscMallocAlign()
508
509 Concepts: memory allocation
510M*/
511#define PetscAddrAlign(a)(void*)((((uintptr_t)(a))+(16 -1)) & ~(16 -1)) (void*)((((PETSC_UINTPTR_Tuintptr_t)(a))+(PETSC_MEMALIGN16-1)) & ~(PETSC_MEMALIGN16-1))
512
513/*MC
514 PetscMalloc1 - Allocates an array of memory aligned to PETSC_MEMALIGN
515
516 Synopsis:
517 #include <petscsys.h>
518 PetscErrorCode PetscMalloc1(size_t m1,type **r1)
519
520 Not Collective
521
522 Input Parameter:
523. m1 - number of elements to allocate (may be zero)
524
525 Output Parameter:
526. r1 - memory allocated in first chunk
527
528 Note:
529 This uses the sizeof() of the memory type requested to determine the total memory to be allocated, therefore you should not
530 multiply the number of elements requested by the sizeof() the type. For example use
531$ PetscInt *id;
532$ PetscMalloc1(10,&id);
533 not
534$ PetscInt *id;
535$ PetscMalloc1(10*sizeof(PetscInt),&id);
536
537 Does not zero the memory allocatd, used PetscCalloc1() to obtain memory that has been zeroed.
538
539 Level: beginner
540
541.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscCalloc1(), PetscMalloc2()
542
543 Concepts: memory allocation
544
545M*/
546#define PetscMalloc1(m1,r1)PetscMallocA(1,PETSC_FALSE,546,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1))
PetscMallocA(1,PETSC_FALSE,__LINE__546,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1))
547
548/*MC
549 PetscCalloc1 - Allocates a cleared (zeroed) array of memory aligned to PETSC_MEMALIGN
550
551 Synopsis:
552 #include <petscsys.h>
553 PetscErrorCode PetscCalloc1(size_t m1,type **r1)
554
555 Not Collective
556
557 Input Parameter:
558. m1 - number of elements to allocate in 1st chunk (may be zero)
559
560 Output Parameter:
561. r1 - memory allocated in first chunk
562
563 Notes:
564 See PetsMalloc1() for more details on usage.
565
566 Level: beginner
567
568.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc1(), PetscCalloc2()
569
570 Concepts: memory allocation
571
572M*/
573#define PetscCalloc1(m1,r1)PetscMallocA(1,PETSC_TRUE,573,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1))
PetscMallocA(1,PETSC_TRUE,__LINE__573,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1))
574
575/*MC
576 PetscMalloc2 - Allocates 2 arrays of memory both aligned to PETSC_MEMALIGN
577
578 Synopsis:
579 #include <petscsys.h>
580 PetscErrorCode PetscMalloc2(size_t m1,type **r1,size_t m2,type **r2)
581
582 Not Collective
583
584 Input Parameter:
585+ m1 - number of elements to allocate in 1st chunk (may be zero)
586- m2 - number of elements to allocate in 2nd chunk (may be zero)
587
588 Output Parameter:
589+ r1 - memory allocated in first chunk
590- r2 - memory allocated in second chunk
591
592 Level: developer
593
594.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc1(), PetscCalloc2()
595
596 Concepts: memory allocation
597
598M*/
599#define PetscMalloc2(m1,r1,m2,r2)PetscMallocA(2,PETSC_FALSE,599,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2))
PetscMallocA(2,PETSC_FALSE,__LINE__599,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2))
600
601/*MC
602 PetscCalloc2 - Allocates 2 cleared (zeroed) arrays of memory both aligned to PETSC_MEMALIGN
603
604 Synopsis:
605 #include <petscsys.h>
606 PetscErrorCode PetscCalloc2(size_t m1,type **r1,size_t m2,type **r2)
607
608 Not Collective
609
610 Input Parameter:
611+ m1 - number of elements to allocate in 1st chunk (may be zero)
612- m2 - number of elements to allocate in 2nd chunk (may be zero)
613
614 Output Parameter:
615+ r1 - memory allocated in first chunk
616- r2 - memory allocated in second chunk
617
618 Level: developer
619
620.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscCalloc1(), PetscMalloc2()
621
622 Concepts: memory allocation
623M*/
624#define PetscCalloc2(m1,r1,m2,r2)PetscMallocA(2,PETSC_TRUE,624,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2))
PetscMallocA(2,PETSC_TRUE,__LINE__624,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2))
625
626/*MC
627 PetscMalloc3 - Allocates 3 arrays of memory, all aligned to PETSC_MEMALIGN
628
629 Synopsis:
630 #include <petscsys.h>
631 PetscErrorCode PetscMalloc3(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3)
632
633 Not Collective
634
635 Input Parameter:
636+ m1 - number of elements to allocate in 1st chunk (may be zero)
637. m2 - number of elements to allocate in 2nd chunk (may be zero)
638- m3 - number of elements to allocate in 3rd chunk (may be zero)
639
640 Output Parameter:
641+ r1 - memory allocated in first chunk
642. r2 - memory allocated in second chunk
643- r3 - memory allocated in third chunk
644
645 Level: developer
646
647.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscCalloc3(), PetscFree3()
648
649 Concepts: memory allocation
650
651M*/
652#define PetscMalloc3(m1,r1,m2,r2,m3,r3)PetscMallocA(3,PETSC_FALSE,652,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3))
PetscMallocA(3,PETSC_FALSE,__LINE__652,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3))
653
654/*MC
655 PetscCalloc3 - Allocates 3 cleared (zeroed) arrays of memory, all aligned to PETSC_MEMALIGN
656
657 Synopsis:
658 #include <petscsys.h>
659 PetscErrorCode PetscCalloc3(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3)
660
661 Not Collective
662
663 Input Parameter:
664+ m1 - number of elements to allocate in 1st chunk (may be zero)
665. m2 - number of elements to allocate in 2nd chunk (may be zero)
666- m3 - number of elements to allocate in 3rd chunk (may be zero)
667
668 Output Parameter:
669+ r1 - memory allocated in first chunk
670. r2 - memory allocated in second chunk
671- r3 - memory allocated in third chunk
672
673 Level: developer
674
675.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscCalloc2(), PetscMalloc3(), PetscFree3()
676
677 Concepts: memory allocation
678M*/
679#define PetscCalloc3(m1,r1,m2,r2,m3,r3)PetscMallocA(3,PETSC_TRUE,679,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3))
PetscMallocA(3,PETSC_TRUE,__LINE__679,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3))
680
681/*MC
682 PetscMalloc4 - Allocates 4 arrays of memory, all aligned to PETSC_MEMALIGN
683
684 Synopsis:
685 #include <petscsys.h>
686 PetscErrorCode PetscMalloc4(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3,size_t m4,type **r4)
687
688 Not Collective
689
690 Input Parameter:
691+ m1 - number of elements to allocate in 1st chunk (may be zero)
692. m2 - number of elements to allocate in 2nd chunk (may be zero)
693. m3 - number of elements to allocate in 3rd chunk (may be zero)
694- m4 - number of elements to allocate in 4th chunk (may be zero)
695
696 Output Parameter:
697+ r1 - memory allocated in first chunk
698. r2 - memory allocated in second chunk
699. r3 - memory allocated in third chunk
700- r4 - memory allocated in fourth chunk
701
702 Level: developer
703
704.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscCalloc4(), PetscFree4()
705
706 Concepts: memory allocation
707
708M*/
709#define PetscMalloc4(m1,r1,m2,r2,m3,r3,m4,r4)PetscMallocA(4,PETSC_FALSE,709,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**
(r4)),(r4))
PetscMallocA(4,PETSC_FALSE,__LINE__709,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**(r4)),(r4))
710
711/*MC
712 PetscCalloc4 - Allocates 4 cleared (zeroed) arrays of memory, all aligned to PETSC_MEMALIGN
713
714 Synopsis:
715 #include <petscsys.h>
716 PetscErrorCode PetscCalloc4(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3,size_t m4,type **r4)
717
718 Not Collective
719
720 Input Parameters:
721+ m1 - number of elements to allocate in 1st chunk (may be zero)
722. m2 - number of elements to allocate in 2nd chunk (may be zero)
723. m3 - number of elements to allocate in 3rd chunk (may be zero)
724- m4 - number of elements to allocate in 4th chunk (may be zero)
725
726 Output Parameters:
727+ r1 - memory allocated in first chunk
728. r2 - memory allocated in second chunk
729. r3 - memory allocated in third chunk
730- r4 - memory allocated in fourth chunk
731
732 Level: developer
733
734.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscCalloc4(), PetscFree4()
735
736 Concepts: memory allocation
737
738M*/
739#define PetscCalloc4(m1,r1,m2,r2,m3,r3,m4,r4)PetscMallocA(4,PETSC_TRUE,739,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**
(r4)),(r4))
PetscMallocA(4,PETSC_TRUE,__LINE__739,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**(r4)),(r4))
740
741/*MC
742 PetscMalloc5 - Allocates 5 arrays of memory, all aligned to PETSC_MEMALIGN
743
744 Synopsis:
745 #include <petscsys.h>
746 PetscErrorCode PetscMalloc5(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3,size_t m4,type **r4,size_t m5,type **r5)
747
748 Not Collective
749
750 Input Parameters:
751+ m1 - number of elements to allocate in 1st chunk (may be zero)
752. m2 - number of elements to allocate in 2nd chunk (may be zero)
753. m3 - number of elements to allocate in 3rd chunk (may be zero)
754. m4 - number of elements to allocate in 4th chunk (may be zero)
755- m5 - number of elements to allocate in 5th chunk (may be zero)
756
757 Output Parameters:
758+ r1 - memory allocated in first chunk
759. r2 - memory allocated in second chunk
760. r3 - memory allocated in third chunk
761. r4 - memory allocated in fourth chunk
762- r5 - memory allocated in fifth chunk
763
764 Level: developer
765
766.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscCalloc5(), PetscFree5()
767
768 Concepts: memory allocation
769
770M*/
771#define PetscMalloc5(m1,r1,m2,r2,m3,r3,m4,r4,m5,r5)PetscMallocA(5,PETSC_FALSE,771,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**
(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5))
PetscMallocA(5,PETSC_FALSE,__LINE__771,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5))
772
773/*MC
774 PetscCalloc5 - Allocates 5 cleared (zeroed) arrays of memory, all aligned to PETSC_MEMALIGN
775
776 Synopsis:
777 #include <petscsys.h>
778 PetscErrorCode PetscCalloc5(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3,size_t m4,type **r4,size_t m5,type **r5)
779
780 Not Collective
781
782 Input Parameters:
783+ m1 - number of elements to allocate in 1st chunk (may be zero)
784. m2 - number of elements to allocate in 2nd chunk (may be zero)
785. m3 - number of elements to allocate in 3rd chunk (may be zero)
786. m4 - number of elements to allocate in 4th chunk (may be zero)
787- m5 - number of elements to allocate in 5th chunk (may be zero)
788
789 Output Parameters:
790+ r1 - memory allocated in first chunk
791. r2 - memory allocated in second chunk
792. r3 - memory allocated in third chunk
793. r4 - memory allocated in fourth chunk
794- r5 - memory allocated in fifth chunk
795
796 Level: developer
797
798.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc5(), PetscFree5()
799
800 Concepts: memory allocation
801
802M*/
803#define PetscCalloc5(m1,r1,m2,r2,m3,r3,m4,r4,m5,r5)PetscMallocA(5,PETSC_TRUE,803,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**
(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5))
PetscMallocA(5,PETSC_TRUE,__LINE__803,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5))
804
805/*MC
806 PetscMalloc6 - Allocates 6 arrays of memory, all aligned to PETSC_MEMALIGN
807
808 Synopsis:
809 #include <petscsys.h>
810 PetscErrorCode PetscMalloc6(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3,size_t m4,type **r4,size_t m5,type **r5,size_t m6,type **r6)
811
812 Not Collective
813
814 Input Parameters:
815+ m1 - number of elements to allocate in 1st chunk (may be zero)
816. m2 - number of elements to allocate in 2nd chunk (may be zero)
817. m3 - number of elements to allocate in 3rd chunk (may be zero)
818. m4 - number of elements to allocate in 4th chunk (may be zero)
819. m5 - number of elements to allocate in 5th chunk (may be zero)
820- m6 - number of elements to allocate in 6th chunk (may be zero)
821
822 Output Parameteasr:
823+ r1 - memory allocated in first chunk
824. r2 - memory allocated in second chunk
825. r3 - memory allocated in third chunk
826. r4 - memory allocated in fourth chunk
827. r5 - memory allocated in fifth chunk
828- r6 - memory allocated in sixth chunk
829
830 Level: developer
831
832.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscCalloc6(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6()
833
834 Concepts: memory allocation
835
836M*/
837#define PetscMalloc6(m1,r1,m2,r2,m3,r3,m4,r4,m5,r5,m6,r6)PetscMallocA(6,PETSC_FALSE,837,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**
(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5),(size_t)(m6)*sizeof
(**(r6)),(r6))
PetscMallocA(6,PETSC_FALSE,__LINE__837,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5),(size_t)(m6)*sizeof(**(r6)),(r6))
838
839/*MC
840 PetscCalloc6 - Allocates 6 cleared (zeroed) arrays of memory, all aligned to PETSC_MEMALIGN
841
842 Synopsis:
843 #include <petscsys.h>
844 PetscErrorCode PetscCalloc6(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3,size_t m4,type **r4,size_t m5,type **r5,size_t m6,type **r6)
845
846 Not Collective
847
848 Input Parameters:
849+ m1 - number of elements to allocate in 1st chunk (may be zero)
850. m2 - number of elements to allocate in 2nd chunk (may be zero)
851. m3 - number of elements to allocate in 3rd chunk (may be zero)
852. m4 - number of elements to allocate in 4th chunk (may be zero)
853. m5 - number of elements to allocate in 5th chunk (may be zero)
854- m6 - number of elements to allocate in 6th chunk (may be zero)
855
856 Output Parameters:
857+ r1 - memory allocated in first chunk
858. r2 - memory allocated in second chunk
859. r3 - memory allocated in third chunk
860. r4 - memory allocated in fourth chunk
861. r5 - memory allocated in fifth chunk
862- r6 - memory allocated in sixth chunk
863
864 Level: developer
865
866.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscMalloc6(), PetscFree6()
867
868 Concepts: memory allocation
869M*/
870#define PetscCalloc6(m1,r1,m2,r2,m3,r3,m4,r4,m5,r5,m6,r6)PetscMallocA(6,PETSC_TRUE,870,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**
(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5),(size_t)(m6)*sizeof
(**(r6)),(r6))
PetscMallocA(6,PETSC_TRUE,__LINE__870,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5),(size_t)(m6)*sizeof(**(r6)),(r6))
871
872/*MC
873 PetscMalloc7 - Allocates 7 arrays of memory, all aligned to PETSC_MEMALIGN
874
875 Synopsis:
876 #include <petscsys.h>
877 PetscErrorCode PetscMalloc7(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3,size_t m4,type **r4,size_t m5,type **r5,size_t m6,type **r6,size_t m7,type **r7)
878
879 Not Collective
880
881 Input Parameters:
882+ m1 - number of elements to allocate in 1st chunk (may be zero)
883. m2 - number of elements to allocate in 2nd chunk (may be zero)
884. m3 - number of elements to allocate in 3rd chunk (may be zero)
885. m4 - number of elements to allocate in 4th chunk (may be zero)
886. m5 - number of elements to allocate in 5th chunk (may be zero)
887. m6 - number of elements to allocate in 6th chunk (may be zero)
888- m7 - number of elements to allocate in 7th chunk (may be zero)
889
890 Output Parameters:
891+ r1 - memory allocated in first chunk
892. r2 - memory allocated in second chunk
893. r3 - memory allocated in third chunk
894. r4 - memory allocated in fourth chunk
895. r5 - memory allocated in fifth chunk
896. r6 - memory allocated in sixth chunk
897- r7 - memory allocated in seventh chunk
898
899 Level: developer
900
901.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscCalloc7(), PetscFree7()
902
903 Concepts: memory allocation
904
905M*/
906#define PetscMalloc7(m1,r1,m2,r2,m3,r3,m4,r4,m5,r5,m6,r6,m7,r7)PetscMallocA(7,PETSC_FALSE,906,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**
(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5),(size_t)(m6)*sizeof
(**(r6)),(r6),(size_t)(m7)*sizeof(**(r7)),(r7))
PetscMallocA(7,PETSC_FALSE,__LINE__906,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5),(size_t)(m6)*sizeof(**(r6)),(r6),(size_t)(m7)*sizeof(**(r7)),(r7))
907
908/*MC
909 PetscCalloc7 - Allocates 7 cleared (zeroed) arrays of memory, all aligned to PETSC_MEMALIGN
910
911 Synopsis:
912 #include <petscsys.h>
913 PetscErrorCode PetscCalloc7(size_t m1,type **r1,size_t m2,type **r2,size_t m3,type **r3,size_t m4,type **r4,size_t m5,type **r5,size_t m6,type **r6,size_t m7,type **r7)
914
915 Not Collective
916
917 Input Parameters:
918+ m1 - number of elements to allocate in 1st chunk (may be zero)
919. m2 - number of elements to allocate in 2nd chunk (may be zero)
920. m3 - number of elements to allocate in 3rd chunk (may be zero)
921. m4 - number of elements to allocate in 4th chunk (may be zero)
922. m5 - number of elements to allocate in 5th chunk (may be zero)
923. m6 - number of elements to allocate in 6th chunk (may be zero)
924- m7 - number of elements to allocate in 7th chunk (may be zero)
925
926 Output Parameters:
927+ r1 - memory allocated in first chunk
928. r2 - memory allocated in second chunk
929. r3 - memory allocated in third chunk
930. r4 - memory allocated in fourth chunk
931. r5 - memory allocated in fifth chunk
932. r6 - memory allocated in sixth chunk
933- r7 - memory allocated in seventh chunk
934
935 Level: developer
936
937.seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscMalloc7(), PetscFree7()
938
939 Concepts: memory allocation
940M*/
941#define PetscCalloc7(m1,r1,m2,r2,m3,r3,m4,r4,m5,r5,m6,r6,m7,r7)PetscMallocA(7,PETSC_TRUE,941,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2))
,(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**
(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5),(size_t)(m6)*sizeof
(**(r6)),(r6),(size_t)(m7)*sizeof(**(r7)),(r7))
PetscMallocA(7,PETSC_TRUE,__LINE__941,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",(size_t)(m1)*sizeof(**(r1)),(r1),(size_t)(m2)*sizeof(**(r2)),(r2),(size_t)(m3)*sizeof(**(r3)),(r3),(size_t)(m4)*sizeof(**(r4)),(r4),(size_t)(m5)*sizeof(**(r5)),(r5),(size_t)(m6)*sizeof(**(r6)),(r6),(size_t)(m7)*sizeof(**(r7)),(r7))
942
943/*MC
944 PetscNew - Allocates memory of a particular type, zeros the memory! Aligned to PETSC_MEMALIGN
945
946 Synopsis:
947 #include <petscsys.h>
948 PetscErrorCode PetscNew(type **result)
949
950 Not Collective
951
952 Output Parameter:
953. result - memory allocated, sized to match pointer type
954
955 Level: beginner
956
957.seealso: PetscFree(), PetscMalloc(), PetscNewLog(), PetscCalloc1(), PetscMalloc1()
958
959 Concepts: memory allocation
960
961M*/
962#define PetscNew(b)PetscMallocA(1,PETSC_TRUE,962,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(1)*sizeof(**((b))),((b)))
PetscCalloc1(1,(b))PetscMallocA(1,PETSC_TRUE,962,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(1)*sizeof(**((b))),((b)))
963
964/*MC
965 PetscNewLog - Allocates memory of a type matching pointer, zeros the memory! Aligned to PETSC_MEMALIGN. Associates the memory allocated
966 with the given object using PetscLogObjectMemory().
967
968 Synopsis:
969 #include <petscsys.h>
970 PetscErrorCode PetscNewLog(PetscObject obj,type **result)
971
972 Not Collective
973
974 Input Parameter:
975. obj - object memory is logged to
976
977 Output Parameter:
978. result - memory allocated, sized to match pointer type
979
980 Level: developer
981
982.seealso: PetscFree(), PetscMalloc(), PetscNew(), PetscLogObjectMemory(), PetscCalloc1(), PetscMalloc1()
983
984 Concepts: memory allocation
985
986M*/
987#define PetscNewLog(o,b)(PetscMallocA(1,PETSC_TRUE,987,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(1)*sizeof(**(((b)))),(((b)))) || PetscLogObjectMemory
((PetscObject)o,sizeof(**(b))))
(PetscNew((b))PetscMallocA(1,PETSC_TRUE,987,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,(size_t)(1)*sizeof(**(((b)))),(((b))))
|| PetscLogObjectMemory((PetscObject)o,sizeof(**(b))))
988
989/*MC
990 PetscFree - Frees memory
991
992 Synopsis:
993 #include <petscsys.h>
994 PetscErrorCode PetscFree(void *memory)
995
996 Not Collective
997
998 Input Parameter:
999. memory - memory to free (the pointer is ALWAYS set to NULL upon sucess)
1000
1001 Level: beginner
1002
1003 Notes:
1004 Do not free memory obtained with PetscMalloc2(), PetscCalloc2() etc, they must be freed with PetscFree2() etc.
1005
1006 It is safe to call PetscFree() on a NULL pointer.
1007
1008.seealso: PetscNew(), PetscMalloc(), PetscNewLog(), PetscMalloc1(), PetscCalloc1()
1009
1010 Concepts: memory allocation
1011
1012M*/
1013#define PetscFree(a)((*PetscTrFree)((void*)(a),1013,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
) || ((a) = 0,0))
((*PetscTrFree)((void*)(a),__LINE__1013,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h") || ((a) = 0,0))
1014
1015/*MC
1016 PetscFree2 - Frees 2 chunks of memory obtained with PetscMalloc2()
1017
1018 Synopsis:
1019 #include <petscsys.h>
1020 PetscErrorCode PetscFree2(void *memory1,void *memory2)
1021
1022 Not Collective
1023
1024 Input Parameters:
1025+ memory1 - memory to free
1026- memory2 - 2nd memory to free
1027
1028 Level: developer
1029
1030 Notes:
1031 Memory must have been obtained with PetscMalloc2()
1032
1033.seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree()
1034
1035 Concepts: memory allocation
1036
1037M*/
1038#define PetscFree2(m1,m2)PetscFreeA(2,1038,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,&(m1),&(m2))
PetscFreeA(2,__LINE__1038,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",&(m1),&(m2))
1039
1040/*MC
1041 PetscFree3 - Frees 3 chunks of memory obtained with PetscMalloc3()
1042
1043 Synopsis:
1044 #include <petscsys.h>
1045 PetscErrorCode PetscFree3(void *memory1,void *memory2,void *memory3)
1046
1047 Not Collective
1048
1049 Input Parameters:
1050+ memory1 - memory to free
1051. memory2 - 2nd memory to free
1052- memory3 - 3rd memory to free
1053
1054 Level: developer
1055
1056 Notes:
1057 Memory must have been obtained with PetscMalloc3()
1058
1059.seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3()
1060
1061 Concepts: memory allocation
1062
1063M*/
1064#define PetscFree3(m1,m2,m3)PetscFreeA(3,1064,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,&(m1),&(m2),&(m3))
PetscFreeA(3,__LINE__1064,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",&(m1),&(m2),&(m3))
1065
1066/*MC
1067 PetscFree4 - Frees 4 chunks of memory obtained with PetscMalloc4()
1068
1069 Synopsis:
1070 #include <petscsys.h>
1071 PetscErrorCode PetscFree4(void *m1,void *m2,void *m3,void *m4)
1072
1073 Not Collective
1074
1075 Input Parameters:
1076+ m1 - memory to free
1077. m2 - 2nd memory to free
1078. m3 - 3rd memory to free
1079- m4 - 4th memory to free
1080
1081 Level: developer
1082
1083 Notes:
1084 Memory must have been obtained with PetscMalloc4()
1085
1086.seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4()
1087
1088 Concepts: memory allocation
1089
1090M*/
1091#define PetscFree4(m1,m2,m3,m4)PetscFreeA(4,1091,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,&(m1),&(m2),&(m3),&(m4))
PetscFreeA(4,__LINE__1091,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",&(m1),&(m2),&(m3),&(m4))
1092
1093/*MC
1094 PetscFree5 - Frees 5 chunks of memory obtained with PetscMalloc5()
1095
1096 Synopsis:
1097 #include <petscsys.h>
1098 PetscErrorCode PetscFree5(void *m1,void *m2,void *m3,void *m4,void *m5)
1099
1100 Not Collective
1101
1102 Input Parameters:
1103+ m1 - memory to free
1104. m2 - 2nd memory to free
1105. m3 - 3rd memory to free
1106. m4 - 4th memory to free
1107- m5 - 5th memory to free
1108
1109 Level: developer
1110
1111 Notes:
1112 Memory must have been obtained with PetscMalloc5()
1113
1114.seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5()
1115
1116 Concepts: memory allocation
1117
1118M*/
1119#define PetscFree5(m1,m2,m3,m4,m5)PetscFreeA(5,1119,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,&(m1),&(m2),&(m3),&(m4),&(m5))
PetscFreeA(5,__LINE__1119,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",&(m1),&(m2),&(m3),&(m4),&(m5))
1120
1121/*MC
1122 PetscFree6 - Frees 6 chunks of memory obtained with PetscMalloc6()
1123
1124 Synopsis:
1125 #include <petscsys.h>
1126 PetscErrorCode PetscFree6(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6)
1127
1128 Not Collective
1129
1130 Input Parameters:
1131+ m1 - memory to free
1132. m2 - 2nd memory to free
1133. m3 - 3rd memory to free
1134. m4 - 4th memory to free
1135. m5 - 5th memory to free
1136- m6 - 6th memory to free
1137
1138
1139 Level: developer
1140
1141 Notes:
1142 Memory must have been obtained with PetscMalloc6()
1143
1144.seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6()
1145
1146 Concepts: memory allocation
1147
1148M*/
1149#define PetscFree6(m1,m2,m3,m4,m5,m6)PetscFreeA(6,1149,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,&(m1),&(m2),&(m3),&(m4),&(m5),&(m6))
PetscFreeA(6,__LINE__1149,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",&(m1),&(m2),&(m3),&(m4),&(m5),&(m6))
1150
1151/*MC
1152 PetscFree7 - Frees 7 chunks of memory obtained with PetscMalloc7()
1153
1154 Synopsis:
1155 #include <petscsys.h>
1156 PetscErrorCode PetscFree7(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6,void *m7)
1157
1158 Not Collective
1159
1160 Input Parameters:
1161+ m1 - memory to free
1162. m2 - 2nd memory to free
1163. m3 - 3rd memory to free
1164. m4 - 4th memory to free
1165. m5 - 5th memory to free
1166. m6 - 6th memory to free
1167- m7 - 7th memory to free
1168
1169
1170 Level: developer
1171
1172 Notes:
1173 Memory must have been obtained with PetscMalloc7()
1174
1175.seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6(),
1176 PetscMalloc7()
1177
1178 Concepts: memory allocation
1179
1180M*/
1181#define PetscFree7(m1,m2,m3,m4,m5,m6,m7)PetscFreeA(7,1181,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,&(m1),&(m2),&(m3),&(m4),&(m5),&(m6),
&(m7))
PetscFreeA(7,__LINE__1181,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h",&(m1),&(m2),&(m3),&(m4),&(m5),&(m6),&(m7))
1182
1183PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocA(int,PetscBool,int,const char *,const char *,size_t,void *,...);
1184PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFreeA(int,int,const char *,const char *,void *,...);
1185PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode (*PetscTrMalloc)(size_t,int,const char[],const char[],void**);
1186PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode (*PetscTrFree)(void*,int,const char[],const char[]);
1187PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode (*PetscTrRealloc)(size_t,int,const char[],const char[],void**);
1188PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocSetCoalesce(PetscBool);
1189PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocSet(PetscErrorCode (*)(size_t,int,const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[]));
1190PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocClear(void);
1191
1192/*
1193 Unlike PetscMallocSet and PetscMallocClear which overwrite the existing settings, these two functions save the previous choice of allocator, and should be used in pair.
1194*/
1195PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocSetDRAM(void);
1196PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocResetDRAM(void);
1197
1198#define MPIU_PETSCLOGDOUBLE((MPI_Datatype)0x4c00080b) MPI_DOUBLE((MPI_Datatype)0x4c00080b)
1199#define MPIU_2PETSCLOGDOUBLE((MPI_Datatype)1275072547) MPI_2DOUBLE_PRECISION((MPI_Datatype)1275072547)
1200
1201/*
1202 Routines for tracing memory corruption/bleeding with default PETSc memory allocation
1203*/
1204PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocDump(FILE *);
1205PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocDumpLog(FILE *);
1206PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocGetCurrentUsage(PetscLogDouble *);
1207PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocGetMaximumUsage(PetscLogDouble *);
1208PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocDebug(PetscBool);
1209PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocGetDebug(PetscBool*);
1210PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocValidate(int,const char[],const char[]);
1211PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocSetDumpLog(void);
1212PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocSetDumpLogThreshold(PetscLogDouble);
1213PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocGetDumpLog(PetscBool*);
1214
1215PETSC_EXTERNextern __attribute__((visibility ("default"))) const char *const PetscDataTypes[];
1216PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
1217PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMPIDataTypeToPetscDataType(MPI_Datatype,PetscDataType*);
1218PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDataTypeGetSize(PetscDataType,size_t*);
1219PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDataTypeFromString(const char*,PetscDataType*,PetscBool*);
1220
1221/*
1222 Basic memory and string operations. These are usually simple wrappers
1223 around the basic Unix system calls, but a few of them have additional
1224 functionality and/or error checking.
1225*/
1226PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType);
1227PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMemmove(void*,void *,size_t);
1228PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMemcmp(const void*,const void*,size_t,PetscBool *);
1229PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrlen(const char[],size_t*);
1230PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrToArray(const char[],char,int*,char ***);
1231PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrToArrayDestroy(int,char **);
1232PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrcmp(const char[],const char[],PetscBool *);
1233PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrgrt(const char[],const char[],PetscBool *);
1234PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrcasecmp(const char[],const char[],PetscBool *);
1235PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrncmp(const char[],const char[],size_t,PetscBool *);
1236PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrcpy(char[],const char[]);
1237PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrcat(char[],const char[]);
1238PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrlcat(char[],const char[],size_t);
1239PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrncpy(char[],const char[],size_t);
1240PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrchr(const char[],char,char *[]);
1241PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrtolower(char[]);
1242PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrtoupper(char[]);
1243PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrrchr(const char[],char,char *[]);
1244PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrstr(const char[],const char[],char *[]);
1245PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrrstr(const char[],const char[],char *[]);
1246PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrendswith(const char[],const char[],PetscBool*);
1247PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrbeginswith(const char[],const char[],PetscBool*);
1248PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrendswithwhich(const char[],const char *const*,PetscInt*);
1249PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrallocpy(const char[],char *[]);
1250PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrArrayallocpy(const char *const*,char***);
1251PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrArrayDestroy(char***);
1252PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrNArrayallocpy(PetscInt,const char *const*,char***);
1253PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrNArrayDestroy(PetscInt,char***);
1254PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrreplace(MPI_Comm,const char[],char[],size_t);
1255
1256PETSC_EXTERNextern __attribute__((visibility ("default"))) void PetscStrcmpNoError(const char[],const char[],PetscBool *);
1257
1258PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTokenCreate(const char[],const char,PetscToken*);
1259PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTokenFind(PetscToken,char *[]);
1260PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTokenDestroy(PetscToken*);
1261PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStrInList(const char[],const char[],char,PetscBool*);
1262
1263PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscEListFind(PetscInt,const char *const*,const char*,PetscInt*,PetscBool*);
1264PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscEnumFind(const char *const*,const char*,PetscEnum*,PetscBool*);
1265
1266/*
1267 These are MPI operations for MPI_Allreduce() etc
1268*/
1269PETSC_EXTERNextern __attribute__((visibility ("default"))) MPI_Op MPIU_MAXSUM_OP;
1270#if (defined(PETSC_HAVE_COMPLEX1) && !defined(PETSC_HAVE_MPI_C_DOUBLE_COMPLEX1)) || defined(PETSC_USE_REAL___FLOAT128) || defined(PETSC_USE_REAL___FP16)
1271PETSC_EXTERNextern __attribute__((visibility ("default"))) MPI_Op MPIU_SUM(MPI_Op)(0x58000003);
1272#else
1273#define MPIU_SUM(MPI_Op)(0x58000003) MPI_SUM(MPI_Op)(0x58000003)
1274#endif
1275#if defined(PETSC_USE_REAL___FLOAT128) || defined(PETSC_USE_REAL___FP16)
1276PETSC_EXTERNextern __attribute__((visibility ("default"))) MPI_Op MPIU_MAX(MPI_Op)(0x58000001);
1277PETSC_EXTERNextern __attribute__((visibility ("default"))) MPI_Op MPIU_MIN(MPI_Op)(0x58000002);
1278#else
1279#define MPIU_MAX(MPI_Op)(0x58000001) MPI_MAX(MPI_Op)(0x58000001)
1280#define MPIU_MIN(MPI_Op)(0x58000002) MPI_MIN(MPI_Op)(0x58000002)
1281#endif
1282PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*);
1283
1284PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode MPIULong_Send(void*,PetscInt,MPI_Datatype,PetscMPIInt,PetscMPIInt,MPI_Comm);
1285PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode MPIULong_Recv(void*,PetscInt,MPI_Datatype,PetscMPIInt,PetscMPIInt,MPI_Comm);
1286
1287PETSC_EXTERNextern __attribute__((visibility ("default"))) const char *const PetscFileModes[];
1288
1289/*
1290 Defines PETSc error handling.
1291*/
1292#include <petscerror.h>
1293
1294#define PETSC_SMALLEST_CLASSID1211211 1211211
1295PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscClassId PETSC_LARGEST_CLASSID;
1296PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscClassId PETSC_OBJECT_CLASSID;
1297PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscClassIdRegister(const char[],PetscClassId *);
1298
1299/*
1300 Routines that get memory usage information from the OS
1301*/
1302PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMemoryGetCurrentUsage(PetscLogDouble *);
1303PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMemoryGetMaximumUsage(PetscLogDouble *);
1304PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMemorySetGetMaximumUsage(void);
1305PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMemoryTrace(const char[]);
1306
1307PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscInfoAllow(PetscBool ,const char []);
1308PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSleep(PetscReal);
1309
1310/*
1311 Initialization of PETSc
1312*/
1313PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscInitialize(int*,char***,const char[],const char[]);
1314PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscInitializeNoPointers(int,char**,const char[],const char[]);
1315PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscInitializeNoArguments(void);
1316PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscInitialized(PetscBool *);
1317PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFinalized(PetscBool *);
1318PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFinalize(void);
1319PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscInitializeFortran(void);
1320PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetArgs(int*,char ***);
1321PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetArguments(char ***);
1322PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFreeArguments(char **);
1323
1324PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscEnd(void);
1325PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSysInitializePackage(void);
1326
1327PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPythonInitialize(const char[],const char[]);
1328PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPythonFinalize(void);
1329PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPythonPrintError(void);
1330PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPythonMonitorSet(PetscObject,const char[]);
1331
1332/*
1333 These are so that in extern C code we can caste function pointers to non-extern C
1334 function pointers. Since the regular C++ code expects its function pointers to be C++
1335*/
1336PETSC_EXTERN_TYPEDEF typedef void (**PetscVoidStarFunction)(void);
1337PETSC_EXTERN_TYPEDEF typedef void (*PetscVoidFunction)(void);
1338PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*PetscErrorCodeFunction)(void);
1339
1340/*
1341 Functions that can act on any PETSc object.
1342*/
1343PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectDestroy(PetscObject*);
1344PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectGetComm(PetscObject,MPI_Comm *);
1345PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectGetClassId(PetscObject,PetscClassId *);
1346PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectGetClassName(PetscObject,const char *[]);
1347PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSetType(PetscObject,const char []);
1348PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectGetType(PetscObject,const char *[]);
1349PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSetName(PetscObject,const char[]);
1350PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectGetName(PetscObject,const char*[]);
1351PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSetTabLevel(PetscObject,PetscInt);
1352PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectGetTabLevel(PetscObject,PetscInt*);
1353PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectIncrementTabLevel(PetscObject,PetscObject,PetscInt);
1354PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectReference(PetscObject);
1355PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectGetReference(PetscObject,PetscInt*);
1356PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectDereference(PetscObject);
1357PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectGetNewTag(PetscObject,PetscMPIInt *);
1358PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectCompose(PetscObject,const char[],PetscObject);
1359PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectRemoveReference(PetscObject,const char[]);
1360PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectQuery(PetscObject,const char[],PetscObject *);
1361PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectComposeFunction_Private(PetscObject,const char[],void (*)(void));
1362#define PetscObjectComposeFunction(a,b,d)PetscObjectComposeFunction_Private(a,b,(PetscVoidFunction)(d)
)
PetscObjectComposeFunction_Private(a,b,(PetscVoidFunction)(d))
1363PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSetFromOptions(PetscObject);
1364PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSetUp(PetscObject);
1365PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSetPrintedOptions(PetscObject);
1366PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectInheritPrintedOptions(PetscObject,PetscObject);
1367PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscCommGetNewTag(MPI_Comm,PetscMPIInt *);
1368
1369#include <petscviewertypes.h>
1370#include <petscoptions.h>
1371
1372PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectsListGetGlobalNumbering(MPI_Comm,PetscInt,PetscObject*,PetscInt*,PetscInt*);
1373
1374PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMemoryShowUsage(PetscViewer,const char[]);
1375PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMemoryView(PetscViewer,const char[]);
1376PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectPrintClassNamePrefixType(PetscObject,PetscViewer);
1377PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectView(PetscObject,PetscViewer);
1378#define PetscObjectQueryFunction(obj,name,fptr)PetscObjectQueryFunction_Private((obj),(name),(PetscVoidFunction
*)(fptr))
PetscObjectQueryFunction_Private((obj),(name),(PetscVoidFunction*)(fptr))
1379PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectQueryFunction_Private(PetscObject,const char[],void (**)(void));
1380PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSetOptionsPrefix(PetscObject,const char[]);
1381PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
1382PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectPrependOptionsPrefix(PetscObject,const char[]);
1383PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectGetOptionsPrefix(PetscObject,const char*[]);
1384PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectChangeTypeName(PetscObject,const char[]);
1385PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectRegisterDestroy(PetscObject);
1386PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectRegisterDestroyAll(void);
1387PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectViewFromOptions(PetscObject,PetscObject,const char[]);
1388PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectName(PetscObject);
1389PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectTypeCompare(PetscObject,const char[],PetscBool *);
1390PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectBaseTypeCompare(PetscObject,const char[],PetscBool *);
1391PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectTypeCompareAny(PetscObject,PetscBool*,const char[],...);
1392PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRegisterFinalize(PetscErrorCode (*)(void));
1393PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRegisterFinalizeAll(void);
1394
1395#if defined(PETSC_HAVE_SAWS)
1396PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSAWsBlock(void);
1397PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSAWsViewOff(PetscObject)0;
1398PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSAWsSetBlock(PetscObject,PetscBool)0;
1399PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSAWsBlock(PetscObject)0;
1400PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSAWsGrantAccess(PetscObject)0;
1401PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectSAWsTakeAccess(PetscObject)0;
1402PETSC_EXTERNextern __attribute__((visibility ("default"))) void PetscStackSAWsGrantAccess(void);
1403PETSC_EXTERNextern __attribute__((visibility ("default"))) void PetscStackSAWsTakeAccess(void);
1404PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStackViewSAWs(void);
1405PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStackSAWsViewOff(void);
1406
1407#else
1408#define PetscSAWsBlock()0 0
1409#define PetscObjectSAWsViewOff(obj)0 0
1410#define PetscObjectSAWsSetBlock(obj,flg)0 0
1411#define PetscObjectSAWsBlock(obj)0 0
1412#define PetscObjectSAWsGrantAccess(obj)0 0
1413#define PetscObjectSAWsTakeAccess(obj)0 0
1414#define PetscStackViewSAWs()0 0
1415#define PetscStackSAWsViewOff()0 0
1416#define PetscStackSAWsTakeAccess()
1417#define PetscStackSAWsGrantAccess()
1418
1419#endif
1420
1421PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLOpen(const char[],PetscDLMode,PetscDLHandle *);
1422PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLClose(PetscDLHandle *);
1423PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLSym(PetscDLHandle,const char[],void **);
1424
1425#if defined(PETSC_USE_DEBUG1)
1426PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMallocGetStack(void*,PetscStack**);
1427#endif
1428PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectsDump(FILE*,PetscBool);
1429
1430PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectListDestroy(PetscObjectList*);
1431PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectListFind(PetscObjectList,const char[],PetscObject*);
1432PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectListReverseFind(PetscObjectList,PetscObject,char**,PetscBool*);
1433PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectListAdd(PetscObjectList *,const char[],PetscObject);
1434PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectListRemoveReference(PetscObjectList *,const char[]);
1435PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscObjectListDuplicate(PetscObjectList,PetscObjectList *);
1436
1437/*
1438 Dynamic library lists. Lists of names of routines in objects or in dynamic
1439 link libraries that will be loaded as needed.
1440*/
1441
1442#define PetscFunctionListAdd(list,name,fptr)PetscFunctionListAdd_Private((list),(name),(PetscVoidFunction
)(fptr))
PetscFunctionListAdd_Private((list),(name),(PetscVoidFunction)(fptr))
1443PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFunctionListAdd_Private(PetscFunctionList*,const char[],void (*)(void));
1444PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFunctionListDestroy(PetscFunctionList*);
1445#define PetscFunctionListFind(list,name,fptr)PetscFunctionListFind_Private((list),(name),(PetscVoidFunction
*)(fptr))
PetscFunctionListFind_Private((list),(name),(PetscVoidFunction*)(fptr))
1446PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFunctionListFind_Private(PetscFunctionList,const char[],void (**)(void));
1447PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFunctionListPrintTypes(MPI_Comm,FILE*,const char[],const char[],const char[],const char[],PetscFunctionList,const char[]);
1448PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFunctionListDuplicate(PetscFunctionList,PetscFunctionList *);
1449PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFunctionListView(PetscFunctionList,PetscViewer);
1450PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFunctionListGet(PetscFunctionList,const char ***,int*);
1451
1452PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscDLLibrary PetscDLLibrariesLoaded;
1453PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLLibraryAppend(MPI_Comm,PetscDLLibrary *,const char[]);
1454PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLLibraryPrepend(MPI_Comm,PetscDLLibrary *,const char[]);
1455PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLLibrarySym(MPI_Comm,PetscDLLibrary *,const char[],const char[],void **);
1456PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLLibraryPrintPath(PetscDLLibrary);
1457PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,size_t,PetscBool *);
1458PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLLibraryOpen(MPI_Comm,const char[],PetscDLLibrary *);
1459PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscDLLibraryClose(PetscDLLibrary);
1460
1461/*
1462 Useful utility routines
1463*/
1464PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*);
1465PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*);
1466PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt);
1467PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt);
1468PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBarrier(PetscObject);
1469PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMPIDump(FILE*);
1470PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGlobalMinMaxInt(MPI_Comm,PetscInt[],PetscInt[]);
1471PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGlobalMinMaxReal(MPI_Comm,PetscReal[],PetscReal[]);
1472
1473/*MC
1474 PetscNot - negates a logical type value and returns result as a PetscBool
1475
1476 Notes:
1477 This is useful in cases like
1478$ int *a;
1479$ PetscBool flag = PetscNot(a)
1480 where !a would not return a PetscBool because we cannot provide a cast from int to PetscBool in C.
1481
1482 Level: beginner
1483
1484 .seealso : PetscBool, PETSC_TRUE, PETSC_FALSE
1485M*/
1486#define PetscNot(a)((a) ? PETSC_FALSE : PETSC_TRUE) ((a) ? PETSC_FALSE : PETSC_TRUE)
1487
1488/*MC
1489 PetscHelpPrintf - Prints help messages.
1490
1491 Synopsis:
1492 #include <petscsys.h>
1493 PetscErrorCode (*PetscHelpPrintf)(const char format[],...);
1494
1495 Not Collective
1496
1497 Input Parameters:
1498. format - the usual printf() format string
1499
1500 Level: developer
1501
1502 Fortran Note:
1503 This routine is not supported in Fortran.
1504
1505 Concepts: help messages^printing
1506 Concepts: printing^help messages
1507
1508.seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf()
1509M*/
1510PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode (*PetscHelpPrintf)(MPI_Comm,const char[],...);
1511
1512/*
1513 Defines PETSc profiling.
1514*/
1515#include <petsclog.h>
1516
1517/*
1518 Simple PETSc parallel IO for ASCII printing
1519*/
1520PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFixFilename(const char[],char[]);
1521PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFOpen(MPI_Comm,const char[],const char[],FILE**);
1522PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFClose(MPI_Comm,FILE*);
1523PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFPrintf(MPI_Comm,FILE*,const char[],...);
1524PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPrintf(MPI_Comm,const char[],...);
1525PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSNPrintf(char*,size_t,const char [],...);
1526PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSNPrintfCount(char*,size_t,const char [],size_t*,...);
1527PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFormatRealArray(char[],size_t,const char*,PetscInt,const PetscReal[]);
1528
1529PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscErrorPrintfDefault(const char [],...);
1530PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscErrorPrintfNone(const char [],...);
1531PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscHelpPrintfDefault(MPI_Comm,const char [],...);
1532
1533PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFormatConvertGetSize(const char*,size_t*);
1534PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFormatConvert(const char*,char *);
1535
1536#if defined(PETSC_HAVE_POPEN1)
1537PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **);
1538PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPClose(MPI_Comm,FILE*);
1539PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPOpenSetMachine(const char[]);
1540#endif
1541
1542PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSynchronizedPrintf(MPI_Comm,const char[],...);
1543PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...);
1544PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSynchronizedFlush(MPI_Comm,FILE*);
1545PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]);
1546PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**);
1547PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStartJava(MPI_Comm,const char[],const char[],FILE**);
1548PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetPetscDir(const char*[]);
1549
1550PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscClassId PETSC_CONTAINER_CLASSID;
1551PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscContainerGetPointer(PetscContainer,void **);
1552PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscContainerSetPointer(PetscContainer,void *);
1553PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscContainerDestroy(PetscContainer*);
1554PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscContainerCreate(MPI_Comm,PetscContainer *);
1555PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscContainerSetUserDestroy(PetscContainer, PetscErrorCode (*)(void*));
1556PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscContainerUserDestroyDefault(void*);
1557
1558/*
1559 For use in debuggers
1560*/
1561PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscMPIInt PetscGlobalRank;
1562PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscMPIInt PetscGlobalSize;
1563PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscIntView(PetscInt,const PetscInt[],PetscViewer);
1564PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRealView(PetscInt,const PetscReal[],PetscViewer);
1565PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscScalarView(PetscInt,const PetscScalar[],PetscViewer);
1566
1567#include <stddef.h>
1568#include <string.h> /* for memcpy, memset */
1569#if defined(PETSC_HAVE_STDLIB_H1)
1570#include <stdlib.h>
1571#endif
1572
1573#if defined(PETSC_HAVE_XMMINTRIN_H1) && !defined(__CUDACC__)
1574#include <xmmintrin.h>
1575#endif
1576
1577/*@C
1578 PetscMemcpy - Copies n bytes, beginning at location b, to the space
1579 beginning at location a. The two memory regions CANNOT overlap, use
1580 PetscMemmove() in that case.
1581
1582 Not Collective
1583
1584 Input Parameters:
1585+ b - pointer to initial memory space
1586- n - length (in bytes) of space to copy
1587
1588 Output Parameter:
1589. a - pointer to copy space
1590
1591 Level: intermediate
1592
1593 Compile Option:
1594 PETSC_PREFER_DCOPY_FOR_MEMCPY will cause the BLAS dcopy() routine to be used
1595 for memory copies on double precision values.
1596 PETSC_PREFER_COPY_FOR_MEMCPY will cause C code to be used
1597 for memory copies on double precision values.
1598 PETSC_PREFER_FORTRAN_FORMEMCPY will cause Fortran code to be used
1599 for memory copies on double precision values.
1600
1601 Note:
1602 This routine is analogous to memcpy().
1603
1604 Not available from Fortran
1605
1606 Developer Note: this is inlined for fastest performance
1607
1608 Concepts: memory^copying
1609 Concepts: copying^memory
1610
1611.seealso: PetscMemmove(), PetscStrallocpy()
1612
1613@*/
1614PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscMemcpy(void *a,const void *b,size_t n)
1615{
1616#if defined(PETSC_USE_DEBUG1)
1617 size_t al = (size_t) a,bl = (size_t) b;
1618 size_t nl = (size_t) n;
1619 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscsys.h"; petscstack
->line[petscstack->currentsize] = 1619; petscstack->
petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1620 if (n > 0 && !b) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Trying to copy from a null pointer")return PetscError(((MPI_Comm)0x44000001),1620,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,85,PETSC_ERROR_INITIAL,"Trying to copy from a null pointer")
;
1621 if (n > 0 && !a) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Trying to copy to a null pointer")return PetscError(((MPI_Comm)0x44000001),1621,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,85,PETSC_ERROR_INITIAL,"Trying to copy to a null pointer")
;
1622#else
1623 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscsys.h"; petscstack
->line[petscstack->currentsize] = 1623; petscstack->
petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1624#endif
1625 if (a != b && n > 0) {
1626#if defined(PETSC_USE_DEBUG1)
1627 if ((al > bl && (al - bl) < nl) || (bl - al) < nl) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Memory regions overlap: either use PetscMemmov()\n\return PetscError(((MPI_Comm)0x44000001),1629,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,75,PETSC_ERROR_INITIAL,"Memory regions overlap: either use PetscMemmov()\n or make sure your copy regions and lengths are correct. \n Length (bytes) %ld first address %ld second address %ld"
,nl,al,bl)
1628 or make sure your copy regions and lengths are correct. \n\return PetscError(((MPI_Comm)0x44000001),1629,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,75,PETSC_ERROR_INITIAL,"Memory regions overlap: either use PetscMemmov()\n or make sure your copy regions and lengths are correct. \n Length (bytes) %ld first address %ld second address %ld"
,nl,al,bl)
1629 Length (bytes) %ld first address %ld second address %ld",nl,al,bl)return PetscError(((MPI_Comm)0x44000001),1629,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,75,PETSC_ERROR_INITIAL,"Memory regions overlap: either use PetscMemmov()\n or make sure your copy regions and lengths are correct. \n Length (bytes) %ld first address %ld second address %ld"
,nl,al,bl)
;
1630#endif
1631#if (defined(PETSC_PREFER_DCOPY_FOR_MEMCPY) || defined(PETSC_PREFER_COPY_FOR_MEMCPY) || defined(PETSC_PREFER_FORTRAN_FORMEMCPY))
1632 if (!(a % sizeof(PetscScalar)) && !(n % sizeof(PetscScalar))) {
1633 size_t len = n/sizeof(PetscScalar);
1634#if defined(PETSC_PREFER_DCOPY_FOR_MEMCPY)
1635 PetscBLASInt one = 1,blen;
1636 PetscErrorCode ierr;
1637 ierr = PetscBLASIntCast(len,&blen);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1637,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1638 PetscStackCallBLAS("BLAScopy",BLAScopy_(&blen,(PetscScalar *)b,&one,(PetscScalar *)a,&one));
1639#elif defined(PETSC_PREFER_FORTRAN_FORMEMCPY)
1640 fortrancopy_(&len,(PetscScalar*)b,(PetscScalar*)a);
1641#else
1642 size_t i;
1643 PetscScalar *x = (PetscScalar*)b, *y = (PetscScalar*)a;
1644 for (i=0; i<len; i++) y[i] = x[i];
1645#endif
1646 } else {
1647 memcpy((char*)(a),(char*)(b),n);
1648 }
1649#else
1650 memcpy((char*)(a),(char*)(b),n);
1651#endif
1652 }
1653 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
1654}
1655
1656/*@C
1657 PetscMemzero - Zeros the specified memory.
1658
1659 Not Collective
1660
1661 Input Parameters:
1662+ a - pointer to beginning memory location
1663- n - length (in bytes) of memory to initialize
1664
1665 Level: intermediate
1666
1667 Compile Option:
1668 PETSC_PREFER_BZERO - on certain machines (the IBM RS6000) the bzero() routine happens
1669 to be faster than the memset() routine. This flag causes the bzero() routine to be used.
1670
1671 Not available from Fortran
1672
1673 Developer Note: this is inlined for fastest performance
1674
1675 Concepts: memory^zeroing
1676 Concepts: zeroing^memory
1677
1678.seealso: PetscMemcpy()
1679@*/
1680PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscMemzero(void *a,size_t n)
1681{
1682 if (n > 0) {
1683#if defined(PETSC_USE_DEBUG1)
1684 if (!a) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Trying to zero at a null pointer")return PetscError(((MPI_Comm)0x44000001),1684,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,85,PETSC_ERROR_INITIAL,"Trying to zero at a null pointer")
;
1685#endif
1686#if defined(PETSC_PREFER_ZERO_FOR_MEMZERO)
1687 if (!(((long) a) % sizeof(PetscScalar)) && !(n % sizeof(PetscScalar))) {
1688 size_t i,len = n/sizeof(PetscScalar);
1689 PetscScalar *x = (PetscScalar*)a;
1690 for (i=0; i<len; i++) x[i] = 0.0;
1691 } else {
1692#elif defined(PETSC_PREFER_FORTRAN_FOR_MEMZERO)
1693 if (!(((long) a) % sizeof(PetscScalar)) && !(n % sizeof(PetscScalar))) {
1694 PetscInt len = n/sizeof(PetscScalar);
1695 fortranzero_(&len,(PetscScalar*)a);
1696 } else {
1697#endif
1698#if defined(PETSC_PREFER_BZERO)
1699 bzero((char *)a,n);
1700#else
1701 memset((char*)a,0,n);
1702#endif
1703#if defined(PETSC_PREFER_ZERO_FOR_MEMZERO) || defined(PETSC_PREFER_FORTRAN_FOR_MEMZERO)
1704 }
1705#endif
1706 }
1707 return 0;
1708}
1709
1710/*MC
1711 PetscPrefetchBlock - Prefetches a block of memory
1712
1713 Synopsis:
1714 #include <petscsys.h>
1715 void PetscPrefetchBlock(const anytype *a,size_t n,int rw,int t)
1716
1717 Not Collective
1718
1719 Input Parameters:
1720+ a - pointer to first element to fetch (any type but usually PetscInt or PetscScalar)
1721. n - number of elements to fetch
1722. rw - 1 if the memory will be written to, otherwise 0 (ignored by many processors)
1723- t - temporal locality (PETSC_PREFETCH_HINT_{NTA,T0,T1,T2}), see note
1724
1725 Level: developer
1726
1727 Notes:
1728 The last two arguments (rw and t) must be compile-time constants.
1729
1730 Adopting Intel's x86/x86-64 conventions, there are four levels of temporal locality. Not all architectures offer
1731 equivalent locality hints, but the following macros are always defined to their closest analogue.
1732+ PETSC_PREFETCH_HINT_NTA - Non-temporal. Prefetches directly to L1, evicts to memory (skips higher level cache unless it was already there when prefetched).
1733. PETSC_PREFETCH_HINT_T0 - Fetch to all levels of cache and evict to the closest level. Use this when the memory will be reused regularly despite necessary eviction from L1.
1734. PETSC_PREFETCH_HINT_T1 - Fetch to level 2 and higher (not L1).
1735- PETSC_PREFETCH_HINT_T2 - Fetch to high-level cache only. (On many systems, T0 and T1 are equivalent.)
1736
1737 This function does nothing on architectures that do not support prefetch and never errors (even if passed an invalid
1738 address).
1739
1740 Concepts: memory
1741M*/
1742#define PetscPrefetchBlock(a,n,rw,t)do { const char *_p = (const char*)(a),*_end = (const char*)(
(a)+(n)); for ( ; _p < _end; _p += 64) (__builtin_prefetch
((void *)((const char*)(_p)), ((((t))) >> 2) & 1, (
((t))) & 0x3)); } while (0)
do { \
1743 const char *_p = (const char*)(a),*_end = (const char*)((a)+(n)); \
1744 for ( ; _p < _end; _p += PETSC_LEVEL1_DCACHE_LINESIZE64) PETSC_Prefetch(_p,(rw),(t))(__builtin_prefetch((void *)((const char*)(_p)), ((((t))) >>
2) & 1, (((t))) & 0x3))
; \
1745 } while (0)
1746
1747/*
1748 Determine if some of the kernel computation routines use
1749 Fortran (rather than C) for the numerical calculations. On some machines
1750 and compilers (like complex numbers) the Fortran version of the routines
1751 is faster than the C/C++ versions. The flag --with-fortran-kernels
1752 should be used with ./configure to turn these on.
1753*/
1754#if defined(PETSC_USE_FORTRAN_KERNELS)
1755
1756#if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCRL)
1757#define PETSC_USE_FORTRAN_KERNEL_MULTCRL
1758#endif
1759
1760#if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJPERM)
1761#define PETSC_USE_FORTRAN_KERNEL_MULTAIJPERM
1762#endif
1763
1764#if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ)
1765#define PETSC_USE_FORTRAN_KERNEL_MULTAIJ
1766#endif
1767
1768#if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ)
1769#define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ
1770#endif
1771
1772#if !defined(PETSC_USE_FORTRAN_KERNEL_NORM)
1773#define PETSC_USE_FORTRAN_KERNEL_NORM
1774#endif
1775
1776#if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY)
1777#define PETSC_USE_FORTRAN_KERNEL_MAXPY
1778#endif
1779
1780#if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ)
1781#define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ
1782#endif
1783
1784#if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ)
1785#define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ
1786#endif
1787
1788#if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ)
1789#define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ
1790#endif
1791
1792#if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ)
1793#define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ
1794#endif
1795
1796#if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT)
1797#define PETSC_USE_FORTRAN_KERNEL_MDOT
1798#endif
1799
1800#if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY)
1801#define PETSC_USE_FORTRAN_KERNEL_XTIMESY
1802#endif
1803
1804#if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX)
1805#define PETSC_USE_FORTRAN_KERNEL_AYPX
1806#endif
1807
1808#if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY)
1809#define PETSC_USE_FORTRAN_KERNEL_WAXPY
1810#endif
1811
1812#endif
1813
1814/*
1815 Macros for indicating code that should be compiled with a C interface,
1816 rather than a C++ interface. Any routines that are dynamically loaded
1817 (such as the PCCreate_XXX() routines) must be wrapped so that the name
1818 mangler does not change the functions symbol name. This just hides the
1819 ugly extern "C" {} wrappers.
1820*/
1821#if defined(__cplusplus)
1822# define EXTERN_C_BEGIN extern "C" {
1823# define EXTERN_C_END }
1824#else
1825# define EXTERN_C_BEGIN
1826# define EXTERN_C_END
1827#endif
1828
1829/* --------------------------------------------------------------------*/
1830
1831/*MC
1832 MPI_Comm - the basic object used by MPI to determine which processes are involved in a
1833 communication
1834
1835 Level: beginner
1836
1837 Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm
1838
1839.seealso: PETSC_COMM_WORLD, PETSC_COMM_SELF
1840M*/
1841
1842#if defined(PETSC_HAVE_MPIIO1)
1843#if !defined(PETSC_WORDS_BIGENDIAN)
1844PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode MPIU_File_write_all(MPI_File,void*,PetscMPIInt,MPI_Datatype,MPI_Status*);
1845PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode MPIU_File_read_all(MPI_File,void*,PetscMPIInt,MPI_Datatype,MPI_Status*);
1846#else
1847#define MPIU_File_write_all(a,b,c,d,e) MPI_File_write_all(a,b,c,d,e)
1848#define MPIU_File_read_all(a,b,c,d,e) MPI_File_read_all(a,b,c,d,e)
1849#endif
1850#endif
1851
1852/* the following petsc_static_inline require petscerror.h */
1853
1854/* Limit MPI to 32-bits */
1855#define PETSC_MPI_INT_MAX2147483647 2147483647
1856#define PETSC_MPI_INT_MIN-2147483647 -2147483647
1857/* Limit BLAS to 32-bits */
1858#define PETSC_BLAS_INT_MAX2147483647 2147483647
1859#define PETSC_BLAS_INT_MIN-2147483647 -2147483647
1860
1861/*@C
1862 PetscBLASIntCast - casts a PetscInt (which may be 64 bits in size) to a PetscBLASInt (which may be 32 bits in size), generates an
1863 error if the PetscBLASInt is not large enough to hold the number.
1864
1865 Not Collective
1866
1867 Input Parameter:
1868. a - the PetscInt value
1869
1870 Output Parameter:
1871. b - the resulting PetscBLASInt value
1872
1873 Level: advanced
1874
1875 Not available from Fortran
1876
1877.seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscMPIIntCast()
1878@*/
1879PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscBLASIntCast(PetscInt a,PetscBLASInt *b)
1880{
1881 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscsys.h"; petscstack
->line[petscstack->currentsize] = 1881; petscstack->
petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1882 *b = (PetscBLASInt)(a);
1883#if defined(PETSC_USE_64BIT_INDICES) && !defined(PETSC_HAVE_64BIT_BLAS_INDICES)
1884 if ((a) > PETSC_BLAS_INT_MAX2147483647) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for BLAS/LAPACK")return PetscError(((MPI_Comm)0x44000001),1884,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,63,PETSC_ERROR_INITIAL,"Array too long for BLAS/LAPACK")
;
1885#endif
1886 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
1887}
1888
1889/*@C
1890 PetscMPIIntCast - casts a PetscInt (which may be 64 bits in size) to a PetscMPIInt (which may be 32 bits in size), generates an
1891 error if the PetscMPIInt is not large enough to hold the number.
1892
1893 Not Collective
1894
1895 Input Parameter:
1896. a - the PetscInt value
1897
1898 Output Parameter:
1899. b - the resulting PetscMPIInt value
1900
1901 Level: advanced
1902
1903 Not available from Fortran
1904
1905.seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscBLASIntCast()
1906@*/
1907PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscMPIIntCast(PetscInt a,PetscMPIInt *b)
1908{
1909 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscsys.h"; petscstack
->line[petscstack->currentsize] = 1909; petscstack->
petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1910 *b = (PetscMPIInt)(a);
1911#if defined(PETSC_USE_64BIT_INDICES)
1912 if ((a) > PETSC_MPI_INT_MAX2147483647) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for MPI")return PetscError(((MPI_Comm)0x44000001),1912,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,63,PETSC_ERROR_INITIAL,"Array too long for MPI")
;
1913#endif
1914 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
1915}
1916
1917#define PetscInt64Mult(a,b)((PetscInt64)(a))*((PetscInt64)(b)) ((PetscInt64)(a))*((PetscInt64)(b))
1918
1919/*@C
1920
1921 PetscRealIntMultTruncate - Computes the product of a positive PetscReal and a positive PetscInt and truncates the value to slightly less than the maximal possible value
1922
1923 Not Collective
1924
1925 Input Parameter:
1926+ a - the PetscReal value
1927- b - the second value
1928
1929 Returns:
1930 the result as a PetscInt value
1931
1932 Use PetscInt64Mult() to compute the product of two PetscInt as a PetscInt64
1933 Use PetscIntMultTruncate() to compute the product of two positive PetscInt and truncate to fit a PetscInt
1934 Use PetscIntMultError() to compute the product of two PetscInt if you wish to generate an error if the result will not fit in a PetscInt
1935
1936 Developers Note:
1937 We currently assume that PetscInt addition can never overflow, this is obviously wrong but requires many more checks.
1938
1939 This is used where we compute approximate sizes for workspace and need to insure the workspace is index-able.
1940
1941 Not available from Fortran
1942
1943 Level: advanced
1944
1945.seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscBLASIntCast(), PetscInt64Mult()
1946@*/
1947PETSC_STATIC_INLINEstatic inline PetscInt PetscRealIntMultTruncate(PetscReal a,PetscInt b)
1948{
1949 PetscInt64 r;
1950
1951 r = (PetscInt64) (a*(PetscReal)b);
1952 if (r > PETSC_MAX_INT2147483647 - 100) r = PETSC_MAX_INT2147483647 - 100;
1953 return (PetscInt) r;
1954}
1955
1956/*@C
1957
1958 PetscIntMultTruncate - Computes the product of two positive PetscInt and truncates the value to slightly less than the maximal possible value
1959
1960 Not Collective
1961
1962 Input Parameter:
1963+ a - the PetscInt value
1964- b - the second value
1965
1966 Returns:
1967 the result as a PetscInt value
1968
1969 Use PetscInt64Mult() to compute the product of two PetscInt as a PetscInt64
1970 Use PetscRealIntMultTruncate() to compute the product of a PetscReal and a PetscInt and truncate to fit a PetscInt
1971 Use PetscIntMultError() to compute the product of two PetscInt if you wish to generate an error if the result will not fit in a PetscInt
1972
1973 Not available from Fortran
1974
1975 Developers Note: We currently assume that PetscInt addition can never overflow, this is obviously wrong but requires many more checks.
1976
1977 This is used where we compute approximate sizes for workspace and need to insure the workspace is index-able.
1978
1979 Level: advanced
1980
1981.seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscBLASIntCast(), PetscInt64Mult()
1982@*/
1983PETSC_STATIC_INLINEstatic inline PetscInt PetscIntMultTruncate(PetscInt a,PetscInt b)
1984{
1985 PetscInt64 r;
1986
1987 r = PetscInt64Mult(a,b)((PetscInt64)(a))*((PetscInt64)(b));
1988 if (r > PETSC_MAX_INT2147483647 - 100) r = PETSC_MAX_INT2147483647 - 100;
1989 return (PetscInt) r;
1990}
1991
1992/*@C
1993
1994 PetscIntSumTruncate - Computes the sum of two positive PetscInt and truncates the value to slightly less than the maximal possible value
1995
1996 Not Collective
1997
1998 Input Parameter:
1999+ a - the PetscInt value
2000- b - the second value
2001
2002 Returns:
2003 the result as a PetscInt value
2004
2005 Use PetscInt64Mult() to compute the product of two PetscInt as a PetscInt64
2006 Use PetscRealIntMultTruncate() to compute the product of a PetscReal and a PetscInt and truncate to fit a PetscInt
2007 Use PetscIntMultError() to compute the product of two PetscInt if you wish to generate an error if the result will not fit in a PetscInt
2008
2009 This is used where we compute approximate sizes for workspace and need to insure the workspace is index-able.
2010
2011 Not available from Fortran
2012
2013 Level: advanced
2014
2015.seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscBLASIntCast(), PetscInt64Mult()
2016@*/
2017PETSC_STATIC_INLINEstatic inline PetscInt PetscIntSumTruncate(PetscInt a,PetscInt b)
2018{
2019 PetscInt64 r;
2020
2021 r = ((PetscInt64)a) + ((PetscInt64)b);
2022 if (r > PETSC_MAX_INT2147483647 - 100) r = PETSC_MAX_INT2147483647 - 100;
2023 return (PetscInt) r;
2024}
2025
2026/*@C
2027
2028 PetscIntMultError - Computes the product of two positive PetscInt and generates an error with overflow.
2029
2030 Not Collective
2031
2032 Input Parameter:
2033+ a - the PetscInt value
2034- b - the second value
2035
2036 Output Parameter:ma
2037. result - the result as a PetscInt value, or NULL if you do not want the result, you just want to check if it overflows
2038
2039 Use PetscInt64Mult() to compute the product of two 32 bit PetscInt and store in a PetscInt64
2040 Use PetscIntMultTruncate() to compute the product of two PetscInt and truncate it to fit in a PetscInt
2041
2042 Not available from Fortran
2043
2044 Developers Note: We currently assume that PetscInt addition does not overflow, this is obviously wrong but requires many more checks.
2045
2046 Level: advanced
2047
2048.seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscBLASIntCast(), PetscIntMult64(), PetscIntSumError()
2049@*/
2050PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscIntMultError(PetscInt a,PetscInt b,PetscInt *result)
2051{
2052 PetscInt64 r;
2053
2054 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscsys.h"; petscstack
->line[petscstack->currentsize] = 2054; petscstack->
petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2055 r = PetscInt64Mult(a,b)((PetscInt64)(a))*((PetscInt64)(b));
2056#if !defined(PETSC_USE_64BIT_INDICES)
2057 if (r > PETSC_MAX_INT2147483647) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_SUP,"Product of two integer %d %d overflow, you must ./configure PETSc with --with-64-bit-indices for the case you are running",a,b)return PetscError(((MPI_Comm)0x44000001),2057,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,56,PETSC_ERROR_INITIAL,"Product of two integer %d %d overflow, you must ./configure PETSc with --with-64-bit-indices for the case you are running"
,a,b)
;
2058#endif
2059 if (result) *result = (PetscInt) r;
2060 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
2061}
2062
2063/*@C
2064
2065 PetscIntSumError - Computes the sum of two positive PetscInt and generates an error with overflow.
2066
2067 Not Collective
2068
2069 Input Parameter:
2070+ a - the PetscInt value
2071- b - the second value
2072
2073 Output Parameter:ma
2074. c - the result as a PetscInt value, or NULL if you do not want the result, you just want to check if it overflows
2075
2076 Use PetscInt64Mult() to compute the product of two 32 bit PetscInt and store in a PetscInt64
2077 Use PetscIntMultTruncate() to compute the product of two PetscInt and truncate it to fit in a PetscInt
2078
2079 Not available from Fortran
2080
2081 Level: advanced
2082
2083.seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscBLASIntCast(), PetscInt64Mult()
2084@*/
2085PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscIntSumError(PetscInt a,PetscInt b,PetscInt *result)
2086{
2087 PetscInt64 r;
2088
2089 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscsys.h"; petscstack
->line[petscstack->currentsize] = 2089; petscstack->
petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2090 r = ((PetscInt64)a) + ((PetscInt64)b);
2091#if !defined(PETSC_USE_64BIT_INDICES)
2092 if (r > PETSC_MAX_INT2147483647) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_SUP,"Sum of two integer %d %d overflow, you must ./configure PETSc with --with-64-bit-indices for the case you are running",a,b)return PetscError(((MPI_Comm)0x44000001),2092,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,56,PETSC_ERROR_INITIAL,"Sum of two integer %d %d overflow, you must ./configure PETSc with --with-64-bit-indices for the case you are running"
,a,b)
;
2093#endif
2094 if (result) *result = (PetscInt) r;
2095 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
2096}
2097
2098/*
2099 The IBM include files define hz, here we hide it so that it may be used as a regular user variable.
2100*/
2101#if defined(hz)
2102# undef hz
2103#endif
2104
2105/* For arrays that contain filenames or paths */
2106
2107#if defined(PETSC_HAVE_LIMITS_H1)
2108# include <limits.h>
2109#endif
2110#if defined(PETSC_HAVE_SYS_PARAM_H1)
2111# include <sys/param.h>
2112#endif
2113#if defined(PETSC_HAVE_SYS_TYPES_H1)
2114# include <sys/types.h>
2115#endif
2116#if defined(MAXPATHLEN4096)
2117# define PETSC_MAX_PATH_LEN4096 MAXPATHLEN4096
2118#elif defined(MAX_PATH)
2119# define PETSC_MAX_PATH_LEN4096 MAX_PATH
2120#elif defined(_MAX_PATH)
2121# define PETSC_MAX_PATH_LEN4096 _MAX_PATH
2122#else
2123# define PETSC_MAX_PATH_LEN4096 4096
2124#endif
2125
2126/*MC
2127
2128 PETSC_VERSION - This manual page provides information about how PETSc documents and uses its version information. This information is available to both C/C++
2129 and Fortran compilers when petscsys.h is included.
2130
2131
2132 The current PETSc version and the API for accessing it are defined in petscversion.h
2133
2134 The complete version number is given as the triple PETSC_VERSION_MAJOR.PETSC_VERSION_MINOR.PETSC_VERSION_SUBMINOR (in short hand x.y.z)
2135
2136 A change in the minor version number (y) indicates possible/likely changes in the PETSc API. Note this is different than with the semantic versioning convention
2137 where only a change in the major version number (x) indicates a change in the API.
2138
2139 A subminor greater than zero indicates a patch release. Version x.y.z maintains source and binary compatibility with version x.y.w for all z and w
2140
2141 Use the macros PETSC_VERSION_EQ(x,y,z), PETSC_VERSION_LT(x,y,z), PETSC_VERSION_LE(x,y,z), PETSC_VERSION_GT(x,y,z),
2142 PETSC_VERSION_GE(x,y,z) to determine if the current version is equal to, less than, less than or equal to, greater than or greater than or equal to a given
2143 version number (x.y.z).
2144
2145 PETSC_RELEASE_DATE is the date the x.y version was released (i.e. the version before any patch releases)
2146
2147 PETSC_VERSION_DATE is the date the x.y.z version was released
2148
2149 PETSC_VERSION_GIT is the last git commit to the repository given in the form vx.y.z-wwwww
2150
2151 PETSC_VERSION_DATE_GIT is the date of the last git commit to the repository
2152
2153 Level: intermediate
2154
2155 PETSC_VERSION_() and PETSC_VERSION_PATCH are deprecated and will eventually be removed. For several releases PETSC_VERSION_PATCH is always 0
2156
2157M*/
2158
2159/*MC
2160
2161 UsingFortran - To use PETSc with Fortran you must use both PETSc include files and modules. At the beginning
2162 of every function and module definition you need something like
2163
2164$
2165$#include "petsc/finclude/petscXXX.h"
2166$ use petscXXX
2167
2168 You can declare PETSc variables using either of the following.
2169
2170$ XXX variablename
2171$ type(tXXX) variablename
2172
2173 For example,
2174
2175$#include "petsc/finclude/petscvec.h"
2176$ use petscvec
2177$
2178$ Vec b
2179$ type(tVec) x
2180
2181 Level: beginner
2182
2183M*/
2184
2185PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetArchType(char[],size_t);
2186PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetHostName(char[],size_t);
2187PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetUserName(char[],size_t);
2188PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetProgramName(char[],size_t);
2189PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSetProgramName(const char[]);
2190PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetDate(char[],size_t);
2191PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetVersion(char[], size_t);
2192PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetVersionNumber(PetscInt*,PetscInt*,PetscInt*,PetscInt*);
2193
2194PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortInt(PetscInt,PetscInt[]);
2195PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortedRemoveDupsInt(PetscInt*,PetscInt[]);
2196PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortRemoveDupsInt(PetscInt*,PetscInt[]);
2197PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFindInt(PetscInt, PetscInt, const PetscInt[], PetscInt*);
2198PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFindMPIInt(PetscMPIInt, PetscInt, const PetscMPIInt[], PetscInt*);
2199PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortIntWithPermutation(PetscInt,const PetscInt[],PetscInt[]);
2200PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortStrWithPermutation(PetscInt,const char*[],PetscInt[]);
2201PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortIntWithArray(PetscInt,PetscInt[],PetscInt[]);
2202PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortIntWithArrayPair(PetscInt,PetscInt[],PetscInt[],PetscInt[]);
2203PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortMPIInt(PetscInt,PetscMPIInt[]);
2204PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortRemoveDupsMPIInt(PetscInt*,PetscMPIInt[]);
2205PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortMPIIntWithArray(PetscMPIInt,PetscMPIInt[],PetscMPIInt[]);
2206PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortMPIIntWithIntArray(PetscMPIInt,PetscMPIInt[],PetscInt[]);
2207PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortIntWithScalarArray(PetscInt,PetscInt[],PetscScalar[]);
2208PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortIntWithDataArray(PetscInt,PetscInt[],void*,size_t,void*);
2209PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortReal(PetscInt,PetscReal[]);
2210PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortRealWithArrayInt(PetscInt,PetscReal[],PetscInt[]);
2211PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortRealWithPermutation(PetscInt,const PetscReal[],PetscInt[]);
2212PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortRemoveDupsReal(PetscInt*,PetscReal[]);
2213PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFindReal(PetscReal,PetscInt,const PetscReal[],PetscReal,PetscInt*);
2214PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortSplit(PetscInt,PetscInt,PetscScalar[],PetscInt[]);
2215PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSortSplitReal(PetscInt,PetscInt,PetscReal[],PetscInt[]);
2216PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscProcessTree(PetscInt,const PetscBool [],const PetscInt[],PetscInt*,PetscInt**,PetscInt**,PetscInt**,PetscInt**);
2217PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMergeIntArrayPair(PetscInt,const PetscInt[],const PetscInt[],PetscInt,const PetscInt[],const PetscInt[],PetscInt*,PetscInt**,PetscInt**);
2218PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMergeIntArray(PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscInt*,PetscInt**);
2219PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMergeMPIIntArray(PetscInt,const PetscMPIInt[],PetscInt,const PetscMPIInt[],PetscInt*,PetscMPIInt**);
2220
2221PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSetDisplay(void);
2222PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetDisplay(char[],size_t);
2223
2224/*J
2225 PetscRandomType - String with the name of a PETSc randomizer
2226
2227 Level: beginner
2228
2229 Notes:
2230 To use SPRNG or RANDOM123 you must have ./configure PETSc
2231 with the option --download-sprng or --download-random123
2232
2233.seealso: PetscRandomSetType(), PetscRandom, PetscRandomCreate()
2234J*/
2235typedef const char* PetscRandomType;
2236#define PETSCRAND"rand" "rand"
2237#define PETSCRAND48"rand48" "rand48"
2238#define PETSCSPRNG"sprng" "sprng"
2239#define PETSCRANDER48"rander48" "rander48"
2240#define PETSCRANDOM123"random123" "random123"
2241
2242/* Logging support */
2243PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscClassId PETSC_RANDOM_CLASSID;
2244
2245PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomInitializePackage(void);
2246
2247/* Dynamic creation and loading functions */
2248PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscFunctionList PetscRandomList;
2249
2250PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomRegister(const char[],PetscErrorCode (*)(PetscRandom));
2251PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomSetType(PetscRandom, PetscRandomType);
2252PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomSetFromOptions(PetscRandom);
2253PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomGetType(PetscRandom, PetscRandomType*);
2254PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscRandomViewFromOptions(PetscRandom A,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,obj,name);}
2255PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomView(PetscRandom,PetscViewer);
2256
2257PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomCreate(MPI_Comm,PetscRandom*);
2258PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomGetValue(PetscRandom,PetscScalar*);
2259PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomGetValueReal(PetscRandom,PetscReal*);
2260PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomGetInterval(PetscRandom,PetscScalar*,PetscScalar*);
2261PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomSetInterval(PetscRandom,PetscScalar,PetscScalar);
2262PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomSetSeed(PetscRandom,unsigned long);
2263PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomGetSeed(PetscRandom,unsigned long *);
2264PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomSeed(PetscRandom);
2265PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRandomDestroy(PetscRandom*);
2266
2267PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetFullPath(const char[],char[],size_t);
2268PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetRelativePath(const char[],char[],size_t);
2269PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetWorkingDirectory(char[],size_t);
2270PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetRealPath(const char[],char[]);
2271PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetHomeDirectory(char[],size_t);
2272PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTestFile(const char[],char,PetscBool *);
2273PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTestDirectory(const char[],char,PetscBool *);
2274PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscMkdir(const char[]);
2275PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscRMTree(const char[]);
2276
2277PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBinaryRead(int,void*,PetscInt,PetscDataType);
2278PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBinarySynchronizedRead(MPI_Comm,int,void*,PetscInt,PetscDataType);
2279PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBinarySynchronizedWrite(MPI_Comm,int,void*,PetscInt,PetscDataType,PetscBool );
2280PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBinaryWrite(int,void*,PetscInt,PetscDataType,PetscBool );
2281PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBinaryOpen(const char[],PetscFileMode,int *);
2282PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBinaryClose(int);
2283PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSharedTmp(MPI_Comm,PetscBool *);
2284PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSharedWorkingDirectory(MPI_Comm,PetscBool *);
2285PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGetTmp(MPI_Comm,char[],size_t);
2286PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscFileRetrieve(MPI_Comm,const char[],char[],size_t,PetscBool *);
2287PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscLs(MPI_Comm,const char[],char[],size_t,PetscBool *);
2288#if defined(PETSC_USE_SOCKET_VIEWER1)
2289PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOpenSocket(const char[],int,int*);
2290#endif
2291
2292PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBinarySeek(int,off_t,PetscBinarySeekType,off_t*);
2293PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBinarySynchronizedSeek(MPI_Comm,int,off_t,PetscBinarySeekType,off_t*);
2294PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscByteSwap(void *,PetscDataType,PetscInt);
2295
2296PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSetDebugTerminal(const char[]);
2297PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSetDebugger(const char[],PetscBool );
2298PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSetDefaultDebugger(void);
2299PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSetDebuggerFromString(const char*);
2300PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscAttachDebugger(void);
2301PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscStopForDebugger(void);
2302
2303PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGatherNumberOfMessages(MPI_Comm,const PetscMPIInt[],const PetscMPIInt[],PetscMPIInt*);
2304PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGatherMessageLengths(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],PetscMPIInt**,PetscMPIInt**);
2305PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGatherMessageLengths2(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],const PetscMPIInt[],PetscMPIInt**,PetscMPIInt**,PetscMPIInt**);
2306PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPostIrecvInt(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],const PetscMPIInt[],PetscInt***,MPI_Request**);
2307PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPostIrecvScalar(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],const PetscMPIInt[],PetscScalar***,MPI_Request**);
2308PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscCommBuildTwoSided(MPI_Comm,PetscMPIInt,MPI_Datatype,PetscMPIInt,const PetscMPIInt*,const void*,PetscMPIInt*,PetscMPIInt**,void*)
2309 PetscAttrMPIPointerWithType(6,3);
2310PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscCommBuildTwoSidedF(MPI_Comm,PetscMPIInt,MPI_Datatype,PetscMPIInt,const PetscMPIInt[],const void*,PetscMPIInt*,PetscMPIInt**,void*,PetscMPIInt,
2311 PetscErrorCode (*send)(MPI_Comm,const PetscMPIInt[],PetscMPIInt,PetscMPIInt,void*,MPI_Request[],void*),
2312 PetscErrorCode (*recv)(MPI_Comm,const PetscMPIInt[],PetscMPIInt,void*,MPI_Request[],void*),void *ctx)
2313 PetscAttrMPIPointerWithType(6,3);
2314PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscCommBuildTwoSidedFReq(MPI_Comm,PetscMPIInt,MPI_Datatype,PetscMPIInt,const PetscMPIInt[],const void*,PetscMPIInt*,PetscMPIInt**,void*,PetscMPIInt,
2315 MPI_Request**,MPI_Request**,
2316 PetscErrorCode (*send)(MPI_Comm,const PetscMPIInt[],PetscMPIInt,PetscMPIInt,void*,MPI_Request[],void*),
2317 PetscErrorCode (*recv)(MPI_Comm,const PetscMPIInt[],PetscMPIInt,void*,MPI_Request[],void*),void *ctx)
2318 PetscAttrMPIPointerWithType(6,3);
2319
2320PETSC_EXTERNextern __attribute__((visibility ("default"))) const char *const PetscBuildTwoSidedTypes[];
2321PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscCommBuildTwoSidedSetType(MPI_Comm,PetscBuildTwoSidedType);
2322PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscCommBuildTwoSidedGetType(MPI_Comm,PetscBuildTwoSidedType*);
2323
2324PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSSEIsEnabled(MPI_Comm,PetscBool*,PetscBool*);
2325
2326PETSC_EXTERNextern __attribute__((visibility ("default"))) MPI_Comm PetscObjectComm(PetscObject);
2327
2328PETSC_EXTERNextern __attribute__((visibility ("default"))) const char *const PetscSubcommTypes[];
2329
2330struct _n_PetscSubcomm {
2331 MPI_Comm parent; /* parent communicator */
2332 MPI_Comm dupparent; /* duplicate parent communicator, under which the processors of this subcomm have contiguous rank */
2333 MPI_Comm child; /* the sub-communicator */
2334 PetscMPIInt n; /* num of subcommunicators under the parent communicator */
2335 PetscMPIInt color; /* color of processors belong to this communicator */
2336 PetscMPIInt *subsize; /* size of subcommunicator[color] */
2337 PetscSubcommType type;
2338 char *subcommprefix;
2339};
2340
2341PETSC_STATIC_INLINEstatic inline MPI_Comm PetscSubcommParent(PetscSubcomm scomm) {return scomm->parent;}
2342PETSC_STATIC_INLINEstatic inline MPI_Comm PetscSubcommChild(PetscSubcomm scomm) {return scomm->child;}
9
Access to field 'child' results in a dereference of a null pointer (loaded from variable 'scomm')
2343PETSC_STATIC_INLINEstatic inline MPI_Comm PetscSubcommContiguousParent(PetscSubcomm scomm) {return scomm->dupparent;}
2344PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSubcommCreate(MPI_Comm,PetscSubcomm*);
2345PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSubcommDestroy(PetscSubcomm*);
2346PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSubcommSetNumber(PetscSubcomm,PetscInt);
2347PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSubcommSetType(PetscSubcomm,PetscSubcommType);
2348PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSubcommSetTypeGeneral(PetscSubcomm,PetscMPIInt,PetscMPIInt);
2349PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSubcommView(PetscSubcomm,PetscViewer);
2350PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSubcommSetFromOptions(PetscSubcomm);
2351PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSubcommSetOptionsPrefix(PetscSubcomm,const char[]);
2352
2353PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscHeapCreate(PetscInt,PetscHeap*);
2354PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscHeapAdd(PetscHeap,PetscInt,PetscInt);
2355PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscHeapPop(PetscHeap,PetscInt*,PetscInt*);
2356PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscHeapPeek(PetscHeap,PetscInt*,PetscInt*);
2357PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscHeapStash(PetscHeap,PetscInt,PetscInt);
2358PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscHeapUnstash(PetscHeap);
2359PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscHeapDestroy(PetscHeap*);
2360PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscHeapView(PetscHeap,PetscViewer);
2361
2362PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscProcessPlacementView(PetscViewer);
2363PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscShmCommGet(MPI_Comm,PetscShmComm*);
2364PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscShmCommGlobalToLocal(PetscShmComm,PetscMPIInt,PetscMPIInt*);
2365PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscShmCommLocalToGlobal(PetscShmComm,PetscMPIInt,PetscMPIInt*);
2366PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscShmCommGetMpiShmComm(PetscShmComm,MPI_Comm*);
2367
2368/* routines to better support OpenMP multithreading needs of some PETSc third party libraries */
2369PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOmpCtrlCreate(MPI_Comm,PetscInt,PetscOmpCtrl*);
2370PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOmpCtrlGetOmpComms(PetscOmpCtrl,MPI_Comm*,MPI_Comm*,PetscBool*);
2371PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOmpCtrlDestroy(PetscOmpCtrl*);
2372PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOmpCtrlBarrier(PetscOmpCtrl);
2373PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOmpCtrlOmpRegionOnMasterBegin(PetscOmpCtrl);
2374PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOmpCtrlOmpRegionOnMasterEnd(PetscOmpCtrl);
2375
2376PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSegBufferCreate(size_t,size_t,PetscSegBuffer*);
2377PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSegBufferDestroy(PetscSegBuffer*);
2378PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSegBufferGet(PetscSegBuffer,size_t,void*);
2379PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSegBufferExtractAlloc(PetscSegBuffer,void*);
2380PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSegBufferExtractTo(PetscSegBuffer,void*);
2381PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSegBufferExtractInPlace(PetscSegBuffer,void*);
2382PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSegBufferGetSize(PetscSegBuffer,size_t*);
2383PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscSegBufferUnuse(PetscSegBuffer,size_t);
2384
2385
2386/* Type-safe wrapper to encourage use of PETSC_RESTRICT. Does not use PetscFunctionBegin because the error handling
2387 * prevents the compiler from completely erasing the stub. This is called in inner loops so it has to be as fast as
2388 * possible. */
2389PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscSegBufferGetInts(PetscSegBuffer seg,PetscInt count,PetscInt *PETSC_RESTRICT__restrict *slot) {return PetscSegBufferGet(seg,(size_t)count,(void**)slot);}
2390
2391extern PetscOptionsHelpPrinted PetscOptionsHelpPrintedSingleton;
2392PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOptionsHelpPrintedDestroy(PetscOptionsHelpPrinted*);
2393PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOptionsHelpPrintedCreate(PetscOptionsHelpPrinted*);
2394PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscOptionsHelpPrintedCheck(PetscOptionsHelpPrinted,const char*,const char*,PetscBool*);
2395
2396#include <stdarg.h>
2397PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscVSNPrintf(char*,size_t,const char[],size_t*,va_list);
2398PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode (*PetscVFPrintf)(FILE*,const char[],va_list);
2399
2400PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscSegBuffer PetscCitationsList;
2401
2402/*@C
2403 PetscCitationsRegister - Register a bibtex item to obtain credit for an implemented algorithm used in the code.
2404
2405 Not Collective - only what is registered on rank 0 of PETSC_COMM_WORLD will be printed
2406
2407 Input Parameters:
2408+ cite - the bibtex item, formated to displayed on multiple lines nicely
2409- set - a boolean variable initially set to PETSC_FALSE; this is used to insure only a single registration of the citation
2410
2411 Level: intermediate
2412
2413 Not available from Fortran
2414
2415 Options Database:
2416. -citations [filename] - print out the bibtex entries for the given computation
2417@*/
2418PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscCitationsRegister(const char cit[],PetscBool *set)
2419{
2420 size_t len;
2421 char *vstring;
2422 PetscErrorCode ierr;
2423
2424 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscsys.h"; petscstack
->line[petscstack->currentsize] = 2424; petscstack->
petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2425 if (set && *set) PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
2426 ierr = PetscStrlen(cit,&len);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2426,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2427 ierr = PetscSegBufferGet(PetscCitationsList,len,&vstring);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2427,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2428 ierr = PetscMemcpy(vstring,cit,len);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2428,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2429 if (set) *set = PETSC_TRUE;
2430 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
2431}
2432
2433PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscURLShorten(const char[],char[],size_t);
2434PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGoogleDriveAuthorize(MPI_Comm,char[],char[],size_t);
2435PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGoogleDriveRefresh(MPI_Comm,const char[],char[],size_t);
2436PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGoogleDriveUpload(MPI_Comm,const char[],const char []);
2437
2438PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBoxAuthorize(MPI_Comm,char[],char[],size_t);
2439PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscBoxRefresh(MPI_Comm,const char[],char[],char[],size_t);
2440
2441PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscGlobusGetTransfers(MPI_Comm,const char[],char[],size_t);
2442
2443PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTextBelt(MPI_Comm,const char[],const char[],PetscBool*);
2444PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTellMyCell(MPI_Comm,const char[],const char[],PetscBool*);
2445
2446PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPullJSONValue(const char[],const char[],char[],size_t,PetscBool*);
2447PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPushJSONValue(char[],const char[],const char[],size_t);
2448
2449
2450#if defined(PETSC_USE_DEBUG1)
2451/*
2452 Verify that all processes in the communicator have called this from the same line of code
2453 */
2454PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscAllreduceBarrierCheck(MPI_Comm,PetscMPIInt,int,const char*,const char *);
2455
2456/*MC
2457 MPIU_Allreduce - a PETSc replacement for MPI_Allreduce() that tries to determine if the call from all the MPI processes occur from the
2458 same place in the PETSc code. This helps to detect bugs where different MPI processes follow different code paths
2459 resulting in inconsistent and incorrect calls to MPI_Allreduce().
2460
2461 Collective on MPI_Comm
2462
2463 Synopsis:
2464 #include <petscsys.h>
2465 PetscErrorCode MPIU_Allreduce(void *indata,void *outdata,PetscMPIInt count,MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
2466
2467 Input Parameters:
2468+ indata - pointer to the input data to be reduced
2469. count - the number of MPI data items in indata and outdata
2470. datatype - the MPI datatype, for example MPI_INT
2471. op - the MPI operation, for example MPI_SUM
2472- comm - the MPI communicator on which the operation occurs
2473
2474 Output Parameter:
2475. outdata - the reduced values
2476
2477 Notes:
2478 In optimized mode this directly calls MPI_Allreduce()
2479
2480 Level: developer
2481
2482.seealso: MPI_Allreduce()
2483M*/
2484#define MPIU_Allreduce(a,b,c,d,e,fcomm)(PetscAllreduceBarrierCheck(fcomm,c,2484,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((fcomm)),0)
|| MPI_Allreduce((a),(b),(c),(d),(e),(fcomm))))
(PetscAllreduceBarrierCheck(fcomm,c,__LINE__2484,PETSC_FUNCTION_NAME__func__,__FILE__"/sandbox/petsc/petsc.next-tmp/include/petscsys.h") || MPI_Allreduce(a,b,c,d,e,fcomm)((petsc_allreduce_ct += PetscMPIParallelComm((fcomm)),0) || MPI_Allreduce
((a),(b),(c),(d),(e),(fcomm)))
)
2485#else
2486#define MPIU_Allreduce(a,b,c,d,e,fcomm)(PetscAllreduceBarrierCheck(fcomm,c,2486,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscsys.h"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((fcomm)),0)
|| MPI_Allreduce((a),(b),(c),(d),(e),(fcomm))))
MPI_Allreduce(a,b,c,d,e,fcomm)((petsc_allreduce_ct += PetscMPIParallelComm((fcomm)),0) || MPI_Allreduce
((a),(b),(c),(d),(e),(fcomm)))
2487#endif
2488
2489#if defined(PETSC_HAVE_MPI_WIN_CREATE_FEATURE1)
2490PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode MPIU_Win_allocate_shared(MPI_Aint,PetscMPIInt,MPI_Info,MPI_Comm,void*,MPI_Win*);
2491PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode MPIU_Win_shared_query(MPI_Win,PetscMPIInt,MPI_Aint*,PetscMPIInt*,void*);
2492#endif
2493
2494/*
2495 Returned from PETSc functions that are called from MPI, such as related to attributes
2496*/
2497PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscMPIInt PETSC_MPI_ERROR_CLASS;
2498PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscMPIInt PETSC_MPI_ERROR_CODE;
2499
2500#endif