Bug Summary

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

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

/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)));
22
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);
21
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