File: | vec/is/utils/isltog.c |
Warning: | line 196, column 10 Array access (via field 'flags') results in a null pointer dereference |
[?] Use j/k keys for keyboard navigation
1 | ||||
2 | #include <petsc/private/isimpl.h> /*I "petscis.h" I*/ | |||
3 | #include <petsc/private/hashmapi.h> | |||
4 | #include <petscsf.h> | |||
5 | #include <petscviewer.h> | |||
6 | ||||
7 | PetscClassId IS_LTOGM_CLASSID; | |||
8 | static PetscErrorCode ISLocalToGlobalMappingGetBlockInfo_Private(ISLocalToGlobalMapping,PetscInt*,PetscInt**,PetscInt**,PetscInt***); | |||
9 | ||||
10 | typedef struct { | |||
11 | PetscInt *globals; | |||
12 | } ISLocalToGlobalMapping_Basic; | |||
13 | ||||
14 | typedef struct { | |||
15 | PetscHMapI globalht; | |||
16 | } ISLocalToGlobalMapping_Hash; | |||
17 | ||||
18 | ||||
19 | PetscErrorCode ISGetPointRange(IS pointIS, PetscInt *pStart, PetscInt *pEnd, const PetscInt **points) | |||
20 | { | |||
21 | PetscInt numCells, step = 1; | |||
22 | PetscBool isStride; | |||
23 | PetscErrorCode ierr; | |||
24 | ||||
25 | PetscFunctionBeginHotdo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 25; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
26 | *pStart = 0; | |||
27 | *points = NULL((void*)0); | |||
28 | ierr = ISGetLocalSize(pointIS, &numCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),28,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
29 | ierr = PetscObjectTypeCompare((PetscObject) pointIS, ISSTRIDE"stride", &isStride);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),29,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
30 | if (isStride) {ierr = ISStrideGetInfo(pointIS, pStart, &step);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),30,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
31 | *pEnd = *pStart + numCells; | |||
32 | if (!isStride || step != 1) {ierr = ISGetIndices(pointIS, points);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),32,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
33 | 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); | |||
34 | } | |||
35 | ||||
36 | PetscErrorCode ISRestorePointRange(IS pointIS, PetscInt *pStart, PetscInt *pEnd, const PetscInt **points) | |||
37 | { | |||
38 | PetscInt step = 1; | |||
39 | PetscBool isStride; | |||
40 | PetscErrorCode ierr; | |||
41 | ||||
42 | PetscFunctionBeginHotdo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 42; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
43 | ierr = PetscObjectTypeCompare((PetscObject) pointIS, ISSTRIDE"stride", &isStride);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),43,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
44 | if (isStride) {ierr = ISStrideGetInfo(pointIS, pStart, &step);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),44,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
45 | if (!isStride || step != 1) {ierr = ISGetIndices(pointIS, points);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),45,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
46 | 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); | |||
47 | } | |||
48 | ||||
49 | PetscErrorCode ISGetPointSubrange(IS subpointIS, PetscInt pStart, PetscInt pEnd, const PetscInt *points) | |||
50 | { | |||
51 | PetscErrorCode ierr; | |||
52 | ||||
53 | PetscFunctionBeginHotdo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 53; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
54 | if (points) { | |||
55 | ierr = ISSetType(subpointIS, ISGENERAL"general");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),55,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
56 | ierr = ISGeneralSetIndices(subpointIS, pEnd-pStart, &points[pStart], PETSC_USE_POINTER);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),56,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
57 | } else { | |||
58 | ierr = ISSetType(subpointIS, ISSTRIDE"stride");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),58,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
59 | ierr = ISStrideSetStride(subpointIS, pEnd-pStart, pStart, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),59,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
60 | } | |||
61 | 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); | |||
62 | } | |||
63 | ||||
64 | /* -----------------------------------------------------------------------------------------*/ | |||
65 | ||||
66 | /* | |||
67 | Creates the global mapping information in the ISLocalToGlobalMapping structure | |||
68 | ||||
69 | If the user has not selected how to handle the global to local mapping then use HASH for "large" problems | |||
70 | */ | |||
71 | static PetscErrorCode ISGlobalToLocalMappingSetUp(ISLocalToGlobalMapping mapping) | |||
72 | { | |||
73 | PetscInt i,*idx = mapping->indices,n = mapping->n,end,start; | |||
74 | PetscErrorCode ierr; | |||
75 | ||||
76 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 76; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
77 | if (mapping->data) PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
78 | end = 0; | |||
79 | start = PETSC_MAX_INT2147483647; | |||
80 | ||||
81 | for (i=0; i<n; i++) { | |||
82 | if (idx[i] < 0) continue; | |||
83 | if (idx[i] < start) start = idx[i]; | |||
84 | if (idx[i] > end) end = idx[i]; | |||
85 | } | |||
86 | if (start > end) {start = 0; end = -1;} | |||
87 | mapping->globalstart = start; | |||
88 | mapping->globalend = end; | |||
89 | if (!((PetscObject)mapping)->type_name) { | |||
90 | if ((end - start) > PetscMax(4*n,1000000)(((4*n)<(1000000)) ? (1000000) : (4*n))) { | |||
91 | ierr = ISLocalToGlobalMappingSetType(mapping,ISLOCALTOGLOBALMAPPINGHASH"hash");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),91,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
92 | } else { | |||
93 | ierr = ISLocalToGlobalMappingSetType(mapping,ISLOCALTOGLOBALMAPPINGBASIC"basic");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),93,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
94 | } | |||
95 | } | |||
96 | ierr = (*mapping->ops->globaltolocalmappingsetup)(mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),96,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
97 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
98 | } | |||
99 | ||||
100 | static PetscErrorCode ISGlobalToLocalMappingSetUp_Basic(ISLocalToGlobalMapping mapping) | |||
101 | { | |||
102 | PetscErrorCode ierr; | |||
103 | PetscInt i,*idx = mapping->indices,n = mapping->n,end,start,*globals; | |||
104 | ISLocalToGlobalMapping_Basic *map; | |||
105 | ||||
106 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 106; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
107 | start = mapping->globalstart; | |||
108 | end = mapping->globalend; | |||
109 | ierr = PetscNew(&map)PetscMallocA(1,PETSC_TRUE,109,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(1)*sizeof(**((&map))),((&map)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),109,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
110 | ierr = PetscMalloc1(end-start+2,&globals)PetscMallocA(1,PETSC_FALSE,110,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(end-start+2)*sizeof(**(&globals)),(&globals ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),110,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
111 | map->globals = globals; | |||
112 | for (i=0; i<end-start+1; i++) globals[i] = -1; | |||
113 | for (i=0; i<n; i++) { | |||
114 | if (idx[i] < 0) continue; | |||
115 | globals[idx[i] - start] = i; | |||
116 | } | |||
117 | mapping->data = (void*)map; | |||
118 | ierr = PetscLogObjectMemory((PetscObject)mapping,(end-start+1)*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),118,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
119 | 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); | |||
120 | } | |||
121 | ||||
122 | static PetscErrorCode ISGlobalToLocalMappingSetUp_Hash(ISLocalToGlobalMapping mapping) | |||
123 | { | |||
124 | PetscErrorCode ierr; | |||
125 | PetscInt i,*idx = mapping->indices,n = mapping->n; | |||
126 | ISLocalToGlobalMapping_Hash *map; | |||
127 | ||||
128 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 128; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
129 | ierr = PetscNew(&map)PetscMallocA(1,PETSC_TRUE,129,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(1)*sizeof(**((&map))),((&map)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),129,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
130 | ierr = PetscHMapICreate(&map->globalht);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),130,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
| ||||
131 | for (i=0; i<n; i++ ) { | |||
132 | if (idx[i] < 0) continue; | |||
133 | ierr = PetscHMapISet(map->globalht,idx[i],i);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),133,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
134 | } | |||
135 | mapping->data = (void*)map; | |||
136 | ierr = PetscLogObjectMemory((PetscObject)mapping,2*n*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),136,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
137 | 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); | |||
138 | } | |||
139 | ||||
140 | static PetscErrorCode ISLocalToGlobalMappingDestroy_Basic(ISLocalToGlobalMapping mapping) | |||
141 | { | |||
142 | PetscErrorCode ierr; | |||
143 | ISLocalToGlobalMapping_Basic *map = (ISLocalToGlobalMapping_Basic *)mapping->data; | |||
144 | ||||
145 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 145; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
146 | if (!map) 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); | |||
147 | ierr = PetscFree(map->globals)((*PetscTrFree)((void*)(map->globals),147,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((map->globals) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),147,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
148 | ierr = PetscFree(mapping->data)((*PetscTrFree)((void*)(mapping->data),148,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((mapping->data) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),148,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
149 | 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); | |||
150 | } | |||
151 | ||||
152 | static PetscErrorCode ISLocalToGlobalMappingDestroy_Hash(ISLocalToGlobalMapping mapping) | |||
153 | { | |||
154 | PetscErrorCode ierr; | |||
155 | ISLocalToGlobalMapping_Hash *map = (ISLocalToGlobalMapping_Hash*)mapping->data; | |||
156 | ||||
157 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 157; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
158 | if (!map) 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); | |||
159 | ierr = PetscHMapIDestroy(&map->globalht);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),159,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
160 | ierr = PetscFree(mapping->data)((*PetscTrFree)((void*)(mapping->data),160,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((mapping->data) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),160,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
161 | 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); | |||
162 | } | |||
163 | ||||
164 | #define GTOLTYPE _Basic | |||
165 | #define GTOLNAME _Basic | |||
166 | #define GTOLBS mapping->bs | |||
167 | #define GTOL(g, local) do { \ | |||
168 | local = map->globals[g/bs - start]; \ | |||
169 | local = bs*local + (g % bs); \ | |||
170 | } while (0) | |||
171 | ||||
172 | #include <../src/vec/is/utils/isltog.h> | |||
173 | ||||
174 | #define GTOLTYPE _Basic | |||
175 | #define GTOLNAME Block_Basic | |||
176 | #define GTOLBS 1 | |||
177 | #define GTOL(g, local) do { \ | |||
178 | local = map->globals[g - start]; \ | |||
179 | } while (0) | |||
180 | #include <../src/vec/is/utils/isltog.h> | |||
181 | ||||
182 | #define GTOLTYPE _Hash | |||
183 | #define GTOLNAME _Hash | |||
184 | #define GTOLBS mapping->bs | |||
185 | #define GTOL(g, local) do { \ | |||
186 | (void)PetscHMapIGet(map->globalht,g/bs,&local); \ | |||
187 | local = bs*local + (g % bs); \ | |||
188 | } while (0) | |||
189 | #include <../src/vec/is/utils/isltog.h> | |||
190 | ||||
191 | #define GTOLTYPE _Hash | |||
192 | #define GTOLNAME Block_Hash | |||
193 | #define GTOLBS 1 | |||
194 | #define GTOL(g, local) do { \ | |||
195 | (void)PetscHMapIGet(map->globalht,g,&local); \ | |||
196 | } while (0) | |||
197 | #include <../src/vec/is/utils/isltog.h> | |||
198 | ||||
199 | /*@ | |||
200 | ISLocalToGlobalMappingDuplicate - Duplicates the local to global mapping object | |||
201 | ||||
202 | Not Collective | |||
203 | ||||
204 | Input Parameter: | |||
205 | . ltog - local to global mapping | |||
206 | ||||
207 | Output Parameter: | |||
208 | . nltog - the duplicated local to global mapping | |||
209 | ||||
210 | Level: advanced | |||
211 | ||||
212 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreate() | |||
213 | @*/ | |||
214 | PetscErrorCode ISLocalToGlobalMappingDuplicate(ISLocalToGlobalMapping ltog,ISLocalToGlobalMapping* nltog) | |||
215 | { | |||
216 | PetscErrorCode ierr; | |||
217 | ||||
218 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 218; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
219 | PetscValidHeaderSpecific(ltog,IS_LTOGM_CLASSID,1)do { if (!ltog) return PetscError(((MPI_Comm)0x44000001),219, __func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(ltog,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),219,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(ltog))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(ltog))->classid == -1) return PetscError (((MPI_Comm)0x44000001),219,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),219,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
220 | ierr = ISLocalToGlobalMappingCreate(PetscObjectComm((PetscObject)ltog),ltog->bs,ltog->n,ltog->indices,PETSC_COPY_VALUES,nltog);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),220,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
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 | /*@ | |||
225 | ISLocalToGlobalMappingGetSize - Gets the local size of a local to global mapping | |||
226 | ||||
227 | Not Collective | |||
228 | ||||
229 | Input Parameter: | |||
230 | . ltog - local to global mapping | |||
231 | ||||
232 | Output Parameter: | |||
233 | . n - the number of entries in the local mapping, ISLocalToGlobalMappingGetIndices() returns an array of this length | |||
234 | ||||
235 | Level: advanced | |||
236 | ||||
237 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreate() | |||
238 | @*/ | |||
239 | PetscErrorCode ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping mapping,PetscInt *n) | |||
240 | { | |||
241 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 241; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
242 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),242 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),242,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),242,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),242,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
243 | PetscValidIntPointer(n,2)do { if (!n) return PetscError(((MPI_Comm)0x44000001),243,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",68,PETSC_ERROR_INITIAL ,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(n, PETSC_INT)) return PetscError(((MPI_Comm)0x44000001),243,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",68,PETSC_ERROR_INITIAL ,"Invalid Pointer to Int: Parameter # %d",2); } while (0); | |||
244 | *n = mapping->bs*mapping->n; | |||
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 | /*@C | |||
249 | ISLocalToGlobalMappingView - View a local to global mapping | |||
250 | ||||
251 | Not Collective | |||
252 | ||||
253 | Input Parameters: | |||
254 | + ltog - local to global mapping | |||
255 | - viewer - viewer | |||
256 | ||||
257 | Level: advanced | |||
258 | ||||
259 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreate() | |||
260 | @*/ | |||
261 | PetscErrorCode ISLocalToGlobalMappingView(ISLocalToGlobalMapping mapping,PetscViewer viewer) | |||
262 | { | |||
263 | PetscInt i; | |||
264 | PetscMPIInt rank; | |||
265 | PetscBool iascii; | |||
266 | PetscErrorCode ierr; | |||
267 | ||||
268 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 268; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
269 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),269 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),269,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),269,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),269,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
270 | if (!viewer) { | |||
271 | ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)mapping),&viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),271,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
272 | } | |||
273 | PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2)do { if (!viewer) return PetscError(((MPI_Comm)0x44000001),273 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",2); if ( !PetscCheckPointer(viewer,PETSC_OBJECT)) return PetscError((( MPI_Comm)0x44000001),273,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,2); if (((PetscObject)(viewer))->classid != PETSC_VIEWER_CLASSID ) { if (((PetscObject)(viewer))->classid == -1) return PetscError (((MPI_Comm)0x44000001),273,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,2); else return PetscError(((MPI_Comm)0x44000001),273,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",2); } } while (0); | |||
274 | ||||
275 | ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)mapping),&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),275,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
276 | ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII"ascii",&iascii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),276,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
277 | if (iascii) { | |||
278 | ierr = PetscObjectPrintClassNamePrefixType((PetscObject)mapping,viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),278,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
279 | ierr = PetscViewerASCIIPushSynchronized(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),279,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
280 | for (i=0; i<mapping->n; i++) { | |||
281 | ierr = PetscViewerASCIISynchronizedPrintf(viewer,"[%d] %D %D\n",rank,i,mapping->indices[i]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),281,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
282 | } | |||
283 | ierr = PetscViewerFlush(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),283,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
284 | ierr = PetscViewerASCIIPopSynchronized(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),284,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
285 | } | |||
286 | 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); | |||
287 | } | |||
288 | ||||
289 | /*@ | |||
290 | ISLocalToGlobalMappingCreateIS - Creates a mapping between a local (0 to n) | |||
291 | ordering and a global parallel ordering. | |||
292 | ||||
293 | Not collective | |||
294 | ||||
295 | Input Parameter: | |||
296 | . is - index set containing the global numbers for each local number | |||
297 | ||||
298 | Output Parameter: | |||
299 | . mapping - new mapping data structure | |||
300 | ||||
301 | Notes: | |||
302 | the block size of the IS determines the block size of the mapping | |||
303 | Level: advanced | |||
304 | ||||
305 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreate(), ISLocalToGlobalMappingSetFromOptions() | |||
306 | @*/ | |||
307 | PetscErrorCode ISLocalToGlobalMappingCreateIS(IS is,ISLocalToGlobalMapping *mapping) | |||
308 | { | |||
309 | PetscErrorCode ierr; | |||
310 | PetscInt n,bs; | |||
311 | const PetscInt *indices; | |||
312 | MPI_Comm comm; | |||
313 | PetscBool isblock; | |||
314 | ||||
315 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.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 | PetscValidHeaderSpecific(is,IS_CLASSID,1)do { if (!is) return PetscError(((MPI_Comm)0x44000001),316,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",85,PETSC_ERROR_INITIAL ,"Null Object: Parameter # %d",1); if (!PetscCheckPointer(is, PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),316,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",64,PETSC_ERROR_INITIAL ,"Invalid Pointer to Object: Parameter # %d",1); if (((PetscObject )(is))->classid != IS_CLASSID) { if (((PetscObject)(is))-> classid == -1) return PetscError(((MPI_Comm)0x44000001),316,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",64,PETSC_ERROR_INITIAL ,"Object already free: Parameter # %d",1); else return PetscError (((MPI_Comm)0x44000001),316,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,1); } } while (0); | |||
317 | PetscValidPointer(mapping,2)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),317 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(mapping,PETSC_CHAR)) return PetscError(( (MPI_Comm)0x44000001),317,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
318 | ||||
319 | ierr = PetscObjectGetComm((PetscObject)is,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),319,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
320 | ierr = ISGetLocalSize(is,&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),320,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
321 | ierr = PetscObjectTypeCompare((PetscObject)is,ISBLOCK"block",&isblock);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),321,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
322 | if (!isblock) { | |||
323 | ierr = ISGetIndices(is,&indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),323,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
324 | ierr = ISLocalToGlobalMappingCreate(comm,1,n,indices,PETSC_COPY_VALUES,mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),324,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
325 | ierr = ISRestoreIndices(is,&indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),325,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
326 | } else { | |||
327 | ierr = ISGetBlockSize(is,&bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),327,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
328 | ierr = ISBlockGetIndices(is,&indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),328,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
329 | ierr = ISLocalToGlobalMappingCreate(comm,bs,n/bs,indices,PETSC_COPY_VALUES,mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),329,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
330 | ierr = ISBlockRestoreIndices(is,&indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),330,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
331 | } | |||
332 | 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); | |||
333 | } | |||
334 | ||||
335 | /*@C | |||
336 | ISLocalToGlobalMappingCreateSF - Creates a mapping between a local (0 to n) | |||
337 | ordering and a global parallel ordering. | |||
338 | ||||
339 | Collective | |||
340 | ||||
341 | Input Parameter: | |||
342 | + sf - star forest mapping contiguous local indices to (rank, offset) | |||
343 | - start - first global index on this process | |||
344 | ||||
345 | Output Parameter: | |||
346 | . mapping - new mapping data structure | |||
347 | ||||
348 | Level: advanced | |||
349 | ||||
350 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreate(), ISLocalToGlobalMappingCreateIS(), ISLocalToGlobalMappingSetFromOptions() | |||
351 | @*/ | |||
352 | PetscErrorCode ISLocalToGlobalMappingCreateSF(PetscSF sf,PetscInt start,ISLocalToGlobalMapping *mapping) | |||
353 | { | |||
354 | PetscErrorCode ierr; | |||
355 | PetscInt i,maxlocal,nroots,nleaves,*globals,*ltog; | |||
356 | const PetscInt *ilocal; | |||
357 | MPI_Comm comm; | |||
358 | ||||
359 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 359; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
360 | PetscValidHeaderSpecific(sf,PETSCSF_CLASSID,1)do { if (!sf) return PetscError(((MPI_Comm)0x44000001),360,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",85,PETSC_ERROR_INITIAL ,"Null Object: Parameter # %d",1); if (!PetscCheckPointer(sf, PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),360,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",64,PETSC_ERROR_INITIAL ,"Invalid Pointer to Object: Parameter # %d",1); if (((PetscObject )(sf))->classid != PETSCSF_CLASSID) { if (((PetscObject)(sf ))->classid == -1) return PetscError(((MPI_Comm)0x44000001 ),360,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),360,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
361 | PetscValidPointer(mapping,3)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),361 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(mapping,PETSC_CHAR)) return PetscError(( (MPI_Comm)0x44000001),361,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); | |||
362 | ||||
363 | ierr = PetscObjectGetComm((PetscObject)sf,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),363,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
364 | ierr = PetscSFGetGraph(sf,&nroots,&nleaves,&ilocal,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),364,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
365 | if (ilocal) { | |||
366 | for (i=0,maxlocal=0; i<nleaves; i++) maxlocal = PetscMax(maxlocal,ilocal[i]+1)(((maxlocal)<(ilocal[i]+1)) ? (ilocal[i]+1) : (maxlocal)); | |||
367 | } | |||
368 | else maxlocal = nleaves; | |||
369 | ierr = PetscMalloc1(nroots,&globals)PetscMallocA(1,PETSC_FALSE,369,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nroots)*sizeof(**(&globals)),(&globals));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),369,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
370 | ierr = PetscMalloc1(maxlocal,<og)PetscMallocA(1,PETSC_FALSE,370,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(maxlocal)*sizeof(**(<og)),(<og));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),370,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
371 | for (i=0; i<nroots; i++) globals[i] = start + i; | |||
372 | for (i=0; i<maxlocal; i++) ltog[i] = -1; | |||
373 | ierr = PetscSFBcastBegin(sf,MPIU_INT((MPI_Datatype)0x4c000405),globals,ltog);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),373,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
374 | ierr = PetscSFBcastEnd(sf,MPIU_INT((MPI_Datatype)0x4c000405),globals,ltog);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),374,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
375 | ierr = ISLocalToGlobalMappingCreate(comm,1,maxlocal,ltog,PETSC_OWN_POINTER,mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),375,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
376 | ierr = PetscFree(globals)((*PetscTrFree)((void*)(globals),376,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((globals) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),376,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
377 | 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); | |||
378 | } | |||
379 | ||||
380 | /*@ | |||
381 | ISLocalToGlobalMappingSetBlockSize - Sets the blocksize of the mapping | |||
382 | ||||
383 | Not collective | |||
384 | ||||
385 | Input Parameters: | |||
386 | . mapping - mapping data structure | |||
387 | . bs - the blocksize | |||
388 | ||||
389 | Level: advanced | |||
390 | ||||
391 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS() | |||
392 | @*/ | |||
393 | PetscErrorCode ISLocalToGlobalMappingSetBlockSize(ISLocalToGlobalMapping mapping,PetscInt bs) | |||
394 | { | |||
395 | PetscInt *nid; | |||
396 | const PetscInt *oid; | |||
397 | PetscInt i,cn,on,obs,nn; | |||
398 | PetscErrorCode ierr; | |||
399 | ||||
400 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 400; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
401 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),401 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),401,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),401,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),401,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
402 | if (bs < 1) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid block size %D",bs)return PetscError(((MPI_Comm)0x44000001),402,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,62,PETSC_ERROR_INITIAL,"Invalid block size %D",bs); | |||
403 | if (bs == mapping->bs) 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); | |||
404 | on = mapping->n; | |||
405 | obs = mapping->bs; | |||
406 | oid = mapping->indices; | |||
407 | nn = (on*obs)/bs; | |||
408 | if ((on*obs)%bs) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Block size %D is inconsistent with block size %D and number of block indices %D",bs,obs,on)return PetscError(((MPI_Comm)0x44000001),408,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,62,PETSC_ERROR_INITIAL,"Block size %D is inconsistent with block size %D and number of block indices %D" ,bs,obs,on); | |||
409 | ||||
410 | ierr = PetscMalloc1(nn,&nid)PetscMallocA(1,PETSC_FALSE,410,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nn)*sizeof(**(&nid)),(&nid));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),410,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
411 | ierr = ISLocalToGlobalMappingGetIndices(mapping,&oid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),411,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
412 | for (i=0;i<nn;i++) { | |||
413 | PetscInt j; | |||
414 | for (j=0,cn=0;j<bs-1;j++) { | |||
415 | if (oid[i*bs+j] < 0) { cn++; continue; } | |||
416 | if (oid[i*bs+j] != oid[i*bs+j+1]-1) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Block sizes %D and %D are incompatible with the block indices: non consecutive indices %D %D",bs,obs,oid[i*bs+j],oid[i*bs+j+1])return PetscError(((MPI_Comm)0x44000001),416,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,62,PETSC_ERROR_INITIAL,"Block sizes %D and %D are incompatible with the block indices: non consecutive indices %D %D" ,bs,obs,oid[i*bs+j],oid[i*bs+j+1]); | |||
417 | } | |||
418 | if (oid[i*bs+j] < 0) cn++; | |||
419 | if (cn) { | |||
420 | if (cn != bs) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Block sizes %D and %D are incompatible with the block indices: invalid number of negative entries in block %D",bs,obs,cn)return PetscError(((MPI_Comm)0x44000001),420,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,62,PETSC_ERROR_INITIAL,"Block sizes %D and %D are incompatible with the block indices: invalid number of negative entries in block %D" ,bs,obs,cn); | |||
421 | nid[i] = -1; | |||
422 | } else { | |||
423 | nid[i] = oid[i*bs]/bs; | |||
424 | } | |||
425 | } | |||
426 | ierr = ISLocalToGlobalMappingRestoreIndices(mapping,&oid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),426,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
427 | ||||
428 | mapping->n = nn; | |||
429 | mapping->bs = bs; | |||
430 | ierr = PetscFree(mapping->indices)((*PetscTrFree)((void*)(mapping->indices),430,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((mapping->indices) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),430,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
431 | mapping->indices = nid; | |||
432 | mapping->globalstart = 0; | |||
433 | mapping->globalend = 0; | |||
434 | ||||
435 | /* reset the cached information */ | |||
436 | ierr = PetscFree(mapping->info_procs)((*PetscTrFree)((void*)(mapping->info_procs),436,__func__, "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( (mapping->info_procs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),436,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
437 | ierr = PetscFree(mapping->info_numprocs)((*PetscTrFree)((void*)(mapping->info_numprocs),437,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( (mapping->info_numprocs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),437,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
438 | if (mapping->info_indices) { | |||
439 | PetscInt i; | |||
440 | ||||
441 | ierr = PetscFree((mapping->info_indices)[0])((*PetscTrFree)((void*)((mapping->info_indices)[0]),441,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( ((mapping->info_indices)[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),441,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
442 | for (i=1; i<mapping->info_nproc; i++) { | |||
443 | ierr = PetscFree(mapping->info_indices[i])((*PetscTrFree)((void*)(mapping->info_indices[i]),443,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( (mapping->info_indices[i]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),443,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
444 | } | |||
445 | ierr = PetscFree(mapping->info_indices)((*PetscTrFree)((void*)(mapping->info_indices),445,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( (mapping->info_indices) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),445,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
446 | } | |||
447 | mapping->info_cached = PETSC_FALSE; | |||
448 | ||||
449 | if (mapping->ops->destroy) { | |||
450 | ierr = (*mapping->ops->destroy)(mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),450,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
451 | } | |||
452 | 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); | |||
453 | } | |||
454 | ||||
455 | /*@ | |||
456 | ISLocalToGlobalMappingGetBlockSize - Gets the blocksize of the mapping | |||
457 | ordering and a global parallel ordering. | |||
458 | ||||
459 | Not Collective | |||
460 | ||||
461 | Input Parameters: | |||
462 | . mapping - mapping data structure | |||
463 | ||||
464 | Output Parameter: | |||
465 | . bs - the blocksize | |||
466 | ||||
467 | Level: advanced | |||
468 | ||||
469 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS() | |||
470 | @*/ | |||
471 | PetscErrorCode ISLocalToGlobalMappingGetBlockSize(ISLocalToGlobalMapping mapping,PetscInt *bs) | |||
472 | { | |||
473 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 473; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
474 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),474 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),474,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),474,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),474,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
475 | *bs = mapping->bs; | |||
476 | 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); | |||
477 | } | |||
478 | ||||
479 | /*@ | |||
480 | ISLocalToGlobalMappingCreate - Creates a mapping between a local (0 to n) | |||
481 | ordering and a global parallel ordering. | |||
482 | ||||
483 | Not Collective, but communicator may have more than one process | |||
484 | ||||
485 | Input Parameters: | |||
486 | + comm - MPI communicator | |||
487 | . bs - the block size | |||
488 | . n - the number of local elements divided by the block size, or equivalently the number of block indices | |||
489 | . indices - the global index for each local element, these do not need to be in increasing order (sorted), these values should not be scaled (i.e. multiplied) by the blocksize bs | |||
490 | - mode - see PetscCopyMode | |||
491 | ||||
492 | Output Parameter: | |||
493 | . mapping - new mapping data structure | |||
494 | ||||
495 | Notes: | |||
496 | There is one integer value in indices per block and it represents the actual indices bs*idx + j, where j=0,..,bs-1 | |||
497 | ||||
498 | For "small" problems when using ISGlobalToLocalMappingApply() and ISGlobalToLocalMappingApplyBlock(), the ISLocalToGlobalMappingType of ISLOCALTOGLOBALMAPPINGBASIC will be used; | |||
499 | this uses more memory but is faster; this approach is not scalable for extremely large mappings. For large problems ISLOCALTOGLOBALMAPPINGHASH is used, this is scalable. | |||
500 | Use ISLocalToGlobalMappingSetType() or call ISLocalToGlobalMappingSetFromOptions() with the option -islocaltoglobalmapping_type <basic,hash> to control which is used. | |||
501 | ||||
502 | Level: advanced | |||
503 | ||||
504 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS(), ISLocalToGlobalMappingSetFromOptions(), ISLOCALTOGLOBALMAPPINGBASIC, ISLOCALTOGLOBALMAPPINGHASH | |||
505 | ISLocalToGlobalMappingSetType(), ISLocalToGlobalMappingType | |||
506 | @*/ | |||
507 | PetscErrorCode ISLocalToGlobalMappingCreate(MPI_Comm comm,PetscInt bs,PetscInt n,const PetscInt indices[],PetscCopyMode mode,ISLocalToGlobalMapping *mapping) | |||
508 | { | |||
509 | PetscErrorCode ierr; | |||
510 | PetscInt *in; | |||
511 | ||||
512 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 512; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
513 | if (n) PetscValidIntPointer(indices,3)do { if (!indices) return PetscError(((MPI_Comm)0x44000001),513 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(indices,PETSC_INT)) return PetscError((( MPI_Comm)0x44000001),513,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,3); } while (0); | |||
514 | PetscValidPointer(mapping,4)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),514 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if (!PetscCheckPointer(mapping,PETSC_CHAR)) return PetscError(( (MPI_Comm)0x44000001),514,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4); } while (0); | |||
515 | ||||
516 | *mapping = NULL((void*)0); | |||
517 | ierr = ISInitializePackage();CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),517,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
518 | ||||
519 | ierr = PetscHeaderCreate(*mapping,IS_LTOGM_CLASSID,"ISLocalToGlobalMapping","Local to global mapping","IS",(PetscMallocA(1,PETSC_TRUE,520,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(1)*sizeof(**((&(*mapping)))),((&(*mapping)) )) || PetscHeaderCreate_Private((PetscObject)*mapping,IS_LTOGM_CLASSID ,"ISLocalToGlobalMapping","Local to global mapping","IS",comm ,(PetscObjectDestroyFunction)ISLocalToGlobalMappingDestroy,(PetscObjectViewFunction )ISLocalToGlobalMappingView) || ((PetscLogPHC) ? (*PetscLogPHC )((PetscObject)(*mapping)) : 0) || PetscLogObjectMemory((PetscObject )*mapping,sizeof(*(*mapping)))) | |||
520 | comm,ISLocalToGlobalMappingDestroy,ISLocalToGlobalMappingView)(PetscMallocA(1,PETSC_TRUE,520,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(1)*sizeof(**((&(*mapping)))),((&(*mapping)) )) || PetscHeaderCreate_Private((PetscObject)*mapping,IS_LTOGM_CLASSID ,"ISLocalToGlobalMapping","Local to global mapping","IS",comm ,(PetscObjectDestroyFunction)ISLocalToGlobalMappingDestroy,(PetscObjectViewFunction )ISLocalToGlobalMappingView) || ((PetscLogPHC) ? (*PetscLogPHC )((PetscObject)(*mapping)) : 0) || PetscLogObjectMemory((PetscObject )*mapping,sizeof(*(*mapping))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),520,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
521 | (*mapping)->n = n; | |||
522 | (*mapping)->bs = bs; | |||
523 | (*mapping)->info_cached = PETSC_FALSE; | |||
524 | (*mapping)->info_free = PETSC_FALSE; | |||
525 | (*mapping)->info_procs = NULL((void*)0); | |||
526 | (*mapping)->info_numprocs = NULL((void*)0); | |||
527 | (*mapping)->info_indices = NULL((void*)0); | |||
528 | (*mapping)->info_nodec = NULL((void*)0); | |||
529 | (*mapping)->info_nodei = NULL((void*)0); | |||
530 | ||||
531 | (*mapping)->ops->globaltolocalmappingapply = NULL((void*)0); | |||
532 | (*mapping)->ops->globaltolocalmappingapplyblock = NULL((void*)0); | |||
533 | (*mapping)->ops->destroy = NULL((void*)0); | |||
534 | if (mode == PETSC_COPY_VALUES) { | |||
535 | ierr = PetscMalloc1(n,&in)PetscMallocA(1,PETSC_FALSE,535,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(n)*sizeof(**(&in)),(&in));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),535,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
536 | ierr = PetscArraycpy(in,indices,n)((sizeof(*(in)) != sizeof(*(indices))) || PetscMemcpy(in,indices ,(n)*sizeof(*(in))));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),536,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
537 | (*mapping)->indices = in; | |||
538 | ierr = PetscLogObjectMemory((PetscObject)*mapping,n*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),538,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
539 | } else if (mode == PETSC_OWN_POINTER) { | |||
540 | (*mapping)->indices = (PetscInt*)indices; | |||
541 | ierr = PetscLogObjectMemory((PetscObject)*mapping,n*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),541,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
542 | } | |||
543 | else SETERRQ(comm,PETSC_ERR_SUP,"Cannot currently use PETSC_USE_POINTER")return PetscError(comm,543,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,56,PETSC_ERROR_INITIAL,"Cannot currently use PETSC_USE_POINTER" ); | |||
544 | 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); | |||
545 | } | |||
546 | ||||
547 | PetscFunctionList ISLocalToGlobalMappingList = NULL((void*)0); | |||
548 | ||||
549 | ||||
550 | /*@ | |||
551 | ISLocalToGlobalMappingSetFromOptions - Set mapping options from the options database. | |||
552 | ||||
553 | Not collective | |||
554 | ||||
555 | Input Parameters: | |||
556 | . mapping - mapping data structure | |||
557 | ||||
558 | Level: advanced | |||
559 | ||||
560 | @*/ | |||
561 | PetscErrorCode ISLocalToGlobalMappingSetFromOptions(ISLocalToGlobalMapping mapping) | |||
562 | { | |||
563 | PetscErrorCode ierr; | |||
564 | char type[256]; | |||
565 | ISLocalToGlobalMappingType defaulttype = "Not set"; | |||
566 | PetscBool flg; | |||
567 | ||||
568 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 568; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
569 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),569 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),569,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),569,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),569,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
570 | ierr = ISLocalToGlobalMappingRegisterAll();CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),570,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
571 | ierr = PetscObjectOptionsBegin((PetscObject)mapping)0; do { PetscOptionItems PetscOptionsObjectBase; PetscOptionItems *PetscOptionsObject = &PetscOptionsObjectBase; PetscOptionsObject ->options = ((PetscObject)(PetscObject)mapping)->options ; for (PetscOptionsObject->count=(PetscOptionsPublish?-1:1 ); PetscOptionsObject->count<2; PetscOptionsObject-> count++) { PetscErrorCode _5_ierr = PetscObjectOptionsBegin_Private (PetscOptionsObject,(PetscObject)mapping);do {if (__builtin_expect (!!(_5_ierr),0)) return PetscError(((MPI_Comm)0x44000001),571 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),571,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
572 | ierr = PetscOptionsFList("-islocaltoglobalmapping_type","ISLocalToGlobalMapping method","ISLocalToGlobalMappingSetType",ISLocalToGlobalMappingList,(char*)(((PetscObject)mapping)->type_name) ? ((PetscObject)mapping)->type_name : defaulttype,type,256,&flg)PetscOptionsFList_Private(PetscOptionsObject,"-islocaltoglobalmapping_type" ,"ISLocalToGlobalMapping method","ISLocalToGlobalMappingSetType" ,ISLocalToGlobalMappingList,(char*)(((PetscObject)mapping)-> type_name) ? ((PetscObject)mapping)->type_name : defaulttype ,type,256,&flg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),572,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
573 | if (flg) { | |||
574 | ierr = ISLocalToGlobalMappingSetType(mapping,type);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),574,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
575 | } | |||
576 | ierr = PetscOptionsEnd()_5_ierr = PetscOptionsEnd_Private(PetscOptionsObject);do {if ( __builtin_expect(!!(_5_ierr),0)) return PetscError(((MPI_Comm )0x44000001),576,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);}} while (0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),576,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
577 | 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); | |||
578 | } | |||
579 | ||||
580 | /*@ | |||
581 | ISLocalToGlobalMappingDestroy - Destroys a mapping between a local (0 to n) | |||
582 | ordering and a global parallel ordering. | |||
583 | ||||
584 | Note Collective | |||
585 | ||||
586 | Input Parameters: | |||
587 | . mapping - mapping data structure | |||
588 | ||||
589 | Level: advanced | |||
590 | ||||
591 | .seealso: ISLocalToGlobalMappingCreate() | |||
592 | @*/ | |||
593 | PetscErrorCode ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping *mapping) | |||
594 | { | |||
595 | PetscErrorCode ierr; | |||
596 | ||||
597 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 597; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
598 | if (!*mapping) 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); | |||
599 | PetscValidHeaderSpecific((*mapping),IS_LTOGM_CLASSID,1)do { if (!(*mapping)) return PetscError(((MPI_Comm)0x44000001 ),599,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer((*mapping),PETSC_OBJECT)) return PetscError (((MPI_Comm)0x44000001),599,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)((*mapping)))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)((*mapping)))->classid == -1) return PetscError(((MPI_Comm)0x44000001),599,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),599,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
600 | if (--((PetscObject)(*mapping))->refct > 0) {*mapping = 0;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);} | |||
601 | ierr = PetscFree((*mapping)->indices)((*PetscTrFree)((void*)((*mapping)->indices),601,__func__, "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( ((*mapping)->indices) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),601,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
602 | ierr = PetscFree((*mapping)->info_procs)((*PetscTrFree)((void*)((*mapping)->info_procs),602,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( ((*mapping)->info_procs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),602,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
603 | ierr = PetscFree((*mapping)->info_numprocs)((*PetscTrFree)((void*)((*mapping)->info_numprocs),603,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( ((*mapping)->info_numprocs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),603,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
604 | if ((*mapping)->info_indices) { | |||
605 | PetscInt i; | |||
606 | ||||
607 | ierr = PetscFree(((*mapping)->info_indices)[0])((*PetscTrFree)((void*)(((*mapping)->info_indices)[0]),607 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((((*mapping)->info_indices)[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),607,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
608 | for (i=1; i<(*mapping)->info_nproc; i++) { | |||
609 | ierr = PetscFree(((*mapping)->info_indices)[i])((*PetscTrFree)((void*)(((*mapping)->info_indices)[i]),609 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((((*mapping)->info_indices)[i]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),609,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
610 | } | |||
611 | ierr = PetscFree((*mapping)->info_indices)((*PetscTrFree)((void*)((*mapping)->info_indices),611,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( ((*mapping)->info_indices) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),611,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
612 | } | |||
613 | if ((*mapping)->info_nodei) { | |||
614 | ierr = PetscFree(((*mapping)->info_nodei)[0])((*PetscTrFree)((void*)(((*mapping)->info_nodei)[0]),614,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c") || ( (((*mapping)->info_nodei)[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),614,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
615 | } | |||
616 | ierr = PetscFree2((*mapping)->info_nodec,(*mapping)->info_nodei)PetscFreeA(2,616,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,&((*mapping)->info_nodec),&((*mapping)->info_nodei ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),616,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
617 | if ((*mapping)->ops->destroy) { | |||
618 | ierr = (*(*mapping)->ops->destroy)(*mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),618,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
619 | } | |||
620 | ierr = PetscHeaderDestroy(mapping)(PetscHeaderDestroy_Private((PetscObject)(*mapping)) || ((*PetscTrFree )((void*)(*mapping),620,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((*mapping) = 0,0)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),620,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
621 | *mapping = 0; | |||
622 | 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); | |||
623 | } | |||
624 | ||||
625 | /*@ | |||
626 | ISLocalToGlobalMappingApplyIS - Creates from an IS in the local numbering | |||
627 | a new index set using the global numbering defined in an ISLocalToGlobalMapping | |||
628 | context. | |||
629 | ||||
630 | Collective on is | |||
631 | ||||
632 | Input Parameters: | |||
633 | + mapping - mapping between local and global numbering | |||
634 | - is - index set in local numbering | |||
635 | ||||
636 | Output Parameters: | |||
637 | . newis - index set in global numbering | |||
638 | ||||
639 | Notes: | |||
640 | The output IS will have the same communicator of the input IS. | |||
641 | ||||
642 | Level: advanced | |||
643 | ||||
644 | .seealso: ISLocalToGlobalMappingApply(), ISLocalToGlobalMappingCreate(), | |||
645 | ISLocalToGlobalMappingDestroy(), ISGlobalToLocalMappingApply() | |||
646 | @*/ | |||
647 | PetscErrorCode ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping mapping,IS is,IS *newis) | |||
648 | { | |||
649 | PetscErrorCode ierr; | |||
650 | PetscInt n,*idxout; | |||
651 | const PetscInt *idxin; | |||
652 | ||||
653 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 653; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
654 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),654 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),654,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),654,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),654,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
655 | PetscValidHeaderSpecific(is,IS_CLASSID,2)do { if (!is) return PetscError(((MPI_Comm)0x44000001),655,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",85,PETSC_ERROR_INITIAL ,"Null Object: Parameter # %d",2); if (!PetscCheckPointer(is, PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),655,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",64,PETSC_ERROR_INITIAL ,"Invalid Pointer to Object: Parameter # %d",2); if (((PetscObject )(is))->classid != IS_CLASSID) { if (((PetscObject)(is))-> classid == -1) return PetscError(((MPI_Comm)0x44000001),655,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",64,PETSC_ERROR_INITIAL ,"Object already free: Parameter # %d",2); else return PetscError (((MPI_Comm)0x44000001),655,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,2); } } while (0); | |||
656 | PetscValidPointer(newis,3)do { if (!newis) return PetscError(((MPI_Comm)0x44000001),656 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(newis,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),656,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); | |||
657 | ||||
658 | ierr = ISGetLocalSize(is,&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),658,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
659 | ierr = ISGetIndices(is,&idxin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),659,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
660 | ierr = PetscMalloc1(n,&idxout)PetscMallocA(1,PETSC_FALSE,660,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(n)*sizeof(**(&idxout)),(&idxout));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),660,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
661 | ierr = ISLocalToGlobalMappingApply(mapping,n,idxin,idxout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),661,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
662 | ierr = ISRestoreIndices(is,&idxin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),662,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
663 | ierr = ISCreateGeneral(PetscObjectComm((PetscObject)is),n,idxout,PETSC_OWN_POINTER,newis);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),663,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
664 | 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); | |||
665 | } | |||
666 | ||||
667 | /*@ | |||
668 | ISLocalToGlobalMappingApply - Takes a list of integers in a local numbering | |||
669 | and converts them to the global numbering. | |||
670 | ||||
671 | Not collective | |||
672 | ||||
673 | Input Parameters: | |||
674 | + mapping - the local to global mapping context | |||
675 | . N - number of integers | |||
676 | - in - input indices in local numbering | |||
677 | ||||
678 | Output Parameter: | |||
679 | . out - indices in global numbering | |||
680 | ||||
681 | Notes: | |||
682 | The in and out array parameters may be identical. | |||
683 | ||||
684 | Level: advanced | |||
685 | ||||
686 | .seealso: ISLocalToGlobalMappingApplyBlock(), ISLocalToGlobalMappingCreate(),ISLocalToGlobalMappingDestroy(), | |||
687 | ISLocalToGlobalMappingApplyIS(),AOCreateBasic(),AOApplicationToPetsc(), | |||
688 | AOPetscToApplication(), ISGlobalToLocalMappingApply() | |||
689 | ||||
690 | @*/ | |||
691 | PetscErrorCode ISLocalToGlobalMappingApply(ISLocalToGlobalMapping mapping,PetscInt N,const PetscInt in[],PetscInt out[]) | |||
692 | { | |||
693 | PetscInt i,bs,Nmax; | |||
694 | ||||
695 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 695; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
696 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),696 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),696,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),696,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),696,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
697 | bs = mapping->bs; | |||
698 | Nmax = bs*mapping->n; | |||
699 | if (bs == 1) { | |||
700 | const PetscInt *idx = mapping->indices; | |||
701 | for (i=0; i<N; i++) { | |||
702 | if (in[i] < 0) { | |||
703 | out[i] = in[i]; | |||
704 | continue; | |||
705 | } | |||
706 | if (in[i] >= Nmax) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local index %D too large %D (max) at %D",in[i],Nmax-1,i)return PetscError(((MPI_Comm)0x44000001),706,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,63,PETSC_ERROR_INITIAL,"Local index %D too large %D (max) at %D" ,in[i],Nmax-1,i); | |||
707 | out[i] = idx[in[i]]; | |||
708 | } | |||
709 | } else { | |||
710 | const PetscInt *idx = mapping->indices; | |||
711 | for (i=0; i<N; i++) { | |||
712 | if (in[i] < 0) { | |||
713 | out[i] = in[i]; | |||
714 | continue; | |||
715 | } | |||
716 | if (in[i] >= Nmax) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local index %D too large %D (max) at %D",in[i],Nmax-1,i)return PetscError(((MPI_Comm)0x44000001),716,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,63,PETSC_ERROR_INITIAL,"Local index %D too large %D (max) at %D" ,in[i],Nmax-1,i); | |||
717 | out[i] = idx[in[i]/bs]*bs + (in[i] % bs); | |||
718 | } | |||
719 | } | |||
720 | 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); | |||
721 | } | |||
722 | ||||
723 | /*@ | |||
724 | ISLocalToGlobalMappingApplyBlock - Takes a list of integers in a local block numbering and converts them to the global block numbering | |||
725 | ||||
726 | Not collective | |||
727 | ||||
728 | Input Parameters: | |||
729 | + mapping - the local to global mapping context | |||
730 | . N - number of integers | |||
731 | - in - input indices in local block numbering | |||
732 | ||||
733 | Output Parameter: | |||
734 | . out - indices in global block numbering | |||
735 | ||||
736 | Notes: | |||
737 | The in and out array parameters may be identical. | |||
738 | ||||
739 | Example: | |||
740 | If the index values are {0,1,6,7} set with a call to ISLocalToGlobalMappingCreate(PETSC_COMM_SELF,2,2,{0,3}) then the mapping applied to 0 | |||
741 | (the first block) would produce 0 and the mapping applied to 1 (the second block) would produce 3. | |||
742 | ||||
743 | Level: advanced | |||
744 | ||||
745 | .seealso: ISLocalToGlobalMappingApply(), ISLocalToGlobalMappingCreate(),ISLocalToGlobalMappingDestroy(), | |||
746 | ISLocalToGlobalMappingApplyIS(),AOCreateBasic(),AOApplicationToPetsc(), | |||
747 | AOPetscToApplication(), ISGlobalToLocalMappingApply() | |||
748 | ||||
749 | @*/ | |||
750 | PetscErrorCode ISLocalToGlobalMappingApplyBlock(ISLocalToGlobalMapping mapping,PetscInt N,const PetscInt in[],PetscInt out[]) | |||
751 | { | |||
752 | ||||
753 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 753; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
754 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),754 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),754,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),754,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),754,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
755 | { | |||
756 | PetscInt i,Nmax = mapping->n; | |||
757 | const PetscInt *idx = mapping->indices; | |||
758 | ||||
759 | for (i=0; i<N; i++) { | |||
760 | if (in[i] < 0) { | |||
761 | out[i] = in[i]; | |||
762 | continue; | |||
763 | } | |||
764 | if (in[i] >= Nmax) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local block index %D too large %D (max) at %D",in[i],Nmax-1,i)return PetscError(((MPI_Comm)0x44000001),764,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,63,PETSC_ERROR_INITIAL,"Local block index %D too large %D (max) at %D" ,in[i],Nmax-1,i); | |||
765 | out[i] = idx[in[i]]; | |||
766 | } | |||
767 | } | |||
768 | 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); | |||
769 | } | |||
770 | ||||
771 | /*@ | |||
772 | ISGlobalToLocalMappingApply - Provides the local numbering for a list of integers | |||
773 | specified with a global numbering. | |||
774 | ||||
775 | Not collective | |||
776 | ||||
777 | Input Parameters: | |||
778 | + mapping - mapping between local and global numbering | |||
779 | . type - IS_GTOLM_MASK - replaces global indices with no local value with -1 | |||
780 | IS_GTOLM_DROP - drops the indices with no local value from the output list | |||
781 | . n - number of global indices to map | |||
782 | - idx - global indices to map | |||
783 | ||||
784 | Output Parameters: | |||
785 | + nout - number of indices in output array (if type == IS_GTOLM_MASK then nout = n) | |||
786 | - idxout - local index of each global index, one must pass in an array long enough | |||
787 | to hold all the indices. You can call ISGlobalToLocalMappingApply() with | |||
788 | idxout == NULL to determine the required length (returned in nout) | |||
789 | and then allocate the required space and call ISGlobalToLocalMappingApply() | |||
790 | a second time to set the values. | |||
791 | ||||
792 | Notes: | |||
793 | Either nout or idxout may be NULL. idx and idxout may be identical. | |||
794 | ||||
795 | For "small" problems when using ISGlobalToLocalMappingApply() and ISGlobalToLocalMappingApplyBlock(), the ISLocalToGlobalMappingType of ISLOCALTOGLOBALMAPPINGBASIC will be used; | |||
796 | this uses more memory but is faster; this approach is not scalable for extremely large mappings. For large problems ISLOCALTOGLOBALMAPPINGHASH is used, this is scalable. | |||
797 | Use ISLocalToGlobalMappingSetType() or call ISLocalToGlobalMappingSetFromOptions() with the option -islocaltoglobalmapping_type <basic,hash> to control which is used. | |||
798 | ||||
799 | Level: advanced | |||
800 | ||||
801 | Developer Note: The manual page states that idx and idxout may be identical but the calling | |||
802 | sequence declares idx as const so it cannot be the same as idxout. | |||
803 | ||||
804 | .seealso: ISLocalToGlobalMappingApply(), ISGlobalToLocalMappingApplyBlock(), ISLocalToGlobalMappingCreate(), | |||
805 | ISLocalToGlobalMappingDestroy() | |||
806 | @*/ | |||
807 | PetscErrorCode ISGlobalToLocalMappingApply(ISLocalToGlobalMapping mapping,ISGlobalToLocalMappingMode type,PetscInt n,const PetscInt idx[],PetscInt *nout,PetscInt idxout[]) | |||
808 | { | |||
809 | PetscErrorCode ierr; | |||
810 | ||||
811 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 811; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
812 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),812 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),812,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),812,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),812,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
813 | if (!mapping->data) { | |||
814 | ierr = ISGlobalToLocalMappingSetUp(mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),814,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
815 | } | |||
816 | ierr = (*mapping->ops->globaltolocalmappingapply)(mapping,type,n,idx,nout,idxout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),816,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
817 | 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); | |||
818 | } | |||
819 | ||||
820 | /*@ | |||
821 | ISGlobalToLocalMappingApplyIS - Creates from an IS in the global numbering | |||
822 | a new index set using the local numbering defined in an ISLocalToGlobalMapping | |||
823 | context. | |||
824 | ||||
825 | Not collective | |||
826 | ||||
827 | Input Parameters: | |||
828 | + mapping - mapping between local and global numbering | |||
829 | . type - IS_GTOLM_MASK - replaces global indices with no local value with -1 | |||
830 | IS_GTOLM_DROP - drops the indices with no local value from the output list | |||
831 | - is - index set in global numbering | |||
832 | ||||
833 | Output Parameters: | |||
834 | . newis - index set in local numbering | |||
835 | ||||
836 | Notes: | |||
837 | The output IS will be sequential, as it encodes a purely local operation | |||
838 | ||||
839 | Level: advanced | |||
840 | ||||
841 | .seealso: ISGlobalToLocalMappingApply(), ISLocalToGlobalMappingCreate(), | |||
842 | ISLocalToGlobalMappingDestroy() | |||
843 | @*/ | |||
844 | PetscErrorCode ISGlobalToLocalMappingApplyIS(ISLocalToGlobalMapping mapping,ISGlobalToLocalMappingMode type,IS is,IS *newis) | |||
845 | { | |||
846 | PetscErrorCode ierr; | |||
847 | PetscInt n,nout,*idxout; | |||
848 | const PetscInt *idxin; | |||
849 | ||||
850 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 850; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
851 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),851 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),851,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),851,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),851,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
852 | PetscValidHeaderSpecific(is,IS_CLASSID,3)do { if (!is) return PetscError(((MPI_Comm)0x44000001),852,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",85,PETSC_ERROR_INITIAL ,"Null Object: Parameter # %d",3); if (!PetscCheckPointer(is, PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),852,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",64,PETSC_ERROR_INITIAL ,"Invalid Pointer to Object: Parameter # %d",3); if (((PetscObject )(is))->classid != IS_CLASSID) { if (((PetscObject)(is))-> classid == -1) return PetscError(((MPI_Comm)0x44000001),852,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",64,PETSC_ERROR_INITIAL ,"Object already free: Parameter # %d",3); else return PetscError (((MPI_Comm)0x44000001),852,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,3); } } while (0); | |||
853 | PetscValidPointer(newis,4)do { if (!newis) return PetscError(((MPI_Comm)0x44000001),853 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if (!PetscCheckPointer(newis,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),853,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4); } while (0); | |||
854 | ||||
855 | ierr = ISGetLocalSize(is,&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),855,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
856 | ierr = ISGetIndices(is,&idxin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),856,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
857 | if (type == IS_GTOLM_MASK) { | |||
858 | ierr = PetscMalloc1(n,&idxout)PetscMallocA(1,PETSC_FALSE,858,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(n)*sizeof(**(&idxout)),(&idxout));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),858,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
859 | } else { | |||
860 | ierr = ISGlobalToLocalMappingApply(mapping,type,n,idxin,&nout,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),860,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
861 | ierr = PetscMalloc1(nout,&idxout)PetscMallocA(1,PETSC_FALSE,861,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nout)*sizeof(**(&idxout)),(&idxout));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),861,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
862 | } | |||
863 | ierr = ISGlobalToLocalMappingApply(mapping,type,n,idxin,&nout,idxout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),863,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
864 | ierr = ISRestoreIndices(is,&idxin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),864,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
865 | ierr = ISCreateGeneral(PETSC_COMM_SELF((MPI_Comm)0x44000001),nout,idxout,PETSC_OWN_POINTER,newis);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),865,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
866 | 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); | |||
867 | } | |||
868 | ||||
869 | /*@ | |||
870 | ISGlobalToLocalMappingApplyBlock - Provides the local block numbering for a list of integers | |||
871 | specified with a block global numbering. | |||
872 | ||||
873 | Not collective | |||
874 | ||||
875 | Input Parameters: | |||
876 | + mapping - mapping between local and global numbering | |||
877 | . type - IS_GTOLM_MASK - replaces global indices with no local value with -1 | |||
878 | IS_GTOLM_DROP - drops the indices with no local value from the output list | |||
879 | . n - number of global indices to map | |||
880 | - idx - global indices to map | |||
881 | ||||
882 | Output Parameters: | |||
883 | + nout - number of indices in output array (if type == IS_GTOLM_MASK then nout = n) | |||
884 | - idxout - local index of each global index, one must pass in an array long enough | |||
885 | to hold all the indices. You can call ISGlobalToLocalMappingApplyBlock() with | |||
886 | idxout == NULL to determine the required length (returned in nout) | |||
887 | and then allocate the required space and call ISGlobalToLocalMappingApplyBlock() | |||
888 | a second time to set the values. | |||
889 | ||||
890 | Notes: | |||
891 | Either nout or idxout may be NULL. idx and idxout may be identical. | |||
892 | ||||
893 | For "small" problems when using ISGlobalToLocalMappingApply() and ISGlobalToLocalMappingApplyBlock(), the ISLocalToGlobalMappingType of ISLOCALTOGLOBALMAPPINGBASIC will be used; | |||
894 | this uses more memory but is faster; this approach is not scalable for extremely large mappings. For large problems ISLOCALTOGLOBALMAPPINGHASH is used, this is scalable. | |||
895 | Use ISLocalToGlobalMappingSetType() or call ISLocalToGlobalMappingSetFromOptions() with the option -islocaltoglobalmapping_type <basic,hash> to control which is used. | |||
896 | ||||
897 | Level: advanced | |||
898 | ||||
899 | Developer Note: The manual page states that idx and idxout may be identical but the calling | |||
900 | sequence declares idx as const so it cannot be the same as idxout. | |||
901 | ||||
902 | .seealso: ISLocalToGlobalMappingApply(), ISGlobalToLocalMappingApply(), ISLocalToGlobalMappingCreate(), | |||
903 | ISLocalToGlobalMappingDestroy() | |||
904 | @*/ | |||
905 | PetscErrorCode ISGlobalToLocalMappingApplyBlock(ISLocalToGlobalMapping mapping,ISGlobalToLocalMappingMode type, | |||
906 | PetscInt n,const PetscInt idx[],PetscInt *nout,PetscInt idxout[]) | |||
907 | { | |||
908 | PetscErrorCode ierr; | |||
909 | ||||
910 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 910; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
911 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),911 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),911,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),911,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),911,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
912 | if (!mapping->data) { | |||
913 | ierr = ISGlobalToLocalMappingSetUp(mapping);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),913,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
914 | } | |||
915 | ierr = (*mapping->ops->globaltolocalmappingapplyblock)(mapping,type,n,idx,nout,idxout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),915,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
916 | 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); | |||
917 | } | |||
918 | ||||
919 | ||||
920 | /*@C | |||
921 | ISLocalToGlobalMappingGetBlockInfo - Gets the neighbor information for each processor and | |||
922 | each index shared by more than one processor | |||
923 | ||||
924 | Collective on ISLocalToGlobalMapping | |||
925 | ||||
926 | Input Parameters: | |||
927 | . mapping - the mapping from local to global indexing | |||
928 | ||||
929 | Output Parameter: | |||
930 | + nproc - number of processors that are connected to this one | |||
931 | . proc - neighboring processors | |||
932 | . numproc - number of indices for each subdomain (processor) | |||
933 | - indices - indices of nodes (in local numbering) shared with neighbors (sorted by global numbering) | |||
934 | ||||
935 | Level: advanced | |||
936 | ||||
937 | Fortran Usage: | |||
938 | $ ISLocalToGlobalMpngGetInfoSize(ISLocalToGlobalMapping,PetscInt nproc,PetscInt numprocmax,ierr) followed by | |||
939 | $ ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,PetscInt nproc, PetscInt procs[nproc],PetscInt numprocs[nproc], | |||
940 | PetscInt indices[nproc][numprocmax],ierr) | |||
941 | There is no ISLocalToGlobalMappingRestoreInfo() in Fortran. You must make sure that procs[], numprocs[] and | |||
942 | indices[][] are large enough arrays, either by allocating them dynamically or defining static ones large enough. | |||
943 | ||||
944 | ||||
945 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS(), ISLocalToGlobalMappingCreate(), | |||
946 | ISLocalToGlobalMappingRestoreInfo() | |||
947 | @*/ | |||
948 | PetscErrorCode ISLocalToGlobalMappingGetBlockInfo(ISLocalToGlobalMapping mapping,PetscInt *nproc,PetscInt *procs[],PetscInt *numprocs[],PetscInt **indices[]) | |||
949 | { | |||
950 | PetscErrorCode ierr; | |||
951 | ||||
952 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 952; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
953 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),953 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),953,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),953,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),953,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
954 | if (mapping->info_cached) { | |||
955 | *nproc = mapping->info_nproc; | |||
956 | *procs = mapping->info_procs; | |||
957 | *numprocs = mapping->info_numprocs; | |||
958 | *indices = mapping->info_indices; | |||
959 | } else { | |||
960 | ierr = ISLocalToGlobalMappingGetBlockInfo_Private(mapping,nproc,procs,numprocs,indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),960,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
961 | } | |||
962 | 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); | |||
963 | } | |||
964 | ||||
965 | static PetscErrorCode ISLocalToGlobalMappingGetBlockInfo_Private(ISLocalToGlobalMapping mapping,PetscInt *nproc,PetscInt *procs[],PetscInt *numprocs[],PetscInt **indices[]) | |||
966 | { | |||
967 | PetscErrorCode ierr; | |||
968 | PetscMPIInt size,rank,tag1,tag2,tag3,*len,*source,imdex; | |||
969 | PetscInt i,n = mapping->n,Ng,ng,max = 0,*lindices = mapping->indices; | |||
970 | PetscInt *nprocs,*owner,nsends,*sends,j,*starts,nmax,nrecvs,*recvs,proc; | |||
971 | PetscInt cnt,scale,*ownedsenders,*nownedsenders,rstart,nowned; | |||
972 | PetscInt node,nownedm,nt,*sends2,nsends2,*starts2,*lens2,*dest,nrecvs2,*starts3,*recvs2,k,*bprocs,*tmp; | |||
973 | PetscInt first_procs,first_numprocs,*first_indices; | |||
974 | MPI_Request *recv_waits,*send_waits; | |||
975 | MPI_Status recv_status,*send_status,*recv_statuses; | |||
976 | MPI_Comm comm; | |||
977 | PetscBool debug = PETSC_FALSE; | |||
978 | ||||
979 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 979; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
980 | ierr = PetscObjectGetComm((PetscObject)mapping,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),980,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
981 | ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),981,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
982 | ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),982,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
983 | if (size == 1) { | |||
984 | *nproc = 0; | |||
985 | *procs = NULL((void*)0); | |||
986 | ierr = PetscNew(numprocs)PetscMallocA(1,PETSC_TRUE,986,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(1)*sizeof(**((numprocs))),((numprocs)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),986,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
987 | (*numprocs)[0] = 0; | |||
988 | ierr = PetscNew(indices)PetscMallocA(1,PETSC_TRUE,988,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(1)*sizeof(**((indices))),((indices)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),988,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
989 | (*indices)[0] = NULL((void*)0); | |||
990 | /* save info for reuse */ | |||
991 | mapping->info_nproc = *nproc; | |||
992 | mapping->info_procs = *procs; | |||
993 | mapping->info_numprocs = *numprocs; | |||
994 | mapping->info_indices = *indices; | |||
995 | mapping->info_cached = PETSC_TRUE; | |||
996 | 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); | |||
997 | } | |||
998 | ||||
999 | ierr = PetscOptionsGetBool(((PetscObject)mapping)->options,NULL((void*)0),"-islocaltoglobalmappinggetinfo_debug",&debug,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),999,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1000 | ||||
1001 | /* | |||
1002 | Notes on ISLocalToGlobalMappingGetBlockInfo | |||
1003 | ||||
1004 | globally owned node - the nodes that have been assigned to this processor in global | |||
1005 | numbering, just for this routine. | |||
1006 | ||||
1007 | nontrivial globally owned node - node assigned to this processor that is on a subdomain | |||
1008 | boundary (i.e. is has more than one local owner) | |||
1009 | ||||
1010 | locally owned node - node that exists on this processors subdomain | |||
1011 | ||||
1012 | nontrivial locally owned node - node that is not in the interior (i.e. has more than one | |||
1013 | local subdomain | |||
1014 | */ | |||
1015 | ierr = PetscObjectGetNewTag((PetscObject)mapping,&tag1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1015,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1016 | ierr = PetscObjectGetNewTag((PetscObject)mapping,&tag2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1016,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1017 | ierr = PetscObjectGetNewTag((PetscObject)mapping,&tag3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1017,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1018 | ||||
1019 | for (i=0; i<n; i++) { | |||
1020 | if (lindices[i] > max) max = lindices[i]; | |||
1021 | } | |||
1022 | ierr = MPIU_Allreduce(&max,&Ng,1,MPIU_INT,MPI_MAX,comm)(PetscAllreduceBarrierCheck(comm,1,1022,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Allreduce((&max),(&Ng),(1),(((MPI_Datatype)0x4c000405 )),((MPI_Op)(0x58000001)),(comm))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1022,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1023 | Ng++; | |||
1024 | ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1024,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1025 | ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1025,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1026 | scale = Ng/size + 1; | |||
1027 | ng = scale; if (rank == size-1) ng = Ng - scale*(size-1); ng = PetscMax(1,ng)(((1)<(ng)) ? (ng) : (1)); | |||
1028 | rstart = scale*rank; | |||
1029 | ||||
1030 | /* determine ownership ranges of global indices */ | |||
1031 | ierr = PetscMalloc1(2*size,&nprocs)PetscMallocA(1,PETSC_FALSE,1031,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(2*size)*sizeof(**(&nprocs)),(&nprocs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1031,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1032 | ierr = PetscArrayzero(nprocs,2*size)PetscMemzero(nprocs,(2*size)*sizeof(*(nprocs)));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1032,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1033 | ||||
1034 | /* determine owners of each local node */ | |||
1035 | ierr = PetscMalloc1(n,&owner)PetscMallocA(1,PETSC_FALSE,1035,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(n)*sizeof(**(&owner)),(&owner));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1035,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1036 | for (i=0; i<n; i++) { | |||
1037 | proc = lindices[i]/scale; /* processor that globally owns this index */ | |||
1038 | nprocs[2*proc+1] = 1; /* processor globally owns at least one of ours */ | |||
1039 | owner[i] = proc; | |||
1040 | nprocs[2*proc]++; /* count of how many that processor globally owns of ours */ | |||
1041 | } | |||
1042 | nsends = 0; for (i=0; i<size; i++) nsends += nprocs[2*i+1]; | |||
1043 | ierr = PetscInfo1(mapping,"Number of global owners for my local data %D\n",nsends)PetscInfo_Private(__func__,mapping,"Number of global owners for my local data %D\n" ,nsends);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1043,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1044 | ||||
1045 | /* inform other processors of number of messages and max length*/ | |||
1046 | ierr = PetscMaxSum(comm,nprocs,&nmax,&nrecvs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1046,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1047 | ierr = PetscInfo1(mapping,"Number of local owners for my global data %D\n",nrecvs)PetscInfo_Private(__func__,mapping,"Number of local owners for my global data %D\n" ,nrecvs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1047,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1048 | ||||
1049 | /* post receives for owned rows */ | |||
1050 | ierr = PetscMalloc1((2*nrecvs+1)*(nmax+1),&recvs)PetscMallocA(1,PETSC_FALSE,1050,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)((2*nrecvs+1)*(nmax+1))*sizeof(**(&recvs)),(& recvs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1050,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1051 | ierr = PetscMalloc1(nrecvs+1,&recv_waits)PetscMallocA(1,PETSC_FALSE,1051,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nrecvs+1)*sizeof(**(&recv_waits)),(&recv_waits ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1051,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1052 | for (i=0; i<nrecvs; i++) { | |||
1053 | ierr = MPI_Irecv(recvs+2*nmax*i,2*nmax,MPIU_INT,MPI_ANY_SOURCE,tag1,comm,recv_waits+i)((petsc_irecv_ct++,0) || PetscMPITypeSize(&(petsc_irecv_len ),(2*nmax),(((MPI_Datatype)0x4c000405))) || MPI_Irecv((recvs+ 2*nmax*i),(2*nmax),(((MPI_Datatype)0x4c000405)),((-2)),(tag1) ,(comm),(recv_waits+i)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1053,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1054 | } | |||
1055 | ||||
1056 | /* pack messages containing lists of local nodes to owners */ | |||
1057 | ierr = PetscMalloc1(2*n+1,&sends)PetscMallocA(1,PETSC_FALSE,1057,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(2*n+1)*sizeof(**(&sends)),(&sends));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1057,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1058 | ierr = PetscMalloc1(size+1,&starts)PetscMallocA(1,PETSC_FALSE,1058,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(size+1)*sizeof(**(&starts)),(&starts));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1058,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1059 | starts[0] = 0; | |||
1060 | for (i=1; i<size; i++) starts[i] = starts[i-1] + 2*nprocs[2*i-2]; | |||
1061 | for (i=0; i<n; i++) { | |||
1062 | sends[starts[owner[i]]++] = lindices[i]; | |||
1063 | sends[starts[owner[i]]++] = i; | |||
1064 | } | |||
1065 | ierr = PetscFree(owner)((*PetscTrFree)((void*)(owner),1065,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((owner) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1065,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1066 | starts[0] = 0; | |||
1067 | for (i=1; i<size; i++) starts[i] = starts[i-1] + 2*nprocs[2*i-2]; | |||
1068 | ||||
1069 | /* send the messages */ | |||
1070 | ierr = PetscMalloc1(nsends+1,&send_waits)PetscMallocA(1,PETSC_FALSE,1070,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nsends+1)*sizeof(**(&send_waits)),(&send_waits ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1070,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1071 | ierr = PetscMalloc1(nsends+1,&dest)PetscMallocA(1,PETSC_FALSE,1071,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nsends+1)*sizeof(**(&dest)),(&dest));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1071,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1072 | cnt = 0; | |||
1073 | for (i=0; i<size; i++) { | |||
1074 | if (nprocs[2*i]) { | |||
1075 | ierr = MPI_Isend(sends+starts[i],2*nprocs[2*i],MPIU_INT,i,tag1,comm,send_waits+cnt)((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len ),(2*nprocs[2*i]),(((MPI_Datatype)0x4c000405))) || MPI_Isend( (sends+starts[i]),(2*nprocs[2*i]),(((MPI_Datatype)0x4c000405) ),(i),(tag1),(comm),(send_waits+cnt)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1075,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1076 | dest[cnt] = i; | |||
1077 | cnt++; | |||
1078 | } | |||
1079 | } | |||
1080 | ierr = PetscFree(starts)((*PetscTrFree)((void*)(starts),1080,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((starts) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1080,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1081 | ||||
1082 | /* wait on receives */ | |||
1083 | ierr = PetscMalloc1(nrecvs+1,&source)PetscMallocA(1,PETSC_FALSE,1083,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nrecvs+1)*sizeof(**(&source)),(&source));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1083,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1084 | ierr = PetscMalloc1(nrecvs+1,&len)PetscMallocA(1,PETSC_FALSE,1084,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nrecvs+1)*sizeof(**(&len)),(&len));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1084,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1085 | cnt = nrecvs; | |||
1086 | ierr = PetscCalloc1(ng+1,&nownedsenders)PetscMallocA(1,PETSC_TRUE,1086,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(ng+1)*sizeof(**(&nownedsenders)),(&nownedsenders ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1086,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1087 | while (cnt) { | |||
1088 | ierr = MPI_Waitany(nrecvs,recv_waits,&imdex,&recv_status)((petsc_wait_any_ct++,petsc_sum_of_waits_ct++,0) || MPI_Waitany ((nrecvs),(recv_waits),(&imdex),(&recv_status)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1088,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1089 | /* unpack receives into our local space */ | |||
1090 | ierr = MPI_Get_count(&recv_status,MPIU_INT((MPI_Datatype)0x4c000405),&len[imdex]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1090,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1091 | source[imdex] = recv_status.MPI_SOURCE; | |||
1092 | len[imdex] = len[imdex]/2; | |||
1093 | /* count how many local owners for each of my global owned indices */ | |||
1094 | for (i=0; i<len[imdex]; i++) nownedsenders[recvs[2*imdex*nmax+2*i]-rstart]++; | |||
1095 | cnt--; | |||
1096 | } | |||
1097 | ierr = PetscFree(recv_waits)((*PetscTrFree)((void*)(recv_waits),1097,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((recv_waits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1097,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1098 | ||||
1099 | /* count how many globally owned indices are on an edge multiplied by how many processors own them. */ | |||
1100 | nowned = 0; | |||
1101 | nownedm = 0; | |||
1102 | for (i=0; i<ng; i++) { | |||
1103 | if (nownedsenders[i] > 1) {nownedm += nownedsenders[i]; nowned++;} | |||
1104 | } | |||
1105 | ||||
1106 | /* create single array to contain rank of all local owners of each globally owned index */ | |||
1107 | ierr = PetscMalloc1(nownedm+1,&ownedsenders)PetscMallocA(1,PETSC_FALSE,1107,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nownedm+1)*sizeof(**(&ownedsenders)),(&ownedsenders ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1107,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1108 | ierr = PetscMalloc1(ng+1,&starts)PetscMallocA(1,PETSC_FALSE,1108,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(ng+1)*sizeof(**(&starts)),(&starts));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1108,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1109 | starts[0] = 0; | |||
1110 | for (i=1; i<ng; i++) { | |||
1111 | if (nownedsenders[i-1] > 1) starts[i] = starts[i-1] + nownedsenders[i-1]; | |||
1112 | else starts[i] = starts[i-1]; | |||
1113 | } | |||
1114 | ||||
1115 | /* for each nontrival globally owned node list all arriving processors */ | |||
1116 | for (i=0; i<nrecvs; i++) { | |||
1117 | for (j=0; j<len[i]; j++) { | |||
1118 | node = recvs[2*i*nmax+2*j]-rstart; | |||
1119 | if (nownedsenders[node] > 1) ownedsenders[starts[node]++] = source[i]; | |||
1120 | } | |||
1121 | } | |||
1122 | ||||
1123 | if (debug) { /* ----------------------------------- */ | |||
1124 | starts[0] = 0; | |||
1125 | for (i=1; i<ng; i++) { | |||
1126 | if (nownedsenders[i-1] > 1) starts[i] = starts[i-1] + nownedsenders[i-1]; | |||
1127 | else starts[i] = starts[i-1]; | |||
1128 | } | |||
1129 | for (i=0; i<ng; i++) { | |||
1130 | if (nownedsenders[i] > 1) { | |||
1131 | ierr = PetscSynchronizedPrintf(comm,"[%d] global node %D local owner processors: ",rank,i+rstart);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1131,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1132 | for (j=0; j<nownedsenders[i]; j++) { | |||
1133 | ierr = PetscSynchronizedPrintf(comm,"%D ",ownedsenders[starts[i]+j]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1133,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1134 | } | |||
1135 | ierr = PetscSynchronizedPrintf(comm,"\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1135,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1136 | } | |||
1137 | } | |||
1138 | ierr = PetscSynchronizedFlush(comm,PETSC_STDOUT);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1138,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1139 | } /* ----------------------------------- */ | |||
1140 | ||||
1141 | /* wait on original sends */ | |||
1142 | if (nsends) { | |||
1143 | ierr = PetscMalloc1(nsends,&send_status)PetscMallocA(1,PETSC_FALSE,1143,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nsends)*sizeof(**(&send_status)),(&send_status ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1143,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1144 | ierr = MPI_Waitall(nsends,send_waits,send_status)((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble ) (nsends),0) || MPI_Waitall((nsends),(send_waits),(send_status )));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1144,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1145 | ierr = PetscFree(send_status)((*PetscTrFree)((void*)(send_status),1145,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((send_status) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1145,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1146 | } | |||
1147 | ierr = PetscFree(send_waits)((*PetscTrFree)((void*)(send_waits),1147,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((send_waits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1147,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1148 | ierr = PetscFree(sends)((*PetscTrFree)((void*)(sends),1148,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((sends) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1148,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1149 | ierr = PetscFree(nprocs)((*PetscTrFree)((void*)(nprocs),1149,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((nprocs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1149,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1150 | ||||
1151 | /* pack messages to send back to local owners */ | |||
1152 | starts[0] = 0; | |||
1153 | for (i=1; i<ng; i++) { | |||
1154 | if (nownedsenders[i-1] > 1) starts[i] = starts[i-1] + nownedsenders[i-1]; | |||
1155 | else starts[i] = starts[i-1]; | |||
1156 | } | |||
1157 | nsends2 = nrecvs; | |||
1158 | ierr = PetscMalloc1(nsends2+1,&nprocs)PetscMallocA(1,PETSC_FALSE,1158,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nsends2+1)*sizeof(**(&nprocs)),(&nprocs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1158,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* length of each message */ | |||
1159 | for (i=0; i<nrecvs; i++) { | |||
1160 | nprocs[i] = 1; | |||
1161 | for (j=0; j<len[i]; j++) { | |||
1162 | node = recvs[2*i*nmax+2*j]-rstart; | |||
1163 | if (nownedsenders[node] > 1) nprocs[i] += 2 + nownedsenders[node]; | |||
1164 | } | |||
1165 | } | |||
1166 | nt = 0; | |||
1167 | for (i=0; i<nsends2; i++) nt += nprocs[i]; | |||
1168 | ||||
1169 | ierr = PetscMalloc1(nt+1,&sends2)PetscMallocA(1,PETSC_FALSE,1169,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nt+1)*sizeof(**(&sends2)),(&sends2));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1169,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1170 | ierr = PetscMalloc1(nsends2+1,&starts2)PetscMallocA(1,PETSC_FALSE,1170,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nsends2+1)*sizeof(**(&starts2)),(&starts2));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1170,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1171 | ||||
1172 | starts2[0] = 0; | |||
1173 | for (i=1; i<nsends2; i++) starts2[i] = starts2[i-1] + nprocs[i-1]; | |||
1174 | /* | |||
1175 | Each message is 1 + nprocs[i] long, and consists of | |||
1176 | (0) the number of nodes being sent back | |||
1177 | (1) the local node number, | |||
1178 | (2) the number of processors sharing it, | |||
1179 | (3) the processors sharing it | |||
1180 | */ | |||
1181 | for (i=0; i<nsends2; i++) { | |||
1182 | cnt = 1; | |||
1183 | sends2[starts2[i]] = 0; | |||
1184 | for (j=0; j<len[i]; j++) { | |||
1185 | node = recvs[2*i*nmax+2*j]-rstart; | |||
1186 | if (nownedsenders[node] > 1) { | |||
1187 | sends2[starts2[i]]++; | |||
1188 | sends2[starts2[i]+cnt++] = recvs[2*i*nmax+2*j+1]; | |||
1189 | sends2[starts2[i]+cnt++] = nownedsenders[node]; | |||
1190 | ierr = PetscArraycpy(&sends2[starts2[i]+cnt],&ownedsenders[starts[node]],nownedsenders[node])((sizeof(*(&sends2[starts2[i]+cnt])) != sizeof(*(&ownedsenders [starts[node]]))) || PetscMemcpy(&sends2[starts2[i]+cnt], &ownedsenders[starts[node]],(nownedsenders[node])*sizeof( *(&sends2[starts2[i]+cnt]))));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1190,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1191 | cnt += nownedsenders[node]; | |||
1192 | } | |||
1193 | } | |||
1194 | } | |||
1195 | ||||
1196 | /* receive the message lengths */ | |||
1197 | nrecvs2 = nsends; | |||
1198 | ierr = PetscMalloc1(nrecvs2+1,&lens2)PetscMallocA(1,PETSC_FALSE,1198,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nrecvs2+1)*sizeof(**(&lens2)),(&lens2));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1198,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1199 | ierr = PetscMalloc1(nrecvs2+1,&starts3)PetscMallocA(1,PETSC_FALSE,1199,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nrecvs2+1)*sizeof(**(&starts3)),(&starts3));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1199,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1200 | ierr = PetscMalloc1(nrecvs2+1,&recv_waits)PetscMallocA(1,PETSC_FALSE,1200,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nrecvs2+1)*sizeof(**(&recv_waits)),(&recv_waits ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1200,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1201 | for (i=0; i<nrecvs2; i++) { | |||
1202 | ierr = MPI_Irecv(&lens2[i],1,MPIU_INT,dest[i],tag2,comm,recv_waits+i)((petsc_irecv_ct++,0) || PetscMPITypeSize(&(petsc_irecv_len ),(1),(((MPI_Datatype)0x4c000405))) || MPI_Irecv((&lens2[ i]),(1),(((MPI_Datatype)0x4c000405)),(dest[i]),(tag2),(comm), (recv_waits+i)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1202,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1203 | } | |||
1204 | ||||
1205 | /* send the message lengths */ | |||
1206 | for (i=0; i<nsends2; i++) { | |||
1207 | ierr = MPI_Send(&nprocs[i],1,MPIU_INT,source[i],tag2,comm)((petsc_send_ct++,0) || PetscMPITypeSize((&petsc_send_len ),(1),(((MPI_Datatype)0x4c000405))) || MPI_Send((&nprocs[ i]),(1),(((MPI_Datatype)0x4c000405)),(source[i]),(tag2),(comm )));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1207,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1208 | } | |||
1209 | ||||
1210 | /* wait on receives of lens */ | |||
1211 | if (nrecvs2) { | |||
1212 | ierr = PetscMalloc1(nrecvs2,&recv_statuses)PetscMallocA(1,PETSC_FALSE,1212,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nrecvs2)*sizeof(**(&recv_statuses)),(&recv_statuses ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1212,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1213 | ierr = MPI_Waitall(nrecvs2,recv_waits,recv_statuses)((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble ) (nrecvs2),0) || MPI_Waitall((nrecvs2),(recv_waits),(recv_statuses )));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1213,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1214 | ierr = PetscFree(recv_statuses)((*PetscTrFree)((void*)(recv_statuses),1214,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((recv_statuses) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1214,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1215 | } | |||
1216 | ierr = PetscFree(recv_waits)((*PetscTrFree)((void*)(recv_waits),1216,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((recv_waits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1216,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1217 | ||||
1218 | starts3[0] = 0; | |||
1219 | nt = 0; | |||
1220 | for (i=0; i<nrecvs2-1; i++) { | |||
1221 | starts3[i+1] = starts3[i] + lens2[i]; | |||
1222 | nt += lens2[i]; | |||
1223 | } | |||
1224 | if (nrecvs2) nt += lens2[nrecvs2-1]; | |||
1225 | ||||
1226 | ierr = PetscMalloc1(nt+1,&recvs2)PetscMallocA(1,PETSC_FALSE,1226,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nt+1)*sizeof(**(&recvs2)),(&recvs2));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1226,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1227 | ierr = PetscMalloc1(nrecvs2+1,&recv_waits)PetscMallocA(1,PETSC_FALSE,1227,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nrecvs2+1)*sizeof(**(&recv_waits)),(&recv_waits ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1227,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1228 | for (i=0; i<nrecvs2; i++) { | |||
1229 | ierr = MPI_Irecv(recvs2+starts3[i],lens2[i],MPIU_INT,dest[i],tag3,comm,recv_waits+i)((petsc_irecv_ct++,0) || PetscMPITypeSize(&(petsc_irecv_len ),(lens2[i]),(((MPI_Datatype)0x4c000405))) || MPI_Irecv((recvs2 +starts3[i]),(lens2[i]),(((MPI_Datatype)0x4c000405)),(dest[i] ),(tag3),(comm),(recv_waits+i)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1229,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1230 | } | |||
1231 | ||||
1232 | /* send the messages */ | |||
1233 | ierr = PetscMalloc1(nsends2+1,&send_waits)PetscMallocA(1,PETSC_FALSE,1233,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nsends2+1)*sizeof(**(&send_waits)),(&send_waits ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1233,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1234 | for (i=0; i<nsends2; i++) { | |||
1235 | ierr = MPI_Isend(sends2+starts2[i],nprocs[i],MPIU_INT,source[i],tag3,comm,send_waits+i)((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len ),(nprocs[i]),(((MPI_Datatype)0x4c000405))) || MPI_Isend((sends2 +starts2[i]),(nprocs[i]),(((MPI_Datatype)0x4c000405)),(source [i]),(tag3),(comm),(send_waits+i)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1235,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1236 | } | |||
1237 | ||||
1238 | /* wait on receives */ | |||
1239 | if (nrecvs2) { | |||
1240 | ierr = PetscMalloc1(nrecvs2,&recv_statuses)PetscMallocA(1,PETSC_FALSE,1240,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nrecvs2)*sizeof(**(&recv_statuses)),(&recv_statuses ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1240,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1241 | ierr = MPI_Waitall(nrecvs2,recv_waits,recv_statuses)((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble ) (nrecvs2),0) || MPI_Waitall((nrecvs2),(recv_waits),(recv_statuses )));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1241,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1242 | ierr = PetscFree(recv_statuses)((*PetscTrFree)((void*)(recv_statuses),1242,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((recv_statuses) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1242,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1243 | } | |||
1244 | ierr = PetscFree(recv_waits)((*PetscTrFree)((void*)(recv_waits),1244,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((recv_waits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1244,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1245 | ierr = PetscFree(nprocs)((*PetscTrFree)((void*)(nprocs),1245,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((nprocs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1245,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1246 | ||||
1247 | if (debug) { /* ----------------------------------- */ | |||
1248 | cnt = 0; | |||
1249 | for (i=0; i<nrecvs2; i++) { | |||
1250 | nt = recvs2[cnt++]; | |||
1251 | for (j=0; j<nt; j++) { | |||
1252 | ierr = PetscSynchronizedPrintf(comm,"[%d] local node %D number of subdomains %D: ",rank,recvs2[cnt],recvs2[cnt+1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1252,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1253 | for (k=0; k<recvs2[cnt+1]; k++) { | |||
1254 | ierr = PetscSynchronizedPrintf(comm,"%D ",recvs2[cnt+2+k]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1254,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1255 | } | |||
1256 | cnt += 2 + recvs2[cnt+1]; | |||
1257 | ierr = PetscSynchronizedPrintf(comm,"\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1257,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1258 | } | |||
1259 | } | |||
1260 | ierr = PetscSynchronizedFlush(comm,PETSC_STDOUT);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1260,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1261 | } /* ----------------------------------- */ | |||
1262 | ||||
1263 | /* count number subdomains for each local node */ | |||
1264 | ierr = PetscCalloc1(size,&nprocs)PetscMallocA(1,PETSC_TRUE,1264,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(size)*sizeof(**(&nprocs)),(&nprocs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1264,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1265 | cnt = 0; | |||
1266 | for (i=0; i<nrecvs2; i++) { | |||
1267 | nt = recvs2[cnt++]; | |||
1268 | for (j=0; j<nt; j++) { | |||
1269 | for (k=0; k<recvs2[cnt+1]; k++) nprocs[recvs2[cnt+2+k]]++; | |||
1270 | cnt += 2 + recvs2[cnt+1]; | |||
1271 | } | |||
1272 | } | |||
1273 | nt = 0; for (i=0; i<size; i++) nt += (nprocs[i] > 0); | |||
1274 | *nproc = nt; | |||
1275 | ierr = PetscMalloc1(nt+1,procs)PetscMallocA(1,PETSC_FALSE,1275,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nt+1)*sizeof(**(procs)),(procs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1275,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1276 | ierr = PetscMalloc1(nt+1,numprocs)PetscMallocA(1,PETSC_FALSE,1276,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nt+1)*sizeof(**(numprocs)),(numprocs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1276,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1277 | ierr = PetscMalloc1(nt+1,indices)PetscMallocA(1,PETSC_FALSE,1277,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nt+1)*sizeof(**(indices)),(indices));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1277,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1278 | for (i=0;i<nt+1;i++) (*indices)[i]=NULL((void*)0); | |||
1279 | ierr = PetscMalloc1(size,&bprocs)PetscMallocA(1,PETSC_FALSE,1279,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(size)*sizeof(**(&bprocs)),(&bprocs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1279,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1280 | cnt = 0; | |||
1281 | for (i=0; i<size; i++) { | |||
1282 | if (nprocs[i] > 0) { | |||
1283 | bprocs[i] = cnt; | |||
1284 | (*procs)[cnt] = i; | |||
1285 | (*numprocs)[cnt] = nprocs[i]; | |||
1286 | ierr = PetscMalloc1(nprocs[i],&(*indices)[cnt])PetscMallocA(1,PETSC_FALSE,1286,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nprocs[i])*sizeof(**(&(*indices)[cnt])),(&( *indices)[cnt]));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1286,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1287 | cnt++; | |||
1288 | } | |||
1289 | } | |||
1290 | ||||
1291 | /* make the list of subdomains for each nontrivial local node */ | |||
1292 | ierr = PetscArrayzero(*numprocs,nt)PetscMemzero(*numprocs,(nt)*sizeof(*(*numprocs)));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1292,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1293 | cnt = 0; | |||
1294 | for (i=0; i<nrecvs2; i++) { | |||
1295 | nt = recvs2[cnt++]; | |||
1296 | for (j=0; j<nt; j++) { | |||
1297 | for (k=0; k<recvs2[cnt+1]; k++) (*indices)[bprocs[recvs2[cnt+2+k]]][(*numprocs)[bprocs[recvs2[cnt+2+k]]]++] = recvs2[cnt]; | |||
1298 | cnt += 2 + recvs2[cnt+1]; | |||
1299 | } | |||
1300 | } | |||
1301 | ierr = PetscFree(bprocs)((*PetscTrFree)((void*)(bprocs),1301,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((bprocs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1301,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1302 | ierr = PetscFree(recvs2)((*PetscTrFree)((void*)(recvs2),1302,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((recvs2) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1302,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1303 | ||||
1304 | /* sort the node indexing by their global numbers */ | |||
1305 | nt = *nproc; | |||
1306 | for (i=0; i<nt; i++) { | |||
1307 | ierr = PetscMalloc1((*numprocs)[i],&tmp)PetscMallocA(1,PETSC_FALSE,1307,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)((*numprocs)[i])*sizeof(**(&tmp)),(&tmp));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1307,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1308 | for (j=0; j<(*numprocs)[i]; j++) tmp[j] = lindices[(*indices)[i][j]]; | |||
1309 | ierr = PetscSortIntWithArray((*numprocs)[i],tmp,(*indices)[i]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1309,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1310 | ierr = PetscFree(tmp)((*PetscTrFree)((void*)(tmp),1310,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((tmp) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1310,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1311 | } | |||
1312 | ||||
1313 | if (debug) { /* ----------------------------------- */ | |||
1314 | nt = *nproc; | |||
1315 | for (i=0; i<nt; i++) { | |||
1316 | ierr = PetscSynchronizedPrintf(comm,"[%d] subdomain %D number of indices %D: ",rank,(*procs)[i],(*numprocs)[i]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1316,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1317 | for (j=0; j<(*numprocs)[i]; j++) { | |||
1318 | ierr = PetscSynchronizedPrintf(comm,"%D ",(*indices)[i][j]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1318,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1319 | } | |||
1320 | ierr = PetscSynchronizedPrintf(comm,"\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1320,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1321 | } | |||
1322 | ierr = PetscSynchronizedFlush(comm,PETSC_STDOUT);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1322,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1323 | } /* ----------------------------------- */ | |||
1324 | ||||
1325 | /* wait on sends */ | |||
1326 | if (nsends2) { | |||
1327 | ierr = PetscMalloc1(nsends2,&send_status)PetscMallocA(1,PETSC_FALSE,1327,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(nsends2)*sizeof(**(&send_status)),(&send_status ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1327,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1328 | ierr = MPI_Waitall(nsends2,send_waits,send_status)((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble ) (nsends2),0) || MPI_Waitall((nsends2),(send_waits),(send_status )));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1328,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1329 | ierr = PetscFree(send_status)((*PetscTrFree)((void*)(send_status),1329,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((send_status) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1329,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1330 | } | |||
1331 | ||||
1332 | ierr = PetscFree(starts3)((*PetscTrFree)((void*)(starts3),1332,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((starts3) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1332,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1333 | ierr = PetscFree(dest)((*PetscTrFree)((void*)(dest),1333,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((dest) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1333,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1334 | ierr = PetscFree(send_waits)((*PetscTrFree)((void*)(send_waits),1334,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((send_waits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1334,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1335 | ||||
1336 | ierr = PetscFree(nownedsenders)((*PetscTrFree)((void*)(nownedsenders),1336,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((nownedsenders) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1336,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1337 | ierr = PetscFree(ownedsenders)((*PetscTrFree)((void*)(ownedsenders),1337,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((ownedsenders) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1337,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1338 | ierr = PetscFree(starts)((*PetscTrFree)((void*)(starts),1338,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((starts) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1338,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1339 | ierr = PetscFree(starts2)((*PetscTrFree)((void*)(starts2),1339,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((starts2) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1339,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1340 | ierr = PetscFree(lens2)((*PetscTrFree)((void*)(lens2),1340,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((lens2) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1340,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1341 | ||||
1342 | ierr = PetscFree(source)((*PetscTrFree)((void*)(source),1342,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((source) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1342,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1343 | ierr = PetscFree(len)((*PetscTrFree)((void*)(len),1343,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((len) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1343,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1344 | ierr = PetscFree(recvs)((*PetscTrFree)((void*)(recvs),1344,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((recvs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1344,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1345 | ierr = PetscFree(nprocs)((*PetscTrFree)((void*)(nprocs),1345,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((nprocs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1345,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1346 | ierr = PetscFree(sends2)((*PetscTrFree)((void*)(sends2),1346,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((sends2) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1346,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1347 | ||||
1348 | /* put the information about myself as the first entry in the list */ | |||
1349 | first_procs = (*procs)[0]; | |||
1350 | first_numprocs = (*numprocs)[0]; | |||
1351 | first_indices = (*indices)[0]; | |||
1352 | for (i=0; i<*nproc; i++) { | |||
1353 | if ((*procs)[i] == rank) { | |||
1354 | (*procs)[0] = (*procs)[i]; | |||
1355 | (*numprocs)[0] = (*numprocs)[i]; | |||
1356 | (*indices)[0] = (*indices)[i]; | |||
1357 | (*procs)[i] = first_procs; | |||
1358 | (*numprocs)[i] = first_numprocs; | |||
1359 | (*indices)[i] = first_indices; | |||
1360 | break; | |||
1361 | } | |||
1362 | } | |||
1363 | ||||
1364 | /* save info for reuse */ | |||
1365 | mapping->info_nproc = *nproc; | |||
1366 | mapping->info_procs = *procs; | |||
1367 | mapping->info_numprocs = *numprocs; | |||
1368 | mapping->info_indices = *indices; | |||
1369 | mapping->info_cached = PETSC_TRUE; | |||
1370 | 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); | |||
1371 | } | |||
1372 | ||||
1373 | /*@C | |||
1374 | ISLocalToGlobalMappingRestoreBlockInfo - Frees the memory allocated by ISLocalToGlobalMappingGetBlockInfo() | |||
1375 | ||||
1376 | Collective on ISLocalToGlobalMapping | |||
1377 | ||||
1378 | Input Parameters: | |||
1379 | . mapping - the mapping from local to global indexing | |||
1380 | ||||
1381 | Output Parameter: | |||
1382 | + nproc - number of processors that are connected to this one | |||
1383 | . proc - neighboring processors | |||
1384 | . numproc - number of indices for each processor | |||
1385 | - indices - indices of local nodes shared with neighbor (sorted by global numbering) | |||
1386 | ||||
1387 | Level: advanced | |||
1388 | ||||
1389 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS(), ISLocalToGlobalMappingCreate(), | |||
1390 | ISLocalToGlobalMappingGetInfo() | |||
1391 | @*/ | |||
1392 | PetscErrorCode ISLocalToGlobalMappingRestoreBlockInfo(ISLocalToGlobalMapping mapping,PetscInt *nproc,PetscInt *procs[],PetscInt *numprocs[],PetscInt **indices[]) | |||
1393 | { | |||
1394 | PetscErrorCode ierr; | |||
1395 | ||||
1396 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1396; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1397 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),1397 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),1397,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1397,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1397,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
1398 | if (mapping->info_free) { | |||
1399 | ierr = PetscFree(*numprocs)((*PetscTrFree)((void*)(*numprocs),1399,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((*numprocs) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1399,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1400 | if (*indices) { | |||
1401 | PetscInt i; | |||
1402 | ||||
1403 | ierr = PetscFree((*indices)[0])((*PetscTrFree)((void*)((*indices)[0]),1403,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || (((*indices)[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1403,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1404 | for (i=1; i<*nproc; i++) { | |||
1405 | ierr = PetscFree((*indices)[i])((*PetscTrFree)((void*)((*indices)[i]),1405,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || (((*indices)[i]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1405,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1406 | } | |||
1407 | ierr = PetscFree(*indices)((*PetscTrFree)((void*)(*indices),1407,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((*indices) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1407,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1408 | } | |||
1409 | } | |||
1410 | *nproc = 0; | |||
1411 | *procs = NULL((void*)0); | |||
1412 | *numprocs = NULL((void*)0); | |||
1413 | *indices = NULL((void*)0); | |||
1414 | 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); | |||
1415 | } | |||
1416 | ||||
1417 | /*@C | |||
1418 | ISLocalToGlobalMappingGetInfo - Gets the neighbor information for each processor and | |||
1419 | each index shared by more than one processor | |||
1420 | ||||
1421 | Collective on ISLocalToGlobalMapping | |||
1422 | ||||
1423 | Input Parameters: | |||
1424 | . mapping - the mapping from local to global indexing | |||
1425 | ||||
1426 | Output Parameter: | |||
1427 | + nproc - number of processors that are connected to this one | |||
1428 | . proc - neighboring processors | |||
1429 | . numproc - number of indices for each subdomain (processor) | |||
1430 | - indices - indices of nodes (in local numbering) shared with neighbors (sorted by global numbering) | |||
1431 | ||||
1432 | Level: advanced | |||
1433 | ||||
1434 | Notes: The user needs to call ISLocalToGlobalMappingRestoreInfo when the data is no longer needed. | |||
1435 | ||||
1436 | Fortran Usage: | |||
1437 | $ ISLocalToGlobalMpngGetInfoSize(ISLocalToGlobalMapping,PetscInt nproc,PetscInt numprocmax,ierr) followed by | |||
1438 | $ ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,PetscInt nproc, PetscInt procs[nproc],PetscInt numprocs[nproc], | |||
1439 | PetscInt indices[nproc][numprocmax],ierr) | |||
1440 | There is no ISLocalToGlobalMappingRestoreInfo() in Fortran. You must make sure that procs[], numprocs[] and | |||
1441 | indices[][] are large enough arrays, either by allocating them dynamically or defining static ones large enough. | |||
1442 | ||||
1443 | ||||
1444 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS(), ISLocalToGlobalMappingCreate(), | |||
1445 | ISLocalToGlobalMappingRestoreInfo() | |||
1446 | @*/ | |||
1447 | PetscErrorCode ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping mapping,PetscInt *nproc,PetscInt *procs[],PetscInt *numprocs[],PetscInt **indices[]) | |||
1448 | { | |||
1449 | PetscErrorCode ierr; | |||
1450 | PetscInt **bindices = NULL((void*)0),*bnumprocs = NULL((void*)0),bs = mapping->bs,i,j,k; | |||
1451 | ||||
1452 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1452; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1453 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),1453 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),1453,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1453,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1453,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
1454 | ierr = ISLocalToGlobalMappingGetBlockInfo(mapping,nproc,procs,&bnumprocs,&bindices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1454,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1455 | if (bs > 1) { /* we need to expand the cached info */ | |||
1456 | ierr = PetscCalloc1(*nproc,&*indices)PetscMallocA(1,PETSC_TRUE,1456,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(*nproc)*sizeof(**(&*indices)),(&*indices));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1456,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1457 | ierr = PetscCalloc1(*nproc,&*numprocs)PetscMallocA(1,PETSC_TRUE,1457,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(*nproc)*sizeof(**(&*numprocs)),(&*numprocs) );CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1457,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1458 | for (i=0; i<*nproc; i++) { | |||
1459 | ierr = PetscMalloc1(bs*bnumprocs[i],&(*indices)[i])PetscMallocA(1,PETSC_FALSE,1459,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(bs*bnumprocs[i])*sizeof(**(&(*indices)[i])),(& (*indices)[i]));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1459,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1460 | for (j=0; j<bnumprocs[i]; j++) { | |||
1461 | for (k=0; k<bs; k++) { | |||
1462 | (*indices)[i][j*bs+k] = bs*bindices[i][j] + k; | |||
1463 | } | |||
1464 | } | |||
1465 | (*numprocs)[i] = bnumprocs[i]*bs; | |||
1466 | } | |||
1467 | mapping->info_free = PETSC_TRUE; | |||
1468 | } else { | |||
1469 | *numprocs = bnumprocs; | |||
1470 | *indices = bindices; | |||
1471 | } | |||
1472 | 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); | |||
1473 | } | |||
1474 | ||||
1475 | /*@C | |||
1476 | ISLocalToGlobalMappingRestoreInfo - Frees the memory allocated by ISLocalToGlobalMappingGetInfo() | |||
1477 | ||||
1478 | Collective on ISLocalToGlobalMapping | |||
1479 | ||||
1480 | Input Parameters: | |||
1481 | . mapping - the mapping from local to global indexing | |||
1482 | ||||
1483 | Output Parameter: | |||
1484 | + nproc - number of processors that are connected to this one | |||
1485 | . proc - neighboring processors | |||
1486 | . numproc - number of indices for each processor | |||
1487 | - indices - indices of local nodes shared with neighbor (sorted by global numbering) | |||
1488 | ||||
1489 | Level: advanced | |||
1490 | ||||
1491 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS(), ISLocalToGlobalMappingCreate(), | |||
1492 | ISLocalToGlobalMappingGetInfo() | |||
1493 | @*/ | |||
1494 | PetscErrorCode ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping mapping,PetscInt *nproc,PetscInt *procs[],PetscInt *numprocs[],PetscInt **indices[]) | |||
1495 | { | |||
1496 | PetscErrorCode ierr; | |||
1497 | ||||
1498 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1498; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1499 | ierr = ISLocalToGlobalMappingRestoreBlockInfo(mapping,nproc,procs,numprocs,indices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1499,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1500 | 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); | |||
1501 | } | |||
1502 | ||||
1503 | /*@C | |||
1504 | ISLocalToGlobalMappingGetNodeInfo - Gets the neighbor information for each node | |||
1505 | ||||
1506 | Collective on ISLocalToGlobalMapping | |||
1507 | ||||
1508 | Input Parameters: | |||
1509 | . mapping - the mapping from local to global indexing | |||
1510 | ||||
1511 | Output Parameter: | |||
1512 | + nnodes - number of local nodes (same ISLocalToGlobalMappingGetSize()) | |||
1513 | . count - number of neighboring processors per node | |||
1514 | - indices - indices of processes sharing the node (sorted) | |||
1515 | ||||
1516 | Level: advanced | |||
1517 | ||||
1518 | Notes: The user needs to call ISLocalToGlobalMappingRestoreInfo when the data is no longer needed. | |||
1519 | ||||
1520 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS(), ISLocalToGlobalMappingCreate(), | |||
1521 | ISLocalToGlobalMappingGetInfo(), ISLocalToGlobalMappingRestoreNodeInfo() | |||
1522 | @*/ | |||
1523 | PetscErrorCode ISLocalToGlobalMappingGetNodeInfo(ISLocalToGlobalMapping mapping,PetscInt *nnodes,PetscInt *count[],PetscInt **indices[]) | |||
1524 | { | |||
1525 | PetscInt n; | |||
1526 | PetscErrorCode ierr; | |||
1527 | ||||
1528 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1528; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1529 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),1529 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),1529,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1529,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1529,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
1530 | ierr = ISLocalToGlobalMappingGetSize(mapping,&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1530,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1531 | if (!mapping->info_nodec) { | |||
1532 | PetscInt i,m,n_neigh,*neigh,*n_shared,**shared; | |||
1533 | ||||
1534 | ierr = PetscMalloc2(n+1,&mapping->info_nodec,n,&mapping->info_nodei)PetscMallocA(2,PETSC_FALSE,1534,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(n+1)*sizeof(**(&mapping->info_nodec)),(& mapping->info_nodec),(size_t)(n)*sizeof(**(&mapping-> info_nodei)),(&mapping->info_nodei));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1534,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1535 | ierr = ISLocalToGlobalMappingGetInfo(mapping,&n_neigh,&neigh,&n_shared,&shared);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1535,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1536 | for (i=0;i<n;i++) { mapping->info_nodec[i] = 1;} | |||
1537 | m = n; | |||
1538 | mapping->info_nodec[n] = 0; | |||
1539 | for (i=1;i<n_neigh;i++) { | |||
1540 | PetscInt j; | |||
1541 | ||||
1542 | m += n_shared[i]; | |||
1543 | for (j=0;j<n_shared[i];j++) mapping->info_nodec[shared[i][j]] += 1; | |||
1544 | } | |||
1545 | if (n) { ierr = PetscMalloc1(m,&mapping->info_nodei[0])PetscMallocA(1,PETSC_FALSE,1545,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(m)*sizeof(**(&mapping->info_nodei[0])),(& mapping->info_nodei[0]));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1545,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); } | |||
1546 | for (i=1;i<n;i++) mapping->info_nodei[i] = mapping->info_nodei[i-1] + mapping->info_nodec[i-1]; | |||
1547 | ierr = PetscArrayzero(mapping->info_nodec,n)PetscMemzero(mapping->info_nodec,(n)*sizeof(*(mapping-> info_nodec)));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1547,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1548 | for (i=0;i<n;i++) { mapping->info_nodec[i] = 1; mapping->info_nodei[i][0] = neigh[0]; } | |||
1549 | for (i=1;i<n_neigh;i++) { | |||
1550 | PetscInt j; | |||
1551 | ||||
1552 | for (j=0;j<n_shared[i];j++) { | |||
1553 | PetscInt k = shared[i][j]; | |||
1554 | ||||
1555 | mapping->info_nodei[k][mapping->info_nodec[k]] = neigh[i]; | |||
1556 | mapping->info_nodec[k] += 1; | |||
1557 | } | |||
1558 | } | |||
1559 | for (i=0;i<n;i++) { ierr = PetscSortRemoveDupsInt(&mapping->info_nodec[i],mapping->info_nodei[i]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1559,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); } | |||
1560 | ierr = ISLocalToGlobalMappingRestoreInfo(mapping,&n_neigh,&neigh,&n_shared,&shared);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1560,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1561 | } | |||
1562 | if (nnodes) *nnodes = n; | |||
1563 | if (count) *count = mapping->info_nodec; | |||
1564 | if (indices) *indices = mapping->info_nodei; | |||
1565 | 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); | |||
1566 | } | |||
1567 | ||||
1568 | /*@C | |||
1569 | ISLocalToGlobalMappingRestoreNodeInfo - Frees the memory allocated by ISLocalToGlobalMappingGetNodeInfo() | |||
1570 | ||||
1571 | Collective on ISLocalToGlobalMapping | |||
1572 | ||||
1573 | Input Parameters: | |||
1574 | . mapping - the mapping from local to global indexing | |||
1575 | ||||
1576 | Output Parameter: | |||
1577 | + nnodes - number of local nodes | |||
1578 | . count - number of neighboring processors per node | |||
1579 | - indices - indices of processes sharing the node (sorted) | |||
1580 | ||||
1581 | Level: advanced | |||
1582 | ||||
1583 | .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS(), ISLocalToGlobalMappingCreate(), | |||
1584 | ISLocalToGlobalMappingGetInfo() | |||
1585 | @*/ | |||
1586 | PetscErrorCode ISLocalToGlobalMappingRestoreNodeInfo(ISLocalToGlobalMapping mapping,PetscInt *nnodes,PetscInt *count[],PetscInt **indices[]) | |||
1587 | { | |||
1588 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1588; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1589 | PetscValidHeaderSpecific(mapping,IS_LTOGM_CLASSID,1)do { if (!mapping) return PetscError(((MPI_Comm)0x44000001),1589 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(mapping,PETSC_OBJECT)) return PetscError(( (MPI_Comm)0x44000001),1589,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(mapping))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(mapping))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1589,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1589,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
1590 | if (nnodes) *nnodes = 0; | |||
1591 | if (count) *count = NULL((void*)0); | |||
1592 | if (indices) *indices = NULL((void*)0); | |||
1593 | 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); | |||
1594 | } | |||
1595 | ||||
1596 | /*@C | |||
1597 | ISLocalToGlobalMappingGetIndices - Get global indices for every local point that is mapped | |||
1598 | ||||
1599 | Not Collective | |||
1600 | ||||
1601 | Input Arguments: | |||
1602 | . ltog - local to global mapping | |||
1603 | ||||
1604 | Output Arguments: | |||
1605 | . array - array of indices, the length of this array may be obtained with ISLocalToGlobalMappingGetSize() | |||
1606 | ||||
1607 | Level: advanced | |||
1608 | ||||
1609 | Notes: | |||
1610 | ISLocalToGlobalMappingGetSize() returns the length the this array | |||
1611 | ||||
1612 | .seealso: ISLocalToGlobalMappingCreate(), ISLocalToGlobalMappingApply(), ISLocalToGlobalMappingRestoreIndices(), ISLocalToGlobalMappingGetBlockIndices(), ISLocalToGlobalMappingRestoreBlockIndices() | |||
1613 | @*/ | |||
1614 | PetscErrorCode ISLocalToGlobalMappingGetIndices(ISLocalToGlobalMapping ltog,const PetscInt **array) | |||
1615 | { | |||
1616 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1616; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1617 | PetscValidHeaderSpecific(ltog,IS_LTOGM_CLASSID,1)do { if (!ltog) return PetscError(((MPI_Comm)0x44000001),1617 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(ltog,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),1617,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(ltog))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(ltog))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1617,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1617,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
1618 | PetscValidPointer(array,2)do { if (!array) return PetscError(((MPI_Comm)0x44000001),1618 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(array,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),1618,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
1619 | if (ltog->bs == 1) { | |||
1620 | *array = ltog->indices; | |||
1621 | } else { | |||
1622 | PetscInt *jj,k,i,j,n = ltog->n, bs = ltog->bs; | |||
1623 | const PetscInt *ii; | |||
1624 | PetscErrorCode ierr; | |||
1625 | ||||
1626 | ierr = PetscMalloc1(bs*n,&jj)PetscMallocA(1,PETSC_FALSE,1626,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(bs*n)*sizeof(**(&jj)),(&jj));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1626,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1627 | *array = jj; | |||
1628 | k = 0; | |||
1629 | ii = ltog->indices; | |||
1630 | for (i=0; i<n; i++) | |||
1631 | for (j=0; j<bs; j++) | |||
1632 | jj[k++] = bs*ii[i] + j; | |||
1633 | } | |||
1634 | 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); | |||
1635 | } | |||
1636 | ||||
1637 | /*@C | |||
1638 | ISLocalToGlobalMappingRestoreIndices - Restore indices obtained with ISLocalToGlobalMappingGetIndices() | |||
1639 | ||||
1640 | Not Collective | |||
1641 | ||||
1642 | Input Arguments: | |||
1643 | + ltog - local to global mapping | |||
1644 | - array - array of indices | |||
1645 | ||||
1646 | Level: advanced | |||
1647 | ||||
1648 | .seealso: ISLocalToGlobalMappingCreate(), ISLocalToGlobalMappingApply(), ISLocalToGlobalMappingGetIndices() | |||
1649 | @*/ | |||
1650 | PetscErrorCode ISLocalToGlobalMappingRestoreIndices(ISLocalToGlobalMapping ltog,const PetscInt **array) | |||
1651 | { | |||
1652 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1652; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1653 | PetscValidHeaderSpecific(ltog,IS_LTOGM_CLASSID,1)do { if (!ltog) return PetscError(((MPI_Comm)0x44000001),1653 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(ltog,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),1653,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(ltog))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(ltog))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1653,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1653,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
1654 | PetscValidPointer(array,2)do { if (!array) return PetscError(((MPI_Comm)0x44000001),1654 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(array,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),1654,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
1655 | if (ltog->bs == 1 && *array != ltog->indices) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_BADPTR,"Trying to return mismatched pointer")return PetscError(((MPI_Comm)0x44000001),1655,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Trying to return mismatched pointer" ); | |||
1656 | ||||
1657 | if (ltog->bs > 1) { | |||
1658 | PetscErrorCode ierr; | |||
1659 | ierr = PetscFree(*(void**)array)((*PetscTrFree)((void*)(*(void**)array),1659,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ) || ((*(void**)array) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1659,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1660 | } | |||
1661 | 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); | |||
1662 | } | |||
1663 | ||||
1664 | /*@C | |||
1665 | ISLocalToGlobalMappingGetBlockIndices - Get global indices for every local block | |||
1666 | ||||
1667 | Not Collective | |||
1668 | ||||
1669 | Input Arguments: | |||
1670 | . ltog - local to global mapping | |||
1671 | ||||
1672 | Output Arguments: | |||
1673 | . array - array of indices | |||
1674 | ||||
1675 | Level: advanced | |||
1676 | ||||
1677 | .seealso: ISLocalToGlobalMappingCreate(), ISLocalToGlobalMappingApply(), ISLocalToGlobalMappingRestoreBlockIndices() | |||
1678 | @*/ | |||
1679 | PetscErrorCode ISLocalToGlobalMappingGetBlockIndices(ISLocalToGlobalMapping ltog,const PetscInt **array) | |||
1680 | { | |||
1681 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1681; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1682 | PetscValidHeaderSpecific(ltog,IS_LTOGM_CLASSID,1)do { if (!ltog) return PetscError(((MPI_Comm)0x44000001),1682 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(ltog,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),1682,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(ltog))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(ltog))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1682,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1682,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
1683 | PetscValidPointer(array,2)do { if (!array) return PetscError(((MPI_Comm)0x44000001),1683 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(array,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),1683,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
1684 | *array = ltog->indices; | |||
1685 | 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); | |||
1686 | } | |||
1687 | ||||
1688 | /*@C | |||
1689 | ISLocalToGlobalMappingRestoreBlockIndices - Restore indices obtained with ISLocalToGlobalMappingGetBlockIndices() | |||
1690 | ||||
1691 | Not Collective | |||
1692 | ||||
1693 | Input Arguments: | |||
1694 | + ltog - local to global mapping | |||
1695 | - array - array of indices | |||
1696 | ||||
1697 | Level: advanced | |||
1698 | ||||
1699 | .seealso: ISLocalToGlobalMappingCreate(), ISLocalToGlobalMappingApply(), ISLocalToGlobalMappingGetIndices() | |||
1700 | @*/ | |||
1701 | PetscErrorCode ISLocalToGlobalMappingRestoreBlockIndices(ISLocalToGlobalMapping ltog,const PetscInt **array) | |||
1702 | { | |||
1703 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1703; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1704 | PetscValidHeaderSpecific(ltog,IS_LTOGM_CLASSID,1)do { if (!ltog) return PetscError(((MPI_Comm)0x44000001),1704 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(ltog,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),1704,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(ltog))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(ltog))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1704,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1704,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
1705 | PetscValidPointer(array,2)do { if (!array) return PetscError(((MPI_Comm)0x44000001),1705 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(array,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),1705,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
1706 | if (*array != ltog->indices) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_BADPTR,"Trying to return mismatched pointer")return PetscError(((MPI_Comm)0x44000001),1706,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Trying to return mismatched pointer" ); | |||
1707 | *array = NULL((void*)0); | |||
1708 | 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); | |||
1709 | } | |||
1710 | ||||
1711 | /*@C | |||
1712 | ISLocalToGlobalMappingConcatenate - Create a new mapping that concatenates a list of mappings | |||
1713 | ||||
1714 | Not Collective | |||
1715 | ||||
1716 | Input Arguments: | |||
1717 | + comm - communicator for the new mapping, must contain the communicator of every mapping to concatenate | |||
1718 | . n - number of mappings to concatenate | |||
1719 | - ltogs - local to global mappings | |||
1720 | ||||
1721 | Output Arguments: | |||
1722 | . ltogcat - new mapping | |||
1723 | ||||
1724 | Note: this currently always returns a mapping with block size of 1 | |||
1725 | ||||
1726 | Developer Note: If all the input mapping have the same block size we could easily handle that as a special case | |||
1727 | ||||
1728 | Level: advanced | |||
1729 | ||||
1730 | .seealso: ISLocalToGlobalMappingCreate() | |||
1731 | @*/ | |||
1732 | PetscErrorCode ISLocalToGlobalMappingConcatenate(MPI_Comm comm,PetscInt n,const ISLocalToGlobalMapping ltogs[],ISLocalToGlobalMapping *ltogcat) | |||
1733 | { | |||
1734 | PetscInt i,cnt,m,*idx; | |||
1735 | PetscErrorCode ierr; | |||
1736 | ||||
1737 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1737; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1738 | if (n < 0) SETERRQ1(comm,PETSC_ERR_ARG_OUTOFRANGE,"Must have a non-negative number of mappings, given %D",n)return PetscError(comm,1738,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,63,PETSC_ERROR_INITIAL,"Must have a non-negative number of mappings, given %D" ,n); | |||
1739 | if (n > 0) PetscValidPointer(ltogs,3)do { if (!ltogs) return PetscError(((MPI_Comm)0x44000001),1739 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(ltogs,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),1739,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); | |||
1740 | for (i=0; i<n; i++) PetscValidHeaderSpecific(ltogs[i],IS_LTOGM_CLASSID,3)do { if (!ltogs[i]) return PetscError(((MPI_Comm)0x44000001), 1740,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",3); if ( !PetscCheckPointer(ltogs[i],PETSC_OBJECT)) return PetscError( ((MPI_Comm)0x44000001),1740,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,3); if (((PetscObject)(ltogs[i]))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(ltogs[i]))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1740,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,3); else return PetscError(((MPI_Comm)0x44000001),1740,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",3); } } while (0); | |||
1741 | PetscValidPointer(ltogcat,4)do { if (!ltogcat) return PetscError(((MPI_Comm)0x44000001),1741 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if (!PetscCheckPointer(ltogcat,PETSC_CHAR)) return PetscError(( (MPI_Comm)0x44000001),1741,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4); } while (0); | |||
1742 | for (cnt=0,i=0; i<n; i++) { | |||
1743 | ierr = ISLocalToGlobalMappingGetSize(ltogs[i],&m);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1743,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1744 | cnt += m; | |||
1745 | } | |||
1746 | ierr = PetscMalloc1(cnt,&idx)PetscMallocA(1,PETSC_FALSE,1746,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,(size_t)(cnt)*sizeof(**(&idx)),(&idx));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1746,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1747 | for (cnt=0,i=0; i<n; i++) { | |||
1748 | const PetscInt *subidx; | |||
1749 | ierr = ISLocalToGlobalMappingGetSize(ltogs[i],&m);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1749,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1750 | ierr = ISLocalToGlobalMappingGetIndices(ltogs[i],&subidx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1750,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1751 | ierr = PetscArraycpy(&idx[cnt],subidx,m)((sizeof(*(&idx[cnt])) != sizeof(*(subidx))) || PetscMemcpy (&idx[cnt],subidx,(m)*sizeof(*(&idx[cnt]))));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1751,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1752 | ierr = ISLocalToGlobalMappingRestoreIndices(ltogs[i],&subidx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1752,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1753 | cnt += m; | |||
1754 | } | |||
1755 | ierr = ISLocalToGlobalMappingCreate(comm,1,cnt,idx,PETSC_OWN_POINTER,ltogcat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1755,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1756 | 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); | |||
1757 | } | |||
1758 | ||||
1759 | /*MC | |||
1760 | ISLOCALTOGLOBALMAPPINGBASIC - basic implementation of the ISLocalToGlobalMapping object. When ISGlobalToLocalMappingApply() is | |||
1761 | used this is good for only small and moderate size problems. | |||
1762 | ||||
1763 | Options Database Keys: | |||
1764 | + -islocaltoglobalmapping_type basic - select this method | |||
1765 | ||||
1766 | Level: beginner | |||
1767 | ||||
1768 | .seealso: ISLocalToGlobalMappingCreate(), ISLocalToGlobalMappingSetType(), ISLOCALTOGLOBALMAPPINGHASH | |||
1769 | M*/ | |||
1770 | PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode ISLocalToGlobalMappingCreate_Basic(ISLocalToGlobalMapping ltog) | |||
1771 | { | |||
1772 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1772; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1773 | ltog->ops->globaltolocalmappingapply = ISGlobalToLocalMappingApply_Basic; | |||
1774 | ltog->ops->globaltolocalmappingsetup = ISGlobalToLocalMappingSetUp_Basic; | |||
1775 | ltog->ops->globaltolocalmappingapplyblock = ISGlobalToLocalMappingApplyBlock_Basic; | |||
1776 | ltog->ops->destroy = ISLocalToGlobalMappingDestroy_Basic; | |||
1777 | 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); | |||
1778 | } | |||
1779 | ||||
1780 | /*MC | |||
1781 | ISLOCALTOGLOBALMAPPINGHASH - hash implementation of the ISLocalToGlobalMapping object. When ISGlobalToLocalMappingApply() is | |||
1782 | used this is good for large memory problems. | |||
1783 | ||||
1784 | Options Database Keys: | |||
1785 | + -islocaltoglobalmapping_type hash - select this method | |||
1786 | ||||
1787 | ||||
1788 | Notes: | |||
1789 | This is selected automatically for large problems if the user does not set the type. | |||
1790 | ||||
1791 | Level: beginner | |||
1792 | ||||
1793 | .seealso: ISLocalToGlobalMappingCreate(), ISLocalToGlobalMappingSetType(), ISLOCALTOGLOBALMAPPINGHASH | |||
1794 | M*/ | |||
1795 | PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode ISLocalToGlobalMappingCreate_Hash(ISLocalToGlobalMapping ltog) | |||
1796 | { | |||
1797 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1797; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1798 | ltog->ops->globaltolocalmappingapply = ISGlobalToLocalMappingApply_Hash; | |||
1799 | ltog->ops->globaltolocalmappingsetup = ISGlobalToLocalMappingSetUp_Hash; | |||
1800 | ltog->ops->globaltolocalmappingapplyblock = ISGlobalToLocalMappingApplyBlock_Hash; | |||
1801 | ltog->ops->destroy = ISLocalToGlobalMappingDestroy_Hash; | |||
1802 | 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); | |||
1803 | } | |||
1804 | ||||
1805 | ||||
1806 | /*@C | |||
1807 | ISLocalToGlobalMappingRegister - Adds a method for applying a global to local mapping with an ISLocalToGlobalMapping | |||
1808 | ||||
1809 | Not Collective | |||
1810 | ||||
1811 | Input Parameters: | |||
1812 | + sname - name of a new method | |||
1813 | - routine_create - routine to create method context | |||
1814 | ||||
1815 | Notes: | |||
1816 | ISLocalToGlobalMappingRegister() may be called multiple times to add several user-defined mappings. | |||
1817 | ||||
1818 | Sample usage: | |||
1819 | .vb | |||
1820 | ISLocalToGlobalMappingRegister("my_mapper",MyCreate); | |||
1821 | .ve | |||
1822 | ||||
1823 | Then, your mapping can be chosen with the procedural interface via | |||
1824 | $ ISLocalToGlobalMappingSetType(ltog,"my_mapper") | |||
1825 | or at runtime via the option | |||
1826 | $ -islocaltoglobalmapping_type my_mapper | |||
1827 | ||||
1828 | Level: advanced | |||
1829 | ||||
1830 | .seealso: ISLocalToGlobalMappingRegisterAll(), ISLocalToGlobalMappingRegisterDestroy(), ISLOCALTOGLOBALMAPPINGBASIC, ISLOCALTOGLOBALMAPPINGHASH | |||
1831 | ||||
1832 | @*/ | |||
1833 | PetscErrorCode ISLocalToGlobalMappingRegister(const char sname[],PetscErrorCode (*function)(ISLocalToGlobalMapping)) | |||
1834 | { | |||
1835 | PetscErrorCode ierr; | |||
1836 | ||||
1837 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1837; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1838 | ierr = ISInitializePackage();CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1838,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1839 | ierr = PetscFunctionListAdd(&ISLocalToGlobalMappingList,sname,function)PetscFunctionListAdd_Private((&ISLocalToGlobalMappingList ),(sname),(PetscVoidFunction)(function));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1839,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1840 | 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); | |||
1841 | } | |||
1842 | ||||
1843 | /*@C | |||
1844 | ISLocalToGlobalMappingSetType - Builds ISLocalToGlobalMapping for a particular global to local mapping approach. | |||
1845 | ||||
1846 | Logically Collective on ISLocalToGlobalMapping | |||
1847 | ||||
1848 | Input Parameters: | |||
1849 | + ltog - the ISLocalToGlobalMapping object | |||
1850 | - type - a known method | |||
1851 | ||||
1852 | Options Database Key: | |||
1853 | . -islocaltoglobalmapping_type <method> - Sets the method; use -help for a list | |||
1854 | of available methods (for instance, basic or hash) | |||
1855 | ||||
1856 | Notes: | |||
1857 | See "petsc/include/petscis.h" for available methods | |||
1858 | ||||
1859 | Normally, it is best to use the ISLocalToGlobalMappingSetFromOptions() command and | |||
1860 | then set the ISLocalToGlobalMapping type from the options database rather than by using | |||
1861 | this routine. | |||
1862 | ||||
1863 | Level: intermediate | |||
1864 | ||||
1865 | Developer Note: ISLocalToGlobalMappingRegister() is used to add new types to ISLocalToGlobalMappingList from which they | |||
1866 | are accessed by ISLocalToGlobalMappingSetType(). | |||
1867 | ||||
1868 | .seealso: PCSetType(), ISLocalToGlobalMappingType, ISLocalToGlobalMappingRegister(), ISLocalToGlobalMappingCreate() | |||
1869 | ||||
1870 | @*/ | |||
1871 | PetscErrorCode ISLocalToGlobalMappingSetType(ISLocalToGlobalMapping ltog, ISLocalToGlobalMappingType type) | |||
1872 | { | |||
1873 | PetscErrorCode ierr,(*r)(ISLocalToGlobalMapping); | |||
1874 | PetscBool match; | |||
1875 | ||||
1876 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1876; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1877 | PetscValidHeaderSpecific(ltog,IS_LTOGM_CLASSID,1)do { if (!ltog) return PetscError(((MPI_Comm)0x44000001),1877 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(ltog,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),1877,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(ltog))->classid != IS_LTOGM_CLASSID ) { if (((PetscObject)(ltog))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1877,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1877,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",62,PETSC_ERROR_INITIAL ,"Wrong type of object: Parameter # %d",1); } } while (0); | |||
1878 | PetscValidCharPointer(type,2)do { if (!type) return PetscError(((MPI_Comm)0x44000001),1878 ,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(type,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),1878,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to char: Parameter # %d" ,2); } while (0); | |||
1879 | ||||
1880 | ierr = PetscObjectTypeCompare((PetscObject)ltog,type,&match);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1880,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1881 | if (match) 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); | |||
1882 | ||||
1883 | ierr = PetscFunctionListFind(ISLocalToGlobalMappingList,type,&r)PetscFunctionListFind_Private((ISLocalToGlobalMappingList),(type ),(PetscVoidFunction*)(&r));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1883,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1884 | if (!r) SETERRQ1(PetscObjectComm((PetscObject)ltog),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested ISLocalToGlobalMapping type %s",type)return PetscError(PetscObjectComm((PetscObject)ltog),1884,__func__ ,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c",86,PETSC_ERROR_INITIAL ,"Unable to find requested ISLocalToGlobalMapping type %s",type ); | |||
1885 | /* Destroy the previous private LTOG context */ | |||
1886 | if (ltog->ops->destroy) { | |||
1887 | ierr = (*ltog->ops->destroy)(ltog);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1887,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1888 | ltog->ops->destroy = NULL((void*)0); | |||
1889 | } | |||
1890 | ierr = PetscObjectChangeTypeName((PetscObject)ltog,type);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1890,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1891 | ierr = (*r)(ltog);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1891,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1892 | 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); | |||
1893 | } | |||
1894 | ||||
1895 | PetscBool ISLocalToGlobalMappingRegisterAllCalled = PETSC_FALSE; | |||
1896 | ||||
1897 | /*@C | |||
1898 | ISLocalToGlobalMappingRegisterAll - Registers all of the local to global mapping components in the IS package. | |||
1899 | ||||
1900 | Not Collective | |||
1901 | ||||
1902 | Level: advanced | |||
1903 | ||||
1904 | .seealso: ISRegister(), ISLocalToGlobalRegister() | |||
1905 | @*/ | |||
1906 | PetscErrorCode ISLocalToGlobalMappingRegisterAll(void) | |||
1907 | { | |||
1908 | PetscErrorCode ierr; | |||
1909 | ||||
1910 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c"; petscstack ->line[petscstack->currentsize] = 1910; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1911 | if (ISLocalToGlobalMappingRegisterAllCalled) 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); | |||
1912 | ISLocalToGlobalMappingRegisterAllCalled = PETSC_TRUE; | |||
1913 | ||||
1914 | ierr = ISLocalToGlobalMappingRegister(ISLOCALTOGLOBALMAPPINGBASIC"basic", ISLocalToGlobalMappingCreate_Basic);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1914,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1915 | ierr = ISLocalToGlobalMappingRegister(ISLOCALTOGLOBALMAPPINGHASH"hash", ISLocalToGlobalMappingCreate_Hash);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1915,__func__,"/sandbox/petsc/petsc.master/src/vec/is/utils/isltog.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1916 | 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); | |||
1917 | } | |||
1918 |
1 | #if !defined(_PETSC_HASHMAPI_H) |
2 | #define _PETSC_HASHMAPI_H |
3 | |
4 | #include <petsc/private/hashmap.h> |
5 | |
6 | PETSC_HASH_MAP(HMapI, PetscInt, PetscInt, PetscHashInt, PetscHashEqual, -1)typedef struct kh_HMapI_s { khint_t n_buckets, size, n_occupied , upper_bound; khint32_t *flags; PetscInt *keys; PetscInt *vals ; } kh_HMapI_t; static inline __attribute((unused)) kh_HMapI_t *kh_init_HMapI(void) { return (kh_HMapI_t*)calloc(1,sizeof(kh_HMapI_t )); } static inline __attribute((unused)) void kh_destroy_HMapI (kh_HMapI_t *h) { if (h) { free((void *)h->keys); free(h-> flags); free((void *)h->vals); free(h); } } static inline __attribute ((unused)) void kh_clear_HMapI(kh_HMapI_t *h) { if (h && h->flags) { memset(h->flags, 0xaa, ((h->n_buckets) < 16? 1 : (h->n_buckets)>>4) * sizeof(khint32_t)); h-> size = h->n_occupied = 0; } } static inline __attribute((unused )) khint_t kh_get_HMapI(const kh_HMapI_t *h, PetscInt key) { if (h->n_buckets) { khint_t k, i, last, mask, step = 0; mask = h->n_buckets - 1; k = PetscHashInt(key); i = k & mask ; last = i; while (!((h->flags[i>>4]>>((i& 0xfU)<<1))&2) && (((h->flags[i>>4] >>((i&0xfU)<<1))&1) || !((h->keys[i]) == (key)))) { i = (i + (++step)) & mask; if (i == last) return h->n_buckets; } return ((h->flags[i>>4]>>( (i&0xfU)<<1))&3)? h->n_buckets : i; } else return 0; } static inline __attribute((unused)) int kh_resize_HMapI (kh_HMapI_t *h, khint_t new_n_buckets) { khint32_t *new_flags = 0; khint_t j = 1; { (--(new_n_buckets), (new_n_buckets)|=( new_n_buckets)>>1, (new_n_buckets)|=(new_n_buckets)>> 2, (new_n_buckets)|=(new_n_buckets)>>4, (new_n_buckets) |=(new_n_buckets)>>8, (new_n_buckets)|=(new_n_buckets)>> 16, ++(new_n_buckets)); if (new_n_buckets < 4) new_n_buckets = 4; if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; else { new_flags = (khint32_t*)malloc(((new_n_buckets ) < 16? 1 : (new_n_buckets)>>4) * sizeof(khint32_t)) ; if (!new_flags) return -1; memset(new_flags, 0xaa, ((new_n_buckets ) < 16? 1 : (new_n_buckets)>>4) * sizeof(khint32_t)) ; if (h->n_buckets < new_n_buckets) { PetscInt *new_keys = (PetscInt*)realloc((void *)h->keys,new_n_buckets * sizeof (PetscInt)); if (!new_keys) { free(new_flags); return -1; } h ->keys = new_keys; if (1) { PetscInt *new_vals = (PetscInt *)realloc((void *)h->vals,new_n_buckets * sizeof(PetscInt) ); if (!new_vals) { free(new_flags); return -1; } h->vals = new_vals; } } } } if (j) { for (j = 0; j != h->n_buckets; ++j) { if (((h->flags[j>>4]>>((j&0xfU)<< 1))&3) == 0) { PetscInt key = h->keys[j]; PetscInt val ; khint_t new_mask; new_mask = new_n_buckets - 1; if (1) val = h->vals[j]; (h->flags[j>>4]|=1ul<<((j& 0xfU)<<1)); while (1) { khint_t k, i, step = 0; k = PetscHashInt (key); i = k & new_mask; while (!((new_flags[i>>4]>> ((i&0xfU)<<1))&2)) i = (i + (++step)) & new_mask ; (new_flags[i>>4]&=~(2ul<<((i&0xfU)<< 1))); if (i < h->n_buckets && ((h->flags[i>> 4]>>((i&0xfU)<<1))&3) == 0) { { PetscInt tmp = h->keys[i]; h->keys[i] = key; key = tmp; } if (1) { PetscInt tmp = h->vals[i]; h->vals[i] = val; val = tmp; } (h-> flags[i>>4]|=1ul<<((i&0xfU)<<1)); } else { h->keys[i] = key; if (1) h->vals[i] = val; break; } } } } if (h->n_buckets > new_n_buckets) { h->keys = ( PetscInt*)realloc((void *)h->keys,new_n_buckets * sizeof(PetscInt )); if (1) h->vals = (PetscInt*)realloc((void *)h->vals ,new_n_buckets * sizeof(PetscInt)); } free(h->flags); h-> flags = new_flags; h->n_buckets = new_n_buckets; h->n_occupied = h->size; h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); } return 0; } static inline __attribute ((unused)) khint_t kh_put_HMapI(kh_HMapI_t *h, PetscInt key, int *ret) { khint_t x; if (h->n_occupied >= h->upper_bound ) { if (h->n_buckets > (h->size<<1)) { if (kh_resize_HMapI (h, h->n_buckets - 1) < 0) { *ret = -1; return h->n_buckets ; } } else if (kh_resize_HMapI(h, h->n_buckets + 1) < 0 ) { *ret = -1; return h->n_buckets; } } { khint_t k, i, site , last, mask = h->n_buckets - 1, step = 0; x = site = h-> n_buckets; k = PetscHashInt(key); i = k & mask; if (((h-> flags[i>>4]>>((i&0xfU)<<1))&2)) x = i; else { last = i; while (!((h->flags[i>>4]>> ((i&0xfU)<<1))&2) && (((h->flags[i>> 4]>>((i&0xfU)<<1))&1) || !((h->keys[i] ) == (key)))) { if (((h->flags[i>>4]>>((i& 0xfU)<<1))&1)) site = i; i = (i + (++step)) & mask ; if (i == last) { x = site; break; } } if (x == h->n_buckets ) { if (((h->flags[i>>4]>>((i&0xfU)<< 1))&2) && site != h->n_buckets) x = site; else x = i; } } } if (((h->flags[x>>4]>>((x&0xfU )<<1))&2)) { h->keys[x] = key; (h->flags[x>> 4]&=~(3ul<<((x&0xfU)<<1))); ++h->size; ++h->n_occupied; *ret = 1; } else if (((h->flags[x>> 4]>>((x&0xfU)<<1))&1)) { h->keys[x] = key ; (h->flags[x>>4]&=~(3ul<<((x&0xfU)<< 1))); ++h->size; *ret = 2; } else *ret = 0; return x; } static inline __attribute((unused)) void kh_del_HMapI(kh_HMapI_t *h , khint_t x) { if (x != h->n_buckets && !((h->flags [x>>4]>>((x&0xfU)<<1))&3)) { (h-> flags[x>>4]|=1ul<<((x&0xfU)<<1)); --h-> size; } } typedef kh_HMapI_t *PetscHMapI; static inline __attribute ((unused)) PetscErrorCode PetscHMapICreate(PetscHMapI *ht) { do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); *ht = kh_init_HMapI(); do { if (__builtin_expect (!!(!(*ht!=((void*)0))),0)) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","*ht!=((void*)0)" ); } while(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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIDestroy (PetscHMapI *ht) { do { do { ; if (petscstack && (petscstack ->currentsize < 64)) { petscstack->function[petscstack ->currentsize] = __func__; petscstack->file[petscstack-> currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); if (!*ht) 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); kh_destroy_HMapI(*ht); *ht = ((void*)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); } static inline __attribute ((unused)) PetscErrorCode PetscHMapIReset(PetscHMapI ht) { do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); { if (ht) { free((ht)->keys); free((ht)-> flags); free((ht)->vals); memset((ht), 0x00, sizeof(*(ht)) ); } }; 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIDuplicate (PetscHMapI ht,PetscHMapI *hd) { int ret; PetscInt key; PetscInt val; do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!hd) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(hd,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); *hd = kh_init_HMapI(); do { if (__builtin_expect (!!(!(*hd!=((void*)0))),0)) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","*hd!=((void*)0)" ); } while(0); ret = kh_resize_HMapI(*hd, ((ht)->size)); do { if (__builtin_expect(!!(!(ret==0)),0)) return PetscError(( (MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret==0" ); } while(0); { khint_t __i; for (__i = (khint_t)(0); __i != ((ht)->n_buckets); ++__i) { if (!(!(((ht)->flags[(__i) >>4]>>(((__i)&0xfU)<<1))&3))) continue ; (key) = ((ht)->keys[__i]); (val) = ((ht)->vals[__i]); { khiter_t i; i = kh_put_HMapI(*hd, key, &ret); do { if ( __builtin_expect(!!(!(ret>=0)),0)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret>=0" ); } while(0); ((*hd)->vals[i]) = val;}; } } 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIClear(PetscHMapI ht) { do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function [petscstack->currentsize] = __func__; petscstack->file[ petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); kh_clear_HMapI(ht); 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIResize(PetscHMapI ht,PetscInt nb) { int ret; do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); ret = kh_resize_HMapI(ht, (khint_t)nb); do { if (__builtin_expect(!!(!(ret>=0)),0)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret>=0" ); } while(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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIGetSize (PetscHMapI ht,PetscInt *n) { do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function [petscstack->currentsize] = __func__; petscstack->file[ petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!n) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(n,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); *n = (PetscInt)((ht)->size); 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); } static inline __attribute ((unused)) PetscErrorCode PetscHMapIGetCapacity(PetscHMapI ht ,PetscInt *n) { do { do { ; if (petscstack && (petscstack ->currentsize < 64)) { petscstack->function[petscstack ->currentsize] = __func__; petscstack->file[petscstack-> currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!n) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(n,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); *n = (PetscInt)((ht)->n_buckets); 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); } static inline __attribute ((unused)) PetscErrorCode PetscHMapIHas(PetscHMapI ht,PetscInt key,PetscBool *has) { khiter_t iter; do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack ->function[petscstack->currentsize] = __func__; petscstack ->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!has) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(has,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); iter = kh_get_HMapI(ht, key); *has = (iter != ( (ht)->n_buckets)) ? PETSC_TRUE : PETSC_FALSE; 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIGet(PetscHMapI ht,PetscInt key,PetscInt *val) { khiter_t iter; do { do { ; if (petscstack && (petscstack-> currentsize < 64)) { petscstack->function[petscstack-> currentsize] = __func__; petscstack->file[petscstack->currentsize ] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!val) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(val,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,3); } while (0); iter = kh_get_HMapI(ht, key); *val = (iter != ((ht)->n_buckets)) ? ((ht)->vals[iter]) : (-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); } static inline __attribute ((unused)) PetscErrorCode PetscHMapISet(PetscHMapI ht,PetscInt key,PetscInt val) { int ret; khiter_t iter; do { do { ; if ( petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize] = __func__ ; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); iter = kh_put_HMapI(ht, key, &ret); do { if (__builtin_expect(!!(!(ret>=0)),0)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret>=0" ); } while(0); ((ht)->vals[iter]) = val; 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIDel(PetscHMapI ht,PetscInt key) { khiter_t iter; do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); iter = kh_get_HMapI(ht, key); kh_del_HMapI(ht, iter ); 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIQuerySet (PetscHMapI ht,PetscInt key,PetscInt val,PetscBool *missing) { int ret; khiter_t iter; do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function [petscstack->currentsize] = __func__; petscstack->file[ petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!missing) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(missing,PETSC_CHAR)) return PetscError(( (MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); iter = kh_put_HMapI(ht, key, &ret); do { if (__builtin_expect(!!(!(ret>=0)),0)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret>=0" ); } while(0); ((ht)->vals[iter]) = val; *missing = ret ? PETSC_TRUE : PETSC_FALSE; 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIQueryDel (PetscHMapI ht,PetscInt key,PetscBool *present) { khiter_t iter ; do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!present) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(present,PETSC_CHAR)) return PetscError(( (MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); iter = kh_get_HMapI(ht, key); if (iter != ((ht) ->n_buckets)) { kh_del_HMapI(ht, iter); *present = PETSC_TRUE ; } else { *present = PETSC_FALSE; } 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIFind(PetscHMapI ht,PetscInt key,PetscHashIter *iter ,PetscBool *found) { do { do { ; if (petscstack && (petscstack ->currentsize < 64)) { petscstack->function[petscstack ->currentsize] = __func__; petscstack->file[petscstack-> currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!iter) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(iter,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); do { if (!found) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(found,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); *iter = kh_get_HMapI(ht, key); *found = (*iter != ((ht)->n_buckets)) ? PETSC_TRUE : PETSC_FALSE; 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); } static inline __attribute ((unused)) PetscErrorCode PetscHMapIPut(PetscHMapI ht,PetscInt key,PetscHashIter *iter,PetscBool *missing) { int ret; do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!iter) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(iter,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); do { if (!missing) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(missing,PETSC_CHAR)) return PetscError(( (MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); *iter = kh_put_HMapI(ht, key, &ret); do { if (__builtin_expect(!!(!(ret>=0)),0)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret>=0" ); } while(0); *missing = ret ? PETSC_TRUE : PETSC_FALSE; 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); } static inline __attribute ((unused)) PetscErrorCode PetscHMapIIterGet(PetscHMapI ht,PetscHashIter iter,PetscInt *val) { do { do { ; if (petscstack && ( petscstack->currentsize < 64)) { petscstack->function [petscstack->currentsize] = __func__; petscstack->file[ petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!val) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(val,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); *val = __builtin_expect(!!(iter < ((ht)-> n_buckets) && (!(((ht)->flags[(iter)>>4]>> (((iter)&0xfU)<<1))&3))),1) ? ((ht)->vals[iter ]) : (-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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIIterSet (PetscHMapI ht,PetscHashIter iter,PetscInt val) { do { do { ; if (petscstack && (petscstack->currentsize < 64 )) { petscstack->function[petscstack->currentsize] = __func__ ; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); if (__builtin_expect(!!(iter < ((ht)->n_buckets ) && (!(((ht)->flags[(iter)>>4]>>(((iter )&0xfU)<<1))&3))),1)) ((ht)->vals[iter]) = val ; 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIIterDel (PetscHMapI ht,PetscHashIter iter) { do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack ->function[petscstack->currentsize] = __func__; petscstack ->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); if (__builtin_expect(!!(iter < ((ht)->n_buckets )),1)) kh_del_HMapI(ht, iter); 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIGetKeys(PetscHMapI ht,PetscInt *off,PetscInt array []) { PetscInt key; PetscInt pos; do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function [petscstack->currentsize] = __func__; petscstack->file[ petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!off) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(off,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); pos = *off; { khint_t __i; for (__i = (khint_t )(0); __i != ((ht)->n_buckets); ++__i) { if (!(!(((ht)-> flags[(__i)>>4]>>(((__i)&0xfU)<<1))& 3))) continue; (key) = ((ht)->keys[__i]); array[pos++] = key ; } }; *off = pos; 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIGetVals (PetscHMapI ht,PetscInt *off,PetscInt array[]) { PetscInt val ; PetscInt pos; do { do { ; if (petscstack && (petscstack ->currentsize < 64)) { petscstack->function[petscstack ->currentsize] = __func__; petscstack->file[petscstack-> currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!off) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(off,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); pos = *off; { khint_t __i; for (__i = (khint_t )(0); __i != ((ht)->n_buckets); ++__i) { if (!(!(((ht)-> flags[(__i)>>4]>>(((__i)&0xfU)<<1))& 3))) continue; (val) = ((ht)->vals[__i]); array[pos++] = val ; } }; *off = pos; 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); } static inline __attribute((unused)) PetscErrorCode PetscHMapIGetPairs (PetscHMapI ht,PetscInt *off,PetscInt karray[],PetscInt varray []) { PetscInt val; PetscInt key; PetscInt pos; do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize] = __func__ ; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ; petscstack->line[petscstack->currentsize] = 6; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if (!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1); } while (0); do { if (!off) return PetscError(((MPI_Comm)0x44000001 ),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(off,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashmapi.h" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); pos = *off; { khint_t __i; for (__i = (khint_t )(0); __i != ((ht)->n_buckets); ++__i) { if (!(!(((ht)-> flags[(__i)>>4]>>(((__i)&0xfU)<<1))& 3))) continue; (key) = ((ht)->keys[__i]); (val) = ((ht)-> vals[__i]); { karray[pos] = key; varray[pos++] = val;}; } } * off = pos; 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); } |
7 | |
8 | #endif /* _PETSC_HASHMAPI_H */ |
1 | #if !defined(_PETSC_HASHTABLE_H) | |||
2 | #define _PETSC_HASHTABLE_H | |||
3 | ||||
4 | #include <petsc/private/petscimpl.h> | |||
5 | ||||
6 | #define kh_inlineinline PETSC_INLINEinline | |||
7 | #define klib_unused__attribute((unused)) PETSC_UNUSED__attribute((unused)) | |||
8 | #include <petsc/private/kernels/khash.h> | |||
9 | ||||
10 | /* Required for khash <= 0.2.5 */ | |||
11 | #if !defined(kcalloc) | |||
12 | #define kcalloc(N,Z)calloc(N,Z) calloc(N,Z) | |||
13 | #endif | |||
14 | #if !defined(kmalloc) | |||
15 | #define kmalloc(Z)malloc(Z) malloc(Z) | |||
16 | #endif | |||
17 | #if !defined(krealloc) | |||
18 | #define krealloc(P,Z)realloc(P,Z) realloc(P,Z) | |||
19 | #endif | |||
20 | #if !defined(kfree) | |||
21 | #define kfree(P)free(P) free(P) | |||
22 | #endif | |||
23 | ||||
24 | /* --- Useful extensions to khash --- */ | |||
25 | ||||
26 | #if !defined(kh_reset) | |||
27 | /*! @function | |||
28 | @abstract Reset a hash table to initial state. | |||
29 | @param name Name of the hash table [symbol] | |||
30 | @param h Pointer to the hash table [khash_t(name)*] | |||
31 | */ | |||
32 | #define kh_reset(name, h){ if (h) { free((h)->keys); free((h)->flags); free((h)-> vals); memset((h), 0x00, sizeof(*(h))); } } { \ | |||
33 | if (h) { \ | |||
34 | kfree((h)->keys)free((h)->keys); kfree((h)->flags)free((h)->flags); \ | |||
35 | kfree((h)->vals)free((h)->vals); \ | |||
36 | memset((h), 0x00, sizeof(*(h))); \ | |||
37 | } } | |||
38 | #endif /*kh_reset*/ | |||
39 | ||||
40 | #if !defined(kh_foreach) | |||
41 | /*! @function | |||
42 | @abstract Iterate over the entries in the hash table | |||
43 | @param h Pointer to the hash table [khash_t(name)*] | |||
44 | @param kvar Variable to which key will be assigned | |||
45 | @param vvar Variable to which value will be assigned | |||
46 | @param code Block of code to execute | |||
47 | */ | |||
48 | #define kh_foreach(h, kvar, vvar, code){ khint_t __i; for (__i = (khint_t)(0); __i != ((h)->n_buckets ); ++__i) { if (!(!(((h)->flags[(__i)>>4]>>((( __i)&0xfU)<<1))&3))) continue; (kvar) = ((h)-> keys[__i]); (vvar) = ((h)->vals[__i]); code; } } { khint_t __i; \ | |||
49 | for (__i = kh_begin(h)(khint_t)(0); __i != kh_end(h)((h)->n_buckets); ++__i) { \ | |||
50 | if (!kh_exist(h,__i)(!(((h)->flags[(__i)>>4]>>(((__i)&0xfU)<< 1))&3))) continue; \ | |||
51 | (kvar) = kh_key(h,__i)((h)->keys[__i]); \ | |||
52 | (vvar) = kh_val(h,__i)((h)->vals[__i]); \ | |||
53 | code; \ | |||
54 | } } | |||
55 | #endif /*kh_foreach*/ | |||
56 | ||||
57 | #if !defined(kh_foreach_key) | |||
58 | /*! @function | |||
59 | @abstract Iterate over the keys in the hash table | |||
60 | @param h Pointer to the hash table [khash_t(name)*] | |||
61 | @param kvar Variable to which key will be assigned | |||
62 | @param code Block of code to execute | |||
63 | */ | |||
64 | #define kh_foreach_key(h, kvar, code){ khint_t __i; for (__i = (khint_t)(0); __i != ((h)->n_buckets ); ++__i) { if (!(!(((h)->flags[(__i)>>4]>>((( __i)&0xfU)<<1))&3))) continue; (kvar) = ((h)-> keys[__i]); code; } } { khint_t __i; \ | |||
65 | for (__i = kh_begin(h)(khint_t)(0); __i != kh_end(h)((h)->n_buckets); ++__i) { \ | |||
66 | if (!kh_exist(h,__i)(!(((h)->flags[(__i)>>4]>>(((__i)&0xfU)<< 1))&3))) continue; \ | |||
67 | (kvar) = kh_key(h,__i)((h)->keys[__i]); \ | |||
68 | code; \ | |||
69 | } } | |||
70 | #endif /*kh_foreach_key*/ | |||
71 | ||||
72 | #if !defined(kh_foreach_value) | |||
73 | /*! @function | |||
74 | @abstract Iterate over the values in the hash table | |||
75 | @param h Pointer to the hash table [khash_t(name)*] | |||
76 | @param vvar Variable to which value will be assigned | |||
77 | @param code Block of code to execute | |||
78 | */ | |||
79 | #define kh_foreach_value(h, vvar, code){ khint_t __i; for (__i = (khint_t)(0); __i != ((h)->n_buckets ); ++__i) { if (!(!(((h)->flags[(__i)>>4]>>((( __i)&0xfU)<<1))&3))) continue; (vvar) = ((h)-> vals[__i]); code; } } { khint_t __i; \ | |||
80 | for (__i = kh_begin(h)(khint_t)(0); __i != kh_end(h)((h)->n_buckets); ++__i) { \ | |||
81 | if (!kh_exist(h,__i)(!(((h)->flags[(__i)>>4]>>(((__i)&0xfU)<< 1))&3))) continue; \ | |||
82 | (vvar) = kh_val(h,__i)((h)->vals[__i]); \ | |||
83 | code; \ | |||
84 | } } | |||
85 | #endif /*kh_foreach_value*/ | |||
86 | ||||
87 | ||||
88 | /* --- Helper macro for error checking --- */ | |||
89 | ||||
90 | #if defined(PETSC_USE_DEBUG1) | |||
91 | #define PetscHashAssert(expr)do { if (__builtin_expect(!!(!(expr)),0)) return PetscError(( (MPI_Comm)0x44000001),91,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashtable.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr" ); } while(0) do { \ | |||
92 | if (PetscUnlikely(!(expr))__builtin_expect(!!(!(expr)),0)) \ | |||
93 | SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB, \return PetscError(((MPI_Comm)0x44000001),95,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashtable.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr" ) | |||
94 | "[khash] Assertion: `%s' failed.", \return PetscError(((MPI_Comm)0x44000001),95,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashtable.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr" ) | |||
95 | PetscStringize(expr))return PetscError(((MPI_Comm)0x44000001),95,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashtable.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr" ); \ | |||
96 | } while(0) | |||
97 | #else | |||
98 | #define PetscHashAssert(expr)do { if (__builtin_expect(!!(!(expr)),0)) return PetscError(( (MPI_Comm)0x44000001),98,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashtable.h" ,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr" ); } while(0) ((void)(expr)) | |||
99 | #endif | |||
100 | ||||
101 | ||||
102 | /* --- Low level iterator API --- */ | |||
103 | ||||
104 | typedef khiter_t PetscHashIter; | |||
105 | ||||
106 | #define PetscHashIterBegin(ht,i)do { (i) = (khint_t)(0); if ((i) != (((ht))->n_buckets) && !(!((((ht))->flags[((i))>>4]>>((((i))&0xfU )<<1))&3))) do { ++((i)); } while (((i)) != ((((ht) ))->n_buckets) && !(!(((((ht)))->flags[(((i)))>> 4]>>(((((i)))&0xfU)<<1))&3))); } while (0 ) do { \ | |||
107 | (i) = kh_begin((ht))(khint_t)(0); \ | |||
108 | if ((i) != kh_end((ht))(((ht))->n_buckets) && !kh_exist((ht),(i))(!((((ht))->flags[((i))>>4]>>((((i))&0xfU) <<1))&3))) \ | |||
109 | PetscHashIterNext((ht),(i))do { ++((i)); } while (((i)) != ((((ht)))->n_buckets) && !(!(((((ht)))->flags[(((i)))>>4]>>(((((i)))& 0xfU)<<1))&3))); \ | |||
110 | } while (0) | |||
111 | ||||
112 | #define PetscHashIterNext(ht,i)do { ++(i); } while ((i) != (((ht))->n_buckets) && !(!((((ht))->flags[((i))>>4]>>((((i))&0xfU )<<1))&3))) \ | |||
113 | do { ++(i); } while ((i) != kh_end((ht))(((ht))->n_buckets) && !kh_exist((ht),(i))(!((((ht))->flags[((i))>>4]>>((((i))&0xfU) <<1))&3))) | |||
114 | ||||
115 | #define PetscHashIterAtEnd(ht,i)((i) == (((ht))->n_buckets)) ((i) == kh_end((ht))(((ht))->n_buckets)) | |||
116 | ||||
117 | #define PetscHashIterGetKey(ht,i,k)((k) = (((ht))->keys[(i)])) ((k) = kh_key((ht),(i))(((ht))->keys[(i)])) | |||
118 | ||||
119 | #define PetscHashIterGetVal(ht,i,v)((v) = (((ht))->vals[(i)])) ((v) = kh_val((ht),(i))(((ht))->vals[(i)])) | |||
120 | ||||
121 | #define PetscHashIterSetVal(ht,i,v)((((ht))->vals[(i)]) = (v)) (kh_val((ht),(i))(((ht))->vals[(i)]) = (v)) | |||
122 | ||||
123 | ||||
124 | /* --- Thomas Wang integer hash functions --- */ | |||
125 | ||||
126 | typedef khint32_t PetscHash32_t; | |||
127 | typedef khint64_t PetscHash64_t; | |||
128 | typedef khint_t PetscHash_t; | |||
129 | ||||
130 | /* Thomas Wang's first version for 32bit integers */ | |||
131 | PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHash_UInt32_v0(PetscHash32_t key) | |||
132 | { | |||
133 | key += ~(key << 15); | |||
134 | key ^= (key >> 10); | |||
135 | key += (key << 3); | |||
136 | key ^= (key >> 6); | |||
137 | key += ~(key << 11); | |||
138 | key ^= (key >> 16); | |||
139 | return key; | |||
140 | } | |||
141 | ||||
142 | /* Thomas Wang's second version for 32bit integers */ | |||
143 | PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHash_UInt32_v1(PetscHash32_t key) | |||
144 | { | |||
145 | key = ~key + (key << 15); /* key = (key << 15) - key - 1; */ | |||
146 | key = key ^ (key >> 12); | |||
147 | key = key + (key << 2); | |||
148 | key = key ^ (key >> 4); | |||
149 | key = key * 2057; /* key = (key + (key << 3)) + (key << 11); */ | |||
150 | key = key ^ (key >> 16); | |||
151 | return key; | |||
152 | } | |||
153 | ||||
154 | PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHash_UInt32(PetscHash32_t key) | |||
155 | { | |||
156 | return PetscHash_UInt32_v1(key); | |||
157 | } | |||
158 | ||||
159 | /* Thomas Wang's version for 64bit integer -> 32bit hash */ | |||
160 | PETSC_STATIC_INLINEstatic inline PetscHash32_t PetscHash_UInt64_32(PetscHash64_t key) | |||
161 | { | |||
162 | key = ~key + (key << 18); /* key = (key << 18) - key - 1; */ | |||
163 | key = key ^ (key >> 31); | |||
164 | key = key * 21; /* key = (key + (key << 2)) + (key << 4); */ | |||
165 | key = key ^ (key >> 11); | |||
166 | key = key + (key << 6); | |||
167 | key = key ^ (key >> 22); | |||
168 | return (PetscHash32_t)key; | |||
169 | } | |||
170 | ||||
171 | /* Thomas Wang's version for 64bit integer -> 64bit hash */ | |||
172 | PETSC_STATIC_INLINEstatic inline PetscHash64_t PetscHash_UInt64_64(PetscHash64_t key) | |||
173 | { | |||
174 | key = ~key + (key << 21); /* key = (key << 21) - key - 1; */ | |||
175 | key = key ^ (key >> 24); | |||
176 | key = key * 265; /* key = (key + (key << 3)) + (key << 8); */ | |||
177 | key = key ^ (key >> 14); | |||
178 | key = key * 21; /* key = (key + (key << 2)) + (key << 4); */ | |||
179 | key = key ^ (key >> 28); | |||
180 | key = key + (key << 31); | |||
181 | return key; | |||
182 | } | |||
183 | ||||
184 | PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHash_UInt64(PetscHash64_t key) | |||
185 | { | |||
186 | return sizeof(PetscHash_t) < sizeof(PetscHash64_t) | |||
187 | ? (PetscHash_t)PetscHash_UInt64_32(key) | |||
188 | : (PetscHash_t)PetscHash_UInt64_64(key); | |||
189 | } | |||
190 | ||||
191 | PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHashInt(PetscInt key) | |||
192 | { | |||
193 | #if defined(PETSC_USE_64BIT_INDICES) | |||
194 | return PetscHash_UInt64((PetscHash64_t)key); | |||
195 | #else | |||
196 | return PetscHash_UInt32((PetscHash32_t)key); | |||
| ||||
197 | #endif | |||
198 | } | |||
199 | ||||
200 | PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHashCombine(PetscHash_t seed, PetscHash_t hash) | |||
201 | { | |||
202 | /* https://doi.org/10.1002/asi.10170 */ | |||
203 | /* https://dl.acm.org/citation.cfm?id=759509 */ | |||
204 | return seed ^ (hash + (seed << 6) + (seed >> 2)); | |||
205 | } | |||
206 | ||||
207 | #define PetscHashEqual(a,b)((a) == (b)) ((a) == (b)) | |||
208 | ||||
209 | ||||
210 | #endif /* _PETSC_HASHTABLE_H */ |