Bug Summary

File:mat/impls/aij/mpi/fdmpiaij.c
Warning:line 24, column 14
Division by zero

Annotated Source Code

[?] Use j/k keys for keyboard navigation

/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c

1#include <../src/mat/impls/sell/mpi/mpisell.h>
2#include <../src/mat/impls/aij/mpi/mpiaij.h>
3#include <../src/mat/impls/baij/mpi/mpibaij.h>
4#include <petsc/private/isimpl.h>
5
6PetscErrorCode MatFDColoringApply_BAIJ(Mat J,MatFDColoring coloring,Vec x1,void *sctx)
7{
8 PetscErrorCode (*f)(void*,Vec,Vec,void*)=(PetscErrorCode (*)(void*,Vec,Vec,void*))coloring->f;
9 PetscErrorCode ierr;
10 PetscInt k,cstart,cend,l,row,col,nz,spidx,i,j;
11 PetscScalar dx=0.0,*w3_array,*dy_i,*dy=coloring->dy;
12 PetscScalar *vscale_array;
13 const PetscScalar *xx;
14 PetscReal epsilon=coloring->error_rel,umin=coloring->umin,unorm;
15 Vec w1=coloring->w1,w2=coloring->w2,w3,vscale=coloring->vscale;
16 void *fctx=coloring->fctx;
17 PetscInt ctype=coloring->ctype,nxloc,nrows_k;
18 PetscScalar *valaddr;
19 MatEntry *Jentry=coloring->matentry;
20 MatEntry2 *Jentry2=coloring->matentry2;
21 const PetscInt ncolors=coloring->ncolors,*ncolumns=coloring->ncolumns,*nrows=coloring->nrows;
22 PetscInt bs=J->rmap->bs;
23
24 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
; petscstack->line[petscstack->currentsize] = 24; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
25 /* (1) Set w1 = F(x1) */
26 if (!coloring->fset) {
27 ierr = PetscLogEventBegin(MAT_FDColoringFunction,coloring,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLB)((MAT_FDColoringFunction
),0,(PetscObject)(coloring),(PetscObject)(0),(PetscObject)(0)
,(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),27,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
28 ierr = (*f)(sctx,x1,w1,fctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),28,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
29 ierr = PetscLogEventEnd(MAT_FDColoringFunction,coloring,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLE)((MAT_FDColoringFunction
),0,(PetscObject)(coloring),(PetscObject)(0),(PetscObject)(0)
,(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),29,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
30 } else {
31 coloring->fset = PETSC_FALSE;
32 }
33
34 /* (2) Compute vscale = 1./dx - the local scale factors, including ghost points */
35 ierr = VecGetLocalSize(x1,&nxloc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),35,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
36 if (coloring->htype[0] == 'w') {
37 /* vscale = dx is a constant scalar */
38 ierr = VecNorm(x1,NORM_2,&unorm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),38,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
39 dx = 1.0/(PetscSqrtReal(1.0 + unorm)sqrt(1.0 + unorm)*epsilon);
40 } else {
41 ierr = VecGetArrayRead(x1,&xx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),41,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
42 ierr = VecGetArray(vscale,&vscale_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),42,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
43 for (col=0; col<nxloc; col++) {
44 dx = xx[col];
45 if (PetscAbsScalar(dx) < umin) {
46 if (PetscRealPart(dx)(dx) >= 0.0) dx = umin;
47 else if (PetscRealPart(dx)(dx) < 0.0 ) dx = -umin;
48 }
49 dx *= epsilon;
50 vscale_array[col] = 1.0/dx;
51 }
52 ierr = VecRestoreArrayRead(x1,&xx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),52,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
53 ierr = VecRestoreArray(vscale,&vscale_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),53,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
54 }
55 if (ctype == IS_COLORING_GLOBAL && coloring->htype[0] == 'd') {
56 ierr = VecGhostUpdateBegin(vscale,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),56,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
57 ierr = VecGhostUpdateEnd(vscale,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),57,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
58 }
59
60 /* (3) Loop over each color */
61 if (!coloring->w3) {
62 ierr = VecDuplicate(x1,&coloring->w3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),62,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
63 ierr = PetscLogObjectParent((PetscObject)coloring,(PetscObject)coloring->w3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),63,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
64 }
65 w3 = coloring->w3;
66
67 ierr = VecGetOwnershipRange(x1,&cstart,&cend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),67,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* used by ghosted vscale */
68 if (vscale) {
69 ierr = VecGetArray(vscale,&vscale_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),69,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
70 }
71 nz = 0;
72 for (k=0; k<ncolors; k++) {
73 coloring->currentcolor = k;
74
75 /*
76 (3-1) Loop over each column associated with color
77 adding the perturbation to the vector w3 = x1 + dx.
78 */
79 ierr = VecCopy(x1,w3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),79,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
80 dy_i = dy;
81 for (i=0; i<bs; i++) { /* Loop over a block of columns */
82 ierr = VecGetArray(w3,&w3_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),82,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
83 if (ctype == IS_COLORING_GLOBAL) w3_array -= cstart; /* shift pointer so global index can be used */
84 if (coloring->htype[0] == 'w') {
85 for (l=0; l<ncolumns[k]; l++) {
86 col = i + bs*coloring->columns[k][l]; /* local column (in global index!) of the matrix we are probing for */
87 w3_array[col] += 1.0/dx;
88 if (i) w3_array[col-1] -= 1.0/dx; /* resume original w3[col-1] */
89 }
90 } else { /* htype == 'ds' */
91 vscale_array -= cstart; /* shift pointer so global index can be used */
92 for (l=0; l<ncolumns[k]; l++) {
93 col = i + bs*coloring->columns[k][l]; /* local column (in global index!) of the matrix we are probing for */
94 w3_array[col] += 1.0/vscale_array[col];
95 if (i) w3_array[col-1] -= 1.0/vscale_array[col-1]; /* resume original w3[col-1] */
96 }
97 vscale_array += cstart;
98 }
99 if (ctype == IS_COLORING_GLOBAL) w3_array += cstart;
100 ierr = VecRestoreArray(w3,&w3_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),100,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
101
102 /*
103 (3-2) Evaluate function at w3 = x1 + dx (here dx is a vector of perturbations)
104 w2 = F(x1 + dx) - F(x1)
105 */
106 ierr = PetscLogEventBegin(MAT_FDColoringFunction,0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLB)((MAT_FDColoringFunction
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),106,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
107 ierr = VecPlaceArray(w2,dy_i);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),107,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* place w2 to the array dy_i */
108 ierr = (*f)(sctx,w3,w2,fctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),108,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
109 ierr = PetscLogEventEnd(MAT_FDColoringFunction,0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLE)((MAT_FDColoringFunction
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),109,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
110 ierr = VecAXPY(w2,-1.0,w1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),110,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
111 ierr = VecResetArray(w2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),111,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
112 dy_i += nxloc; /* points to dy+i*nxloc */
113 }
114
115 /*
116 (3-3) Loop over rows of vector, putting results into Jacobian matrix
117 */
118 nrows_k = nrows[k];
119 if (coloring->htype[0] == 'w') {
120 for (l=0; l<nrows_k; l++) {
121 row = bs*Jentry2[nz].row; /* local row index */
122 valaddr = Jentry2[nz++].valaddr;
123 spidx = 0;
124 dy_i = dy;
125 for (i=0; i<bs; i++) { /* column of the block */
126 for (j=0; j<bs; j++) { /* row of the block */
127 valaddr[spidx++] = dy_i[row+j]*dx;
128 }
129 dy_i += nxloc; /* points to dy+i*nxloc */
130 }
131 }
132 } else { /* htype == 'ds' */
133 for (l=0; l<nrows_k; l++) {
134 row = bs*Jentry[nz].row; /* local row index */
135 col = bs*Jentry[nz].col; /* local column index */
136 valaddr = Jentry[nz++].valaddr;
137 spidx = 0;
138 dy_i = dy;
139 for (i=0; i<bs; i++) { /* column of the block */
140 for (j=0; j<bs; j++) { /* row of the block */
141 valaddr[spidx++] = dy_i[row+j]*vscale_array[col+i];
142 }
143 dy_i += nxloc; /* points to dy+i*nxloc */
144 }
145 }
146 }
147 }
148 ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),148,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
149 ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),149,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
150 if (vscale) {
151 ierr = VecRestoreArray(vscale,&vscale_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),151,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
152 }
153
154 coloring->currentcolor = -1;
155 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)
;
156}
157
158/* this is declared PETSC_EXTERN because it is used by MatFDColoringUseDM() which is in the DM library */
159PetscErrorCode MatFDColoringApply_AIJ(Mat J,MatFDColoring coloring,Vec x1,void *sctx)
160{
161 PetscErrorCode (*f)(void*,Vec,Vec,void*) = (PetscErrorCode (*)(void*,Vec,Vec,void*))coloring->f;
162 PetscErrorCode ierr;
163 PetscInt k,cstart,cend,l,row,col,nz;
164 PetscScalar dx=0.0,*y,*w3_array;
165 const PetscScalar *xx;
166 PetscScalar *vscale_array;
167 PetscReal epsilon=coloring->error_rel,umin=coloring->umin,unorm;
168 Vec w1=coloring->w1,w2=coloring->w2,w3,vscale=coloring->vscale;
169 void *fctx=coloring->fctx;
170 ISColoringType ctype=coloring->ctype;
171 PetscInt nxloc,nrows_k;
172 MatEntry *Jentry=coloring->matentry;
173 MatEntry2 *Jentry2=coloring->matentry2;
174 const PetscInt ncolors=coloring->ncolors,*ncolumns=coloring->ncolumns,*nrows=coloring->nrows;
175
176 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
; petscstack->line[petscstack->currentsize] = 176; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
177 if ((ctype == IS_COLORING_LOCAL) && (J->ops->fdcoloringapply == MatFDColoringApply_AIJ)) SETERRQ(PetscObjectComm((PetscObject)J),PETSC_ERR_SUP,"Must call MatColoringUseDM() with IS_COLORING_LOCAL")return PetscError(PetscObjectComm((PetscObject)J),177,__func__
,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,56,PETSC_ERROR_INITIAL,"Must call MatColoringUseDM() with IS_COLORING_LOCAL"
)
;
178 /* (1) Set w1 = F(x1) */
179 if (!coloring->fset) {
180 ierr = PetscLogEventBegin(MAT_FDColoringFunction,0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLB)((MAT_FDColoringFunction
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),180,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
181 ierr = (*f)(sctx,x1,w1,fctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),181,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
182 ierr = PetscLogEventEnd(MAT_FDColoringFunction,0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLE)((MAT_FDColoringFunction
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),182,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
183 } else {
184 coloring->fset = PETSC_FALSE;
185 }
186
187 /* (2) Compute vscale = 1./dx - the local scale factors, including ghost points */
188 if (coloring->htype[0] == 'w') {
189 /* vscale = 1./dx is a constant scalar */
190 ierr = VecNorm(x1,NORM_2,&unorm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),190,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
191 dx = 1.0/(PetscSqrtReal(1.0 + unorm)sqrt(1.0 + unorm)*epsilon);
192 } else {
193 ierr = VecGetLocalSize(x1,&nxloc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),193,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
194 ierr = VecGetArrayRead(x1,&xx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),194,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
195 ierr = VecGetArray(vscale,&vscale_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),195,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
196 for (col=0; col<nxloc; col++) {
197 dx = xx[col];
198 if (PetscAbsScalar(dx) < umin) {
199 if (PetscRealPart(dx)(dx) >= 0.0) dx = umin;
200 else if (PetscRealPart(dx)(dx) < 0.0 ) dx = -umin;
201 }
202 dx *= epsilon;
203 vscale_array[col] = 1.0/dx;
204 }
205 ierr = VecRestoreArrayRead(x1,&xx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),205,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
206 ierr = VecRestoreArray(vscale,&vscale_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),206,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
207 }
208 if (ctype == IS_COLORING_GLOBAL && coloring->htype[0] == 'd') {
209 ierr = VecGhostUpdateBegin(vscale,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),209,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
210 ierr = VecGhostUpdateEnd(vscale,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),210,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
211 }
212
213 /* (3) Loop over each color */
214 if (!coloring->w3) {
215 ierr = VecDuplicate(x1,&coloring->w3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),215,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
216 ierr = PetscLogObjectParent((PetscObject)coloring,(PetscObject)coloring->w3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),216,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
217 }
218 w3 = coloring->w3;
219
220 ierr = VecGetOwnershipRange(x1,&cstart,&cend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),220,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* used by ghosted vscale */
221 if (vscale) {
222 ierr = VecGetArray(vscale,&vscale_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),222,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
223 }
224 nz = 0;
225
226 if (coloring->bcols > 1) { /* use blocked insertion of Jentry */
227 PetscInt i,m=J->rmap->n,nbcols,bcols=coloring->bcols;
228 PetscScalar *dy=coloring->dy,*dy_k;
229
230 nbcols = 0;
231 for (k=0; k<ncolors; k+=bcols) {
232
233 /*
234 (3-1) Loop over each column associated with color
235 adding the perturbation to the vector w3 = x1 + dx.
236 */
237
238 dy_k = dy;
239 if (k + bcols > ncolors) bcols = ncolors - k;
240 for (i=0; i<bcols; i++) {
241 coloring->currentcolor = k+i;
242
243 ierr = VecCopy(x1,w3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),243,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
244 ierr = VecGetArray(w3,&w3_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),244,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
245 if (ctype == IS_COLORING_GLOBAL) w3_array -= cstart; /* shift pointer so global index can be used */
246 if (coloring->htype[0] == 'w') {
247 for (l=0; l<ncolumns[k+i]; l++) {
248 col = coloring->columns[k+i][l]; /* local column (in global index!) of the matrix we are probing for */
249 w3_array[col] += 1.0/dx;
250 }
251 } else { /* htype == 'ds' */
252 vscale_array -= cstart; /* shift pointer so global index can be used */
253 for (l=0; l<ncolumns[k+i]; l++) {
254 col = coloring->columns[k+i][l]; /* local column (in global index!) of the matrix we are probing for */
255 w3_array[col] += 1.0/vscale_array[col];
256 }
257 vscale_array += cstart;
258 }
259 if (ctype == IS_COLORING_GLOBAL) w3_array += cstart;
260 ierr = VecRestoreArray(w3,&w3_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),260,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
261
262 /*
263 (3-2) Evaluate function at w3 = x1 + dx (here dx is a vector of perturbations)
264 w2 = F(x1 + dx) - F(x1)
265 */
266 ierr = PetscLogEventBegin(MAT_FDColoringFunction,0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLB)((MAT_FDColoringFunction
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),266,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
267 ierr = VecPlaceArray(w2,dy_k);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),267,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* place w2 to the array dy_i */
268 ierr = (*f)(sctx,w3,w2,fctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),268,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
269 ierr = PetscLogEventEnd(MAT_FDColoringFunction,0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLE)((MAT_FDColoringFunction
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),269,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
270 ierr = VecAXPY(w2,-1.0,w1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),270,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
271 ierr = VecResetArray(w2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),271,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
272 dy_k += m; /* points to dy+i*nxloc */
273 }
274
275 /*
276 (3-3) Loop over block rows of vector, putting results into Jacobian matrix
277 */
278 nrows_k = nrows[nbcols++];
279 ierr = VecGetArray(w2,&y);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),279,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
280
281 if (coloring->htype[0] == 'w') {
282 for (l=0; l<nrows_k; l++) {
283 row = Jentry2[nz].row; /* local row index */
284 *(Jentry2[nz++].valaddr) = dy[row]*dx;
285 }
286 } else { /* htype == 'ds' */
287 for (l=0; l<nrows_k; l++) {
288 row = Jentry[nz].row; /* local row index */
289 *(Jentry[nz].valaddr) = dy[row]*vscale_array[Jentry[nz].col];
290 nz++;
291 }
292 }
293 ierr = VecRestoreArray(w2,&y);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),293,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
294 }
295 } else { /* bcols == 1 */
296 for (k=0; k<ncolors; k++) {
297 coloring->currentcolor = k;
298
299 /*
300 (3-1) Loop over each column associated with color
301 adding the perturbation to the vector w3 = x1 + dx.
302 */
303 ierr = VecCopy(x1,w3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),303,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
304 ierr = VecGetArray(w3,&w3_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),304,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
305 if (ctype == IS_COLORING_GLOBAL) w3_array -= cstart; /* shift pointer so global index can be used */
306 if (coloring->htype[0] == 'w') {
307 for (l=0; l<ncolumns[k]; l++) {
308 col = coloring->columns[k][l]; /* local column (in global index!) of the matrix we are probing for */
309 w3_array[col] += 1.0/dx;
310 }
311 } else { /* htype == 'ds' */
312 vscale_array -= cstart; /* shift pointer so global index can be used */
313 for (l=0; l<ncolumns[k]; l++) {
314 col = coloring->columns[k][l]; /* local column (in global index!) of the matrix we are probing for */
315 w3_array[col] += 1.0/vscale_array[col];
316 }
317 vscale_array += cstart;
318 }
319 if (ctype == IS_COLORING_GLOBAL) w3_array += cstart;
320 ierr = VecRestoreArray(w3,&w3_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),320,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
321
322 /*
323 (3-2) Evaluate function at w3 = x1 + dx (here dx is a vector of perturbations)
324 w2 = F(x1 + dx) - F(x1)
325 */
326 ierr = PetscLogEventBegin(MAT_FDColoringFunction,0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLB)((MAT_FDColoringFunction
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),326,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
327 ierr = (*f)(sctx,w3,w2,fctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),327,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
328 ierr = PetscLogEventEnd(MAT_FDColoringFunction,0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[MAT_FDColoringFunction].active) ? (*PetscLogPLE)((MAT_FDColoringFunction
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),328,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
329 ierr = VecAXPY(w2,-1.0,w1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),329,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
330
331 /*
332 (3-3) Loop over rows of vector, putting results into Jacobian matrix
333 */
334 nrows_k = nrows[k];
335 ierr = VecGetArray(w2,&y);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),335,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
336 if (coloring->htype[0] == 'w') {
337 for (l=0; l<nrows_k; l++) {
338 row = Jentry2[nz].row; /* local row index */
339 *(Jentry2[nz++].valaddr) = y[row]*dx;
340 }
341 } else { /* htype == 'ds' */
342 for (l=0; l<nrows_k; l++) {
343 row = Jentry[nz].row; /* local row index */
344 *(Jentry[nz].valaddr) = y[row]*vscale_array[Jentry[nz].col];
345 nz++;
346 }
347 }
348 ierr = VecRestoreArray(w2,&y);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),348,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
349 }
350 }
351
352 ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),352,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
353 ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),353,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
354 if (vscale) {
355 ierr = VecRestoreArray(vscale,&vscale_array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),355,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
356 }
357 coloring->currentcolor = -1;
358 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)
;
359}
360
361PetscErrorCode MatFDColoringSetUp_MPIXAIJ(Mat mat,ISColoring iscoloring,MatFDColoring c)
362{
363 PetscErrorCode ierr;
364 PetscMPIInt size,*ncolsonproc,*disp,nn;
365 PetscInt i,n,nrows,nrows_i,j,k,m,ncols,col,*rowhit,cstart,cend,colb;
366 const PetscInt *is,*A_ci,*A_cj,*B_ci,*B_cj,*row=NULL((void*)0),*ltog=NULL((void*)0);
367 PetscInt nis=iscoloring->n,nctot,*cols;
368 IS *isa;
369 ISLocalToGlobalMapping map=mat->cmap->mapping;
370 PetscInt ctype=c->ctype,*spidxA,*spidxB,nz,bs,bs2,spidx;
371 Mat A,B;
372 PetscScalar *A_val,*B_val,**valaddrhit;
373 MatEntry *Jentry;
374 MatEntry2 *Jentry2;
375 PetscBool isBAIJ,isSELL;
376 PetscInt bcols=c->bcols;
377#if defined(PETSC_USE_CTABLE1)
378 PetscTable colmap=NULL((void*)0);
379#else
380 PetscInt *colmap=NULL((void*)0); /* local col number of off-diag col */
381#endif
382
383 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
; petscstack->line[petscstack->currentsize] = 383; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
384 if (ctype == IS_COLORING_LOCAL) {
1
Assuming 'ctype' is not equal to IS_COLORING_LOCAL
2
Taking false branch
385 if (!map) SETERRQ(PetscObjectComm((PetscObject)mat),PETSC_ERR_ARG_INCOMP,"When using ghosted differencing matrix must have local to global mapping provided with MatSetLocalToGlobalMapping")return PetscError(PetscObjectComm((PetscObject)mat),385,__func__
,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,75,PETSC_ERROR_INITIAL,"When using ghosted differencing matrix must have local to global mapping provided with MatSetLocalToGlobalMapping"
)
;
386 ierr = ISLocalToGlobalMappingGetIndices(map,&ltog);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),386,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
387 }
388
389 ierr = MatGetBlockSize(mat,&bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),389,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
390 ierr = PetscObjectTypeCompare((PetscObject)mat,MATMPIBAIJ"mpibaij",&isBAIJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),390,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
391 ierr = PetscObjectTypeCompare((PetscObject)mat,MATMPISELL"mpisell",&isSELL);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),391,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
392 if (isBAIJ) {
3
Assuming 'isBAIJ' is 0
4
Taking false branch
393 Mat_MPIBAIJ *baij=(Mat_MPIBAIJ*)mat->data;
394 Mat_SeqBAIJ *spA,*spB;
395 A = baij->A; spA = (Mat_SeqBAIJ*)A->data; A_val = spA->a;
396 B = baij->B; spB = (Mat_SeqBAIJ*)B->data; B_val = spB->a;
397 nz = spA->nz + spB->nz; /* total nonzero entries of mat */
398 if (!baij->colmap) {
399 ierr = MatCreateColmap_MPIBAIJ_Private(mat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),399,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
400 }
401 colmap = baij->colmap;
402 ierr = MatGetColumnIJ_SeqBAIJ_Color(A,0,PETSC_FALSE,PETSC_FALSE,&ncols,&A_ci,&A_cj,&spidxA,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),402,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
403 ierr = MatGetColumnIJ_SeqBAIJ_Color(B,0,PETSC_FALSE,PETSC_FALSE,&ncols,&B_ci,&B_cj,&spidxB,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),403,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
404
405 if (ctype == IS_COLORING_GLOBAL && c->htype[0] == 'd') { /* create vscale for storing dx */
406 PetscInt *garray;
407 ierr = PetscMalloc1(B->cmap->n,&garray)PetscMallocA(1,PETSC_FALSE,407,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(B->cmap->n)*sizeof(**(&garray)),(&garray
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),407,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
408 for (i=0; i<baij->B->cmap->n/bs; i++) {
409 for (j=0; j<bs; j++) {
410 garray[i*bs+j] = bs*baij->garray[i]+j;
411 }
412 }
413 ierr = VecCreateGhost(PetscObjectComm((PetscObject)mat),mat->cmap->n,PETSC_DETERMINE-1,B->cmap->n,garray,&c->vscale);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),413,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
414 ierr = PetscFree(garray)((*PetscTrFree)((void*)(garray),414,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
) || ((garray) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),414,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
415 }
416 } else if (isSELL) {
5
Assuming 'isSELL' is 0
6
Taking false branch
417 Mat_MPISELL *sell=(Mat_MPISELL*)mat->data;
418 Mat_SeqSELL *spA,*spB;
419 A = sell->A; spA = (Mat_SeqSELL*)A->data; A_val = spA->val;
420 B = sell->B; spB = (Mat_SeqSELL*)B->data; B_val = spB->val;
421 nz = spA->nz + spB->nz; /* total nonzero entries of mat */
422 if (!sell->colmap) {
423 /* Allow access to data structures of local part of matrix
424 - creates aij->colmap which maps global column number to local number in part B */
425 ierr = MatCreateColmap_MPISELL_Private(mat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),425,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
426 }
427 colmap = sell->colmap;
428 ierr = MatGetColumnIJ_SeqSELL_Color(A,0,PETSC_FALSE,PETSC_FALSE,&ncols,&A_ci,&A_cj,&spidxA,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),428,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
429 ierr = MatGetColumnIJ_SeqSELL_Color(B,0,PETSC_FALSE,PETSC_FALSE,&ncols,&B_ci,&B_cj,&spidxB,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),429,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
430
431 bs = 1; /* only bs=1 is supported for non MPIBAIJ matrix */
432
433 if (ctype == IS_COLORING_GLOBAL && c->htype[0] == 'd') { /* create vscale for storing dx */
434 ierr = VecCreateGhost(PetscObjectComm((PetscObject)mat),mat->cmap->n,PETSC_DETERMINE-1,B->cmap->n,sell->garray,&c->vscale);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),434,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
435 }
436 } else {
437 Mat_MPIAIJ *aij=(Mat_MPIAIJ*)mat->data;
438 Mat_SeqAIJ *spA,*spB;
439 A = aij->A; spA = (Mat_SeqAIJ*)A->data; A_val = spA->a;
440 B = aij->B; spB = (Mat_SeqAIJ*)B->data; B_val = spB->a;
441 nz = spA->nz + spB->nz; /* total nonzero entries of mat */
442 if (!aij->colmap) {
7
Assuming the condition is false
8
Taking false branch
443 /* Allow access to data structures of local part of matrix
444 - creates aij->colmap which maps global column number to local number in part B */
445 ierr = MatCreateColmap_MPIAIJ_Private(mat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),445,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
446 }
447 colmap = aij->colmap;
448 ierr = MatGetColumnIJ_SeqAIJ_Color(A,0,PETSC_FALSE,PETSC_FALSE,&ncols,&A_ci,&A_cj,&spidxA,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),448,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
449 ierr = MatGetColumnIJ_SeqAIJ_Color(B,0,PETSC_FALSE,PETSC_FALSE,&ncols,&B_ci,&B_cj,&spidxB,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),449,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
450
451 bs = 1; /* only bs=1 is supported for non MPIBAIJ matrix */
452
453 if (ctype == IS_COLORING_GLOBAL && c->htype[0] == 'd') { /* create vscale for storing dx */
9
Assuming 'ctype' is equal to IS_COLORING_GLOBAL
10
Assuming the condition is false
11
Taking false branch
454 ierr = VecCreateGhost(PetscObjectComm((PetscObject)mat),mat->cmap->n,PETSC_DETERMINE-1,B->cmap->n,aij->garray,&c->vscale);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),454,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
455 }
456 }
457
458 m = mat->rmap->n/bs;
459 cstart = mat->cmap->rstart/bs;
460 cend = mat->cmap->rend/bs;
461
462 ierr = PetscMalloc1(nis,&c->ncolumns)PetscMallocA(1,PETSC_FALSE,462,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(nis)*sizeof(**(&c->ncolumns)),(&c->ncolumns
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),462,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
463 ierr = PetscMalloc1(nis,&c->columns)PetscMallocA(1,PETSC_FALSE,463,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(nis)*sizeof(**(&c->columns)),(&c->columns
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),463,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
464 ierr = PetscCalloc1(nis,&c->nrows)PetscMallocA(1,PETSC_TRUE,464,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(nis)*sizeof(**(&c->nrows)),(&c->nrows
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),464,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
465 ierr = PetscLogObjectMemory((PetscObject)c,3*nis*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),465,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
466
467 if (c->htype[0] == 'd') {
12
Assuming the condition is false
13
Taking false branch
468 ierr = PetscMalloc1(nz,&Jentry)PetscMallocA(1,PETSC_FALSE,468,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(nz)*sizeof(**(&Jentry)),(&Jentry))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),468,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
469 ierr = PetscLogObjectMemory((PetscObject)c,nz*sizeof(MatEntry));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),469,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
470 c->matentry = Jentry;
471 } else if (c->htype[0] == 'w') {
14
Assuming the condition is true
15
Taking true branch
472 ierr = PetscMalloc1(nz,&Jentry2)PetscMallocA(1,PETSC_FALSE,472,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(nz)*sizeof(**(&Jentry2)),(&Jentry2))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),472,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
473 ierr = PetscLogObjectMemory((PetscObject)c,nz*sizeof(MatEntry2));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),473,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
474 c->matentry2 = Jentry2;
475 } else SETERRQ(PetscObjectComm((PetscObject)mat),PETSC_ERR_SUP,"htype is not supported")return PetscError(PetscObjectComm((PetscObject)mat),475,__func__
,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,56,PETSC_ERROR_INITIAL,"htype is not supported")
;
476
477 ierr = PetscMalloc2(m+1,&rowhit,m+1,&valaddrhit)PetscMallocA(2,PETSC_FALSE,477,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(m+1)*sizeof(**(&rowhit)),(&rowhit),(size_t)
(m+1)*sizeof(**(&valaddrhit)),(&valaddrhit))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),477,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
478 nz = 0;
479 ierr = ISColoringGetIS(iscoloring,PETSC_IGNORE((void*)0),&isa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),479,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
480 for (i=0; i<nis; i++) { /* for each local color */
16
Assuming 'i' is < 'nis'
17
Loop condition is true. Entering loop body
30
Assuming 'i' is < 'nis'
31
Loop condition is true. Entering loop body
42
Assuming 'i' is < 'nis'
43
Loop condition is true. Entering loop body
481 ierr = ISGetLocalSize(isa[i],&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),481,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
482 ierr = ISGetIndices(isa[i],&is);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),482,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
483
484 c->ncolumns[i] = n; /* local number of columns of this color on this process */
485 if (n) {
18
Assuming 'n' is 0
19
Taking false branch
32
Assuming 'n' is 0
33
Taking false branch
44
Assuming 'n' is 0
45
Taking false branch
486 ierr = PetscMalloc1(n,&c->columns[i])PetscMallocA(1,PETSC_FALSE,486,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(n)*sizeof(**(&c->columns[i])),(&c->columns
[i]))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),486,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
487 ierr = PetscLogObjectMemory((PetscObject)c,n*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),487,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
488 ierr = PetscMemcpy(c->columns[i],is,n*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),488,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
489 } else {
490 c->columns[i] = 0;
491 }
492
493 if (ctype == IS_COLORING_GLOBAL) {
20
Taking true branch
34
Taking true branch
46
Taking true branch
494 /* Determine nctot, the total (parallel) number of columns of this color */
495 ierr = MPI_Comm_size(PetscObjectComm((PetscObject)mat),&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),495,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
496 ierr = PetscMalloc2(size,&ncolsonproc,size,&disp)PetscMallocA(2,PETSC_FALSE,496,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(size)*sizeof(**(&ncolsonproc)),(&ncolsonproc
),(size_t)(size)*sizeof(**(&disp)),(&disp))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),496,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
497
498 /* ncolsonproc[j]: local ncolumns on proc[j] of this color */
499 ierr = PetscMPIIntCast(n,&nn);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),499,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
500 ierr = MPI_Allgather(&nn,1,MPI_INT,ncolsonproc,1,MPI_INT,PetscObjectComm((PetscObject)mat))((petsc_gather_ct += PetscMPIParallelComm((PetscObjectComm((PetscObject
)mat))),0) || MPI_Allgather((&nn),(1),(((MPI_Datatype)0x4c000405
)),(ncolsonproc),(1),(((MPI_Datatype)0x4c000405)),(PetscObjectComm
((PetscObject)mat))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),500,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
501 nctot = 0; for (j=0; j<size; j++) nctot += ncolsonproc[j];
21
Assuming 'j' is >= 'size'
22
Loop condition is false. Execution continues on line 502
35
Assuming 'j' is >= 'size'
36
Loop condition is false. Execution continues on line 502
47
Assuming 'j' is < 'size'
48
Loop condition is true. Entering loop body
49
Assuming 'j' is >= 'size'
50
Loop condition is false. Execution continues on line 502
502 if (!nctot) {
23
Taking true branch
37
Taking true branch
51
Assuming 'nctot' is not equal to 0
52
Taking false branch
503 ierr = PetscInfo(mat,"Coloring of matrix has some unneeded colors with no corresponding rows\n")PetscInfo_Private(__func__,mat,"Coloring of matrix has some unneeded colors with no corresponding rows\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),503,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
504 }
505
506 disp[0] = 0;
507 for (j=1; j<size; j++) {
24
Loop condition is false. Execution continues on line 512
38
Loop condition is false. Execution continues on line 512
53
Loop condition is false. Execution continues on line 512
508 disp[j] = disp[j-1] + ncolsonproc[j-1];
509 }
510
511 /* Get cols, the complete list of columns for this color on each process */
512 ierr = PetscMalloc1(nctot+1,&cols)PetscMallocA(1,PETSC_FALSE,512,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(nctot+1)*sizeof(**(&cols)),(&cols))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),512,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
513 ierr = MPI_Allgatherv((void*)is,n,MPIU_INT,cols,ncolsonproc,disp,MPIU_INT,PetscObjectComm((PetscObject)mat))((petsc_gather_ct += PetscMPIParallelComm((PetscObjectComm((PetscObject
)mat))),0) || MPI_Allgatherv(((void*)is),(n),(((MPI_Datatype)
0x4c000405)),(cols),(ncolsonproc),(disp),(((MPI_Datatype)0x4c000405
)),(PetscObjectComm((PetscObject)mat))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),513,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
514 ierr = PetscFree2(ncolsonproc,disp)PetscFreeA(2,514,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,&(ncolsonproc),&(disp))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),514,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
515 } else if (ctype == IS_COLORING_LOCAL) {
516 /* Determine local number of columns of this color on this process, including ghost points */
517 nctot = n;
518 ierr = PetscMalloc1(nctot+1,&cols)PetscMallocA(1,PETSC_FALSE,518,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(nctot+1)*sizeof(**(&cols)),(&cols))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),518,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
519 ierr = PetscMemcpy(cols,is,n*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),519,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
520 } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not provided for this MatFDColoring type")return PetscError(((MPI_Comm)0x44000001),520,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,56,PETSC_ERROR_INITIAL,"Not provided for this MatFDColoring type"
)
;
521
522 /* Mark all rows affect by these columns */
523 ierr = PetscMemzero(rowhit,m*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),523,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
524 bs2 = bs*bs;
525 nrows_i = 0;
526 for (j=0; j<nctot; j++) { /* loop over columns*/
25
Loop condition is false. Execution continues on line 567
39
Loop condition is false. Execution continues on line 567
54
Assuming 'j' is < 'nctot'
55
Loop condition is true. Entering loop body
59
Assuming 'j' is < 'nctot'
60
Loop condition is true. Entering loop body
527 if (ctype == IS_COLORING_LOCAL) {
56
Taking false branch
61
Taking false branch
528 col = ltog[cols[j]];
529 } else {
530 col = cols[j];
531 }
532 if (col >= cstart && col < cend) { /* column is in A, diagonal block of mat */
533 row = A_cj + A_ci[col-cstart];
534 nrows = A_ci[col-cstart+1] - A_ci[col-cstart];
535 nrows_i += nrows;
536 /* loop over columns of A marking them in rowhit */
537 for (k=0; k<nrows; k++) {
538 /* set valaddrhit for part A */
539 spidx = bs2*spidxA[A_ci[col-cstart] + k];
540 valaddrhit[*row] = &A_val[spidx];
541 rowhit[*row++] = col - cstart + 1; /* local column index */
542 }
543 } else { /* column is in B, off-diagonal block of mat */
544#if defined(PETSC_USE_CTABLE1)
545 ierr = PetscTableFind(colmap,col+1,&colb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),545,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
62
Calling 'PetscTableFind'
546 colb--;
547#else
548 colb = colmap[col] - 1; /* local column index */
549#endif
550 if (colb == -1) {
57
Taking true branch
551 nrows = 0;
552 } else {
553 colb = colb/bs;
554 row = B_cj + B_ci[colb];
555 nrows = B_ci[colb+1] - B_ci[colb];
556 }
557 nrows_i += nrows;
558 /* loop over columns of B marking them in rowhit */
559 for (k=0; k<nrows; k++) {
58
Loop condition is false. Execution continues on line 526
560 /* set valaddrhit for part B */
561 spidx = bs2*spidxB[B_ci[colb] + k];
562 valaddrhit[*row] = &B_val[spidx];
563 rowhit[*row++] = colb + 1 + cend - cstart; /* local column index */
564 }
565 }
566 }
567 c->nrows[i] = nrows_i;
568
569 if (c->htype[0] == 'd') {
26
Assuming the condition is false
27
Taking false branch
40
Taking false branch
570 for (j=0; j<m; j++) {
571 if (rowhit[j]) {
572 Jentry[nz].row = j; /* local row index */
573 Jentry[nz].col = rowhit[j] - 1; /* local column index */
574 Jentry[nz].valaddr = valaddrhit[j]; /* address of mat value for this entry */
575 nz++;
576 }
577 }
578 } else { /* c->htype == 'wp' */
579 for (j=0; j<m; j++) {
28
Assuming 'j' is >= 'm'
29
Loop condition is false. Execution continues on line 587
41
Loop condition is false. Execution continues on line 587
580 if (rowhit[j]) {
581 Jentry2[nz].row = j; /* local row index */
582 Jentry2[nz].valaddr = valaddrhit[j]; /* address of mat value for this entry */
583 nz++;
584 }
585 }
586 }
587 ierr = PetscFree(cols)((*PetscTrFree)((void*)(cols),587,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
) || ((cols) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),587,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
588 }
589
590 if (bcols > 1) { /* reorder Jentry for faster MatFDColoringApply() */
591 ierr = MatFDColoringSetUpBlocked_AIJ_Private(mat,c,nz);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),591,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
592 }
593
594 if (isBAIJ) {
595 ierr = MatRestoreColumnIJ_SeqBAIJ_Color(A,0,PETSC_FALSE,PETSC_FALSE,&ncols,&A_ci,&A_cj,&spidxA,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),595,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
596 ierr = MatRestoreColumnIJ_SeqBAIJ_Color(B,0,PETSC_FALSE,PETSC_FALSE,&ncols,&B_ci,&B_cj,&spidxB,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),596,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
597 ierr = PetscMalloc1(bs*mat->rmap->n,&c->dy)PetscMallocA(1,PETSC_FALSE,597,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,(size_t)(bs*mat->rmap->n)*sizeof(**(&c->dy)),(&
c->dy))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),597,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
598 } else if (isSELL) {
599 ierr = MatRestoreColumnIJ_SeqSELL_Color(A,0,PETSC_FALSE,PETSC_FALSE,&ncols,&A_ci,&A_cj,&spidxA,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),599,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
600 ierr = MatRestoreColumnIJ_SeqSELL_Color(B,0,PETSC_FALSE,PETSC_FALSE,&ncols,&B_ci,&B_cj,&spidxB,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),600,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
601 }else {
602 ierr = MatRestoreColumnIJ_SeqAIJ_Color(A,0,PETSC_FALSE,PETSC_FALSE,&ncols,&A_ci,&A_cj,&spidxA,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),602,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
603 ierr = MatRestoreColumnIJ_SeqAIJ_Color(B,0,PETSC_FALSE,PETSC_FALSE,&ncols,&B_ci,&B_cj,&spidxB,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),603,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
604 }
605
606 ierr = ISColoringRestoreIS(iscoloring,&isa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),606,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
607 ierr = PetscFree2(rowhit,valaddrhit)PetscFreeA(2,607,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,&(rowhit),&(valaddrhit))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),607,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
608
609 if (ctype == IS_COLORING_LOCAL) {
610 ierr = ISLocalToGlobalMappingRestoreIndices(map,&ltog);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),610,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
611 }
612 ierr = PetscInfo3(c,"ncolors %D, brows %D and bcols %D are used.\n",c->ncolors,c->brows,c->bcols)PetscInfo_Private(__func__,c,"ncolors %D, brows %D and bcols %D are used.\n"
,c->ncolors,c->brows,c->bcols)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),612,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
613 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)
;
614}
615
616PetscErrorCode MatFDColoringCreate_MPIXAIJ(Mat mat,ISColoring iscoloring,MatFDColoring c)
617{
618 PetscErrorCode ierr;
619 PetscInt bs,nis=iscoloring->n,m=mat->rmap->n;
620 PetscBool isBAIJ,isSELL;
621
622 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
; petscstack->line[petscstack->currentsize] = 622; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
623 /* set default brows and bcols for speedup inserting the dense matrix into sparse Jacobian;
624 bcols is chosen s.t. dy-array takes 50% of memory space as mat */
625 ierr = MatGetBlockSize(mat,&bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),625,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
626 ierr = PetscObjectTypeCompare((PetscObject)mat,MATMPIBAIJ"mpibaij",&isBAIJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),626,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
627 ierr = PetscObjectTypeCompare((PetscObject)mat,MATMPISELL"mpisell",&isSELL);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),627,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/fdmpiaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
628 if (isBAIJ || m == 0) {
629 c->brows = m;
630 c->bcols = 1;
631 } else if (isSELL) {
632 /* bcols is chosen s.t. dy-array takes 50% of local memory space as mat */
633 Mat_MPISELL *sell=(Mat_MPISELL*)mat->data;
634 Mat_SeqSELL *spA,*spB;
635 Mat A,B;
636 PetscInt nz,brows,bcols;
637 PetscReal mem;
638
639 bs = 1; /* only bs=1 is supported for MPISELL matrix */
640
641 A = sell->A; spA = (Mat_SeqSELL*)A->data;
642 B = sell->B; spB = (Mat_SeqSELL*)B->data;
643 nz = spA->nz + spB->nz; /* total local nonzero entries of mat */
644 mem = nz*(sizeof(PetscScalar) + sizeof(PetscInt)) + 3*m*sizeof(PetscInt);
645 bcols = (PetscInt)(0.5*mem /(m*sizeof(PetscScalar)));
646 brows = 1000/bcols;
647 if (bcols > nis) bcols = nis;
648 if (brows == 0 || brows > m) brows = m;
649 c->brows = brows;
650 c->bcols = bcols;
651 } else { /* mpiaij matrix */
652 /* bcols is chosen s.t. dy-array takes 50% of local memory space as mat */
653 Mat_MPIAIJ *aij=(Mat_MPIAIJ*)mat->data;
654 Mat_SeqAIJ *spA,*spB;
655 Mat A,B;
656 PetscInt nz,brows,bcols;
657 PetscReal mem;
658
659 bs = 1; /* only bs=1 is supported for MPIAIJ matrix */
660
661 A = aij->A; spA = (Mat_SeqAIJ*)A->data;
662 B = aij->B; spB = (Mat_SeqAIJ*)B->data;
663 nz = spA->nz + spB->nz; /* total local nonzero entries of mat */
664 mem = nz*(sizeof(PetscScalar) + sizeof(PetscInt)) + 3*m*sizeof(PetscInt);
665 bcols = (PetscInt)(0.5*mem /(m*sizeof(PetscScalar)));
666 brows = 1000/bcols;
667 if (bcols > nis) bcols = nis;
668 if (brows == 0 || brows > m) brows = m;
669 c->brows = brows;
670 c->bcols = bcols;
671 }
672
673 c->M = mat->rmap->N/bs; /* set the global rows and columns and local rows */
674 c->N = mat->cmap->N/bs;
675 c->m = mat->rmap->n/bs;
676 c->rstart = mat->rmap->rstart/bs;
677 c->ncolors = nis;
678 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)
;
679}

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

