Lines Matching full:map

2    This file contains routines for basic map object implementation.
16 . map - the new `PetscLayout`
50 PetscErrorCode PetscLayoutCreate(MPI_Comm comm, PetscLayout *map) in PetscLayoutCreate() argument
53 PetscCall(PetscNew(map)); in PetscLayoutCreate()
54 PetscCallMPI(MPI_Comm_size(comm, &(*map)->size)); in PetscLayoutCreate()
55 (*map)->comm = comm; in PetscLayoutCreate()
56 (*map)->bs = 1; in PetscLayoutCreate()
57 (*map)->n = -1; in PetscLayoutCreate()
58 (*map)->N = -1; in PetscLayoutCreate()
59 (*map)->range = NULL; in PetscLayoutCreate()
60 (*map)->range_alloc = PETSC_TRUE; in PetscLayoutCreate()
61 (*map)->rstart = 0; in PetscLayoutCreate()
62 (*map)->rend = 0; in PetscLayoutCreate()
63 (*map)->setupcalled = PETSC_FALSE; in PetscLayoutCreate()
64 (*map)->oldn = -1; in PetscLayoutCreate()
65 (*map)->oldN = -1; in PetscLayoutCreate()
66 (*map)->oldbs = -1; in PetscLayoutCreate()
82 . map - the new `PetscLayout`
102 …de PetscLayoutCreateFromSizes(MPI_Comm comm, PetscInt n, PetscInt N, PetscInt bs, PetscLayout *map) in PetscLayoutCreateFromSizes() argument
105 PetscCall(PetscLayoutCreate(comm, map)); in PetscLayoutCreateFromSizes()
106 PetscCall(PetscLayoutSetLocalSize(*map, n)); in PetscLayoutCreateFromSizes()
107 PetscCall(PetscLayoutSetSize(*map, N)); in PetscLayoutCreateFromSizes()
108 PetscCall(PetscLayoutSetBlockSize(*map, bs)); in PetscLayoutCreateFromSizes()
109 PetscCall(PetscLayoutSetUp(*map)); in PetscLayoutCreateFromSizes()
119 . map - the `PetscLayout`
127 PetscErrorCode PetscLayoutDestroy(PetscLayout *map) in PetscLayoutDestroy() argument
130 if (!*map) PetscFunctionReturn(PETSC_SUCCESS); in PetscLayoutDestroy()
131 if (!(*map)->refcnt--) { in PetscLayoutDestroy()
132 if ((*map)->range_alloc) PetscCall(PetscFree((*map)->range)); in PetscLayoutDestroy()
133 PetscCall(ISLocalToGlobalMappingDestroy(&(*map)->mapping)); in PetscLayoutDestroy()
134 PetscCall(PetscFree(*map)); in PetscLayoutDestroy()
136 *map = NULL; in PetscLayoutDestroy()
162 PetscLayout map; in PetscLayoutCreateFromRanges() local
167 PetscCall(PetscLayoutCreate(comm, &map)); in PetscLayoutCreateFromRanges()
168 PetscCall(PetscLayoutSetBlockSize(map, bs)); in PetscLayoutCreateFromRanges()
171 PetscCall(PetscMalloc1(map->size + 1, &map->range)); in PetscLayoutCreateFromRanges()
172 PetscCall(PetscArraycpy(map->range, range, map->size + 1)); in PetscLayoutCreateFromRanges()
175 map->range_alloc = PETSC_FALSE; /* fall through */ in PetscLayoutCreateFromRanges()
177 map->range = (PetscInt *)range; in PetscLayoutCreateFromRanges()
182 map->rstart = map->range[rank]; in PetscLayoutCreateFromRanges()
183 map->rend = map->range[rank + 1]; in PetscLayoutCreateFromRanges()
184 map->n = map->rend - map->rstart; in PetscLayoutCreateFromRanges()
185 map->N = map->range[map->size] - map->range[0]; in PetscLayoutCreateFromRanges()
188 PetscCallMPI(MPIU_Allreduce(&map->n, &tmp, 1, MPIU_INT, MPI_SUM, map->comm)); in PetscLayoutCreateFromRanges()
189map->N, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Sum of local lengths %" PetscInt_FMT " does not equal… in PetscLayoutCreateFromRanges()
190 …eck(map->n % map->bs == 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Local size %" PetscInt_FMT " must be … in PetscLayoutCreateFromRanges()
191 …Check(map->N % map->bs == 0, map->comm, PETSC_ERR_PLIB, "Global size %" PetscInt_FMT " must be div… in PetscLayoutCreateFromRanges()
194 map->setupcalled = PETSC_TRUE; in PetscLayoutCreateFromRanges()
195 map->oldn = map->n; in PetscLayoutCreateFromRanges()
196 map->oldN = map->N; in PetscLayoutCreateFromRanges()
197 map->oldbs = map->bs; in PetscLayoutCreateFromRanges()
198 *newmap = map; in PetscLayoutCreateFromRanges()
203 PetscLayoutSetUp - given a map where you have set either the global or local
204 size sets up the map so that it may be used.
209 . map - pointer to the map
231 PetscErrorCode PetscLayoutSetUp(PetscLayout map) in PetscLayoutSetUp() argument
237 …PetscCheck(!map->setupcalled || !(map->n != map->oldn || map->N != map->oldN), map->comm, PETSC_ER… in PetscLayoutSetUp()
238 map->oldn, map->oldN, map->n, map->N); in PetscLayoutSetUp()
239 if (map->setupcalled) PetscFunctionReturn(PETSC_SUCCESS); in PetscLayoutSetUp()
241map->n < 0 || map->n % map->bs == 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Local size %" PetscInt_FMT … in PetscLayoutSetUp()
242map->N < 0 || map->N % map->bs == 0, map->comm, PETSC_ERR_PLIB, "Global size %" PetscInt_FMT " mus… in PetscLayoutSetUp()
244 PetscCallMPI(MPI_Comm_rank(map->comm, &rank)); in PetscLayoutSetUp()
245 if (map->n > 0) map->n = map->n / map->bs; in PetscLayoutSetUp()
246 if (map->N > 0) map->N = map->N / map->bs; in PetscLayoutSetUp()
247 PetscCall(PetscSplitOwnership(map->comm, &map->n, &map->N)); in PetscLayoutSetUp()
248 map->n = map->n * map->bs; in PetscLayoutSetUp()
249 map->N = map->N * map->bs; in PetscLayoutSetUp()
250 if (!map->range) PetscCall(PetscMalloc1(map->size + 1, &map->range)); in PetscLayoutSetUp()
251 PetscCallMPI(MPI_Allgather(&map->n, 1, MPIU_INT, map->range + 1, 1, MPIU_INT, map->comm)); in PetscLayoutSetUp()
253 map->range[0] = 0; in PetscLayoutSetUp()
254 for (p = 2; p <= map->size; p++) map->range[p] += map->range[p - 1]; in PetscLayoutSetUp()
256 map->rstart = map->range[rank]; in PetscLayoutSetUp()
257 map->rend = map->range[rank + 1]; in PetscLayoutSetUp()
260 map->setupcalled = PETSC_TRUE; in PetscLayoutSetUp()
261 map->oldn = map->n; in PetscLayoutSetUp()
262 map->oldN = map->N; in PetscLayoutSetUp()
263 map->oldbs = map->bs; in PetscLayoutSetUp()
369 + map - pointer to the map
377 PetscErrorCode PetscLayoutSetLocalSize(PetscLayout map, PetscInt n) in PetscLayoutSetLocalSize() argument
380 …cCheck(n % map->bs == 0, map->comm, PETSC_ERR_ARG_INCOMP, "Local size %" PetscInt_FMT " not compat… in PetscLayoutSetLocalSize()
381 map->n = n; in PetscLayoutSetLocalSize()
391 . map - pointer to the map
404 PetscErrorCode PetscLayoutGetLocalSize(PetscLayout map, PetscInt *n) in PetscLayoutGetLocalSize() argument
407 *n = map->n; in PetscLayoutGetLocalSize()
417 + map - pointer to the map
425 PetscErrorCode PetscLayoutSetSize(PetscLayout map, PetscInt n) in PetscLayoutSetSize() argument
428 map->N = n; in PetscLayoutSetSize()
438 . map - pointer to the map
451 PetscErrorCode PetscLayoutGetSize(PetscLayout map, PetscInt *n) in PetscLayoutGetSize() argument
454 *n = map->N; in PetscLayoutGetSize()
464 + map - pointer to the map
472 PetscErrorCode PetscLayoutSetBlockSize(PetscLayout map, PetscInt bs) in PetscLayoutSetBlockSize() argument
476map->n <= 0 || (map->n % bs) == 0, PETSC_COMM_SELF, PETSC_ERR_ARG_INCOMP, "Local size %" PetscInt_… in PetscLayoutSetBlockSize()
477 if (map->mapping) { in PetscLayoutSetBlockSize()
480 PetscCall(ISLocalToGlobalMappingGetBlockSize(map->mapping, &obs)); in PetscLayoutSetBlockSize()
481 if (obs > 1) PetscCall(ISLocalToGlobalMappingSetBlockSize(map->mapping, bs)); in PetscLayoutSetBlockSize()
483 map->bs = bs; in PetscLayoutSetBlockSize()
493 . map - pointer to the map
506 PetscErrorCode PetscLayoutGetBlockSize(PetscLayout map, PetscInt *bs) in PetscLayoutGetBlockSize() argument
509 *bs = map->bs; in PetscLayoutGetBlockSize()
519 . map - pointer to the map
533 PetscErrorCode PetscLayoutGetRange(PetscLayout map, PetscInt *rstart, PetscInt *rend) in PetscLayoutGetRange() argument
536 if (rstart) *rstart = map->rstart; in PetscLayoutGetRange()
537 if (rend) *rend = map->rend; in PetscLayoutGetRange()
547 . map - pointer to the map
552 communicator owned by `map`
569 PetscErrorCode PetscLayoutGetRanges(PetscLayout map, const PetscInt *range[]) in PetscLayoutGetRanges() argument
572 *range = map->range; in PetscLayoutGetRanges()
582 + mapa - pointer to the first map
583 - mapb - pointer to the second map
607 + map - the layout
617 PetscErrorCode PetscLayoutFindOwner(PetscLayout map, PetscInt idx, PetscMPIInt *owner) in PetscLayoutFindOwner() argument
623 …PetscAssert((map->n >= 0) && (map->N >= 0) && (map->range), PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGST… in PetscLayoutFindOwner()
624 …PetscAssert(idx >= 0 && idx <= map->N, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index %" PetscI… in PetscLayoutFindOwner()
625 hi = map->size; in PetscLayoutFindOwner()
628 if (idx < map->range[t]) hi = t; in PetscLayoutFindOwner()
641 + map - the layout
652 PetscErrorCode PetscLayoutFindOwnerIndex(PetscLayout map, PetscInt idx, PetscMPIInt *owner, PetscIn… in PetscLayoutFindOwnerIndex() argument
657 …PetscAssert((map->n >= 0) && (map->N >= 0) && (map->range), PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGST… in PetscLayoutFindOwnerIndex()
658 …PetscAssert(idx >= 0 && idx <= map->N, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index %" PetscI… in PetscLayoutFindOwnerIndex()
659 hi = map->size; in PetscLayoutFindOwnerIndex()
662 if (idx < map->range[t]) hi = t; in PetscLayoutFindOwnerIndex()
666 if (lidx) *lidx = idx - map->range[lo]; in PetscLayoutFindOwnerIndex()