File: | mat/coarsen/impls/hem/hem.c |
Warning: | line 756, column 33 Dereference of undefined pointer value |
[?] Use j/k keys for keyboard navigation
1 | ||||||
2 | #include <petsc/private/matimpl.h> /*I "petscmat.h" I*/ | |||||
3 | #include <../src/mat/impls/aij/seq/aij.h> | |||||
4 | #include <../src/mat/impls/aij/mpi/mpiaij.h> | |||||
5 | ||||||
6 | /* linked list methods | |||||
7 | * | |||||
8 | * PetscCDCreate | |||||
9 | */ | |||||
10 | PetscErrorCode PetscCDCreate(PetscInt a_size, PetscCoarsenData **a_out) | |||||
11 | { | |||||
12 | PetscErrorCode ierr; | |||||
13 | PetscCoarsenData *ail; | |||||
14 | ||||||
15 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 15; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
16 | /* alocate pool, partially */ | |||||
17 | ierr = PetscNew(&ail)PetscMallocA(1,PETSC_TRUE,17,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(1)*sizeof(**((&ail))),((&ail)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),17,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
18 | *a_out = ail; | |||||
19 | ail->pool_list.next = NULL((void*)0); | |||||
20 | ail->pool_list.array = NULL((void*)0); | |||||
21 | ail->chk_sz = 0; | |||||
22 | /* allocate array */ | |||||
23 | ail->size = a_size; | |||||
24 | ierr = PetscCalloc1(a_size, &ail->array)PetscMallocA(1,PETSC_TRUE,24,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(a_size)*sizeof(**(&ail->array)),(&ail-> array));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),24,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
25 | ail->extra_nodes = NULL((void*)0); | |||||
26 | ail->mat = NULL((void*)0); | |||||
27 | 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); | |||||
28 | } | |||||
29 | ||||||
30 | /* NPDestroy | |||||
31 | */ | |||||
32 | PetscErrorCode PetscCDDestroy(PetscCoarsenData *ail) | |||||
33 | { | |||||
34 | PetscErrorCode ierr; | |||||
35 | PetscCDArrNd *n = &ail->pool_list; | |||||
36 | ||||||
37 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 37; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
38 | n = n->next; | |||||
39 | while (n) { | |||||
40 | PetscCDArrNd *lstn = n; | |||||
41 | n = n->next; | |||||
42 | ierr = PetscFree(lstn)((*PetscTrFree)((void*)(lstn),42,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((lstn) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),42,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
43 | } | |||||
44 | if (ail->pool_list.array) { | |||||
45 | ierr = PetscFree(ail->pool_list.array)((*PetscTrFree)((void*)(ail->pool_list.array),45,__func__, "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((ail->pool_list.array) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),45,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
46 | } | |||||
47 | ierr = PetscFree(ail->array)((*PetscTrFree)((void*)(ail->array),47,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((ail->array) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),47,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
48 | /* delete this (+agg+pool array) */ | |||||
49 | ierr = PetscFree(ail)((*PetscTrFree)((void*)(ail),49,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((ail) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),49,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
50 | 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); | |||||
51 | } | |||||
52 | ||||||
53 | /* PetscCDSetChuckSize | |||||
54 | */ | |||||
55 | PetscErrorCode PetscCDSetChuckSize(PetscCoarsenData *ail, PetscInt a_sz) | |||||
56 | { | |||||
57 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 57; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
58 | ail->chk_sz = a_sz; | |||||
59 | 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); | |||||
60 | } | |||||
61 | ||||||
62 | /* PetscCDGetNewNode | |||||
63 | */ | |||||
64 | PetscErrorCode PetscCDGetNewNode(PetscCoarsenData *ail, PetscCDIntNd **a_out, PetscInt a_id) | |||||
65 | { | |||||
66 | PetscErrorCode ierr; | |||||
67 | ||||||
68 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 68; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
69 | *a_out = NULL((void*)0); /* squelch -Wmaybe-uninitialized */ | |||||
70 | if (ail->extra_nodes) { | |||||
71 | PetscCDIntNd *node = ail->extra_nodes; | |||||
72 | ail->extra_nodes = node->next; | |||||
73 | node->gid = a_id; | |||||
74 | node->next = NULL((void*)0); | |||||
75 | *a_out = node; | |||||
76 | } else { | |||||
77 | if (!ail->pool_list.array) { | |||||
78 | if (!ail->chk_sz) ail->chk_sz = 10; /* use a chuck size of ail->size? */ | |||||
79 | ierr = PetscMalloc1(ail->chk_sz, &ail->pool_list.array)PetscMallocA(1,PETSC_FALSE,79,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(ail->chk_sz)*sizeof(**(&ail->pool_list.array )),(&ail->pool_list.array));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),79,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
80 | ail->new_node = ail->pool_list.array; | |||||
81 | ail->new_left = ail->chk_sz; | |||||
82 | ail->new_node->next = NULL((void*)0); | |||||
83 | } else if (!ail->new_left) { | |||||
84 | PetscCDArrNd *node; | |||||
85 | ierr = PetscMalloc(ail->chk_sz*sizeof(PetscCDIntNd) + sizeof(PetscCDArrNd), &node)((*PetscTrMalloc)((ail->chk_sz*sizeof(PetscCDIntNd) + sizeof (PetscCDArrNd)),PETSC_FALSE,85,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(void**)(&node)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),85,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
86 | node->array = (PetscCDIntNd*)(node + 1); | |||||
87 | node->next = ail->pool_list.next; | |||||
88 | ail->pool_list.next = node; | |||||
89 | ail->new_left = ail->chk_sz; | |||||
90 | ail->new_node = node->array; | |||||
91 | } | |||||
92 | ail->new_node->gid = a_id; | |||||
93 | ail->new_node->next = NULL((void*)0); | |||||
94 | *a_out = ail->new_node++; ail->new_left--; | |||||
95 | } | |||||
96 | 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); | |||||
97 | } | |||||
98 | ||||||
99 | /* PetscCDIntNdSetID | |||||
100 | */ | |||||
101 | PetscErrorCode PetscCDIntNdSetID(PetscCDIntNd *a_this, PetscInt a_id) | |||||
102 | { | |||||
103 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 103; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
104 | a_this->gid = a_id; | |||||
105 | 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); | |||||
106 | } | |||||
107 | ||||||
108 | /* PetscCDIntNdGetID | |||||
109 | */ | |||||
110 | PetscErrorCode PetscCDIntNdGetID(const PetscCDIntNd *a_this, PetscInt *a_gid) | |||||
111 | { | |||||
112 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 112; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
113 | *a_gid = a_this->gid; | |||||
114 | 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); | |||||
115 | } | |||||
116 | ||||||
117 | /* PetscCDGetHeadPos | |||||
118 | */ | |||||
119 | PetscErrorCode PetscCDGetHeadPos(const PetscCoarsenData *ail, PetscInt a_idx, PetscCDIntNd **pos) | |||||
120 | { | |||||
121 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 121; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
122 | if (a_idx>=ail->size) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"a_idx >= ail->size: a_idx=%D.",a_idx)return PetscError(((MPI_Comm)0x44000001),122,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"a_idx >= ail->size: a_idx=%D." ,a_idx); | |||||
123 | *pos = ail->array[a_idx]; | |||||
124 | 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); | |||||
125 | } | |||||
126 | ||||||
127 | /* PetscCDGetNextPos | |||||
128 | */ | |||||
129 | PetscErrorCode PetscCDGetNextPos(const PetscCoarsenData *ail, PetscInt l_idx, PetscCDIntNd **pos) | |||||
130 | { | |||||
131 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 131; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
132 | if (!(*pos)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"NULL input position.")return PetscError(((MPI_Comm)0x44000001),132,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"NULL input position."); | |||||
133 | *pos = (*pos)->next; | |||||
134 | 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); | |||||
135 | } | |||||
136 | ||||||
137 | /* PetscCDAppendID | |||||
138 | */ | |||||
139 | PetscErrorCode PetscCDAppendID(PetscCoarsenData *ail, PetscInt a_idx, PetscInt a_id) | |||||
140 | { | |||||
141 | PetscErrorCode ierr; | |||||
142 | PetscCDIntNd *n,*n2; | |||||
143 | ||||||
144 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 144; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
145 | ierr = PetscCDGetNewNode(ail, &n, a_id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),145,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
146 | if (a_idx>=ail->size) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Index %D out of range.",a_idx)return PetscError(((MPI_Comm)0x44000001),146,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"Index %D out of range.",a_idx); | |||||
147 | if (!(n2=ail->array[a_idx])) ail->array[a_idx] = n; | |||||
148 | else { | |||||
149 | do { | |||||
150 | if (!n2->next) { | |||||
151 | n2->next = n; | |||||
152 | if (n->next) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"n should not have a next")return PetscError(((MPI_Comm)0x44000001),152,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"n should not have a next"); | |||||
153 | break; | |||||
154 | } | |||||
155 | n2 = n2->next; | |||||
156 | } while (n2); | |||||
157 | if (!n2) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"n2 should be non-null")return PetscError(((MPI_Comm)0x44000001),157,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"n2 should be non-null"); | |||||
158 | } | |||||
159 | 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); | |||||
160 | } | |||||
161 | ||||||
162 | /* PetscCDAppendNode | |||||
163 | */ | |||||
164 | PetscErrorCode PetscCDAppendNode(PetscCoarsenData *ail, PetscInt a_idx, PetscCDIntNd *a_n) | |||||
165 | { | |||||
166 | PetscCDIntNd *n2; | |||||
167 | ||||||
168 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 168; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
169 | if (a_idx>=ail->size) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Index %D out of range.",a_idx)return PetscError(((MPI_Comm)0x44000001),169,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"Index %D out of range.",a_idx); | |||||
170 | if (!(n2=ail->array[a_idx])) ail->array[a_idx] = a_n; | |||||
171 | else { | |||||
172 | do { | |||||
173 | if (!n2->next) { | |||||
174 | n2->next = a_n; | |||||
175 | a_n->next = NULL((void*)0); | |||||
176 | break; | |||||
177 | } | |||||
178 | n2 = n2->next; | |||||
179 | } while (n2); | |||||
180 | if (!n2) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"n2 should be non-null")return PetscError(((MPI_Comm)0x44000001),180,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"n2 should be non-null"); | |||||
181 | } | |||||
182 | 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); | |||||
183 | } | |||||
184 | ||||||
185 | /* PetscCDRemoveNextNode: a_last->next, this exposes single linked list structure to API | |||||
186 | */ | |||||
187 | PetscErrorCode PetscCDRemoveNextNode(PetscCoarsenData *ail, PetscInt a_idx, PetscCDIntNd *a_last) | |||||
188 | { | |||||
189 | PetscCDIntNd *del; | |||||
190 | ||||||
191 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 191; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
192 | if (a_idx>=ail->size) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Index %D out of range.",a_idx)return PetscError(((MPI_Comm)0x44000001),192,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"Index %D out of range.",a_idx); | |||||
193 | if (!a_last->next) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"a_last should have a next")return PetscError(((MPI_Comm)0x44000001),193,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"a_last should have a next"); | |||||
194 | del = a_last->next; | |||||
195 | a_last->next = del->next; | |||||
196 | /* del->next = NULL; -- this still used in a iterator so keep it intact -- need to fix this with a double linked list */ | |||||
197 | /* could reuse n2 but PetscCDAppendNode sometimes uses it */ | |||||
198 | 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); | |||||
199 | } | |||||
200 | ||||||
201 | /* PetscCDPrint | |||||
202 | */ | |||||
203 | PetscErrorCode PetscCDPrint(const PetscCoarsenData *ail, MPI_Comm comm) | |||||
204 | { | |||||
205 | PetscErrorCode ierr; | |||||
206 | PetscCDIntNd *n; | |||||
207 | PetscInt ii,kk; | |||||
208 | PetscMPIInt rank; | |||||
209 | ||||||
210 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 210; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
211 | ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),211,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
212 | for (ii=0; ii<ail->size; ii++) { | |||||
213 | kk = 0; | |||||
214 | n = ail->array[ii]; | |||||
215 | if (n) {ierr = PetscPrintf(comm,"[%d]%s list %d:\n",rank,PETSC_FUNCTION_NAME__func__,ii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),215,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||||
216 | while (n) { | |||||
217 | PetscPrintf(comm,"\t[%d] %D) id %D\n",rank,++kk,n->gid); | |||||
218 | n = n->next; | |||||
219 | } | |||||
220 | } | |||||
221 | 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); | |||||
222 | } | |||||
223 | ||||||
224 | /* PetscCDAppendRemove | |||||
225 | */ | |||||
226 | PetscErrorCode PetscCDAppendRemove(PetscCoarsenData *ail, PetscInt a_destidx, PetscInt a_srcidx) | |||||
227 | { | |||||
228 | PetscCDIntNd *n; | |||||
229 | ||||||
230 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 230; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
231 | if (a_srcidx>=ail->size) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Index %D out of range.",a_srcidx)return PetscError(((MPI_Comm)0x44000001),231,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"Index %D out of range.",a_srcidx); | |||||
232 | if (a_destidx>=ail->size) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Index %D out of range.",a_destidx)return PetscError(((MPI_Comm)0x44000001),232,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"Index %D out of range.",a_destidx); | |||||
233 | if (a_destidx==a_srcidx) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"a_destidx==a_srcidx %D.",a_destidx)return PetscError(((MPI_Comm)0x44000001),233,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"a_destidx==a_srcidx %D.",a_destidx); | |||||
234 | n = ail->array[a_destidx]; | |||||
235 | if (!n) ail->array[a_destidx] = ail->array[a_srcidx]; | |||||
236 | else { | |||||
237 | do { | |||||
238 | if (!n->next) { | |||||
239 | n->next = ail->array[a_srcidx]; | |||||
240 | break; | |||||
241 | } | |||||
242 | n = n->next; | |||||
243 | } while (1); | |||||
244 | } | |||||
245 | ail->array[a_srcidx] = NULL((void*)0); | |||||
246 | 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); | |||||
247 | } | |||||
248 | ||||||
249 | /* PetscCDRemoveAll | |||||
250 | */ | |||||
251 | PetscErrorCode PetscCDRemoveAll(PetscCoarsenData *ail, PetscInt a_idx) | |||||
252 | { | |||||
253 | PetscCDIntNd *rem,*n1; | |||||
254 | ||||||
255 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 255; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
256 | if (a_idx>=ail->size) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Index %D out of range.",a_idx)return PetscError(((MPI_Comm)0x44000001),256,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"Index %D out of range.",a_idx); | |||||
257 | rem = ail->array[a_idx]; | |||||
258 | ail->array[a_idx] = NULL((void*)0); | |||||
259 | if (!(n1=ail->extra_nodes)) ail->extra_nodes = rem; | |||||
260 | else { | |||||
261 | while (n1->next) n1 = n1->next; | |||||
262 | n1->next = rem; | |||||
263 | } | |||||
264 | 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); | |||||
265 | } | |||||
266 | ||||||
267 | /* PetscCDSizeAt | |||||
268 | */ | |||||
269 | PetscErrorCode PetscCDSizeAt(const PetscCoarsenData *ail, PetscInt a_idx, PetscInt *a_sz) | |||||
270 | { | |||||
271 | PetscCDIntNd *n1; | |||||
272 | PetscInt sz = 0; | |||||
273 | ||||||
274 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 274; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
275 | if (a_idx>=ail->size) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Index %D out of range.",a_idx)return PetscError(((MPI_Comm)0x44000001),275,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"Index %D out of range.",a_idx); | |||||
276 | n1 = ail->array[a_idx]; | |||||
277 | while (n1) { | |||||
278 | n1 = n1->next; | |||||
279 | sz++; | |||||
280 | } | |||||
281 | *a_sz = sz; | |||||
282 | 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); | |||||
283 | } | |||||
284 | ||||||
285 | /* PetscCDEmptyAt | |||||
286 | */ | |||||
287 | PetscErrorCode PetscCDEmptyAt(const PetscCoarsenData *ail, PetscInt a_idx, PetscBool *a_e) | |||||
288 | { | |||||
289 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 289; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
290 | if (a_idx>=ail->size) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Index %D out of range.",a_idx)return PetscError(((MPI_Comm)0x44000001),290,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"Index %D out of range.",a_idx); | |||||
291 | *a_e = (PetscBool)(ail->array[a_idx]==NULL((void*)0)); | |||||
292 | 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); | |||||
293 | } | |||||
294 | ||||||
295 | /* PetscCDGetMIS | |||||
296 | */ | |||||
297 | PetscErrorCode PetscCDGetMIS(PetscCoarsenData *ail, IS *a_mis) | |||||
298 | { | |||||
299 | PetscErrorCode ierr; | |||||
300 | PetscCDIntNd *n; | |||||
301 | PetscInt ii,kk; | |||||
302 | PetscInt *permute; | |||||
303 | ||||||
304 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 304; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
305 | for (ii=kk=0; ii<ail->size; ii++) { | |||||
306 | n = ail->array[ii]; | |||||
307 | if (n) kk++; | |||||
308 | } | |||||
309 | ierr = PetscMalloc1(kk, &permute)PetscMallocA(1,PETSC_FALSE,309,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(kk)*sizeof(**(&permute)),(&permute));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),309,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
310 | for (ii=kk=0; ii<ail->size; ii++) { | |||||
311 | n = ail->array[ii]; | |||||
312 | if (n) permute[kk++] = ii; | |||||
313 | } | |||||
314 | ierr = ISCreateGeneral(PETSC_COMM_SELF((MPI_Comm)0x44000001), kk, permute, PETSC_OWN_POINTER, a_mis);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),314,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
315 | 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); | |||||
316 | } | |||||
317 | ||||||
318 | /* PetscCDGetMat | |||||
319 | */ | |||||
320 | PetscErrorCode PetscCDGetMat(const PetscCoarsenData *ail, Mat *a_mat) | |||||
321 | { | |||||
322 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 322; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
323 | *a_mat = ail->mat; | |||||
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 | } | |||||
326 | ||||||
327 | /* PetscCDSetMat | |||||
328 | */ | |||||
329 | PetscErrorCode PetscCDSetMat(PetscCoarsenData *ail, Mat a_mat) | |||||
330 | { | |||||
331 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 331; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
332 | ail->mat = a_mat; | |||||
333 | 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); | |||||
334 | } | |||||
335 | ||||||
336 | /* PetscCDGetASMBlocks | |||||
337 | */ | |||||
338 | PetscErrorCode PetscCDGetASMBlocks(const PetscCoarsenData *ail, const PetscInt a_bs, Mat mat, PetscInt *a_sz, IS **a_local_is) | |||||
339 | { | |||||
340 | PetscErrorCode ierr; | |||||
341 | PetscCDIntNd *n; | |||||
342 | PetscInt lsz,ii,kk,*idxs,jj,s,e,gid; | |||||
343 | IS *is_loc,is_bcs; | |||||
344 | ||||||
345 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 345; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
346 | for (ii=kk=0; ii<ail->size; ii++) { | |||||
347 | if (ail->array[ii]) kk++; | |||||
348 | } | |||||
349 | /* count BCs */ | |||||
350 | ierr = MatGetOwnershipRange(mat, &s, &e);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),350,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
351 | for (gid=s,lsz=0; gid<e; gid++) { | |||||
352 | ierr = MatGetRow(mat,gid,&jj,0,0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),352,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
353 | if (jj<2) lsz++; | |||||
354 | ierr = MatRestoreRow(mat,gid,&jj,0,0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),354,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
355 | } | |||||
356 | if (lsz) { | |||||
357 | ierr = PetscMalloc1(a_bs*lsz, &idxs)PetscMallocA(1,PETSC_FALSE,357,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(a_bs*lsz)*sizeof(**(&idxs)),(&idxs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),357,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
358 | for (gid=s,lsz=0; gid<e; gid++) { | |||||
359 | ierr = MatGetRow(mat,gid,&jj,0,0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),359,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
360 | if (jj<2) { | |||||
361 | for (jj=0; jj<a_bs; lsz++,jj++) idxs[lsz] = a_bs*gid + jj; | |||||
362 | } | |||||
363 | ierr = MatRestoreRow(mat,gid,&jj,0,0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),363,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
364 | } | |||||
365 | ierr = ISCreateGeneral(PETSC_COMM_SELF((MPI_Comm)0x44000001), lsz, idxs, PETSC_OWN_POINTER, &is_bcs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),365,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
366 | *a_sz = kk + 1; /* out */ | |||||
367 | } else { | |||||
368 | is_bcs=0; | |||||
369 | *a_sz = kk; /* out */ | |||||
370 | } | |||||
371 | ierr = PetscMalloc1(*a_sz, &is_loc)PetscMallocA(1,PETSC_FALSE,371,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(*a_sz)*sizeof(**(&is_loc)),(&is_loc));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),371,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
372 | ||||||
373 | for (ii=kk=0; ii<ail->size; ii++) { | |||||
374 | for (lsz=0, n=ail->array[ii]; n; lsz++, n=n->next) /* void */; | |||||
375 | if (lsz) { | |||||
376 | ierr = PetscMalloc1(a_bs*lsz, &idxs)PetscMallocA(1,PETSC_FALSE,376,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(a_bs*lsz)*sizeof(**(&idxs)),(&idxs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),376,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
377 | for (lsz = 0, n=ail->array[ii]; n; n = n->next) { | |||||
378 | ierr = PetscCDIntNdGetID(n, &gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),378,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
379 | for (jj=0; jj<a_bs; lsz++,jj++) idxs[lsz] = a_bs*gid + jj; | |||||
380 | } | |||||
381 | ierr = ISCreateGeneral(PETSC_COMM_SELF((MPI_Comm)0x44000001), lsz, idxs, PETSC_OWN_POINTER, &is_loc[kk++]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),381,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
382 | } | |||||
383 | } | |||||
384 | if (is_bcs) { | |||||
385 | is_loc[kk++] = is_bcs; | |||||
386 | } | |||||
387 | if (*a_sz != kk) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"*a_sz %D != kk %D",*a_sz,kk)return PetscError(((MPI_Comm)0x44000001),387,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"*a_sz %D != kk %D",*a_sz,kk); | |||||
388 | *a_local_is = is_loc; /* out */ | |||||
389 | ||||||
390 | 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); | |||||
391 | } | |||||
392 | ||||||
393 | /* ********************************************************************** */ | |||||
394 | /* edge for priority queue */ | |||||
395 | typedef struct edge_tag { | |||||
396 | PetscReal weight; | |||||
397 | PetscInt lid0,gid1,cpid1; | |||||
398 | } Edge; | |||||
399 | ||||||
400 | static int gamg_hem_compare(const void *a, const void *b) | |||||
401 | { | |||||
402 | PetscReal va = ((Edge*)a)->weight, vb = ((Edge*)b)->weight; | |||||
403 | return (va < vb) ? 1 : (va == vb) ? 0 : -1; /* 0 for equal */ | |||||
404 | } | |||||
405 | ||||||
406 | /* -------------------------------------------------------------------------- */ | |||||
407 | /* | |||||
408 | heavyEdgeMatchAgg - parallel heavy edge matching (HEM). MatAIJ specific!!! | |||||
409 | ||||||
410 | Input Parameter: | |||||
411 | . perm - permutation | |||||
412 | . a_Gmat - glabal matrix of graph (data not defined) | |||||
413 | ||||||
414 | Output Parameter: | |||||
415 | . a_locals_llist - array of list of local nodes rooted at local node | |||||
416 | */ | |||||
417 | static PetscErrorCode heavyEdgeMatchAgg(IS perm,Mat a_Gmat,PetscCoarsenData **a_locals_llist) | |||||
418 | { | |||||
419 | PetscErrorCode ierr; | |||||
420 | PetscBool isMPI; | |||||
421 | MPI_Comm comm; | |||||
422 | PetscInt sub_it,kk,n,ix,*idx,*ii,iter,Iend,my0; | |||||
423 | PetscMPIInt rank,size; | |||||
424 | const PetscInt nloc = a_Gmat->rmap->n,n_iter=6; /* need to figure out how to stop this */ | |||||
425 | PetscInt *lid_cprowID,*lid_gid; | |||||
426 | PetscBool *lid_matched; | |||||
427 | Mat_SeqAIJ *matA, *matB=0; | |||||
428 | Mat_MPIAIJ *mpimat =0; | |||||
429 | PetscScalar one =1.; | |||||
430 | PetscCoarsenData *agg_llists = NULL((void*)0),*deleted_list = NULL((void*)0); | |||||
431 | Mat cMat,tMat,P; | |||||
432 | MatScalar *ap; | |||||
433 | PetscMPIInt tag1,tag2; | |||||
434 | ||||||
435 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 435; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
436 | ierr = PetscObjectGetComm((PetscObject)a_Gmat,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),436,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
437 | ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),437,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
438 | ierr = MPI_Comm_size(comm, &size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),438,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
439 | ierr = MatGetOwnershipRange(a_Gmat, &my0, &Iend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),439,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
440 | ierr = PetscCommGetNewTag(comm, &tag1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),440,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
441 | ierr = PetscCommGetNewTag(comm, &tag2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),441,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
442 | ||||||
443 | ierr = PetscMalloc1(nloc, &lid_gid)PetscMallocA(1,PETSC_FALSE,443,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(nloc)*sizeof(**(&lid_gid)),(&lid_gid));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),443,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* explicit array needed */ | |||||
444 | ierr = PetscMalloc1(nloc, &lid_cprowID)PetscMallocA(1,PETSC_FALSE,444,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(nloc)*sizeof(**(&lid_cprowID)),(&lid_cprowID ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),444,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
445 | ierr = PetscMalloc1(nloc, &lid_matched)PetscMallocA(1,PETSC_FALSE,445,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(nloc)*sizeof(**(&lid_matched)),(&lid_matched ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),445,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
446 | ||||||
447 | ierr = PetscCDCreate(nloc, &agg_llists);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),447,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
448 | /* ierr = PetscCDSetChuckSize(agg_llists, nloc+1);CHKERRQ(ierr); */ | |||||
449 | *a_locals_llist = agg_llists; | |||||
450 | ierr = PetscCDCreate(size, &deleted_list);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),450,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
451 | ierr = PetscCDSetChuckSize(deleted_list, 100);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),451,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
452 | /* setup 'lid_gid' for scatters and add self to all lists */ | |||||
453 | for (kk=0; kk<nloc; kk++) { | |||||
| ||||||
454 | lid_gid[kk] = kk + my0; | |||||
455 | ierr = PetscCDAppendID(agg_llists, kk, my0+kk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),455,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
456 | } | |||||
457 | ||||||
458 | /* make a copy of the graph, this gets destroyed in iterates */ | |||||
459 | ierr = MatDuplicate(a_Gmat,MAT_COPY_VALUES,&cMat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),459,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
460 | ierr = PetscObjectTypeCompare((PetscObject)a_Gmat, MATMPIAIJ"mpiaij", &isMPI);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),460,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
461 | iter = 0; | |||||
462 | while (iter++ < n_iter) { | |||||
463 | PetscScalar *cpcol_gid,*cpcol_max_ew,*cpcol_max_pe,*lid_max_ew; | |||||
464 | PetscBool *cpcol_matched; | |||||
465 | PetscMPIInt *cpcol_pe,proc; | |||||
466 | Vec locMaxEdge,locMaxPE,ghostMaxEdge,ghostMaxPE; | |||||
467 | PetscInt nEdges,n_nz_row,jj; | |||||
468 | Edge *Edges; | |||||
469 | PetscInt gid; | |||||
470 | const PetscInt *perm_ix, n_sub_its = 120; | |||||
471 | ||||||
472 | /* get submatrices of cMat */ | |||||
473 | if (isMPI) { | |||||
474 | mpimat = (Mat_MPIAIJ*)cMat->data; | |||||
475 | matA = (Mat_SeqAIJ*)mpimat->A->data; | |||||
476 | matB = (Mat_SeqAIJ*)mpimat->B->data; | |||||
477 | if (!matB->compressedrow.use) { | |||||
478 | /* force construction of compressed row data structure since code below requires it */ | |||||
479 | ierr = MatCheckCompressedRow(mpimat->B,matB->nonzerorowcnt,&matB->compressedrow,matB->i,mpimat->B->rmap->n,-1.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),479,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
480 | } | |||||
481 | } else { | |||||
482 | matA = (Mat_SeqAIJ*)cMat->data; | |||||
483 | } | |||||
484 | ||||||
485 | /* set max edge on nodes */ | |||||
486 | ierr = MatCreateVecs(cMat, &locMaxEdge, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),486,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
487 | ierr = MatCreateVecs(cMat, &locMaxPE, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),487,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
488 | ||||||
489 | /* get 'cpcol_pe' & 'cpcol_gid' & init. 'cpcol_matched' using 'mpimat->lvec' */ | |||||
490 | if (mpimat) { | |||||
491 | Vec vec; | |||||
492 | PetscScalar vval; | |||||
493 | ||||||
494 | ierr = MatCreateVecs(cMat, &vec, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),494,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
495 | /* cpcol_pe */ | |||||
496 | vval = (PetscScalar)(rank); | |||||
497 | for (kk=0,gid=my0; kk<nloc; kk++,gid++) { | |||||
498 | ierr = VecSetValues(vec, 1, &gid, &vval, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),498,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* set with GID */ | |||||
499 | } | |||||
500 | ierr = VecAssemblyBegin(vec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),500,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
501 | ierr = VecAssemblyEnd(vec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),501,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
502 | ierr = VecScatterBegin(mpimat->Mvctx,vec,mpimat->lvec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),502,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
503 | ierr = VecScatterEnd(mpimat->Mvctx,vec,mpimat->lvec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),503,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
504 | ierr = VecGetArray(mpimat->lvec, &cpcol_gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),504,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* get proc ID in 'cpcol_gid' */ | |||||
505 | ierr = VecGetLocalSize(mpimat->lvec, &n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),505,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
506 | ierr = PetscMalloc1(n, &cpcol_pe)PetscMallocA(1,PETSC_FALSE,506,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(n)*sizeof(**(&cpcol_pe)),(&cpcol_pe));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),506,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
507 | for (kk=0; kk<n; kk++) cpcol_pe[kk] = (PetscMPIInt)PetscRealPart(cpcol_gid[kk])(cpcol_gid[kk]); | |||||
508 | ierr = VecRestoreArray(mpimat->lvec, &cpcol_gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),508,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
509 | ||||||
510 | /* cpcol_gid */ | |||||
511 | for (kk=0,gid=my0; kk<nloc; kk++,gid++) { | |||||
512 | vval = (PetscScalar)(gid); | |||||
513 | ierr = VecSetValues(vec, 1, &gid, &vval, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),513,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* set with GID */ | |||||
514 | } | |||||
515 | ierr = VecAssemblyBegin(vec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),515,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
516 | ierr = VecAssemblyEnd(vec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),516,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
517 | ierr = VecScatterBegin(mpimat->Mvctx,vec,mpimat->lvec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),517,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
518 | ierr = VecScatterEnd(mpimat->Mvctx,vec,mpimat->lvec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),518,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
519 | ierr = VecDestroy(&vec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),519,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
520 | ierr = VecGetArray(mpimat->lvec, &cpcol_gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),520,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* get proc ID in 'cpcol_gid' */ | |||||
521 | ||||||
522 | /* cpcol_matched */ | |||||
523 | ierr = VecGetLocalSize(mpimat->lvec, &n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),523,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
524 | ierr = PetscMalloc1(n, &cpcol_matched)PetscMallocA(1,PETSC_FALSE,524,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(n)*sizeof(**(&cpcol_matched)),(&cpcol_matched ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),524,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
525 | for (kk=0; kk<n; kk++) cpcol_matched[kk] = PETSC_FALSE; | |||||
526 | } | |||||
527 | ||||||
528 | /* need an inverse map - locals */ | |||||
529 | for (kk=0; kk<nloc; kk++) lid_cprowID[kk] = -1; | |||||
530 | /* set index into compressed row 'lid_cprowID' */ | |||||
531 | if (matB) { | |||||
532 | for (ix=0; ix<matB->compressedrow.nrows; ix++) { | |||||
533 | lid_cprowID[matB->compressedrow.rindex[ix]] = ix; | |||||
534 | } | |||||
535 | } | |||||
536 | ||||||
537 | /* compute 'locMaxEdge' & 'locMaxPE', and create list of edges, count edges' */ | |||||
538 | for (nEdges=0,kk=0,gid=my0; kk<nloc; kk++,gid++) { | |||||
539 | PetscReal max_e = 0., tt; | |||||
540 | PetscScalar vval; | |||||
541 | PetscInt lid = kk; | |||||
542 | PetscMPIInt max_pe=rank,pe; | |||||
543 | ||||||
544 | ii = matA->i; n = ii[lid+1] - ii[lid]; idx = matA->j + ii[lid]; | |||||
545 | ap = matA->a + ii[lid]; | |||||
546 | for (jj=0; jj<n; jj++) { | |||||
547 | PetscInt lidj = idx[jj]; | |||||
548 | if (lidj != lid && PetscRealPart(ap[jj])(ap[jj]) > max_e) max_e = PetscRealPart(ap[jj])(ap[jj]); | |||||
549 | if (lidj > lid) nEdges++; | |||||
550 | } | |||||
551 | if ((ix=lid_cprowID[lid]) != -1) { /* if I have any ghost neighbors */ | |||||
552 | ii = matB->compressedrow.i; n = ii[ix+1] - ii[ix]; | |||||
553 | ap = matB->a + ii[ix]; | |||||
554 | idx = matB->j + ii[ix]; | |||||
555 | for (jj=0; jj<n; jj++) { | |||||
556 | if ((tt=PetscRealPart(ap[jj])(ap[jj])) > max_e) max_e = tt; | |||||
557 | nEdges++; | |||||
558 | if ((pe=cpcol_pe[idx[jj]]) > max_pe) max_pe = pe; | |||||
559 | } | |||||
560 | } | |||||
561 | vval = max_e; | |||||
562 | ierr = VecSetValues(locMaxEdge, 1, &gid, &vval, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),562,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
563 | ||||||
564 | vval = (PetscScalar)max_pe; | |||||
565 | ierr = VecSetValues(locMaxPE, 1, &gid, &vval, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),565,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
566 | } | |||||
567 | ierr = VecAssemblyBegin(locMaxEdge);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),567,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
568 | ierr = VecAssemblyEnd(locMaxEdge);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),568,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
569 | ierr = VecAssemblyBegin(locMaxPE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),569,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
570 | ierr = VecAssemblyEnd(locMaxPE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),570,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
571 | ||||||
572 | /* get 'cpcol_max_ew' & 'cpcol_max_pe' */ | |||||
573 | if (mpimat) { | |||||
574 | ierr = VecDuplicate(mpimat->lvec, &ghostMaxEdge);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),574,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
575 | ierr = VecScatterBegin(mpimat->Mvctx,locMaxEdge,ghostMaxEdge,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),575,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
576 | ierr = VecScatterEnd(mpimat->Mvctx,locMaxEdge,ghostMaxEdge,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),576,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
577 | ierr = VecGetArray(ghostMaxEdge, &cpcol_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),577,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
578 | ||||||
579 | ierr = VecDuplicate(mpimat->lvec, &ghostMaxPE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),579,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
580 | ierr = VecScatterBegin(mpimat->Mvctx,locMaxPE,ghostMaxPE,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),580,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
581 | ierr = VecScatterEnd(mpimat->Mvctx,locMaxPE,ghostMaxPE,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),581,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
582 | ierr = VecGetArray(ghostMaxPE, &cpcol_max_pe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),582,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
583 | } | |||||
584 | ||||||
585 | /* setup sorted list of edges */ | |||||
586 | ierr = PetscMalloc1(nEdges, &Edges)PetscMallocA(1,PETSC_FALSE,586,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(nEdges)*sizeof(**(&Edges)),(&Edges));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),586,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
587 | ierr = ISGetIndices(perm, &perm_ix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),587,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
588 | for (nEdges=n_nz_row=kk=0; kk<nloc; kk++) { | |||||
589 | PetscInt nn, lid = perm_ix[kk]; | |||||
590 | ii = matA->i; nn = n = ii[lid+1] - ii[lid]; idx = matA->j + ii[lid]; | |||||
591 | ap = matA->a + ii[lid]; | |||||
592 | for (jj=0; jj<n; jj++) { | |||||
593 | PetscInt lidj = idx[jj]; | |||||
594 | if (lidj > lid) { | |||||
595 | Edges[nEdges].lid0 = lid; | |||||
596 | Edges[nEdges].gid1 = lidj + my0; | |||||
597 | Edges[nEdges].cpid1 = -1; | |||||
598 | Edges[nEdges].weight = PetscRealPart(ap[jj])(ap[jj]); | |||||
599 | nEdges++; | |||||
600 | } | |||||
601 | } | |||||
602 | if ((ix=lid_cprowID[lid]) != -1) { /* if I have any ghost neighbors */ | |||||
603 | ii = matB->compressedrow.i; n = ii[ix+1] - ii[ix]; | |||||
604 | ap = matB->a + ii[ix]; | |||||
605 | idx = matB->j + ii[ix]; | |||||
606 | nn += n; | |||||
607 | for (jj=0; jj<n; jj++) { | |||||
608 | Edges[nEdges].lid0 = lid; | |||||
609 | Edges[nEdges].gid1 = (PetscInt)PetscRealPart(cpcol_gid[idx[jj]])(cpcol_gid[idx[jj]]); | |||||
610 | Edges[nEdges].cpid1 = idx[jj]; | |||||
611 | Edges[nEdges].weight = PetscRealPart(ap[jj])(ap[jj]); | |||||
612 | nEdges++; | |||||
613 | } | |||||
614 | } | |||||
615 | if (nn > 1) n_nz_row++; | |||||
616 | else if (iter == 1) { | |||||
617 | /* should select this because it is technically in the MIS but lets not */ | |||||
618 | ierr = PetscCDRemoveAll(agg_llists, lid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),618,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
619 | } | |||||
620 | } | |||||
621 | ierr = ISRestoreIndices(perm,&perm_ix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),621,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
622 | ||||||
623 | qsort(Edges, nEdges, sizeof(Edge), gamg_hem_compare); | |||||
624 | ||||||
625 | /* projection matrix */ | |||||
626 | ierr = MatCreateAIJ(comm, nloc, nloc, PETSC_DETERMINE-1, PETSC_DETERMINE-1, 1, 0, 1, 0, &P);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),626,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
627 | ||||||
628 | /* clear matched flags */ | |||||
629 | for (kk=0; kk<nloc; kk++) lid_matched[kk] = PETSC_FALSE; | |||||
630 | /* process - communicate - process */ | |||||
631 | for (sub_it=0; sub_it<n_sub_its; sub_it++) { | |||||
632 | PetscInt nactive_edges; | |||||
633 | ||||||
634 | ierr = VecGetArray(locMaxEdge, &lid_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),634,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
635 | for (kk=nactive_edges=0; kk<nEdges; kk++) { | |||||
636 | /* HEM */ | |||||
637 | const Edge *e = &Edges[kk]; | |||||
638 | const PetscInt lid0 =e->lid0,gid1=e->gid1,cpid1=e->cpid1,gid0=lid0+my0,lid1=gid1-my0; | |||||
639 | PetscBool isOK = PETSC_TRUE; | |||||
640 | ||||||
641 | /* skip if either (local) vertex is done already */ | |||||
642 | if (lid_matched[lid0] || (gid1>=my0 && gid1<Iend && lid_matched[gid1-my0])) continue; | |||||
643 | ||||||
644 | /* skip if ghost vertex is done */ | |||||
645 | if (cpid1 != -1 && cpcol_matched[cpid1]) continue; | |||||
646 | ||||||
647 | nactive_edges++; | |||||
648 | /* skip if I have a bigger edge someplace (lid_max_ew gets updated) */ | |||||
649 | if (PetscRealPart(lid_max_ew[lid0])(lid_max_ew[lid0]) > e->weight + PETSC_SMALL1.e-10) continue; | |||||
650 | ||||||
651 | if (cpid1 == -1) { | |||||
652 | if (PetscRealPart(lid_max_ew[lid1])(lid_max_ew[lid1]) > e->weight + PETSC_SMALL1.e-10) continue; | |||||
653 | } else { | |||||
654 | /* see if edge might get matched on other proc */ | |||||
655 | PetscReal g_max_e = PetscRealPart(cpcol_max_ew[cpid1])(cpcol_max_ew[cpid1]); | |||||
656 | if (g_max_e > e->weight + PETSC_SMALL1.e-10) continue; | |||||
657 | else if (e->weight > g_max_e - PETSC_SMALL1.e-10 && (PetscMPIInt)PetscRealPart(cpcol_max_pe[cpid1])(cpcol_max_pe[cpid1]) > rank) { | |||||
658 | /* check for max_e == to this edge and larger processor that will deal with this */ | |||||
659 | continue; | |||||
660 | } | |||||
661 | } | |||||
662 | ||||||
663 | /* check ghost for v0 */ | |||||
664 | if (isOK) { | |||||
665 | PetscReal max_e,ew; | |||||
666 | if ((ix=lid_cprowID[lid0]) != -1) { /* if I have any ghost neighbors */ | |||||
667 | ii = matB->compressedrow.i; n = ii[ix+1] - ii[ix]; | |||||
668 | ap = matB->a + ii[ix]; | |||||
669 | idx = matB->j + ii[ix]; | |||||
670 | for (jj=0; jj<n && isOK; jj++) { | |||||
671 | PetscInt lidj = idx[jj]; | |||||
672 | if (cpcol_matched[lidj]) continue; | |||||
673 | ew = PetscRealPart(ap[jj])(ap[jj]); max_e = PetscRealPart(cpcol_max_ew[lidj])(cpcol_max_ew[lidj]); | |||||
674 | /* check for max_e == to this edge and larger processor that will deal with this */ | |||||
675 | if (ew > max_e - PETSC_SMALL1.e-10 && ew > PetscRealPart(lid_max_ew[lid0])(lid_max_ew[lid0]) - PETSC_SMALL1.e-10 && (PetscMPIInt)PetscRealPart(cpcol_max_pe[lidj])(cpcol_max_pe[lidj]) > rank) { | |||||
676 | isOK = PETSC_FALSE; | |||||
677 | } | |||||
678 | } | |||||
679 | } | |||||
680 | ||||||
681 | /* for v1 */ | |||||
682 | if (cpid1 == -1 && isOK) { | |||||
683 | if ((ix=lid_cprowID[lid1]) != -1) { /* if I have any ghost neighbors */ | |||||
684 | ii = matB->compressedrow.i; n = ii[ix+1] - ii[ix]; | |||||
685 | ap = matB->a + ii[ix]; | |||||
686 | idx = matB->j + ii[ix]; | |||||
687 | for (jj=0; jj<n && isOK; jj++) { | |||||
688 | PetscInt lidj = idx[jj]; | |||||
689 | if (cpcol_matched[lidj]) continue; | |||||
690 | ew = PetscRealPart(ap[jj])(ap[jj]); max_e = PetscRealPart(cpcol_max_ew[lidj])(cpcol_max_ew[lidj]); | |||||
691 | /* check for max_e == to this edge and larger processor that will deal with this */ | |||||
692 | if (ew > max_e - PETSC_SMALL1.e-10 && ew > PetscRealPart(lid_max_ew[lid1])(lid_max_ew[lid1]) - PETSC_SMALL1.e-10 && (PetscMPIInt)PetscRealPart(cpcol_max_pe[lidj])(cpcol_max_pe[lidj]) > rank) { | |||||
693 | isOK = PETSC_FALSE; | |||||
694 | } | |||||
695 | } | |||||
696 | } | |||||
697 | } | |||||
698 | } | |||||
699 | ||||||
700 | /* do it */ | |||||
701 | if (isOK) { | |||||
702 | if (cpid1 == -1) { | |||||
703 | lid_matched[lid1] = PETSC_TRUE; /* keep track of what we've done this round */ | |||||
704 | ierr = PetscCDAppendRemove(agg_llists, lid0, lid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),704,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
705 | } else if (sub_it != n_sub_its-1) { | |||||
706 | /* add gid1 to list of ghost deleted by me -- I need their children */ | |||||
707 | proc = cpcol_pe[cpid1]; | |||||
708 | ||||||
709 | cpcol_matched[cpid1] = PETSC_TRUE; /* messing with VecGetArray array -- needed??? */ | |||||
710 | ||||||
711 | ierr = PetscCDAppendID(deleted_list, proc, cpid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),711,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* cache to send messages */ | |||||
712 | ierr = PetscCDAppendID(deleted_list, proc, lid0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),712,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
713 | } else continue; | |||||
714 | ||||||
715 | lid_matched[lid0] = PETSC_TRUE; /* keep track of what we've done this round */ | |||||
716 | /* set projection */ | |||||
717 | ierr = MatSetValues(P,1,&gid0,1,&gid0,&one,INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),717,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
718 | ierr = MatSetValues(P,1,&gid1,1,&gid0,&one,INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),718,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
719 | } /* matched */ | |||||
720 | } /* edge loop */ | |||||
721 | ||||||
722 | /* deal with deleted ghost on first pass */ | |||||
723 | if (size>1 && sub_it != n_sub_its-1) { | |||||
724 | #define REQ_BF_SIZE100 100 | |||||
725 | PetscCDIntNd *pos; | |||||
726 | PetscBool ise = PETSC_FALSE; | |||||
727 | PetscInt nSend1, **sbuffs1,nSend2; | |||||
728 | MPI_Request *sreqs2[REQ_BF_SIZE100],*rreqs2[REQ_BF_SIZE100]; | |||||
729 | MPI_Status status; | |||||
730 | ||||||
731 | /* send request */ | |||||
732 | for (proc=0,nSend1=0; proc<size; proc++) { | |||||
733 | ierr = PetscCDEmptyAt(deleted_list,proc,&ise);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),733,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
734 | if (!ise) nSend1++; | |||||
735 | } | |||||
736 | ierr = PetscMalloc1(nSend1, &sbuffs1)PetscMallocA(1,PETSC_FALSE,736,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(nSend1)*sizeof(**(&sbuffs1)),(&sbuffs1));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),736,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
737 | for (proc=0,nSend1=0; proc<size; proc++) { | |||||
738 | /* count ghosts */ | |||||
739 | ierr = PetscCDSizeAt(deleted_list,proc,&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),739,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
740 | if (n>0) { | |||||
741 | #define CHUNCK_SIZE100 100 | |||||
742 | PetscInt *sbuff,*pt; | |||||
743 | MPI_Request *request; | |||||
744 | n /= 2; | |||||
745 | ierr = PetscMalloc1(2 + 2*n + n*CHUNCK_SIZE + 2, &sbuff)PetscMallocA(1,PETSC_FALSE,745,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(2 + 2*n + n*100 + 2)*sizeof(**(&sbuff)),(&sbuff ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),745,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
746 | /* save requests */ | |||||
747 | sbuffs1[nSend1] = sbuff; | |||||
748 | request = (MPI_Request*)sbuff; | |||||
749 | sbuff = pt = (PetscInt*)(request+1); | |||||
750 | *pt++ = n; *pt++ = rank; | |||||
751 | ||||||
752 | ierr = PetscCDGetHeadPos(deleted_list,proc,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),752,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
753 | while (pos) { | |||||
754 | PetscInt lid0, cpid, gid; | |||||
755 | ierr = PetscCDIntNdGetID(pos, &cpid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),755,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
756 | gid = (PetscInt)PetscRealPart(cpcol_gid[cpid])(cpcol_gid[cpid]); | |||||
| ||||||
757 | ierr = PetscCDGetNextPos(deleted_list,proc,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),757,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
758 | ierr = PetscCDIntNdGetID(pos, &lid0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),758,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
759 | ierr = PetscCDGetNextPos(deleted_list,proc,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),759,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
760 | *pt++ = gid; *pt++ = lid0; | |||||
761 | } | |||||
762 | /* send request tag1 [n, proc, n*[gid1,lid0] ] */ | |||||
763 | ierr = MPI_Isend(sbuff, 2*n+2, MPIU_INT, proc, tag1, comm, request)((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len ),(2*n+2),(((MPI_Datatype)0x4c000405))) || MPI_Isend((sbuff), (2*n+2),(((MPI_Datatype)0x4c000405)),(proc),(tag1),(comm),(request )));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),763,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
764 | /* post recieve */ | |||||
765 | request = (MPI_Request*)pt; | |||||
766 | rreqs2[nSend1] = request; /* cache recv request */ | |||||
767 | pt = (PetscInt*)(request+1); | |||||
768 | ierr = MPI_Irecv(pt, n*CHUNCK_SIZE, MPIU_INT, proc, tag2, comm, request)((petsc_irecv_ct++,0) || PetscMPITypeSize(&(petsc_irecv_len ),(n*100),(((MPI_Datatype)0x4c000405))) || MPI_Irecv((pt),(n* 100),(((MPI_Datatype)0x4c000405)),(proc),(tag2),(comm),(request )));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),768,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
769 | /* clear list */ | |||||
770 | ierr = PetscCDRemoveAll(deleted_list, proc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),770,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
771 | nSend1++; | |||||
772 | } | |||||
773 | } | |||||
774 | /* recieve requests, send response, clear lists */ | |||||
775 | kk = nactive_edges; | |||||
776 | ierr = MPIU_Allreduce(&kk,&nactive_edges,1,MPIU_INT,MPI_SUM,comm)(PetscAllreduceBarrierCheck(comm,1,776,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Allreduce((&kk),(&nactive_edges),(1),(((MPI_Datatype )0x4c000405)),((MPI_Op)(0x58000003)),(comm))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),776,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* not correct syncronization and global */ | |||||
777 | nSend2 = 0; | |||||
778 | while (1) { | |||||
779 | #define BF_SZ10000 10000 | |||||
780 | PetscMPIInt flag,count; | |||||
781 | PetscInt rbuff[BF_SZ10000],*pt,*pt2,*pt3,count2,*sbuff,count3; | |||||
782 | MPI_Request *request; | |||||
783 | ||||||
784 | ierr = MPI_Iprobe(MPI_ANY_SOURCE(-2), tag1, comm, &flag, &status);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),784,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
785 | if (!flag) break; | |||||
786 | ierr = MPI_Get_count(&status, MPIU_INT((MPI_Datatype)0x4c000405), &count);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),786,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
787 | if (count > BF_SZ10000) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"buffer too small for recieve: %d",count)return PetscError(((MPI_Comm)0x44000001),787,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,56,PETSC_ERROR_INITIAL,"buffer too small for recieve: %d",count ); | |||||
788 | proc = status.MPI_SOURCE; | |||||
789 | /* recieve request tag1 [n, proc, n*[gid1,lid0] ] */ | |||||
790 | ierr = MPI_Recv(rbuff, count, MPIU_INT, proc, tag1, comm, &status)((petsc_recv_ct++,0) || PetscMPITypeSize((&petsc_recv_len ),(count),(((MPI_Datatype)0x4c000405))) || MPI_Recv((rbuff),( count),(((MPI_Datatype)0x4c000405)),(proc),(tag1),(comm),(& status)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),790,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
791 | /* count sends */ | |||||
792 | pt = rbuff; count3 = count2 = 0; | |||||
793 | n = *pt++; kk = *pt++; | |||||
794 | while (n--) { | |||||
795 | PetscInt gid1=*pt++, lid1=gid1-my0; kk=*pt++; | |||||
796 | if (lid_matched[lid1]) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Recieved deleted gid %D, deleted by (lid) %D from proc %D\n",sub_it,gid1,kk)return PetscError(((MPI_Comm)0x44000001),796,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,77,PETSC_ERROR_INITIAL,"Recieved deleted gid %D, deleted by (lid) %D from proc %D\n" ,sub_it,gid1,kk); | |||||
797 | lid_matched[lid1] = PETSC_TRUE; /* keep track of what we've done this round */ | |||||
798 | ierr = PetscCDSizeAt(agg_llists, lid1, &kk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),798,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
799 | count2 += kk + 2; | |||||
800 | count3++; /* number of verts requested (n) */ | |||||
801 | } | |||||
802 | if (count2 > count3*CHUNCK_SIZE100) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Irecv will be too small: %D",count2)return PetscError(((MPI_Comm)0x44000001),802,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,56,PETSC_ERROR_INITIAL,"Irecv will be too small: %D",count2); | |||||
803 | /* send tag2 *[lid0, n, n*[gid] ] */ | |||||
804 | ierr = PetscMalloc(count2*sizeof(PetscInt) + sizeof(MPI_Request), &sbuff)((*PetscTrMalloc)((count2*sizeof(PetscInt) + sizeof(MPI_Request )),PETSC_FALSE,804,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(void**)(&sbuff)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),804,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
805 | request = (MPI_Request*)sbuff; | |||||
806 | sreqs2[nSend2++] = request; /* cache request */ | |||||
807 | if (nSend2==REQ_BF_SIZE100) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"buffer too small for requests: %D",nSend2)return PetscError(((MPI_Comm)0x44000001),807,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,56,PETSC_ERROR_INITIAL,"buffer too small for requests: %D",nSend2 ); | |||||
808 | pt2 = sbuff = (PetscInt*)(request+1); | |||||
809 | pt = rbuff; | |||||
810 | n = *pt++; kk = *pt++; | |||||
811 | while (n--) { | |||||
812 | /* read [n, proc, n*[gid1,lid0] */ | |||||
813 | PetscInt gid1=*pt++, lid1=gid1-my0, lid0=*pt++; | |||||
814 | /* write [lid0, n, n*[gid] ] */ | |||||
815 | *pt2++ = lid0; | |||||
816 | pt3 = pt2++; /* save pointer for later */ | |||||
817 | ierr = PetscCDGetHeadPos(agg_llists,lid1,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),817,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
818 | while (pos) { | |||||
819 | PetscInt gid; | |||||
820 | ierr = PetscCDIntNdGetID(pos, &gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),820,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
821 | ierr = PetscCDGetNextPos(agg_llists,lid1,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),821,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
822 | *pt2++ = gid; | |||||
823 | } | |||||
824 | *pt3 = (pt2-pt3)-1; | |||||
825 | /* clear list */ | |||||
826 | ierr = PetscCDRemoveAll(agg_llists, lid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),826,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
827 | } | |||||
828 | /* send requested data tag2 *[lid0, n, n*[gid1] ] */ | |||||
829 | ierr = MPI_Isend(sbuff, count2, MPIU_INT, proc, tag2, comm, request)((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len ),(count2),(((MPI_Datatype)0x4c000405))) || MPI_Isend((sbuff) ,(count2),(((MPI_Datatype)0x4c000405)),(proc),(tag2),(comm),( request)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),829,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
830 | } | |||||
831 | ||||||
832 | /* recieve tag2 *[lid0, n, n*[gid] ] */ | |||||
833 | for (kk=0; kk<nSend1; kk++) { | |||||
834 | PetscMPIInt count; | |||||
835 | MPI_Request *request; | |||||
836 | PetscInt *pt, *pt2; | |||||
837 | ||||||
838 | request = rreqs2[kk]; /* no need to free -- buffer is in 'sbuffs1' */ | |||||
839 | ierr = MPI_Wait(request, &status)((petsc_wait_ct++,petsc_sum_of_waits_ct++,0) || MPI_Wait((request ),(&status)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),839,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
840 | ierr = MPI_Get_count(&status, MPIU_INT((MPI_Datatype)0x4c000405), &count);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),840,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
841 | pt = pt2 = (PetscInt*)(request+1); | |||||
842 | while (pt-pt2 < count) { | |||||
843 | PetscInt lid0 = *pt++, n = *pt++; | |||||
844 | while (n--) { | |||||
845 | PetscInt gid1 = *pt++; | |||||
846 | ierr = PetscCDAppendID(agg_llists, lid0, gid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),846,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
847 | } | |||||
848 | } | |||||
849 | } | |||||
850 | ||||||
851 | /* wait for tag1 isends */ | |||||
852 | while (nSend1--) { | |||||
853 | MPI_Request *request; | |||||
854 | request = (MPI_Request*)sbuffs1[nSend1]; | |||||
855 | ierr = MPI_Wait(request, &status)((petsc_wait_ct++,petsc_sum_of_waits_ct++,0) || MPI_Wait((request ),(&status)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),855,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
856 | ierr = PetscFree(request)((*PetscTrFree)((void*)(request),856,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((request) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),856,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
857 | } | |||||
858 | ierr = PetscFree(sbuffs1)((*PetscTrFree)((void*)(sbuffs1),858,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((sbuffs1) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),858,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
859 | ||||||
860 | /* wait for tag2 isends */ | |||||
861 | while (nSend2--) { | |||||
862 | MPI_Request *request = sreqs2[nSend2]; | |||||
863 | ierr = MPI_Wait(request, &status)((petsc_wait_ct++,petsc_sum_of_waits_ct++,0) || MPI_Wait((request ),(&status)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),863,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
864 | ierr = PetscFree(request)((*PetscTrFree)((void*)(request),864,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((request) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),864,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
865 | } | |||||
866 | ||||||
867 | ierr = VecRestoreArray(ghostMaxEdge, &cpcol_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),867,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
868 | ierr = VecRestoreArray(ghostMaxPE, &cpcol_max_pe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),868,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
869 | ||||||
870 | /* get 'cpcol_matched' - use locMaxPE, ghostMaxEdge, cpcol_max_ew */ | |||||
871 | for (kk=0,gid=my0; kk<nloc; kk++,gid++) { | |||||
872 | PetscScalar vval = lid_matched[kk] ? 1.0 : 0.0; | |||||
873 | ierr = VecSetValues(locMaxPE, 1, &gid, &vval, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),873,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* set with GID */ | |||||
874 | } | |||||
875 | ierr = VecAssemblyBegin(locMaxPE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),875,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
876 | ierr = VecAssemblyEnd(locMaxPE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),876,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
877 | ierr = VecScatterBegin(mpimat->Mvctx,locMaxPE,ghostMaxEdge,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),877,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
878 | ierr = VecScatterEnd(mpimat->Mvctx,locMaxPE,ghostMaxEdge,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),878,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
879 | ierr = VecGetArray(ghostMaxEdge, &cpcol_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),879,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
880 | ierr = VecGetLocalSize(mpimat->lvec, &n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),880,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
881 | for (kk=0; kk<n; kk++) { | |||||
882 | cpcol_matched[kk] = (PetscBool)(PetscRealPart(cpcol_max_ew[kk])(cpcol_max_ew[kk]) != 0.0); | |||||
883 | } | |||||
884 | ierr = VecRestoreArray(ghostMaxEdge, &cpcol_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),884,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
885 | } /* size > 1 */ | |||||
886 | ||||||
887 | /* compute 'locMaxEdge' */ | |||||
888 | ierr = VecRestoreArray(locMaxEdge, &lid_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),888,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
889 | for (kk=0,gid=my0; kk<nloc; kk++,gid++) { | |||||
890 | PetscReal max_e = 0.,tt; | |||||
891 | PetscScalar vval; | |||||
892 | PetscInt lid = kk; | |||||
893 | ||||||
894 | if (lid_matched[lid]) vval = 0.; | |||||
895 | else { | |||||
896 | ii = matA->i; n = ii[lid+1] - ii[lid]; idx = matA->j + ii[lid]; | |||||
897 | ap = matA->a + ii[lid]; | |||||
898 | for (jj=0; jj<n; jj++) { | |||||
899 | PetscInt lidj = idx[jj]; | |||||
900 | if (lid_matched[lidj]) continue; /* this is new - can change local max */ | |||||
901 | if (lidj != lid && PetscRealPart(ap[jj])(ap[jj]) > max_e) max_e = PetscRealPart(ap[jj])(ap[jj]); | |||||
902 | } | |||||
903 | if (lid_cprowID && (ix=lid_cprowID[lid]) != -1) { /* if I have any ghost neighbors */ | |||||
904 | ii = matB->compressedrow.i; n = ii[ix+1] - ii[ix]; | |||||
905 | ap = matB->a + ii[ix]; | |||||
906 | idx = matB->j + ii[ix]; | |||||
907 | for (jj=0; jj<n; jj++) { | |||||
908 | PetscInt lidj = idx[jj]; | |||||
909 | if (cpcol_matched[lidj]) continue; | |||||
910 | if ((tt=PetscRealPart(ap[jj])(ap[jj])) > max_e) max_e = tt; | |||||
911 | } | |||||
912 | } | |||||
913 | } | |||||
914 | vval = (PetscScalar)max_e; | |||||
915 | ierr = VecSetValues(locMaxEdge, 1, &gid, &vval, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),915,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* set with GID */ | |||||
916 | } | |||||
917 | ierr = VecAssemblyBegin(locMaxEdge);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),917,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
918 | ierr = VecAssemblyEnd(locMaxEdge);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),918,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
919 | ||||||
920 | if (size>1 && sub_it != n_sub_its-1) { | |||||
921 | /* compute 'cpcol_max_ew' */ | |||||
922 | ierr = VecScatterBegin(mpimat->Mvctx,locMaxEdge,ghostMaxEdge,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),922,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
923 | ierr = VecScatterEnd(mpimat->Mvctx,locMaxEdge,ghostMaxEdge,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),923,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
924 | ierr = VecGetArray(ghostMaxEdge, &cpcol_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),924,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
925 | ierr = VecGetArray(locMaxEdge, &lid_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),925,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
926 | ||||||
927 | /* compute 'cpcol_max_pe' */ | |||||
928 | for (kk=0,gid=my0; kk<nloc; kk++,gid++) { | |||||
929 | PetscInt lid = kk; | |||||
930 | PetscReal ew,v1_max_e,v0_max_e=PetscRealPart(lid_max_ew[lid])(lid_max_ew[lid]); | |||||
931 | PetscScalar vval; | |||||
932 | PetscMPIInt max_pe=rank,pe; | |||||
933 | ||||||
934 | if (lid_matched[lid]) vval = (PetscScalar)rank; | |||||
935 | else if ((ix=lid_cprowID[lid]) != -1) { /* if I have any ghost neighbors */ | |||||
936 | ii = matB->compressedrow.i; n = ii[ix+1] - ii[ix]; | |||||
937 | ap = matB->a + ii[ix]; | |||||
938 | idx = matB->j + ii[ix]; | |||||
939 | for (jj=0; jj<n; jj++) { | |||||
940 | PetscInt lidj = idx[jj]; | |||||
941 | if (cpcol_matched[lidj]) continue; | |||||
942 | ew = PetscRealPart(ap[jj])(ap[jj]); v1_max_e = PetscRealPart(cpcol_max_ew[lidj])(cpcol_max_ew[lidj]); | |||||
943 | /* get max pe that has a max_e == to this edge w */ | |||||
944 | if ((pe=cpcol_pe[idx[jj]]) > max_pe && ew > v1_max_e - PETSC_SMALL1.e-10 && ew > v0_max_e - PETSC_SMALL1.e-10) max_pe = pe; | |||||
945 | } | |||||
946 | vval = (PetscScalar)max_pe; | |||||
947 | } | |||||
948 | ierr = VecSetValues(locMaxPE, 1, &gid, &vval, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),948,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
949 | } | |||||
950 | ierr = VecAssemblyBegin(locMaxPE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),950,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
951 | ierr = VecAssemblyEnd(locMaxPE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),951,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
952 | ||||||
953 | ierr = VecScatterBegin(mpimat->Mvctx,locMaxPE,ghostMaxPE,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),953,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
954 | ierr = VecScatterEnd(mpimat->Mvctx,locMaxPE,ghostMaxPE,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),954,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
955 | ierr = VecGetArray(ghostMaxPE, &cpcol_max_pe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),955,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
956 | ierr = VecRestoreArray(locMaxEdge, &lid_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),956,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
957 | } /* deal with deleted ghost */ | |||||
958 | ierr = PetscInfo3(a_Gmat,"\t %D.%D: %D active edges.\n",iter,sub_it,nactive_edges)PetscInfo_Private(__func__,a_Gmat,"\t %D.%D: %D active edges.\n" ,iter,sub_it,nactive_edges);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),958,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
959 | if (!nactive_edges) break; | |||||
960 | } /* sub_it loop */ | |||||
961 | ||||||
962 | /* clean up iteration */ | |||||
963 | ierr = PetscFree(Edges)((*PetscTrFree)((void*)(Edges),963,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((Edges) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),963,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
964 | if (mpimat) { | |||||
965 | ierr = VecRestoreArray(ghostMaxEdge, &cpcol_max_ew);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),965,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
966 | ierr = VecDestroy(&ghostMaxEdge);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),966,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
967 | ierr = VecRestoreArray(ghostMaxPE, &cpcol_max_pe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),967,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
968 | ierr = VecDestroy(&ghostMaxPE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),968,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
969 | ierr = PetscFree(cpcol_pe)((*PetscTrFree)((void*)(cpcol_pe),969,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((cpcol_pe) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),969,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
970 | ierr = PetscFree(cpcol_matched)((*PetscTrFree)((void*)(cpcol_matched),970,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((cpcol_matched) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),970,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
971 | } | |||||
972 | ||||||
973 | ierr = VecDestroy(&locMaxEdge);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),973,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
974 | ierr = VecDestroy(&locMaxPE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),974,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
975 | ||||||
976 | if (mpimat) { | |||||
977 | ierr = VecRestoreArray(mpimat->lvec, &cpcol_gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),977,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
978 | } | |||||
979 | ||||||
980 | /* create next G if needed */ | |||||
981 | if (iter == n_iter) { /* hard wired test - need to look at full surrounded nodes or something */ | |||||
982 | ierr = MatDestroy(&P);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),982,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
983 | ierr = MatDestroy(&cMat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),983,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
984 | break; | |||||
985 | } else { | |||||
986 | Vec diag; | |||||
987 | /* add identity for unmatched vertices so they stay alive */ | |||||
988 | for (kk=0,gid=my0; kk<nloc; kk++,gid++) { | |||||
989 | if (!lid_matched[kk]) { | |||||
990 | gid = kk+my0; | |||||
991 | ierr = MatGetRow(cMat,gid,&n,0,0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),991,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
992 | if (n>1) { | |||||
993 | ierr = MatSetValues(P,1,&gid,1,&gid,&one,INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),993,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
994 | } | |||||
995 | ierr = MatRestoreRow(cMat,gid,&n,0,0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),995,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
996 | } | |||||
997 | } | |||||
998 | ierr = MatAssemblyBegin(P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),998,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
999 | ierr = MatAssemblyEnd(P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),999,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1000 | ||||||
1001 | /* project to make new graph with colapsed edges */ | |||||
1002 | ierr = MatPtAP(cMat,P,MAT_INITIAL_MATRIX,1.0,&tMat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1002,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1003 | ierr = MatDestroy(&P);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1003,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1004 | ierr = MatDestroy(&cMat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1004,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1005 | cMat = tMat; | |||||
1006 | ierr = MatCreateVecs(cMat, &diag, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1006,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1007 | ierr = MatGetDiagonal(cMat, diag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1007,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* effectively PCJACOBI */ | |||||
1008 | ierr = VecReciprocal(diag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1008,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1009 | ierr = VecSqrtAbs(diag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1009,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1010 | ierr = MatDiagonalScale(cMat, diag, diag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1010,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1011 | ierr = VecDestroy(&diag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1011,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1012 | } | |||||
1013 | } /* coarsen iterator */ | |||||
1014 | ||||||
1015 | /* make fake matrix */ | |||||
1016 | if (size>1) { | |||||
1017 | Mat mat; | |||||
1018 | PetscCDIntNd *pos; | |||||
1019 | PetscInt gid, NN, MM, jj = 0, mxsz = 0; | |||||
1020 | ||||||
1021 | for (kk=0; kk<nloc; kk++) { | |||||
1022 | ierr = PetscCDSizeAt(agg_llists, kk, &jj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1022,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1023 | if (jj > mxsz) mxsz = jj; | |||||
1024 | } | |||||
1025 | ierr = MatGetSize(a_Gmat, &MM, &NN);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1025,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1026 | if (mxsz > MM-nloc) mxsz = MM-nloc; | |||||
1027 | ||||||
1028 | ierr = MatCreateAIJ(comm, nloc, nloc,PETSC_DETERMINE-1, PETSC_DETERMINE-1,0, 0, mxsz, 0, &mat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1028,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1029 | ||||||
1030 | for (kk=0,gid=my0; kk<nloc; kk++,gid++) { | |||||
1031 | /* for (pos=PetscCDGetHeadPos(agg_llists,kk) ; pos ; pos=PetscCDGetNextPos(agg_llists,kk,pos)) { */ | |||||
1032 | ierr = PetscCDGetHeadPos(agg_llists,kk,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1032,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1033 | while (pos) { | |||||
1034 | PetscInt gid1; | |||||
1035 | ierr = PetscCDIntNdGetID(pos, &gid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1035,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1036 | ierr = PetscCDGetNextPos(agg_llists,kk,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1036,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1037 | ||||||
1038 | if (gid1 < my0 || gid1 >= my0+nloc) { | |||||
1039 | ierr = MatSetValues(mat,1,&gid,1,&gid1,&one,ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1039,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1040 | } | |||||
1041 | } | |||||
1042 | } | |||||
1043 | ierr = MatAssemblyBegin(mat,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1043,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1044 | ierr = MatAssemblyEnd(mat,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1044,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1045 | ierr = PetscCDSetMat(agg_llists, mat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1045,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1046 | } | |||||
1047 | ||||||
1048 | ierr = PetscFree(lid_cprowID)((*PetscTrFree)((void*)(lid_cprowID),1048,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((lid_cprowID) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1048,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1049 | ierr = PetscFree(lid_gid)((*PetscTrFree)((void*)(lid_gid),1049,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((lid_gid) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1049,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1050 | ierr = PetscFree(lid_matched)((*PetscTrFree)((void*)(lid_matched),1050,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((lid_matched) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1050,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1051 | ierr = PetscCDDestroy(deleted_list);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1051,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1052 | 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); | |||||
1053 | } | |||||
1054 | ||||||
1055 | typedef struct { | |||||
1056 | int dummy; | |||||
1057 | } MatCoarsen_HEM; | |||||
1058 | /* | |||||
1059 | HEM coarsen, simple greedy. | |||||
1060 | */ | |||||
1061 | static PetscErrorCode MatCoarsenApply_HEM(MatCoarsen coarse) | |||||
1062 | { | |||||
1063 | /* MatCoarsen_HEM *HEM = (MatCoarsen_HEM*)coarse->subctx; */ | |||||
1064 | PetscErrorCode ierr; | |||||
1065 | Mat mat = coarse->graph; | |||||
1066 | ||||||
1067 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 1067; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
1068 | PetscValidHeaderSpecific(coarse,MAT_COARSEN_CLASSID,1)do { if (!coarse) return PetscError(((MPI_Comm)0x44000001),1068 ,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(coarse,PETSC_OBJECT)) return PetscError((( MPI_Comm)0x44000001),1068,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(coarse))->classid != MAT_COARSEN_CLASSID ) { if (((PetscObject)(coarse))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1068,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1068,__func__ ,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,1); } } while (0); | |||||
1069 | if (!coarse->perm) { | |||||
1070 | IS perm; | |||||
1071 | PetscInt n,m; | |||||
1072 | ||||||
1073 | ierr = MatGetLocalSize(mat, &m, &n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1073,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1074 | ierr = ISCreateStride(PetscObjectComm((PetscObject)mat), m, 0, 1, &perm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1074,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1075 | ierr = heavyEdgeMatchAgg(perm, mat, &coarse->agg_lists);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1075,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1076 | ierr = ISDestroy(&perm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1076,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1077 | } else { | |||||
1078 | ierr = heavyEdgeMatchAgg(coarse->perm, mat, &coarse->agg_lists);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1078,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1079 | } | |||||
1080 | 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); | |||||
1081 | } | |||||
1082 | ||||||
1083 | static PetscErrorCode MatCoarsenView_HEM(MatCoarsen coarse,PetscViewer viewer) | |||||
1084 | { | |||||
1085 | /* MatCoarsen_HEM *HEM = (MatCoarsen_HEM*)coarse->subctx; */ | |||||
1086 | PetscErrorCode ierr; | |||||
1087 | PetscMPIInt rank; | |||||
1088 | PetscBool iascii; | |||||
1089 | ||||||
1090 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 1090; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
1091 | PetscValidHeaderSpecific(coarse,MAT_COARSEN_CLASSID,1)do { if (!coarse) return PetscError(((MPI_Comm)0x44000001),1091 ,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(coarse,PETSC_OBJECT)) return PetscError((( MPI_Comm)0x44000001),1091,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(coarse))->classid != MAT_COARSEN_CLASSID ) { if (((PetscObject)(coarse))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1091,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1091,__func__ ,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,1); } } while (0); | |||||
1092 | ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)coarse),&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1092,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1093 | ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII"ascii",&iascii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1093,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1094 | if (iascii) { | |||||
1095 | ierr = PetscViewerASCIIPushSynchronized(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1095,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1096 | ierr = PetscViewerASCIISynchronizedPrintf(viewer," [%d] HEM aggregator\n",rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1096,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1097 | ierr = PetscViewerFlush(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1097,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1098 | ierr = PetscViewerASCIIPopSynchronized(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1098,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1099 | } | |||||
1100 | 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); | |||||
1101 | } | |||||
1102 | ||||||
1103 | static PetscErrorCode MatCoarsenDestroy_HEM(MatCoarsen coarse) | |||||
1104 | { | |||||
1105 | MatCoarsen_HEM *HEM = (MatCoarsen_HEM*)coarse->subctx; | |||||
1106 | PetscErrorCode ierr; | |||||
1107 | ||||||
1108 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 1108; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
1109 | PetscValidHeaderSpecific(coarse,MAT_COARSEN_CLASSID,1)do { if (!coarse) return PetscError(((MPI_Comm)0x44000001),1109 ,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(coarse,PETSC_OBJECT)) return PetscError((( MPI_Comm)0x44000001),1109,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(coarse))->classid != MAT_COARSEN_CLASSID ) { if (((PetscObject)(coarse))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1109,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1109,__func__ ,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,1); } } while (0); | |||||
1110 | ierr = PetscFree(HEM)((*PetscTrFree)((void*)(HEM),1110,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ) || ((HEM) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1110,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1111 | 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); | |||||
1112 | } | |||||
1113 | ||||||
1114 | /*MC | |||||
1115 | MATCOARSENHEM - A coarsener that uses HEM a simple greedy coarsener | |||||
1116 | ||||||
1117 | Level: beginner | |||||
1118 | ||||||
1119 | .seealso: MatCoarsenSetType(), MatCoarsenType, MatCoarsenCreate() | |||||
1120 | ||||||
1121 | M*/ | |||||
1122 | ||||||
1123 | PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode MatCoarsenCreate_HEM(MatCoarsen coarse) | |||||
1124 | { | |||||
1125 | PetscErrorCode ierr; | |||||
1126 | MatCoarsen_HEM *HEM; | |||||
1127 | ||||||
1128 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ; petscstack->line[petscstack->currentsize] = 1128; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||
1129 | ierr = PetscNewLog(coarse,&HEM)(PetscMallocA(1,PETSC_TRUE,1129,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,(size_t)(1)*sizeof(**(((&HEM)))),(((&HEM)))) || PetscLogObjectMemory ((PetscObject)coarse,sizeof(**(&HEM))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1129,__func__,"/sandbox/petsc/petsc.master/src/mat/coarsen/impls/hem/hem.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||
1130 | coarse->subctx = (void*)HEM; | |||||
1131 | coarse->ops->apply = MatCoarsenApply_HEM; | |||||
1132 | coarse->ops->view = MatCoarsenView_HEM; | |||||
1133 | coarse->ops->destroy = MatCoarsenDestroy_HEM; | |||||
1134 | 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); | |||||
1135 | } |