1#ifndef PETSCCTABLE_H
2#define PETSCCTABLE_H
3#include <petscsys.h>
4
5struct _n_PetscTable {
6 PetscInt *keytable;
7 PetscInt *table;
8 PetscInt count;
9 PetscInt tablesize;
10 PetscInt head;
11 PetscInt maxkey; /* largest key allowed */
12};
13
14typedef struct _n_PetscTable* PetscTable;
15typedef PetscInt* PetscTablePosition;
16
17PETSC_STATIC_INLINEstatic inline unsigned long PetscHash(PetscTable ta,unsigned long x)
18{
19 return(x%(unsigned long)ta->tablesize);
20}
21
22PETSC_STATIC_INLINEstatic inline unsigned long PetscHashStep(PetscTable ta,unsigned long x)
23{
24 return(1+(x%(unsigned long)(ta->tablesize-1)));
64
Division by zero
25}
26
27PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableCreate(const PetscInt,PetscInt,PetscTable*);
28PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableCreateCopy(const PetscTable,PetscTable*);
29PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableDestroy(PetscTable*);
30PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableGetCount(const PetscTable,PetscInt*);
31PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableIsEmpty(const PetscTable,PetscInt*);
32PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableAddExpand(PetscTable,PetscInt,PetscInt,InsertMode);
33PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableAddCountExpand(PetscTable,PetscInt);
34PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableGetHeadPosition(PetscTable,PetscTablePosition*);
35PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableGetNext(PetscTable,PetscTablePosition*,PetscInt*,PetscInt*);
36PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscTableRemoveAll(PetscTable);
37
38PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscTableAdd(PetscTable ta,PetscInt key,PetscInt data,InsertMode imode)
39{
40 PetscErrorCode ierr;
41 PetscInt i,hash = (PetscInt)PetscHash(ta,(unsigned long)key);
42 PetscInt hashstep = (PetscInt)PetscHashStep(ta,(unsigned long)key);
43
44 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscctable.h"; petscstack
->line[petscstack->currentsize] = 44; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
45 if (key <= 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"key <= 0")return PetscError(((MPI_Comm)0x44000001),45,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,63,PETSC_ERROR_INITIAL,"key <= 0")
;
46 if (key > ta->maxkey) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"key %D is greater than largest key allowed %D",key,ta->maxkey)return PetscError(((MPI_Comm)0x44000001),46,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,63,PETSC_ERROR_INITIAL,"key %D is greater than largest key allowed %D"
,key,ta->maxkey)
;
47 if (!data) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Null data")return PetscError(((MPI_Comm)0x44000001),47,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,63,PETSC_ERROR_INITIAL,"Null data")
;
48
49 for (i=0; i<ta->tablesize; i++) {
50 if (ta->keytable[hash] == key) {
51 switch (imode) {
52 case INSERT_VALUES:
53 ta->table[hash] = data; /* over write */
54 break;
55 case ADD_VALUES:
56 ta->table[hash] += data;
57 break;
58 case MAX_VALUES:
59 ta->table[hash] = PetscMax(ta->table[hash],data)(((ta->table[hash])<(data)) ? (data) : (ta->table[hash
]))
;
60 break;
61 case NOT_SET_VALUES:
62 case INSERT_ALL_VALUES:
63 case ADD_ALL_VALUES:
64 case INSERT_BC_VALUES:
65 case ADD_BC_VALUES:
66 SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Unsupported InsertMode")return PetscError(((MPI_Comm)0x44000001),66,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,56,PETSC_ERROR_INITIAL,"Unsupported InsertMode")
;
67 }
68 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)
;
69 } else if (!ta->keytable[hash]) {
70 if (ta->count < 5*(ta->tablesize/6) - 1) {
71 ta->count++; /* add */
72 ta->keytable[hash] = key;
73 ta->table[hash] = data;
74 } else {
75 ierr = PetscTableAddExpand(ta,key,data,imode);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),75,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
76 }
77 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)
;
78 }
79 hash = (hash + hashstep)%ta->tablesize;
80 }
81 SETERRQ(PETSC_COMM_SELF,PETSC_ERR_COR,"Full table")return PetscError(((MPI_Comm)0x44000001),81,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,74,PETSC_ERROR_INITIAL,"Full table")
;
82 /* PetscFunctionReturn(0); */
83}
84
85PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscTableAddCount(PetscTable ta,PetscInt key)
86{
87 PetscErrorCode ierr;
88 PetscInt i,hash = (PetscInt)PetscHash(ta,(unsigned long)key);
89 PetscInt hashstep = (PetscInt)PetscHashStep(ta,(unsigned long)key);
90
91 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscctable.h"; petscstack
->line[petscstack->currentsize] = 91; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
92 if (key <= 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"key <= 0")return PetscError(((MPI_Comm)0x44000001),92,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,63,PETSC_ERROR_INITIAL,"key <= 0")
;
93 if (key > ta->maxkey) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"key %D is greater than largest key allowed %D",key,ta->maxkey)return PetscError(((MPI_Comm)0x44000001),93,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,63,PETSC_ERROR_INITIAL,"key %D is greater than largest key allowed %D"
,key,ta->maxkey)
;
94
95 for (i=0; i<ta->tablesize; i++) {
96 if (ta->keytable[hash] == key) {
97 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)
;
98 } else if (!ta->keytable[hash]) {
99 if (ta->count < 5*(ta->tablesize/6) - 1) {
100 ta->count++; /* add */
101 ta->keytable[hash] = key;
102 ta->table[hash] = ta->count;
103 } else {
104 ierr = PetscTableAddCountExpand(ta,key);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),104,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
105 }
106 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)
;
107 }
108 hash = (hash + hashstep)%ta->tablesize;
109 }
110 SETERRQ(PETSC_COMM_SELF,PETSC_ERR_COR,"Full table")return PetscError(((MPI_Comm)0x44000001),110,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,74,PETSC_ERROR_INITIAL,"Full table")
;
111 /* PetscFunctionReturn(0); */
112}
113
114/*
115 PetscTableFind - checks if a key is in the table
116
117 If data==0, then no table entry exists.
118
119*/
120PETSC_STATIC_INLINEstatic inline PetscErrorCode PetscTableFind(PetscTable ta,PetscInt key,PetscInt *data)
121{
122 PetscInt ii = 0;
123 PetscInt hash = (PetscInt)PetscHash(ta,(unsigned long)key);
124 PetscInt hashstep = (PetscInt)PetscHashStep(ta,(unsigned long)key);
63
Calling 'PetscHashStep'
125
126 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petscctable.h"; petscstack
->line[petscstack->currentsize] = 126; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
127 *data = 0;
128 if (key <= 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Key <= 0")return PetscError(((MPI_Comm)0x44000001),128,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,63,PETSC_ERROR_INITIAL,"Key <= 0")
;
129 if (key > ta->maxkey) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"key %D is greater than largest key allowed %D",key,ta->maxkey)return PetscError(((MPI_Comm)0x44000001),129,__func__,"/sandbox/petsc/petsc.next-tmp/include/petscctable.h"
,63,PETSC_ERROR_INITIAL,"key %D is greater than largest key allowed %D"
,key,ta->maxkey)
;
130
131 while (ii++ < ta->tablesize) {
132 if (!ta->keytable[hash]) break;
133 else if (ta->keytable[hash] == key) {
134 *data = ta->table[hash];
135 break;
136 }
137 hash = (hash + hashstep)%ta->tablesize;
138 }
139 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)
;
140}
141
142#endif