File: | mat/partition/impls/hierarchical/hierarchical.c |
Warning: | line 158, column 12 2nd function call argument is an uninitialized value |
[?] Use j/k keys for keyboard navigation
1 | ||||
2 | #include <../src/mat/impls/adj/mpi/mpiadj.h> /*I "petscmat.h" I*/ | |||
3 | #include <petscsf.h> | |||
4 | #include <petsc/private/matimpl.h> | |||
5 | ||||
6 | /* | |||
7 | It is a hierarchical partitioning. The partitioner has two goals: | |||
8 | (1) Most of current partitioners fail at a large scale. The hierarchical partitioning | |||
9 | strategy is trying to produce large number of subdomains when number of processor cores is large. | |||
10 | (2) PCGASM needs one 'big' subdomain across multi-cores. The partitioner provides two | |||
11 | consistent partitions, coarse parts and fine parts. A coarse part is a 'big' subdomain consisting | |||
12 | of several small subdomains. | |||
13 | */ | |||
14 | ||||
15 | PetscErrorCode MatPartitioningHierarchical_DetermineDestination(MatPartitioning,IS,PetscInt,PetscInt,IS*); | |||
16 | PetscErrorCode MatPartitioningHierarchical_AssembleSubdomain(Mat,IS,IS,IS*,Mat*,ISLocalToGlobalMapping*); | |||
17 | PetscErrorCode MatPartitioningHierarchical_ReassembleFineparts(Mat,IS,ISLocalToGlobalMapping,IS*); | |||
18 | ||||
19 | typedef struct { | |||
20 | char* fineparttype; /* partitioner on fine level */ | |||
21 | char* coarseparttype; /* partitioner on coarse level */ | |||
22 | PetscInt nfineparts; /* number of fine parts on each coarse subdomain */ | |||
23 | PetscInt ncoarseparts; /* number of coarse parts */ | |||
24 | IS coarseparts; /* partitioning on coarse level */ | |||
25 | IS fineparts; /* partitioning on fine level */ | |||
26 | MatPartitioning coarseMatPart; /* MatPartititioning on coarse level (first level) */ | |||
27 | MatPartitioning fineMatPart; /* MatPartitioning on fine level (second level) */ | |||
28 | MatPartitioning improver; /* Improve the quality of a partition */ | |||
29 | } MatPartitioning_Hierarchical; | |||
30 | ||||
31 | /* | |||
32 | Uses a hierarchical partitioning strategy to partition the matrix in parallel. | |||
33 | Use this interface to make the partitioner consistent with others | |||
34 | */ | |||
35 | static PetscErrorCode MatPartitioningApply_Hierarchical(MatPartitioning part,IS *partitioning) | |||
36 | { | |||
37 | MatPartitioning_Hierarchical *hpart = (MatPartitioning_Hierarchical*)part->data; | |||
38 | const PetscInt *fineparts_indices, *coarseparts_indices; | |||
39 | PetscInt *fineparts_indices_tmp; | |||
40 | PetscInt *parts_indices,i,j,mat_localsize, *offsets; | |||
41 | Mat mat = part->adj,adj,sadj; | |||
42 | PetscReal *part_weights; | |||
43 | PetscBool flg; | |||
44 | PetscInt bs = 1; | |||
45 | PetscInt *coarse_vertex_weights = 0; | |||
46 | PetscMPIInt size,rank; | |||
47 | MPI_Comm comm,scomm; | |||
48 | IS destination,fineparts_temp, vweights, svweights; | |||
| ||||
49 | PetscInt nsvwegihts,*fp_vweights; | |||
50 | const PetscInt *svweights_indices; | |||
51 | ISLocalToGlobalMapping mapping; | |||
52 | const char *prefix; | |||
53 | PetscErrorCode ierr; | |||
54 | ||||
55 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 55; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
56 | ierr = PetscObjectGetComm((PetscObject)part,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),56,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
57 | ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),57,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
58 | ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),58,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
59 | ierr = PetscObjectTypeCompare((PetscObject)mat,MATMPIADJ"mpiadj",&flg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),59,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
60 | if (flg) { | |||
61 | adj = mat; | |||
62 | ierr = PetscObjectReference((PetscObject)adj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),62,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
63 | }else { | |||
64 | /* bs indicates if the converted matrix is "reduced" from the original and hence the | |||
65 | resulting partition results need to be stretched to match the original matrix */ | |||
66 | ierr = MatConvert(mat,MATMPIADJ"mpiadj",MAT_INITIAL_MATRIX,&adj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),66,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
67 | if (adj->rmap->n > 0) bs = mat->rmap->n/adj->rmap->n; | |||
68 | } | |||
69 | /* local size of mat */ | |||
70 | mat_localsize = adj->rmap->n; | |||
71 | /* check parameters */ | |||
72 | /* how many small subdomains we want from a given 'big' suddomain */ | |||
73 | if(!hpart->nfineparts) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG," must set number of small subdomains for each big subdomain \n")return PetscError(((MPI_Comm)0x44000001),73,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,62,PETSC_ERROR_INITIAL," must set number of small subdomains for each big subdomain \n" ); | |||
74 | if(!hpart->ncoarseparts && !part->n) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE," did not either set number of coarse parts or total number of parts \n")return PetscError(((MPI_Comm)0x44000001),74,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,73,PETSC_ERROR_INITIAL," did not either set number of coarse parts or total number of parts \n" ); | |||
75 | ||||
76 | /* Partitioning the domain into one single subdomain is a trivial case, and we should just return */ | |||
77 | if (part->n==1) { | |||
78 | ierr = PetscCalloc1(bs*adj->rmap->n,&parts_indices)PetscMallocA(1,PETSC_TRUE,78,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(bs*adj->rmap->n)*sizeof(**(&parts_indices )),(&parts_indices));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),78,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
79 | ierr = ISCreateGeneral(comm,bs*adj->rmap->n,parts_indices,PETSC_OWN_POINTER,partitioning);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),79,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
80 | hpart->ncoarseparts = 1; | |||
81 | hpart->nfineparts = 1; | |||
82 | ierr = PetscStrallocpy("NONE",&hpart->coarseparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),82,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
83 | ierr = PetscStrallocpy("NONE",&hpart->fineparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),83,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
84 | ierr = MatDestroy(&adj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),84,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
85 | 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); | |||
86 | } | |||
87 | ||||
88 | if(part->n){ | |||
89 | hpart->ncoarseparts = part->n/hpart->nfineparts; | |||
90 | ||||
91 | if (part->n%hpart->nfineparts != 0) hpart->ncoarseparts++; | |||
92 | }else{ | |||
93 | part->n = hpart->ncoarseparts*hpart->nfineparts; | |||
94 | } | |||
95 | ||||
96 | ierr = PetscMalloc1(hpart->ncoarseparts+1, &offsets)PetscMallocA(1,PETSC_FALSE,96,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(hpart->ncoarseparts+1)*sizeof(**(&offsets)), (&offsets));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),96,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
97 | ierr = PetscMalloc1(hpart->ncoarseparts, &part_weights)PetscMallocA(1,PETSC_FALSE,97,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(hpart->ncoarseparts)*sizeof(**(&part_weights )),(&part_weights));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),97,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
98 | ||||
99 | offsets[0] = 0; | |||
100 | if (part->n%hpart->nfineparts != 0) offsets[1] = part->n%hpart->nfineparts; | |||
101 | else offsets[1] = hpart->nfineparts; | |||
102 | ||||
103 | part_weights[0] = ((PetscReal)offsets[1])/part->n; | |||
104 | ||||
105 | for (i=2; i<=hpart->ncoarseparts; i++) { | |||
106 | offsets[i] = hpart->nfineparts; | |||
107 | part_weights[i-1] = ((PetscReal)offsets[i])/part->n; | |||
108 | } | |||
109 | ||||
110 | offsets[0] = 0; | |||
111 | for (i=1;i<=hpart->ncoarseparts; i++) | |||
112 | offsets[i] += offsets[i-1]; | |||
113 | ||||
114 | /* If these exists a mat partitioner, we should delete it */ | |||
115 | ierr = MatPartitioningDestroy(&hpart->coarseMatPart);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),115,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
116 | ierr = MatPartitioningCreate(comm,&hpart->coarseMatPart);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),116,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
117 | ierr = PetscObjectGetOptionsPrefix((PetscObject)part,&prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),117,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
118 | ierr = PetscObjectSetOptionsPrefix((PetscObject)hpart->coarseMatPart,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),118,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
119 | ierr = PetscObjectAppendOptionsPrefix((PetscObject)hpart->coarseMatPart,"hierarch_coarse_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),119,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
120 | /* if did not set partitioning type yet, use parmetis by default */ | |||
121 | if (!hpart->coarseparttype){ | |||
122 | #if defined(PETSC_HAVE_PARMETIS1) | |||
123 | ierr = MatPartitioningSetType(hpart->coarseMatPart,MATPARTITIONINGPARMETIS"parmetis");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),123,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
124 | ierr = PetscStrallocpy(MATPARTITIONINGPARMETIS"parmetis",&hpart->coarseparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),124,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
125 | #elif defined(PETSC_HAVE_PTSCOTCH1) | |||
126 | ierr = MatPartitioningSetType(hpart->coarseMatPart,MATPARTITIONINGPTSCOTCH"ptscotch");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),126,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
127 | ierr = PetscStrallocpy(MATPARTITIONINGPTSCOTCH"ptscotch",&hpart->coarseparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),127,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
128 | #else | |||
129 | SETERRQ(PetscObjectComm((PetscObject)mat),PETSC_ERR_SUP,"Requires PETSc be installed with ParMetis or run with -mat_partitioning_hierarchical_coarseparttype partitiontype")return PetscError(PetscObjectComm((PetscObject)mat),129,__func__ ,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,56,PETSC_ERROR_INITIAL,"Requires PETSc be installed with ParMetis or run with -mat_partitioning_hierarchical_coarseparttype partitiontype" ); | |||
130 | #endif | |||
131 | } else { | |||
132 | ierr = MatPartitioningSetType(hpart->coarseMatPart,hpart->coarseparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),132,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
133 | } | |||
134 | ierr = MatPartitioningSetAdjacency(hpart->coarseMatPart,adj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),134,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
135 | ierr = MatPartitioningSetNParts(hpart->coarseMatPart, hpart->ncoarseparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),135,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
136 | /* copy over vertex weights */ | |||
137 | if(part->vertex_weights){ | |||
138 | ierr = PetscMalloc1(mat_localsize,&coarse_vertex_weights)PetscMallocA(1,PETSC_FALSE,138,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(mat_localsize)*sizeof(**(&coarse_vertex_weights )),(&coarse_vertex_weights));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),138,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
139 | ierr = PetscArraycpy(coarse_vertex_weights,part->vertex_weights,mat_localsize)((sizeof(*(coarse_vertex_weights)) != sizeof(*(part->vertex_weights ))) || PetscMemcpy(coarse_vertex_weights,part->vertex_weights ,(mat_localsize)*sizeof(*(coarse_vertex_weights))));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),139,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
140 | ierr = MatPartitioningSetVertexWeights(hpart->coarseMatPart,coarse_vertex_weights);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),140,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
141 | } | |||
142 | ||||
143 | ierr = MatPartitioningSetPartitionWeights(hpart->coarseMatPart, part_weights);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),143,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
144 | ierr = MatPartitioningApply(hpart->coarseMatPart,&hpart->coarseparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),144,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
145 | ||||
146 | /* Wrap the original vertex weights into an index set so that we can extract the corresponding | |||
147 | * vertex weights for each big subdomain using ISCreateSubIS(). | |||
148 | * */ | |||
149 | if (part->vertex_weights) { | |||
150 | ierr = ISCreateGeneral(comm,mat_localsize,part->vertex_weights,PETSC_COPY_VALUES,&vweights);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),150,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
151 | } | |||
152 | ||||
153 | ierr = PetscCalloc1(mat_localsize, &fineparts_indices_tmp)PetscMallocA(1,PETSC_TRUE,153,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(mat_localsize)*sizeof(**(&fineparts_indices_tmp )),(&fineparts_indices_tmp));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),153,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
154 | for(i=0; i<hpart->ncoarseparts; i+=size){ | |||
155 | /* Determine where we want to send big subdomains */ | |||
156 | ierr = MatPartitioningHierarchical_DetermineDestination(part,hpart->coarseparts,i,i+size,&destination);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),156,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
157 | /* Assemble a submatrix and its vertex weights for partitioning subdomains */ | |||
158 | ierr = MatPartitioningHierarchical_AssembleSubdomain(adj,part->vertex_weights? vweights:NULL((void*)0),destination,part->vertex_weights? &svweights:NULL((void*)0),&sadj,&mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),158,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
| ||||
159 | /* We have to create a new array to hold vertex weights since coarse partitioner needs to own the vertex-weights array */ | |||
160 | if (part->vertex_weights) { | |||
161 | ierr = ISGetLocalSize(svweights,&nsvwegihts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),161,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
162 | ierr = PetscMalloc1(nsvwegihts,&fp_vweights)PetscMallocA(1,PETSC_FALSE,162,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(nsvwegihts)*sizeof(**(&fp_vweights)),(&fp_vweights ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),162,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
163 | ierr = ISGetIndices(svweights,&svweights_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),163,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
164 | ierr = PetscArraycpy(fp_vweights,svweights_indices,nsvwegihts)((sizeof(*(fp_vweights)) != sizeof(*(svweights_indices))) || PetscMemcpy (fp_vweights,svweights_indices,(nsvwegihts)*sizeof(*(fp_vweights ))));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),164,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
165 | ierr = ISRestoreIndices(svweights,&svweights_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),165,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
166 | ierr = ISDestroy(&svweights);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),166,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
167 | } | |||
168 | ||||
169 | ierr = ISDestroy(&destination);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),169,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
170 | ierr = PetscObjectGetComm((PetscObject)sadj,&scomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),170,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
171 | ||||
172 | /* | |||
173 | * If the number of big subdomains is smaller than the number of processor cores, the higher ranks do not | |||
174 | * need to do partitioning | |||
175 | * */ | |||
176 | if((i+rank)<hpart->ncoarseparts) { | |||
177 | ierr = MatPartitioningDestroy(&hpart->fineMatPart);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),177,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
178 | /* create a fine partitioner */ | |||
179 | ierr = MatPartitioningCreate(scomm,&hpart->fineMatPart);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),179,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
180 | ierr = PetscObjectSetOptionsPrefix((PetscObject)hpart->fineMatPart,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),180,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
181 | ierr = PetscObjectAppendOptionsPrefix((PetscObject)hpart->fineMatPart,"hierarch_fine_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),181,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
182 | /* if do not set partitioning type, use parmetis by default */ | |||
183 | if(!hpart->fineparttype){ | |||
184 | #if defined(PETSC_HAVE_PARMETIS1) | |||
185 | ierr = MatPartitioningSetType(hpart->fineMatPart,MATPARTITIONINGPARMETIS"parmetis");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),185,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
186 | ierr = PetscStrallocpy(MATPARTITIONINGPARMETIS"parmetis",&hpart->fineparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),186,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
187 | #elif defined(PETSC_HAVE_PTSCOTCH1) | |||
188 | ierr = MatPartitioningSetType(hpart->fineMatPart,MATPARTITIONINGPTSCOTCH"ptscotch");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),188,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
189 | ierr = PetscStrallocpy(MATPARTITIONINGPTSCOTCH"ptscotch",&hpart->fineparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),189,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
190 | #elif defined(PETSC_HAVE_CHACO) | |||
191 | ierr = MatPartitioningSetType(hpart->fineMatPart,MATPARTITIONINGCHACO"chaco");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),191,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
192 | ierr = PetscStrallocpy(MATPARTITIONINGCHACO"chaco",&hpart->fineparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),192,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
193 | #elif defined(PETSC_HAVE_PARTY) | |||
194 | ierr = MatPartitioningSetType(hpart->fineMatPart,MATPARTITIONINGPARTY"party");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),194,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
195 | ierr = PetscStrallocpy(PETSC_HAVE_PARTY,&hpart->fineparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),195,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
196 | #else | |||
197 | SETERRQ(PetscObjectComm((PetscObject)mat),PETSC_ERR_SUP,"Requires PETSc be installed with ParMetis or run with -mat_partitioning_hierarchical_coarseparttype partitiontype")return PetscError(PetscObjectComm((PetscObject)mat),197,__func__ ,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,56,PETSC_ERROR_INITIAL,"Requires PETSc be installed with ParMetis or run with -mat_partitioning_hierarchical_coarseparttype partitiontype" ); | |||
198 | #endif | |||
199 | } else { | |||
200 | ierr = MatPartitioningSetType(hpart->fineMatPart,hpart->fineparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),200,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
201 | } | |||
202 | ierr = MatPartitioningSetAdjacency(hpart->fineMatPart,sadj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),202,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
203 | ierr = MatPartitioningSetNParts(hpart->fineMatPart, offsets[rank+1+i]-offsets[rank+i]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),203,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
204 | if (part->vertex_weights) { | |||
205 | ierr = MatPartitioningSetVertexWeights(hpart->fineMatPart,fp_vweights);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),205,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
206 | } | |||
207 | ierr = MatPartitioningApply(hpart->fineMatPart,&fineparts_temp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),207,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
208 | } else { | |||
209 | ierr = ISCreateGeneral(scomm,0,NULL((void*)0),PETSC_OWN_POINTER,&fineparts_temp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),209,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
210 | } | |||
211 | ||||
212 | ierr = MatDestroy(&sadj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),212,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
213 | ||||
214 | /* Send partition back to the original owners */ | |||
215 | ierr = MatPartitioningHierarchical_ReassembleFineparts(adj,fineparts_temp,mapping,&hpart->fineparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),215,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
216 | ierr = ISGetIndices(hpart->fineparts,&fineparts_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),216,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
217 | for (j=0;j<mat_localsize;j++) | |||
218 | if (fineparts_indices[j] >=0) fineparts_indices_tmp[j] = fineparts_indices[j]; | |||
219 | ||||
220 | ierr = ISRestoreIndices(hpart->fineparts,&fineparts_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),220,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
221 | ierr = ISDestroy(&hpart->fineparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),221,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
222 | ierr = ISDestroy(&fineparts_temp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),222,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
223 | ierr = ISLocalToGlobalMappingDestroy(&mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),223,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
224 | } | |||
225 | ||||
226 | if (part->vertex_weights) { | |||
227 | ierr = ISDestroy(&vweights);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),227,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
228 | } | |||
229 | ||||
230 | ierr = ISCreateGeneral(comm,mat_localsize,fineparts_indices_tmp,PETSC_OWN_POINTER,&hpart->fineparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),230,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
231 | ierr = ISGetIndices(hpart->fineparts,&fineparts_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),231,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
232 | ierr = ISGetIndices(hpart->coarseparts,&coarseparts_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),232,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
233 | ierr = PetscMalloc1(bs*adj->rmap->n,&parts_indices)PetscMallocA(1,PETSC_FALSE,233,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(bs*adj->rmap->n)*sizeof(**(&parts_indices )),(&parts_indices));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),233,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
234 | /* Modify the local indices to the global indices by combing the coarse partition and the fine partitions */ | |||
235 | for(i=0; i<adj->rmap->n; i++){ | |||
236 | for(j=0; j<bs; j++){ | |||
237 | parts_indices[bs*i+j] = fineparts_indices[i]+offsets[coarseparts_indices[i]]; | |||
238 | } | |||
239 | } | |||
240 | ierr = ISRestoreIndices(hpart->fineparts,&fineparts_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),240,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
241 | ierr = ISRestoreIndices(hpart->coarseparts,&coarseparts_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),241,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
242 | ierr = PetscFree(offsets)((*PetscTrFree)((void*)(offsets),242,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ) || ((offsets) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),242,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
243 | ierr = ISCreateGeneral(comm,bs*adj->rmap->n,parts_indices,PETSC_OWN_POINTER,partitioning);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),243,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
244 | ierr = MatDestroy(&adj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),244,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
245 | 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); | |||
246 | } | |||
247 | ||||
248 | ||||
249 | PetscErrorCode MatPartitioningHierarchical_ReassembleFineparts(Mat adj, IS fineparts, ISLocalToGlobalMapping mapping, IS *sfineparts) | |||
250 | { | |||
251 | PetscInt *local_indices, *global_indices,*owners,*sfineparts_indices,localsize,i; | |||
252 | const PetscInt *ranges,*fineparts_indices; | |||
253 | PetscMPIInt rank; | |||
254 | MPI_Comm comm; | |||
255 | PetscLayout rmap; | |||
256 | PetscSFNode *remote; | |||
257 | PetscSF sf; | |||
258 | PetscErrorCode ierr; | |||
259 | ||||
260 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 260; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
261 | PetscValidPointer(sfineparts, 4)do { if (!sfineparts) return PetscError(((MPI_Comm)0x44000001 ),261,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if (!PetscCheckPointer(sfineparts,PETSC_CHAR)) return PetscError (((MPI_Comm)0x44000001),261,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4); } while (0); | |||
262 | ierr = PetscObjectGetComm((PetscObject)adj,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),262,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
263 | ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),263,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
264 | ierr = MatGetLayouts(adj,&rmap,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),264,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
265 | ierr = ISGetLocalSize(fineparts,&localsize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),265,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
266 | ierr = PetscMalloc2(localsize,&global_indices,localsize,&local_indices)PetscMallocA(2,PETSC_FALSE,266,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(localsize)*sizeof(**(&global_indices)),(&global_indices ),(size_t)(localsize)*sizeof(**(&local_indices)),(&local_indices ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),266,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
267 | for (i=0; i<localsize; i++){ | |||
268 | local_indices[i] = i; | |||
269 | } | |||
270 | /* map local indices back to global so that we can permulate data globally */ | |||
271 | ierr = ISLocalToGlobalMappingApply(mapping,localsize,local_indices,global_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),271,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
272 | ierr = PetscCalloc1(localsize,&owners)PetscMallocA(1,PETSC_TRUE,272,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(localsize)*sizeof(**(&owners)),(&owners));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),272,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
273 | /* find owners for global indices */ | |||
274 | for(i=0; i<localsize; i++){ | |||
275 | ierr = PetscLayoutFindOwner(rmap,global_indices[i],&owners[i]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),275,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
276 | } | |||
277 | ierr = PetscLayoutGetRanges(rmap,&ranges);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),277,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
278 | ierr = PetscMalloc1(ranges[rank+1]-ranges[rank],&sfineparts_indices)PetscMallocA(1,PETSC_FALSE,278,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(ranges[rank+1]-ranges[rank])*sizeof(**(&sfineparts_indices )),(&sfineparts_indices));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),278,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
279 | ||||
280 | for (i=0; i<ranges[rank+1]-ranges[rank]; i++) { | |||
281 | sfineparts_indices[i] = -1; | |||
282 | } | |||
283 | ||||
284 | ierr = ISGetIndices(fineparts,&fineparts_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),284,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
285 | ierr = PetscSFCreate(comm,&sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),285,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
286 | ierr = PetscMalloc1(localsize,&remote)PetscMallocA(1,PETSC_FALSE,286,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(localsize)*sizeof(**(&remote)),(&remote));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),286,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
287 | for(i=0; i<localsize; i++){ | |||
288 | remote[i].rank = owners[i]; | |||
289 | remote[i].index = global_indices[i]-ranges[owners[i]]; | |||
290 | } | |||
291 | ierr = PetscSFSetType(sf,PETSCSFBASIC"basic");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),291,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
292 | /* not sure how to add prefix to sf */ | |||
293 | ierr = PetscSFSetFromOptions(sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),293,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
294 | ierr = PetscSFSetGraph(sf,localsize,localsize,NULL((void*)0),PETSC_OWN_POINTER,remote,PETSC_OWN_POINTER);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),294,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
295 | ierr = PetscSFReduceBegin(sf,MPIU_INT((MPI_Datatype)0x4c000405),fineparts_indices,sfineparts_indices,MPIU_REPLACE(MPI_Op)(0x5800000d));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),295,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
296 | ierr = PetscSFReduceEnd(sf,MPIU_INT((MPI_Datatype)0x4c000405),fineparts_indices,sfineparts_indices,MPIU_REPLACE(MPI_Op)(0x5800000d));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),296,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
297 | ierr = PetscSFDestroy(&sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),297,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
298 | ierr = ISRestoreIndices(fineparts,&fineparts_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),298,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
299 | ierr = ISCreateGeneral(comm,ranges[rank+1]-ranges[rank],sfineparts_indices,PETSC_OWN_POINTER,sfineparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),299,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
300 | ierr = PetscFree2(global_indices,local_indices)PetscFreeA(2,300,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,&(global_indices),&(local_indices));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),300,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
301 | ierr = PetscFree(owners)((*PetscTrFree)((void*)(owners),301,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ) || ((owners) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),301,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
302 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
303 | } | |||
304 | ||||
305 | ||||
306 | PetscErrorCode MatPartitioningHierarchical_AssembleSubdomain(Mat adj,IS vweights, IS destination,IS *svweights,Mat *sadj,ISLocalToGlobalMapping *mapping) | |||
307 | { | |||
308 | IS irows,icols; | |||
309 | PetscInt irows_ln; | |||
310 | PetscMPIInt rank; | |||
311 | const PetscInt *irows_indices; | |||
312 | MPI_Comm comm; | |||
313 | PetscErrorCode ierr; | |||
314 | ||||
315 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 315; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
316 | ierr = PetscObjectGetComm((PetscObject)adj,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),316,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
317 | ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),317,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
318 | /* figure out where data comes from */ | |||
319 | ierr = ISBuildTwoSided(destination,NULL((void*)0),&irows);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),319,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
320 | ierr = ISDuplicate(irows,&icols);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),320,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
321 | ierr = ISGetLocalSize(irows,&irows_ln);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),321,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
322 | ierr = ISGetIndices(irows,&irows_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),322,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
323 | ierr = ISLocalToGlobalMappingCreate(comm,1,irows_ln,irows_indices,PETSC_COPY_VALUES,mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),323,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
324 | ierr = ISRestoreIndices(irows,&irows_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),324,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
325 | ierr = MatCreateSubMatrices(adj,1,&irows,&icols,MAT_INITIAL_MATRIX,&sadj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),325,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
326 | if (vweights && svweights) { | |||
327 | ierr = ISCreateSubIS(vweights,irows,svweights);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),327,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
328 | } | |||
329 | ierr = ISDestroy(&irows);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),329,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
330 | ierr = ISDestroy(&icols);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),330,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
331 | 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); | |||
332 | } | |||
333 | ||||
334 | ||||
335 | PetscErrorCode MatPartitioningHierarchical_DetermineDestination(MatPartitioning part, IS partitioning, PetscInt pstart, PetscInt pend, IS *destination) | |||
336 | { | |||
337 | MPI_Comm comm; | |||
338 | PetscMPIInt rank,size,target; | |||
339 | PetscInt plocalsize,*dest_indices,i; | |||
340 | const PetscInt *part_indices; | |||
341 | PetscErrorCode ierr; | |||
342 | ||||
343 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 343; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
344 | ierr = PetscObjectGetComm((PetscObject)part,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),344,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
345 | ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),345,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
346 | ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),346,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
347 | if((pend-pstart)>size) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"range [%D, %D] should be smaller than or equal to size %D",pstart,pend,size)return PetscError(((MPI_Comm)0x44000001),347,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,75,PETSC_ERROR_INITIAL,"range [%D, %D] should be smaller than or equal to size %D" ,pstart,pend,size); | |||
348 | if(pstart>pend) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP," pstart %D should be smaller than pend %D",pstart,pend)return PetscError(((MPI_Comm)0x44000001),348,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,75,PETSC_ERROR_INITIAL," pstart %D should be smaller than pend %D" ,pstart,pend); | |||
349 | ierr = ISGetLocalSize(partitioning,&plocalsize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),349,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
350 | ierr = PetscMalloc1(plocalsize,&dest_indices)PetscMallocA(1,PETSC_FALSE,350,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(plocalsize)*sizeof(**(&dest_indices)),(&dest_indices ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),350,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
351 | ierr = ISGetIndices(partitioning,&part_indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),351,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
352 | for (i=0; i<plocalsize; i++){ | |||
353 | /* compute target */ | |||
354 | target = part_indices[i]-pstart; | |||
355 | /* mark out of range entity as -1 */ | |||
356 | if (part_indices[i]<pstart || part_indices[i]>=pend) target = -1; | |||
357 | dest_indices[i] = target; | |||
358 | } | |||
359 | ierr = ISCreateGeneral(comm,plocalsize,dest_indices,PETSC_OWN_POINTER,destination);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),359,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
360 | 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); | |||
361 | } | |||
362 | ||||
363 | ||||
364 | PetscErrorCode MatPartitioningView_Hierarchical(MatPartitioning part,PetscViewer viewer) | |||
365 | { | |||
366 | MatPartitioning_Hierarchical *hpart = (MatPartitioning_Hierarchical*)part->data; | |||
367 | PetscErrorCode ierr; | |||
368 | PetscMPIInt rank; | |||
369 | PetscBool iascii; | |||
370 | PetscViewer sviewer; | |||
371 | ||||
372 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 372; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
373 | ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)part),&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),373,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
374 | ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII"ascii",&iascii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),374,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
375 | if(iascii){ | |||
376 | ierr = PetscViewerASCIIPrintf(viewer," Number of coarse parts: %D\n",hpart->ncoarseparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),376,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
377 | ierr = PetscViewerASCIIPrintf(viewer," Coarse partitioner: %s\n",hpart->coarseparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),377,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
378 | if (hpart->coarseMatPart) { | |||
379 | ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),379,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
380 | ierr = MatPartitioningView(hpart->coarseMatPart,viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),380,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
381 | ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),381,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
382 | } | |||
383 | ierr = PetscViewerASCIIPrintf(viewer," Number of fine parts: %D\n",hpart->nfineparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),383,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
384 | ierr = PetscViewerASCIIPrintf(viewer," Fine partitioner: %s\n",hpart->fineparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),384,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
385 | ierr = PetscViewerGetSubViewer(viewer,PETSC_COMM_SELF((MPI_Comm)0x44000001),&sviewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),385,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
386 | if (!rank && hpart->fineMatPart) { | |||
387 | ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),387,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
388 | ierr = MatPartitioningView(hpart->fineMatPart,sviewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),388,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
389 | ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),389,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
390 | } | |||
391 | ierr = PetscViewerRestoreSubViewer(viewer,PETSC_COMM_SELF((MPI_Comm)0x44000001),&sviewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),391,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
392 | } | |||
393 | 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); | |||
394 | } | |||
395 | ||||
396 | ||||
397 | PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning part,IS *fineparts) | |||
398 | { | |||
399 | MatPartitioning_Hierarchical *hpart = (MatPartitioning_Hierarchical*)part->data; | |||
400 | PetscErrorCode ierr; | |||
401 | ||||
402 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 402; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
403 | *fineparts = hpart->fineparts; | |||
404 | ierr = PetscObjectReference((PetscObject)hpart->fineparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),404,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
405 | 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); | |||
406 | } | |||
407 | ||||
408 | PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning part,IS *coarseparts) | |||
409 | { | |||
410 | MatPartitioning_Hierarchical *hpart = (MatPartitioning_Hierarchical*)part->data; | |||
411 | PetscErrorCode ierr; | |||
412 | ||||
413 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 413; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
414 | *coarseparts = hpart->coarseparts; | |||
415 | ierr = PetscObjectReference((PetscObject)hpart->coarseparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),415,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
416 | 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); | |||
417 | } | |||
418 | ||||
419 | PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning part, PetscInt ncoarseparts) | |||
420 | { | |||
421 | MatPartitioning_Hierarchical *hpart = (MatPartitioning_Hierarchical*)part->data; | |||
422 | ||||
423 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 423; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
424 | hpart->ncoarseparts = ncoarseparts; | |||
425 | 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); | |||
426 | } | |||
427 | ||||
428 | PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning part, PetscInt nfineparts) | |||
429 | { | |||
430 | MatPartitioning_Hierarchical *hpart = (MatPartitioning_Hierarchical*)part->data; | |||
431 | ||||
432 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 432; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
433 | hpart->nfineparts = nfineparts; | |||
434 | 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); | |||
435 | } | |||
436 | ||||
437 | PetscErrorCode MatPartitioningSetFromOptions_Hierarchical(PetscOptionItems *PetscOptionsObject,MatPartitioning part) | |||
438 | { | |||
439 | MatPartitioning_Hierarchical *hpart = (MatPartitioning_Hierarchical*)part->data; | |||
440 | PetscErrorCode ierr; | |||
441 | char value[1024]; | |||
442 | PetscBool flag = PETSC_FALSE; | |||
443 | ||||
444 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 444; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
445 | ierr = PetscOptionsHead(PetscOptionsObject,"Set hierarchical partitioning options");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),445,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
446 | ierr = PetscOptionsString("-mat_partitioning_hierarchical_coarseparttype","coarse part type",NULL,NULL,value,1024,&flag)PetscOptionsString_Private(PetscOptionsObject,"-mat_partitioning_hierarchical_coarseparttype" ,"coarse part type",((void*)0),((void*)0),value,1024,&flag );CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),446,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
447 | if (flag){ | |||
448 | ierr = PetscStrallocpy(value,&hpart->coarseparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),448,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
449 | } | |||
450 | ierr = PetscOptionsString("-mat_partitioning_hierarchical_fineparttype","fine part type",NULL,NULL,value,1024,&flag)PetscOptionsString_Private(PetscOptionsObject,"-mat_partitioning_hierarchical_fineparttype" ,"fine part type",((void*)0),((void*)0),value,1024,&flag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),450,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
451 | if (flag){ | |||
452 | ierr = PetscStrallocpy(value,&hpart->fineparttype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),452,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
453 | } | |||
454 | ierr = PetscOptionsInt("-mat_partitioning_hierarchical_ncoarseparts","number of coarse parts",NULL,hpart->ncoarseparts,&hpart->ncoarseparts,&flag)PetscOptionsInt_Private(PetscOptionsObject,"-mat_partitioning_hierarchical_ncoarseparts" ,"number of coarse parts",((void*)0),hpart->ncoarseparts,& hpart->ncoarseparts,&flag,(-2147483647 - 1),2147483647 );CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),454,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
455 | ierr = PetscOptionsInt("-mat_partitioning_hierarchical_nfineparts","number of fine parts",NULL,hpart->nfineparts,&hpart->nfineparts,&flag)PetscOptionsInt_Private(PetscOptionsObject,"-mat_partitioning_hierarchical_nfineparts" ,"number of fine parts",((void*)0),hpart->nfineparts,& hpart->nfineparts,&flag,(-2147483647 - 1),2147483647);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),455,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
456 | ierr = PetscOptionsTail()0; do {if (PetscOptionsObject->count != 1) do { do { ; if ( petscstack && petscstack->currentsize > 0) { petscstack ->currentsize--; petscstack->function[petscstack->currentsize ] = 0; petscstack->file[petscstack->currentsize] = 0; petscstack ->line[petscstack->currentsize] = 0; petscstack->petscroutine [petscstack->currentsize] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)< (0)) ? (0) : (petscstack->hotdepth-1)); } ; } while (0); return (0);} while (0);} while(0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),456,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
457 | 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); | |||
458 | } | |||
459 | ||||
460 | ||||
461 | PetscErrorCode MatPartitioningDestroy_Hierarchical(MatPartitioning part) | |||
462 | { | |||
463 | MatPartitioning_Hierarchical *hpart = (MatPartitioning_Hierarchical*)part->data; | |||
464 | PetscErrorCode ierr; | |||
465 | ||||
466 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 466; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
467 | if(hpart->coarseparttype) {ierr = PetscFree(hpart->coarseparttype)((*PetscTrFree)((void*)(hpart->coarseparttype),467,__func__ ,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ) || ((hpart->coarseparttype) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),467,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
468 | if(hpart->fineparttype) {ierr = PetscFree(hpart->fineparttype)((*PetscTrFree)((void*)(hpart->fineparttype),468,__func__, "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ) || ((hpart->fineparttype) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),468,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
469 | ierr = ISDestroy(&hpart->fineparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),469,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
470 | ierr = ISDestroy(&hpart->coarseparts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),470,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
471 | ierr = MatPartitioningDestroy(&hpart->coarseMatPart);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),471,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
472 | ierr = MatPartitioningDestroy(&hpart->fineMatPart);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),472,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
473 | ierr = MatPartitioningDestroy(&hpart->improver);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),473,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
474 | ierr = PetscFree(hpart)((*PetscTrFree)((void*)(hpart),474,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ) || ((hpart) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),474,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
475 | 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); | |||
476 | } | |||
477 | ||||
478 | /* | |||
479 | Improves the quality of a partition | |||
480 | */ | |||
481 | static PetscErrorCode MatPartitioningImprove_Hierarchical(MatPartitioning part, IS *partitioning) | |||
482 | { | |||
483 | PetscErrorCode ierr; | |||
484 | MatPartitioning_Hierarchical *hpart = (MatPartitioning_Hierarchical*)part->data; | |||
485 | Mat mat = part->adj, adj; | |||
486 | PetscBool flg; | |||
487 | PetscInt *vertex_weights; | |||
488 | const char *prefix; | |||
489 | ||||
490 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 490; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
491 | ierr = PetscObjectTypeCompare((PetscObject)mat,MATMPIADJ"mpiadj",&flg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),491,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
492 | if (flg) { | |||
493 | adj = mat; | |||
494 | ierr = PetscObjectReference((PetscObject)adj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),494,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
495 | }else { | |||
496 | /* bs indicates if the converted matrix is "reduced" from the original and hence the | |||
497 | resulting partition results need to be stretched to match the original matrix */ | |||
498 | ierr = MatConvert(mat,MATMPIADJ"mpiadj",MAT_INITIAL_MATRIX,&adj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),498,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
499 | } | |||
500 | ||||
501 | /* If there exists a mat partitioner, we should delete it */ | |||
502 | ierr = MatPartitioningDestroy(&hpart->improver);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),502,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
503 | ierr = MatPartitioningCreate(PetscObjectComm((PetscObject)part),&hpart->improver);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),503,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
504 | ierr = PetscObjectGetOptionsPrefix((PetscObject)part,&prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),504,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
505 | ierr = PetscObjectSetOptionsPrefix((PetscObject)hpart->improver,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),505,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
506 | ierr = PetscObjectAppendOptionsPrefix((PetscObject)hpart->improver,"hierarch_improver_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),506,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
507 | /* Only parmetis supports to refine a partition */ | |||
508 | #if defined(PETSC_HAVE_PARMETIS1) | |||
509 | ierr = MatPartitioningSetType(hpart->improver,MATPARTITIONINGPARMETIS"parmetis");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),509,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
510 | #else | |||
511 | SETERRQ(PetscObjectComm((PetscObject)adj),PETSC_ERR_SUP,"Requires PETSc be installed with ParMetis\n")return PetscError(PetscObjectComm((PetscObject)adj),511,__func__ ,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,56,PETSC_ERROR_INITIAL,"Requires PETSc be installed with ParMetis\n" ); | |||
512 | #endif | |||
513 | ||||
514 | ierr = MatPartitioningSetAdjacency(hpart->improver,adj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),514,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
515 | ierr = MatPartitioningSetNParts(hpart->improver, part->n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),515,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
516 | /* copy over vertex weights */ | |||
517 | if(part->vertex_weights){ | |||
518 | ierr = PetscMalloc1(adj->rmap->n,&vertex_weights)PetscMallocA(1,PETSC_FALSE,518,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(adj->rmap->n)*sizeof(**(&vertex_weights)) ,(&vertex_weights));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),518,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
519 | ierr = PetscArraycpy(vertex_weights,part->vertex_weights,adj->rmap->n)((sizeof(*(vertex_weights)) != sizeof(*(part->vertex_weights ))) || PetscMemcpy(vertex_weights,part->vertex_weights,(adj ->rmap->n)*sizeof(*(vertex_weights))));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),519,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
520 | ierr = MatPartitioningSetVertexWeights(hpart->improver,vertex_weights);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),520,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
521 | } | |||
522 | ierr = MatPartitioningImprove(hpart->improver,partitioning);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),522,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
523 | ierr = MatDestroy(&adj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),523,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
524 | 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); | |||
525 | } | |||
526 | ||||
527 | ||||
528 | /*MC | |||
529 | MATPARTITIONINGHIERARCH - Creates a partitioning context via hierarchical partitioning strategy. | |||
530 | The graph is partitioned into a number of subgraphs, and each subgraph is further split into a few smaller | |||
531 | subgraphs. The idea can be applied in a recursive manner. It is useful when you want to partition the graph | |||
532 | into a large number of subgraphs (often more than 10K) since partitions obtained with existing partitioners | |||
533 | such as ParMETIS and PTScotch are far from ideal. The hierarchical partitioning also tries to avoid off-node | |||
534 | communication as much as possible for multi-core processor. Another user case for the hierarchical partitioning | |||
535 | is to improve PCGASM convergence by generating multi-rank connected subdomain. | |||
536 | ||||
537 | Collective | |||
538 | ||||
539 | Input Parameter: | |||
540 | . part - the partitioning context | |||
541 | ||||
542 | Options Database Keys: | |||
543 | + -mat_partitioning_hierarchical_coarseparttype - partitioner type at the first level and parmetis is used by default | |||
544 | . -mat_partitioning_hierarchical_fineparttype - partitioner type at the second level and parmetis is used by default | |||
545 | . -mat_partitioning_hierarchical_ncoarseparts - number of subgraphs is required at the first level, which is often the number of compute nodes | |||
546 | - -mat_partitioning_hierarchical_nfineparts - number of smaller subgraphs for each subgraph, which is often the number of cores per compute node | |||
547 | ||||
548 | Level: beginner | |||
549 | ||||
550 | References: | |||
551 | 1. Fande Kong, Xiao-Chuan Cai, A highly scalable multilevel Schwarz method with boundary geometry preserving coarse spaces for 3D elasticity | |||
552 | problems on domains with complex geometry, SIAM Journal on Scientific Computing 38 (2), C73-C95, 2016 | |||
553 | 2. Fande Kong, Roy H. Stogner, Derek Gaston, John W. Peterson, Cody J. Permann, Andrew E. Slaughter, and Richard C. Martineau, | |||
554 | A general-purpose hierarchical mesh partitioning method with node balancing strategies for large-scale numerical simulations, | |||
555 | arXiv preprint arXiv:1809.02666CoRR, 2018. | |||
556 | ||||
557 | .seealso: MatPartitioningSetType(), MatPartitioningType | |||
558 | ||||
559 | M*/ | |||
560 | ||||
561 | PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode MatPartitioningCreate_Hierarchical(MatPartitioning part) | |||
562 | { | |||
563 | PetscErrorCode ierr; | |||
564 | MatPartitioning_Hierarchical *hpart; | |||
565 | ||||
566 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ; petscstack->line[petscstack->currentsize] = 566; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
567 | ierr = PetscNewLog(part,&hpart)(PetscMallocA(1,PETSC_TRUE,567,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,(size_t)(1)*sizeof(**(((&hpart)))),(((&hpart)))) || PetscLogObjectMemory ((PetscObject)part,sizeof(**(&hpart))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),567,__func__,"/sandbox/petsc/petsc.master/src/mat/partition/impls/hierarchical/hierarchical.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
568 | part->data = (void*)hpart; | |||
569 | ||||
570 | hpart->fineparttype = 0; /* fine level (second) partitioner */ | |||
571 | hpart->coarseparttype = 0; /* coarse level (first) partitioner */ | |||
572 | hpart->nfineparts = 1; /* we do not further partition coarse partition any more by default */ | |||
573 | hpart->ncoarseparts = 0; /* number of coarse parts (first level) */ | |||
574 | hpart->coarseparts = 0; | |||
575 | hpart->fineparts = 0; | |||
576 | hpart->coarseMatPart = 0; | |||
577 | hpart->fineMatPart = 0; | |||
578 | ||||
579 | part->ops->apply = MatPartitioningApply_Hierarchical; | |||
580 | part->ops->view = MatPartitioningView_Hierarchical; | |||
581 | part->ops->destroy = MatPartitioningDestroy_Hierarchical; | |||
582 | part->ops->setfromoptions = MatPartitioningSetFromOptions_Hierarchical; | |||
583 | part->ops->improve = MatPartitioningImprove_Hierarchical; | |||
584 | 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); | |||
585 | } |