Bug Summary

File:mat/impls/baij/mpi/mmbaij.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/baij/mpi/mmbaij.c

1
2/*
3 Support for the parallel BAIJ matrix vector multiply
4*/
5#include <../src/mat/impls/baij/mpi/mpibaij.h>
6#include <petsc/private/isimpl.h> /* needed because accesses data structure of ISLocalToGlobalMapping directly */
7
8PetscErrorCode MatSetUpMultiply_MPIBAIJ(Mat mat)
9{
10 Mat_MPIBAIJ *baij = (Mat_MPIBAIJ*)mat->data;
11 Mat_SeqBAIJ *B = (Mat_SeqBAIJ*)(baij->B->data);
12 PetscErrorCode ierr;
13 PetscInt i,j,*aj = B->j,ec = 0,*garray;
14 PetscInt bs = mat->rmap->bs,*stmp;
15 IS from,to;
16 Vec gvec;
17#if defined(PETSC_USE_CTABLE1)
18 PetscTable gid1_lid1;
19 PetscTablePosition tpos;
20 PetscInt gid,lid;
21#else
22 PetscInt Nbs = baij->Nbs,*indices;
23#endif
24
25 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
; petscstack->line[petscstack->currentsize] = 25; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
26#if defined(PETSC_USE_CTABLE1)
27 /* use a table - Mark Adams */
28 ierr = PetscTableCreate(B->mbs,baij->Nbs+1,&gid1_lid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),28,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
29 for (i=0; i<B->mbs; i++) {
1
Assuming the condition is true
2
Loop condition is true. Entering loop body
5
Assuming the condition is true
6
Loop condition is true. Entering loop body
9
Assuming the condition is true
10
Loop condition is true. Entering loop body
13
Assuming the condition is true
14
Loop condition is true. Entering loop body
30 for (j=0; j<B->ilen[i]; j++) {
3
Assuming the condition is false
4
Loop condition is false. Execution continues on line 29
7
Assuming the condition is false
8
Loop condition is false. Execution continues on line 29
11
Assuming the condition is false
12
Loop condition is false. Execution continues on line 29
15
Assuming the condition is true
16
Loop condition is true. Entering loop body
31 PetscInt data,gid1 = aj[B->i[i]+j] + 1;
32 ierr = PetscTableFind(gid1_lid1,gid1,&data);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),32,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
33 if (!data) {
17
Taking true branch
34 /* one based table */
35 ierr = PetscTableAdd(gid1_lid1,gid1,++ec,INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),35,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
18
Calling 'PetscTableAdd'
36 }
37 }
38 }
39 /* form array of columns we need */
40 ierr = PetscMalloc1(ec+1,&garray)PetscMallocA(1,PETSC_FALSE,40,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(ec+1)*sizeof(**(&garray)),(&garray))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),40,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
41 ierr = PetscTableGetHeadPosition(gid1_lid1,&tpos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),41,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
42 while (tpos) {
43 ierr = PetscTableGetNext(gid1_lid1,&tpos,&gid,&lid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),43,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
44 gid--; lid--;
45 garray[lid] = gid;
46 }
47 ierr = PetscSortInt(ec,garray);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),47,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
48 ierr = PetscTableRemoveAll(gid1_lid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),48,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
49 for (i=0; i<ec; i++) {
50 ierr = PetscTableAdd(gid1_lid1,garray[i]+1,i+1,INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),50,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
51 }
52 /* compact out the extra columns in B */
53 for (i=0; i<B->mbs; i++) {
54 for (j=0; j<B->ilen[i]; j++) {
55 PetscInt gid1 = aj[B->i[i] + j] + 1;
56 ierr = PetscTableFind(gid1_lid1,gid1,&lid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),56,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
57 lid--;
58 aj[B->i[i]+j] = lid;
59 }
60 }
61 B->nbs = ec;
62 baij->B->cmap->n = baij->B->cmap->N = ec*mat->rmap->bs;
63
64 ierr = PetscLayoutSetUp((baij->B->cmap));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),64,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
65 ierr = PetscTableDestroy(&gid1_lid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),65,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
66#else
67 /* Make an array as long as the number of columns */
68 /* mark those columns that are in baij->B */
69 ierr = PetscCalloc1(Nbs+1,&indices)PetscMallocA(1,PETSC_TRUE,69,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(Nbs+1)*sizeof(**(&indices)),(&indices))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),69,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
70 for (i=0; i<B->mbs; i++) {
71 for (j=0; j<B->ilen[i]; j++) {
72 if (!indices[aj[B->i[i] + j]]) ec++;
73 indices[aj[B->i[i] + j]] = 1;
74 }
75 }
76
77 /* form array of columns we need */
78 ierr = PetscMalloc1(ec+1,&garray)PetscMallocA(1,PETSC_FALSE,78,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(ec+1)*sizeof(**(&garray)),(&garray))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),78,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
79 ec = 0;
80 for (i=0; i<Nbs; i++) {
81 if (indices[i]) {
82 garray[ec++] = i;
83 }
84 }
85
86 /* make indices now point into garray */
87 for (i=0; i<ec; i++) {
88 indices[garray[i]] = i;
89 }
90
91 /* compact out the extra columns in B */
92 for (i=0; i<B->mbs; i++) {
93 for (j=0; j<B->ilen[i]; j++) {
94 aj[B->i[i] + j] = indices[aj[B->i[i] + j]];
95 }
96 }
97 B->nbs = ec;
98 baij->B->cmap->n = baij->B->cmap->N = ec*mat->rmap->bs;
99
100 ierr = PetscLayoutSetUp((baij->B->cmap));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),100,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
101 ierr = PetscFree(indices)((*PetscTrFree)((void*)(indices),101,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
) || ((indices) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),101,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
102#endif
103
104 /* create local vector that is used to scatter into */
105 ierr = VecCreateSeq(PETSC_COMM_SELF((MPI_Comm)0x44000001),ec*bs,&baij->lvec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),105,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
106
107 /* create two temporary index sets for building scatter-gather */
108 ierr = ISCreateBlock(PETSC_COMM_SELF((MPI_Comm)0x44000001),bs,ec,garray,PETSC_COPY_VALUES,&from);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),108,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
109
110 ierr = PetscMalloc1(ec+1,&stmp)PetscMallocA(1,PETSC_FALSE,110,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(ec+1)*sizeof(**(&stmp)),(&stmp))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),110,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
111 for (i=0; i<ec; i++) stmp[i] = i;
112 ierr = ISCreateBlock(PETSC_COMM_SELF((MPI_Comm)0x44000001),bs,ec,stmp,PETSC_OWN_POINTER,&to);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),112,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
113
114 /* create temporary global vector to generate scatter context */
115 ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)mat),1,mat->cmap->n,mat->cmap->N,NULL((void*)0),&gvec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),115,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
116
117 ierr = VecScatterCreate(gvec,from,baij->lvec,to,&baij->Mvctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),117,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
118
119 ierr = PetscLogObjectParent((PetscObject)mat,(PetscObject)baij->Mvctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),119,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
120 ierr = PetscLogObjectParent((PetscObject)mat,(PetscObject)baij->lvec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),120,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
121 ierr = PetscLogObjectParent((PetscObject)mat,(PetscObject)from);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),121,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
122 ierr = PetscLogObjectParent((PetscObject)mat,(PetscObject)to);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),122,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
123
124 baij->garray = garray;
125
126 ierr = PetscLogObjectMemory((PetscObject)mat,(ec+1)*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),126,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
127 ierr = ISDestroy(&from);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),127,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
128 ierr = ISDestroy(&to);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),128,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
129 ierr = VecDestroy(&gvec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),129,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
130 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)
;
131}
132
133/*
134 Takes the local part of an already assembled MPIBAIJ matrix
135 and disassembles it. This is to allow new nonzeros into the matrix
136 that require more communication in the matrix vector multiply.
137 Thus certain data-structures must be rebuilt.
138
139 Kind of slow! But that's what application programmers get when
140 they are sloppy.
141*/
142PetscErrorCode MatDisAssemble_MPIBAIJ(Mat A)
143{
144 Mat_MPIBAIJ *baij = (Mat_MPIBAIJ*)A->data;
145 Mat B = baij->B,Bnew;
146 Mat_SeqBAIJ *Bbaij = (Mat_SeqBAIJ*)B->data;
147 PetscErrorCode ierr;
148 PetscInt i,j,mbs=Bbaij->mbs,n = A->cmap->N,col,*garray=baij->garray;
149 PetscInt bs2 = baij->bs2,*nz,ec,m = A->rmap->n;
150 MatScalar *a = Bbaij->a;
151 MatScalar *atmp;
152
153
154 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
; petscstack->line[petscstack->currentsize] = 154; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
155 /* free stuff related to matrix-vec multiply */
156 ierr = VecGetSize(baij->lvec,&ec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),156,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* needed for PetscLogObjectMemory below */
157 ierr = VecDestroy(&baij->lvec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),157,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; baij->lvec = 0;
158 ierr = VecScatterDestroy(&baij->Mvctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),158,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; baij->Mvctx = 0;
159 if (baij->colmap) {
160#if defined(PETSC_USE_CTABLE1)
161 ierr = PetscTableDestroy(&baij->colmap);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),161,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
162#else
163 ierr = PetscFree(baij->colmap)((*PetscTrFree)((void*)(baij->colmap),163,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
) || ((baij->colmap) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),163,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
164 ierr = PetscLogObjectMemory((PetscObject)A,-Bbaij->nbs*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),164,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
165#endif
166 }
167
168 /* make sure that B is assembled so we can access its values */
169 ierr = MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),169,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
170 ierr = MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),170,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
171
172 /* invent new B and copy stuff over */
173 ierr = PetscMalloc1(mbs,&nz)PetscMallocA(1,PETSC_FALSE,173,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(mbs)*sizeof(**(&nz)),(&nz))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),173,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
174 for (i=0; i<mbs; i++) {
175 nz[i] = Bbaij->i[i+1]-Bbaij->i[i];
176 }
177 ierr = MatCreate(PetscObjectComm((PetscObject)B),&Bnew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),177,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
178 ierr = MatSetSizes(Bnew,m,n,m,n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),178,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
179 ierr = MatSetType(Bnew,((PetscObject)B)->type_name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),179,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
180 ierr = MatSeqBAIJSetPreallocation(Bnew,B->rmap->bs,0,nz);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),180,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
181 if (Bbaij->nonew >= 0) { /* Inherit insertion error options (if positive). */
182 ((Mat_SeqBAIJ*)Bnew->data)->nonew = Bbaij->nonew;
183 }
184
185 ierr = MatSetOption(Bnew,MAT_ROW_ORIENTED,PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),185,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
186 /*
187 Ensure that B's nonzerostate is monotonically increasing.
188 Or should this follow the MatSetValuesBlocked() loop to preserve B's nonzerstate across a MatDisAssemble() call?
189 */
190 Bnew->nonzerostate = B->nonzerostate;
191
192 for (i=0; i<mbs; i++) {
193 for (j=Bbaij->i[i]; j<Bbaij->i[i+1]; j++) {
194 col = garray[Bbaij->j[j]];
195 atmp = a + j*bs2;
196 ierr = MatSetValuesBlocked_SeqBAIJ(Bnew,1,&i,1,&col,atmp,B->insertmode);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),196,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
197 }
198 }
199 ierr = MatSetOption(Bnew,MAT_ROW_ORIENTED,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),199,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
200
201 ierr = PetscFree(nz)((*PetscTrFree)((void*)(nz),201,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
) || ((nz) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),201,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
202 ierr = PetscFree(baij->garray)((*PetscTrFree)((void*)(baij->garray),202,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
) || ((baij->garray) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),202,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
203 ierr = PetscLogObjectMemory((PetscObject)A,-ec*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),203,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
204 ierr = MatDestroy(&B);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),204,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
205 ierr = PetscLogObjectParent((PetscObject)A,(PetscObject)Bnew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),205,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
206
207 baij->B = Bnew;
208 A->was_assembled = PETSC_FALSE;
209 A->assembled = PETSC_FALSE;
210 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)
;
211}
212
213/* ugly stuff added for Glenn someday we should fix this up */
214
215static PetscInt *uglyrmapd = 0,*uglyrmapo = 0; /* mapping from the local ordering to the "diagonal" and "off-diagonal" parts of the local matrix */
216static Vec uglydd = 0,uglyoo = 0; /* work vectors used to scale the two parts of the local matrix */
217
218
219PetscErrorCode MatMPIBAIJDiagonalScaleLocalSetUp(Mat inA,Vec scale)
220{
221 Mat_MPIBAIJ *ina = (Mat_MPIBAIJ*) inA->data; /*access private part of matrix */
222 Mat_SeqBAIJ *B = (Mat_SeqBAIJ*)ina->B->data;
223 PetscErrorCode ierr;
224 PetscInt bs = inA->rmap->bs,i,n,nt,j,cstart,cend,no,*garray = ina->garray,*lindices;
225 PetscInt *r_rmapd,*r_rmapo;
226
227 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
; petscstack->line[petscstack->currentsize] = 227; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
228 ierr = MatGetOwnershipRange(inA,&cstart,&cend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),228,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
229 ierr = MatGetSize(ina->A,NULL((void*)0),&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),229,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
230 ierr = PetscCalloc1(inA->rmap->mapping->n+1,&r_rmapd)PetscMallocA(1,PETSC_TRUE,230,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(inA->rmap->mapping->n+1)*sizeof(**(&r_rmapd
)),(&r_rmapd))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),230,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
231 nt = 0;
232 for (i=0; i<inA->rmap->mapping->n; i++) {
233 if (inA->rmap->mapping->indices[i]*bs >= cstart && inA->rmap->mapping->indices[i]*bs < cend) {
234 nt++;
235 r_rmapd[i] = inA->rmap->mapping->indices[i] + 1;
236 }
237 }
238 if (nt*bs != n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Hmm nt*bs %D n %D",nt*bs,n)return PetscError(((MPI_Comm)0x44000001),238,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,77,PETSC_ERROR_INITIAL,"Hmm nt*bs %D n %D",nt*bs,n)
;
239 ierr = PetscMalloc1(n+1,&uglyrmapd)PetscMallocA(1,PETSC_FALSE,239,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(n+1)*sizeof(**(&uglyrmapd)),(&uglyrmapd))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),239,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
240 for (i=0; i<inA->rmap->mapping->n; i++) {
241 if (r_rmapd[i]) {
242 for (j=0; j<bs; j++) {
243 uglyrmapd[(r_rmapd[i]-1)*bs+j-cstart] = i*bs + j;
244 }
245 }
246 }
247 ierr = PetscFree(r_rmapd)((*PetscTrFree)((void*)(r_rmapd),247,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
) || ((r_rmapd) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),247,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
248 ierr = VecCreateSeq(PETSC_COMM_SELF((MPI_Comm)0x44000001),n,&uglydd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),248,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
249
250 ierr = PetscCalloc1(ina->Nbs+1,&lindices)PetscMallocA(1,PETSC_TRUE,250,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(ina->Nbs+1)*sizeof(**(&lindices)),(&lindices
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),250,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
251 for (i=0; i<B->nbs; i++) {
252 lindices[garray[i]] = i+1;
253 }
254 no = inA->rmap->mapping->n - nt;
255 ierr = PetscCalloc1(inA->rmap->mapping->n+1,&r_rmapo)PetscMallocA(1,PETSC_TRUE,255,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(inA->rmap->mapping->n+1)*sizeof(**(&r_rmapo
)),(&r_rmapo))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),255,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
256 nt = 0;
257 for (i=0; i<inA->rmap->mapping->n; i++) {
258 if (lindices[inA->rmap->mapping->indices[i]]) {
259 nt++;
260 r_rmapo[i] = lindices[inA->rmap->mapping->indices[i]];
261 }
262 }
263 if (nt > no) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Hmm nt %D no %D",nt,n)return PetscError(((MPI_Comm)0x44000001),263,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,77,PETSC_ERROR_INITIAL,"Hmm nt %D no %D",nt,n)
;
264 ierr = PetscFree(lindices)((*PetscTrFree)((void*)(lindices),264,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
) || ((lindices) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),264,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
265 ierr = PetscMalloc1(nt*bs+1,&uglyrmapo)PetscMallocA(1,PETSC_FALSE,265,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,(size_t)(nt*bs+1)*sizeof(**(&uglyrmapo)),(&uglyrmapo
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),265,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
266 for (i=0; i<inA->rmap->mapping->n; i++) {
267 if (r_rmapo[i]) {
268 for (j=0; j<bs; j++) {
269 uglyrmapo[(r_rmapo[i]-1)*bs+j] = i*bs + j;
270 }
271 }
272 }
273 ierr = PetscFree(r_rmapo)((*PetscTrFree)((void*)(r_rmapo),273,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
) || ((r_rmapo) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),273,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
274 ierr = VecCreateSeq(PETSC_COMM_SELF((MPI_Comm)0x44000001),nt*bs,&uglyoo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),274,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
275 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)
;
276}
277
278PetscErrorCode MatMPIBAIJDiagonalScaleLocal(Mat A,Vec scale)
279{
280 /* This routine should really be abandoned as it duplicates MatDiagonalScaleLocal */
281 PetscErrorCode ierr;
282
283 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
; petscstack->line[petscstack->currentsize] = 283; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
284 ierr = PetscTryMethod(A,"MatDiagonalScaleLocal_C",(Mat,Vec),(A,scale))0; do { PetscErrorCode (*_7_f)(Mat,Vec), _7_ierr; _7_ierr = PetscObjectQueryFunction_Private
(((PetscObject)(A)),("MatDiagonalScaleLocal_C"),(PetscVoidFunction
*)(&_7_f));do {if (__builtin_expect(!!(_7_ierr),0)) return
PetscError(((MPI_Comm)0x44000001),284,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (_7_f) {_7_ierr
= (*_7_f)(A,scale);do {if (__builtin_expect(!!(_7_ierr),0)) return
PetscError(((MPI_Comm)0x44000001),284,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} } while(0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),284,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
285 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)
;
286}
287
288PetscErrorCode MatDiagonalScaleLocal_MPIBAIJ(Mat A,Vec scale)
289{
290 Mat_MPIBAIJ *a = (Mat_MPIBAIJ*) A->data; /*access private part of matrix */
291 PetscErrorCode ierr;
292 PetscInt n,i;
293 PetscScalar *d,*o;
294 const PetscScalar *s;
295
296 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
; petscstack->line[petscstack->currentsize] = 296; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
297 if (!uglyrmapd) {
298 ierr = MatMPIBAIJDiagonalScaleLocalSetUp(A,scale);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),298,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
299 }
300
301 ierr = VecGetArrayRead(scale,&s);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),301,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
302
303 ierr = VecGetLocalSize(uglydd,&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),303,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
304 ierr = VecGetArray(uglydd,&d);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),304,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
305 for (i=0; i<n; i++) {
306 d[i] = s[uglyrmapd[i]]; /* copy "diagonal" (true local) portion of scale into dd vector */
307 }
308 ierr = VecRestoreArray(uglydd,&d);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),308,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
309 /* column scale "diagonal" portion of local matrix */
310 ierr = MatDiagonalScale(a->A,NULL((void*)0),uglydd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),310,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
311
312 ierr = VecGetLocalSize(uglyoo,&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),312,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
313 ierr = VecGetArray(uglyoo,&o);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),313,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
314 for (i=0; i<n; i++) {
315 o[i] = s[uglyrmapo[i]]; /* copy "off-diagonal" portion of scale into oo vector */
316 }
317 ierr = VecRestoreArrayRead(scale,&s);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),317,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
318 ierr = VecRestoreArray(uglyoo,&o);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),318,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
319 /* column scale "off-diagonal" portion of local matrix */
320 ierr = MatDiagonalScale(a->B,NULL((void*)0),uglyoo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),320,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/baij/mpi/mmbaij.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
321 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)
;
322}

/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)));
20
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);
19
Calling 'PetscHashStep'
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);
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