Lines Matching refs:sf
18 …sf, arg) PetscCheck((sf)->graphset, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Must call PetscSFS… argument
20 #define PetscSFCheckGraphSet(sf, arg) \ argument
55 PetscErrorCode PetscSFCreate(MPI_Comm comm, PetscSF *sf) in PetscSFCreate() argument
60 PetscAssertPointer(sf, 2); in PetscSFCreate()
95 *sf = b; in PetscSFCreate()
111 PetscErrorCode PetscSFReset(PetscSF sf) in PetscSFReset() argument
114 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFReset()
115 PetscTryTypeMethod(sf, Reset); in PetscSFReset()
116 PetscCall(PetscSFDestroy(&sf->rankssf)); in PetscSFReset()
118 sf->nroots = -1; in PetscSFReset()
119 sf->nleaves = -1; in PetscSFReset()
120 sf->minleaf = PETSC_INT_MAX; in PetscSFReset()
121 sf->maxleaf = PETSC_INT_MIN; in PetscSFReset()
122 sf->mine = NULL; in PetscSFReset()
123 sf->remote = NULL; in PetscSFReset()
124 sf->graphset = PETSC_FALSE; in PetscSFReset()
125 PetscCall(PetscFree(sf->mine_alloc)); in PetscSFReset()
126 PetscCall(PetscFree(sf->remote_alloc)); in PetscSFReset()
127 sf->nranks = -1; in PetscSFReset()
128 PetscCall(PetscFree4(sf->ranks, sf->roffset, sf->rmine, sf->rremote)); in PetscSFReset()
129 sf->degreeknown = PETSC_FALSE; in PetscSFReset()
130 PetscCall(PetscFree(sf->degree)); in PetscSFReset()
131 if (sf->ingroup != MPI_GROUP_NULL) PetscCallMPI(MPI_Group_free(&sf->ingroup)); in PetscSFReset()
132 if (sf->outgroup != MPI_GROUP_NULL) PetscCallMPI(MPI_Group_free(&sf->outgroup)); in PetscSFReset()
134 if (sf->multi) sf->multi->multi = NULL; in PetscSFReset()
135 PetscCall(PetscSFDestroy(&sf->multi)); in PetscSFReset()
137 PetscCall(PetscLayoutDestroy(&sf->map)); in PetscSFReset()
140 for (PetscInt i = 0; i < 2; i++) PetscCall(PetscSFFree(sf, PETSC_MEMTYPE_DEVICE, sf->rmine_d[i])); in PetscSFReset()
143 sf->setupcalled = PETSC_FALSE; in PetscSFReset()
170 PetscErrorCode PetscSFSetType(PetscSF sf, PetscSFType type) in PetscSFSetType() argument
176 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFSetType()
179 PetscCall(PetscObjectTypeCompare((PetscObject)sf, type, &match)); in PetscSFSetType()
183 …PetscCheck(r, PetscObjectComm((PetscObject)sf), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unable to find reques… in PetscSFSetType()
185 PetscTryTypeMethod(sf, Destroy); in PetscSFSetType()
186 PetscCall(PetscMemzero(sf->ops, sizeof(*sf->ops))); in PetscSFSetType()
187 PetscCall(PetscObjectChangeTypeName((PetscObject)sf, type)); in PetscSFSetType()
188 PetscCall((*r)(sf)); in PetscSFSetType()
207 PetscErrorCode PetscSFGetType(PetscSF sf, PetscSFType *type) in PetscSFGetType() argument
210 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGetType()
212 *type = ((PetscObject)sf)->type_name; in PetscSFGetType()
228 PetscErrorCode PetscSFDestroy(PetscSF *sf) in PetscSFDestroy() argument
231 if (!*sf) PetscFunctionReturn(PETSC_SUCCESS); in PetscSFDestroy()
232 PetscValidHeaderSpecific(*sf, PETSCSF_CLASSID, 1); in PetscSFDestroy()
233 if (--((PetscObject)*sf)->refct > 0) { in PetscSFDestroy()
234 *sf = NULL; in PetscSFDestroy()
237 PetscCall(PetscSFReset(*sf)); in PetscSFDestroy()
238 PetscTryTypeMethod(*sf, Destroy); in PetscSFDestroy()
239 PetscCall(PetscSFDestroy(&(*sf)->vscat.lsf)); in PetscSFDestroy()
240 if ((*sf)->vscat.bs > 1) PetscCallMPI(MPI_Type_free(&(*sf)->vscat.unit)); in PetscSFDestroy()
242 if ((*sf)->use_stream_aware_mpi) { in PetscSFDestroy()
243 PetscCallMPI(MPIX_Stream_free(&(*sf)->mpi_stream)); in PetscSFDestroy()
244 PetscCallMPI(MPI_Comm_free(&(*sf)->stream_comm)); in PetscSFDestroy()
247 PetscCall(PetscHeaderDestroy(sf)); in PetscSFDestroy()
251 static PetscErrorCode PetscSFCheckGraphValid_Private(PetscSF sf) in PetscSFCheckGraphValid_Private() argument
259 if (!sf->graphset || !PetscDefined(USE_DEBUG)) PetscFunctionReturn(PETSC_SUCCESS); in PetscSFCheckGraphValid_Private()
260 PetscCall(PetscSFGetGraph(sf, NULL, &nleaves, &ilocal, &iremote)); in PetscSFCheckGraphValid_Private()
261 PetscCallMPI(MPI_Comm_size(PetscObjectComm((PetscObject)sf), &size)); in PetscSFCheckGraphValid_Private()
285 PetscErrorCode PetscSFSetUp(PetscSF sf) in PetscSFSetUp() argument
288 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFSetUp()
289 PetscSFCheckGraphSet(sf, 1); in PetscSFSetUp()
290 if (sf->setupcalled) PetscFunctionReturn(PETSC_SUCCESS); in PetscSFSetUp()
291 PetscCall(PetscLogEventBegin(PETSCSF_SetUp, sf, 0, 0, 0)); in PetscSFSetUp()
292 PetscCall(PetscSFCheckGraphValid_Private(sf)); in PetscSFSetUp()
293 …if (!((PetscObject)sf)->type_name) PetscCall(PetscSFSetType(sf, PETSCSFBASIC)); /* Zero all sf->op… in PetscSFSetUp()
294 PetscTryTypeMethod(sf, SetUp); in PetscSFSetUp()
296 if (sf->backend == PETSCSF_BACKEND_CUDA) { in PetscSFSetUp()
297 sf->ops->Malloc = PetscSFMalloc_CUDA; in PetscSFSetUp()
298 sf->ops->Free = PetscSFFree_CUDA; in PetscSFSetUp()
302 if (sf->backend == PETSCSF_BACKEND_HIP) { in PetscSFSetUp()
303 sf->ops->Malloc = PetscSFMalloc_HIP; in PetscSFSetUp()
304 sf->ops->Free = PetscSFFree_HIP; in PetscSFSetUp()
309 if (sf->backend == PETSCSF_BACKEND_KOKKOS) { in PetscSFSetUp()
310 sf->ops->Malloc = PetscSFMalloc_Kokkos; in PetscSFSetUp()
311 sf->ops->Free = PetscSFFree_Kokkos; in PetscSFSetUp()
314 PetscCall(PetscLogEventEnd(PETSCSF_SetUp, sf, 0, 0, 0)); in PetscSFSetUp()
315 sf->setupcalled = PETSC_TRUE; in PetscSFSetUp()
344 PetscErrorCode PetscSFSetFromOptions(PetscSF sf) in PetscSFSetFromOptions() argument
351 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFSetFromOptions()
352 PetscObjectOptionsBegin((PetscObject)sf); in PetscSFSetFromOptions()
353 deft = ((PetscObject)sf)->type_name ? ((PetscObject)sf)->type_name : PETSCSFBASIC; in PetscSFSetFromOptions()
355 PetscCall(PetscSFSetType(sf, flg ? type : deft)); in PetscSFSetFromOptions()
356 …, gathers are non-deterministic otherwise", "PetscSFSetRankOrder", sf->rankorder, &sf->rankorder, … in PetscSFSetFromOptions()
357 …onsBool("-sf_monitor", "monitor the MPI communication in sf", NULL, sf->monitor, &sf->monitor, NUL… in PetscSFSetFromOptions()
363 …on arbitrary streams unknown to SF", "PetscSFSetFromOptions", sf->unknown_input_stream, &sf->unkno… in PetscSFSetFromOptions()
364 …nderlying MPI is cuda-stream aware", "PetscSFSetFromOptions", sf->use_stream_aware_mpi, &sf->use_s… in PetscSFSetFromOptions()
370 if (isCuda) sf->backend = PETSCSF_BACKEND_CUDA; in PetscSFSetFromOptions()
371 else if (isKokkos) sf->backend = PETSCSF_BACKEND_KOKKOS; in PetscSFSetFromOptions()
372 else if (isHip) sf->backend = PETSCSF_BACKEND_HIP; in PetscSFSetFromOptions()
379 if (sf->use_stream_aware_mpi) { in PetscSFSetFromOptions()
385 PetscCallMPI(MPIX_Stream_create(info, &sf->mpi_stream)); in PetscSFSetFromOptions()
387 …PetscCallMPI(MPIX_Stream_comm_create(PetscObjectComm((PetscObject)sf), sf->mpi_stream, &sf->stream… in PetscSFSetFromOptions()
392 PetscTryTypeMethod(sf, SetFromOptions, PetscOptionsObject); in PetscSFSetFromOptions()
410 PetscErrorCode PetscSFSetRankOrder(PetscSF sf, PetscBool flg) in PetscSFSetRankOrder() argument
413 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFSetRankOrder()
414 PetscValidLogicalCollectiveBool(sf, flg, 2); in PetscSFSetRankOrder()
415 …PetscCheck(!sf->multi, PetscObjectComm((PetscObject)sf), PETSC_ERR_ARG_WRONGSTATE, "Rank ordering … in PetscSFSetRankOrder()
416 sf->rankorder = flg; in PetscSFSetRankOrder()
456 PetscErrorCode PetscSFSetGraph(PetscSF sf, PetscInt nroots, PetscInt nleaves, PetscInt ilocal[], Pe… in PetscSFSetGraph() argument
461 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFSetGraph()
471 if (sf->nroots >= 0) { /* Reset only if graph already set */ in PetscSFSetGraph()
472 PetscCall(PetscSFReset(sf)); in PetscSFSetGraph()
475 PetscCall(PetscLogEventBegin(PETSCSF_SetGraph, sf, 0, 0, 0)); in PetscSFSetGraph()
479 PetscCallMPI(MPI_Comm_size(PetscObjectComm((PetscObject)sf), &size)); in PetscSFSetGraph()
483 sf->nroots = nroots; in PetscSFSetGraph()
484 sf->nleaves = nleaves; in PetscSFSetGraph()
507 …PetscCheck(sf->allow_multi_leaves || unique, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Input ilocal h… in PetscSFSetGraph()
508 sf->minleaf = ilocal[0]; in PetscSFSetGraph()
509 sf->maxleaf = ilocal[nleaves - 1]; in PetscSFSetGraph()
512 sf->minleaf = 0; in PetscSFSetGraph()
513 sf->maxleaf = nleaves - 1; in PetscSFSetGraph()
525 sf->mine = ilocal; in PetscSFSetGraph()
527 sf->mine_alloc = NULL; in PetscSFSetGraph()
529 sf->mine_alloc = ilocal; in PetscSFSetGraph()
534 PetscCallMPI(MPI_Comm_size(PetscObjectComm((PetscObject)sf), &size)); in PetscSFSetGraph()
537 sf->remote = iremote; in PetscSFSetGraph()
539 sf->remote_alloc = NULL; in PetscSFSetGraph()
541 sf->remote_alloc = iremote; in PetscSFSetGraph()
543 PetscCall(PetscLogEventEnd(PETSCSF_SetGraph, sf, 0, 0, 0)); in PetscSFSetGraph()
544 sf->graphset = PETSC_TRUE; in PetscSFSetGraph()
578 PetscErrorCode PetscSFSetGraphWithPattern(PetscSF sf, PetscLayout map, PetscSFPattern pattern) in PetscSFSetGraphWithPattern() argument
586 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFSetGraphWithPattern()
587 PetscValidLogicalCollectiveEnum(sf, pattern, 3); in PetscSFSetGraphWithPattern()
589 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFSetGraphWithPattern()
598 PetscCall(PetscLayoutCreate(comm, &sf->map)); in PetscSFSetGraphWithPattern()
599 PetscCall(PetscLayoutSetLocalSize(sf->map, size)); in PetscSFSetGraphWithPattern()
600 PetscCall(PetscLayoutSetSize(sf->map, PetscSqr(sizei))); in PetscSFSetGraphWithPattern()
601 PetscCall(PetscLayoutSetUp(sf->map)); in PetscSFSetGraphWithPattern()
614 PetscCall(PetscLayoutReference(map, &sf->map)); in PetscSFSetGraphWithPattern()
616 PetscCall(PetscSFSetType(sf, type)); in PetscSFSetGraphWithPattern()
618 sf->pattern = pattern; in PetscSFSetGraphWithPattern()
619 sf->mine = NULL; /* Contiguous */ in PetscSFSetGraphWithPattern()
625 sf->nleaves = N; in PetscSFSetGraphWithPattern()
626 sf->nroots = n; in PetscSFSetGraphWithPattern()
627 sf->nranks = size; in PetscSFSetGraphWithPattern()
628 sf->minleaf = 0; in PetscSFSetGraphWithPattern()
629 sf->maxleaf = N - 1; in PetscSFSetGraphWithPattern()
631 sf->nleaves = rank ? 0 : N; in PetscSFSetGraphWithPattern()
632 sf->nroots = n; in PetscSFSetGraphWithPattern()
633 sf->nranks = rank ? 0 : size; in PetscSFSetGraphWithPattern()
634 sf->minleaf = 0; in PetscSFSetGraphWithPattern()
635 sf->maxleaf = rank ? -1 : N - 1; in PetscSFSetGraphWithPattern()
637 sf->nleaves = size; in PetscSFSetGraphWithPattern()
638 sf->nroots = size; in PetscSFSetGraphWithPattern()
639 sf->nranks = size; in PetscSFSetGraphWithPattern()
640 sf->minleaf = 0; in PetscSFSetGraphWithPattern()
641 sf->maxleaf = size - 1; in PetscSFSetGraphWithPattern()
643 …sf->ndranks = 0; /* We do not need to separate out distinguished ranks for patterned graphs to im… in PetscSFSetGraphWithPattern()
644 sf->graphset = PETSC_TRUE; in PetscSFSetGraphWithPattern()
668 PetscErrorCode PetscSFCreateInverseSF(PetscSF sf, PetscSF *isf) in PetscSFCreateInverseSF() argument
676 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFCreateInverseSF()
677 PetscSFCheckGraphSet(sf, 1); in PetscSFCreateInverseSF()
680 PetscCall(PetscSFGetGraph(sf, &nroots, &nleaves, &ilocal, NULL)); in PetscSFCreateInverseSF()
681 maxlocal = sf->maxleaf + 1; /* TODO: We should use PetscSFGetLeafRange() */ in PetscSFCreateInverseSF()
683 PetscCallMPI(MPI_Comm_rank(PetscObjectComm((PetscObject)sf), &rank)); in PetscSFCreateInverseSF()
693 PetscCall(PetscSFReduceBegin(sf, MPIU_SF_NODE, leaves, roots, MPI_REPLACE)); in PetscSFCreateInverseSF()
694 PetscCall(PetscSFReduceEnd(sf, MPIU_SF_NODE, leaves, roots, MPI_REPLACE)); in PetscSFCreateInverseSF()
712 PetscCall(PetscSFDuplicate(sf, PETSCSF_DUPLICATE_CONFONLY, isf)); in PetscSFCreateInverseSF()
734 PetscErrorCode PetscSFDuplicate(PetscSF sf, PetscSFDuplicateOption opt, PetscSF *newsf) in PetscSFDuplicate() argument
740 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFDuplicate()
741 PetscValidLogicalCollectiveEnum(sf, opt, 2); in PetscSFDuplicate()
743 PetscCall(PetscSFCreate(PetscObjectComm((PetscObject)sf), newsf)); in PetscSFDuplicate()
744 PetscCall(PetscSFGetType(sf, &type)); in PetscSFDuplicate()
746 …(*newsf)->allow_multi_leaves = sf->allow_multi_leaves; /* Dup this flag earlier since PetscSFSetGr… in PetscSFDuplicate()
748 PetscSFCheckGraphSet(sf, 1); in PetscSFDuplicate()
749 if (sf->pattern == PETSCSF_PATTERN_GENERAL) { in PetscSFDuplicate()
753 PetscCall(PetscSFGetGraph(sf, &nroots, &nleaves, &ilocal, &iremote)); in PetscSFDuplicate()
756 PetscCall(PetscSFSetGraphWithPattern(*newsf, sf->map, sf->pattern)); in PetscSFDuplicate()
760 if (sf->vscat.bs > 1) PetscCallMPI(MPI_Type_dup(sf->vscat.unit, &dtype)); in PetscSFDuplicate()
761 (*newsf)->vscat.bs = sf->vscat.bs; in PetscSFDuplicate()
763 (*newsf)->vscat.to_n = sf->vscat.to_n; in PetscSFDuplicate()
764 (*newsf)->vscat.from_n = sf->vscat.from_n; in PetscSFDuplicate()
768 (*newsf)->backend = sf->backend; in PetscSFDuplicate()
769 (*newsf)->unknown_input_stream = sf->unknown_input_stream; in PetscSFDuplicate()
770 (*newsf)->use_gpu_aware_mpi = sf->use_gpu_aware_mpi; in PetscSFDuplicate()
771 (*newsf)->use_stream_aware_mpi = sf->use_stream_aware_mpi; in PetscSFDuplicate()
773 PetscTryTypeMethod(sf, Duplicate, opt, *newsf); in PetscSFDuplicate()
804 PetscErrorCode PetscSFGetGraph(PetscSF sf, PetscInt *nroots, PetscInt *nleaves, const PetscInt *ilo… in PetscSFGetGraph() argument
807 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGetGraph()
808 if (sf->ops->GetGraph) { in PetscSFGetGraph()
809 PetscCall(sf->ops->GetGraph(sf, nroots, nleaves, ilocal, iremote)); in PetscSFGetGraph()
811 if (nroots) *nroots = sf->nroots; in PetscSFGetGraph()
812 if (nleaves) *nleaves = sf->nleaves; in PetscSFGetGraph()
813 if (ilocal) *ilocal = sf->mine; in PetscSFGetGraph()
814 if (iremote) *iremote = sf->remote; in PetscSFGetGraph()
835 PetscErrorCode PetscSFGetLeafRange(PetscSF sf, PetscInt *minleaf, PetscInt *maxleaf) in PetscSFGetLeafRange() argument
838 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGetLeafRange()
839 PetscSFCheckGraphSet(sf, 1); in PetscSFGetLeafRange()
840 if (minleaf) *minleaf = sf->minleaf; in PetscSFGetLeafRange()
841 if (maxleaf) *maxleaf = sf->maxleaf; in PetscSFGetLeafRange()
883 PetscErrorCode PetscSFView(PetscSF sf, PetscViewer viewer) in PetscSFView() argument
889 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFView()
890 if (!viewer) PetscCall(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)sf), &viewer)); in PetscSFView()
892 PetscCheckSameComm(sf, 1, viewer, 2); in PetscSFView()
893 if (sf->graphset) PetscCall(PetscSFSetUp(sf)); in PetscSFView()
899 PetscCall(PetscObjectPrintClassNamePrefixType((PetscObject)sf, viewer)); in PetscSFView()
901 if (sf->pattern == PETSCSF_PATTERN_GENERAL) { in PetscSFView()
902 if (!sf->graphset) { in PetscSFView()
907 PetscCallMPI(MPI_Comm_rank(PetscObjectComm((PetscObject)sf), &rank)); in PetscSFView()
909 …Int_FMT ", leaves=%" PetscInt_FMT ", remote ranks=%d\n", rank, sf->nroots, sf->nleaves, sf->nranks… in PetscSFView()
910 …sf->nleaves; i++) PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, "[%d] %" PetscInt_FMT " <- … in PetscSFView()
916 PetscCall(PetscMalloc2(sf->nranks, &tmpranks, sf->nranks, &perm)); in PetscSFView()
917 PetscCall(PetscArraycpy(tmpranks, sf->ranks, sf->nranks)); in PetscSFView()
918 for (PetscMPIInt i = 0; i < sf->nranks; i++) perm[i] = i; in PetscSFView()
919 PetscCall(PetscSortMPIIntWithArray(sf->nranks, tmpranks, perm)); in PetscSFView()
921 for (PetscMPIInt ii = 0; ii < sf->nranks; ii++) { in PetscSFView()
924 …rintf(viewer, "[%d] %d: %" PetscInt_FMT " edges\n", rank, sf->ranks[i], sf->roffset[i + 1] - sf->r… in PetscSFView()
925 …sf->roffset[i]; j < sf->roffset[i + 1]; j++) PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, … in PetscSFView()
934 PetscTryTypeMethod(sf, View, viewer); in PetscSFView()
957 PetscErrorCode PetscSFGetRootRanks(PetscSF sf, PetscMPIInt *nranks, const PetscMPIInt *ranks[], con… in PetscSFGetRootRanks() argument
960 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGetRootRanks()
961 …PetscCheck(sf->setupcalled, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Must call PetscSFSetUp() b… in PetscSFGetRootRanks()
962 if (sf->ops->GetRootRanks) { in PetscSFGetRootRanks()
963 PetscUseTypeMethod(sf, GetRootRanks, nranks, ranks, roffset, rmine, rremote); in PetscSFGetRootRanks()
966 if (nranks) *nranks = sf->nranks; in PetscSFGetRootRanks()
967 if (ranks) *ranks = sf->ranks; in PetscSFGetRootRanks()
968 if (roffset) *roffset = sf->roffset; in PetscSFGetRootRanks()
969 if (rmine) *rmine = sf->rmine; in PetscSFGetRootRanks()
970 if (rremote) *rremote = sf->rremote; in PetscSFGetRootRanks()
993 PetscErrorCode PetscSFGetLeafRanks(PetscSF sf, PetscMPIInt *niranks, const PetscMPIInt *iranks[], c… in PetscSFGetLeafRanks() argument
996 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGetLeafRanks()
997 …PetscCheck(sf->setupcalled, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Must call PetscSFSetUp() b… in PetscSFGetLeafRanks()
998 if (sf->ops->GetLeafRanks) { in PetscSFGetLeafRanks()
999 PetscUseTypeMethod(sf, GetLeafRanks, niranks, iranks, ioffset, irootloc); in PetscSFGetLeafRanks()
1002 PetscCall(PetscSFGetType(sf, &type)); in PetscSFGetLeafRanks()
1030 PetscErrorCode PetscSFSetUpRanks(PetscSF sf, MPI_Group dgroup) in PetscSFSetUpRanks() argument
1040 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFSetUpRanks()
1041 PetscSFCheckGraphSet(sf, 1); in PetscSFSetUpRanks()
1042 PetscCallMPI(MPI_Comm_size(PetscObjectComm((PetscObject)sf), &size)); in PetscSFSetUpRanks()
1044 for (i = 0; i < sf->nleaves; i++) { in PetscSFSetUpRanks()
1046 PetscCall(PetscHMapISetWithMode(table, sf->remote[i].rank + 1, 1, ADD_VALUES)); in PetscSFSetUpRanks()
1049 PetscCall(PetscMPIIntCast(sfnrank, &sf->nranks)); in PetscSFSetUpRanks()
1050 …PetscCall(PetscMalloc4(sf->nranks, &sf->ranks, sf->nranks + 1, &sf->roffset, sf->nleaves, &sf->rmi… in PetscSFSetUpRanks()
1051 PetscCall(PetscMalloc2(sf->nranks, &rcount, sf->nranks, &ranks)); in PetscSFSetUpRanks()
1053 for (i = 0; i < sf->nranks; i++) { in PetscSFSetUpRanks()
1067 PetscCallMPI(MPI_Comm_group(PetscObjectComm((PetscObject)sf), &group)); in PetscSFSetUpRanks()
1078 for (sf->ndranks = 0, i = sf->nranks; sf->ndranks < i;) { in PetscSFSetUpRanks()
1079 for (i--; sf->ndranks < i; i--) { /* Scan i backward looking for distinguished rank */ in PetscSFSetUpRanks()
1082 …for (; sf->ndranks <= i; sf->ndranks++) { /* Scan sf->ndranks forward looking for non-distinguishe… in PetscSFSetUpRanks()
1083 if (!InList(ranks[sf->ndranks], groupsize, groupranks)) break; in PetscSFSetUpRanks()
1085 if (sf->ndranks < i) { /* Swap ranks[sf->ndranks] with ranks[i] */ in PetscSFSetUpRanks()
1091 ranks[i] = ranks[sf->ndranks]; in PetscSFSetUpRanks()
1092 rcount[i] = rcount[sf->ndranks]; in PetscSFSetUpRanks()
1093 ranks[sf->ndranks] = tmprank; in PetscSFSetUpRanks()
1094 rcount[sf->ndranks] = tmpcount; in PetscSFSetUpRanks()
1095 sf->ndranks++; in PetscSFSetUpRanks()
1099 PetscCall(PetscSortMPIIntWithIntArray(sf->ndranks, ranks, rcount)); in PetscSFSetUpRanks()
1100 …(rcount) PetscCall(PetscSortMPIIntWithIntArray(sf->nranks - sf->ndranks, ranks + sf->ndranks, rcou… in PetscSFSetUpRanks()
1101 sf->roffset[0] = 0; in PetscSFSetUpRanks()
1102 for (i = 0; i < sf->nranks; i++) { in PetscSFSetUpRanks()
1103 PetscCall(PetscMPIIntCast(ranks[i], sf->ranks + i)); in PetscSFSetUpRanks()
1104 sf->roffset[i + 1] = sf->roffset[i] + rcount[i]; in PetscSFSetUpRanks()
1107 for (i = 0, irank = -1, orank = -1; i < sf->nleaves; i++) { in PetscSFSetUpRanks()
1109 if (orank != sf->remote[i].rank) { in PetscSFSetUpRanks()
1111 PetscCall(PetscMPIIntCast(sf->remote[i].rank, &orank)); in PetscSFSetUpRanks()
1112 PetscCall(PetscFindMPIInt(orank, sf->ndranks, sf->ranks, &irank)); in PetscSFSetUpRanks()
1114 … PetscCall(PetscFindMPIInt(orank, sf->nranks - sf->ndranks, sf->ranks + sf->ndranks, &irank)); in PetscSFSetUpRanks()
1115 if (irank >= 0) irank += sf->ndranks; in PetscSFSetUpRanks()
1119 sf->rmine[sf->roffset[irank] + rcount[irank]] = sf->mine ? sf->mine[i] : i; in PetscSFSetUpRanks()
1120 sf->rremote[sf->roffset[irank] + rcount[irank]] = sf->remote[i].index; in PetscSFSetUpRanks()
1143 PetscErrorCode PetscSFGetGroups(PetscSF sf, MPI_Group *incoming, MPI_Group *outgoing) in PetscSFGetGroups() argument
1148 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGetGroups()
1149 …PetscCheck(sf->nranks >= 0, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Must call PetscSFSetUpRank… in PetscSFGetGroups()
1150 if (sf->ingroup == MPI_GROUP_NULL) { in PetscSFGetGroups()
1158 PetscCall(PetscMalloc1(sf->nranks, &remote)); in PetscSFGetGroups()
1159 for (i = 0; i < sf->nranks; i++) { in PetscSFGetGroups()
1160 remote[i].rank = sf->ranks[i]; in PetscSFGetGroups()
1163 PetscCall(PetscSFDuplicate(sf, PETSCSF_DUPLICATE_CONFONLY, &bgcount)); in PetscSFGetGroups()
1164 …PetscCall(PetscSFSetGraph(bgcount, 1, sf->nranks, NULL, PETSC_COPY_VALUES, remote, PETSC_OWN_POINT… in PetscSFGetGroups()
1168 PetscCall(PetscMalloc2(indegree[0], &inranks, sf->nranks, &outranks)); in PetscSFGetGroups()
1169 PetscCallMPI(MPI_Comm_rank(PetscObjectComm((PetscObject)sf), &rank)); in PetscSFGetGroups()
1170 for (i = 0; i < sf->nranks; i++) outranks[i] = rank; in PetscSFGetGroups()
1173 PetscCallMPI(MPI_Comm_group(PetscObjectComm((PetscObject)sf), &group)); in PetscSFGetGroups()
1175 PetscCallMPI(MPI_Group_incl(group, indegree0, inranks, &sf->ingroup)); in PetscSFGetGroups()
1180 *incoming = sf->ingroup; in PetscSFGetGroups()
1182 if (sf->outgroup == MPI_GROUP_NULL) { in PetscSFGetGroups()
1183 PetscCallMPI(MPI_Comm_group(PetscObjectComm((PetscObject)sf), &group)); in PetscSFGetGroups()
1184 PetscCallMPI(MPI_Group_incl(group, sf->nranks, sf->ranks, &sf->outgroup)); in PetscSFGetGroups()
1187 *outgoing = sf->outgroup; in PetscSFGetGroups()
1206 PetscErrorCode PetscSFGetRanksSF(PetscSF sf, PetscSF *rsf) in PetscSFGetRanksSF() argument
1209 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGetRanksSF()
1211 if (!sf->rankssf) { in PetscSFGetRanksSF()
1216 PetscCall(PetscSFGetRootRanks(sf, &nranks, &ranks, NULL, NULL, NULL)); in PetscSFGetRanksSF()
1222 PetscCall(PetscSFDuplicate(sf, PETSCSF_DUPLICATE_CONFONLY, &sf->rankssf)); in PetscSFGetRanksSF()
1223 …PetscCall(PetscSFSetGraph(sf->rankssf, 1, nranks, NULL, PETSC_OWN_POINTER, rremotes, PETSC_OWN_POI… in PetscSFGetRanksSF()
1225 *rsf = sf->rankssf; in PetscSFGetRanksSF()
1249 PetscErrorCode PetscSFGetMultiSF(PetscSF sf, PetscSF *multi) in PetscSFGetMultiSF() argument
1252 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGetMultiSF()
1254 if (sf->nroots < 0) { /* Graph has not been set yet; why do we need this? */ in PetscSFGetMultiSF()
1255 PetscCall(PetscSFDuplicate(sf, PETSCSF_DUPLICATE_RANKS, &sf->multi)); in PetscSFGetMultiSF()
1256 *multi = sf->multi; in PetscSFGetMultiSF()
1257 sf->multi->multi = sf->multi; in PetscSFGetMultiSF()
1260 if (!sf->multi) { in PetscSFGetMultiSF()
1264 maxlocal = sf->maxleaf + 1; /* TODO: We should use PetscSFGetLeafRange() */ in PetscSFGetMultiSF()
1265 PetscCall(PetscSFComputeDegreeBegin(sf, &indegree)); in PetscSFGetMultiSF()
1266 PetscCall(PetscSFComputeDegreeEnd(sf, &indegree)); in PetscSFGetMultiSF()
1267 PetscCall(PetscMalloc3(sf->nroots + 1, &inoffset, maxlocal, &outones, maxlocal, &outoffset)); in PetscSFGetMultiSF()
1269 for (i = 0; i < sf->nroots; i++) inoffset[i + 1] = inoffset[i] + indegree[i]; in PetscSFGetMultiSF()
1271 PetscCall(PetscSFFetchAndOpBegin(sf, MPIU_INT, inoffset, outones, outoffset, MPI_SUM)); in PetscSFGetMultiSF()
1272 PetscCall(PetscSFFetchAndOpEnd(sf, MPIU_INT, inoffset, outones, outoffset, MPI_SUM)); in PetscSFGetMultiSF()
1273 for (i = 0; i < sf->nroots; i++) inoffset[i] -= indegree[i]; /* Undo the increment */ in PetscSFGetMultiSF()
1275 …for (i = 0; i < sf->nroots; i++) PetscCheck(inoffset[i] + indegree[i] == inoffset[i + 1], PETSC_CO… in PetscSFGetMultiSF()
1277 PetscCall(PetscMalloc1(sf->nleaves, &remote)); in PetscSFGetMultiSF()
1278 for (i = 0; i < sf->nleaves; i++) { in PetscSFGetMultiSF()
1279 remote[i].rank = sf->remote[i].rank; in PetscSFGetMultiSF()
1280 remote[i].index = outoffset[sf->mine ? sf->mine[i] : i]; in PetscSFGetMultiSF()
1282 PetscCall(PetscSFDuplicate(sf, PETSCSF_DUPLICATE_RANKS, &sf->multi)); in PetscSFGetMultiSF()
1283 sf->multi->multi = sf->multi; in PetscSFGetMultiSF()
1284 …PetscCall(PetscSFSetGraph(sf->multi, inoffset[sf->nroots], sf->nleaves, sf->mine, PETSC_COPY_VALUE… in PetscSFGetMultiSF()
1285 if (sf->rankorder) { /* Sort the ranks */ in PetscSFGetMultiSF()
1289 PetscCallMPI(MPI_Comm_rank(PetscObjectComm((PetscObject)sf), &rank)); in PetscSFGetMultiSF()
1290 for (i = 0, maxdegree = 0; i < sf->nroots; i++) maxdegree = PetscMax(maxdegree, indegree[i]); in PetscSFGetMultiSF()
1291 …PetscCall(PetscMalloc5(sf->multi->nroots, &inranks, sf->multi->nroots, &newoffset, maxlocal, &outr… in PetscSFGetMultiSF()
1293 PetscCall(PetscSFReduceBegin(sf->multi, MPIU_INT, outranks, inranks, MPI_REPLACE)); in PetscSFGetMultiSF()
1294 PetscCall(PetscSFReduceEnd(sf->multi, MPIU_INT, outranks, inranks, MPI_REPLACE)); in PetscSFGetMultiSF()
1296 for (i = 0; i < sf->nroots; i++) { in PetscSFGetMultiSF()
1302 PetscCall(PetscSFBcastBegin(sf->multi, MPIU_INT, newoffset, newoutoffset, MPI_REPLACE)); in PetscSFGetMultiSF()
1303 PetscCall(PetscSFBcastEnd(sf->multi, MPIU_INT, newoffset, newoutoffset, MPI_REPLACE)); in PetscSFGetMultiSF()
1304 PetscCall(PetscMalloc1(sf->nleaves, &newremote)); in PetscSFGetMultiSF()
1305 for (i = 0; i < sf->nleaves; i++) { in PetscSFGetMultiSF()
1306 newremote[i].rank = sf->remote[i].rank; in PetscSFGetMultiSF()
1307 newremote[i].index = newoutoffset[sf->mine ? sf->mine[i] : i]; in PetscSFGetMultiSF()
1309 …PetscCall(PetscSFSetGraph(sf->multi, inoffset[sf->nroots], sf->nleaves, sf->mine, PETSC_COPY_VALUE… in PetscSFGetMultiSF()
1314 *multi = sf->multi; in PetscSFGetMultiSF()
1339 PetscErrorCode PetscSFCreateEmbeddedRootSF(PetscSF sf, PetscInt nselected, const PetscInt selected[… in PetscSFCreateEmbeddedRootSF() argument
1349 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFCreateEmbeddedRootSF()
1350 PetscSFCheckGraphSet(sf, 1); in PetscSFCreateEmbeddedRootSF()
1354 PetscCall(PetscSFSetUp(sf)); in PetscSFCreateEmbeddedRootSF()
1355 PetscCall(PetscLogEventBegin(PETSCSF_EmbedSF, sf, 0, 0, 0)); in PetscSFCreateEmbeddedRootSF()
1356 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFCreateEmbeddedRootSF()
1357 PetscCall(PetscSFGetGraph(sf, &nroots, &nleaves, &ilocal, &iremote)); in PetscSFCreateEmbeddedRootSF()
1366 …if (sf->ops->CreateEmbeddedRootSF) PetscUseTypeMethod(sf, CreateEmbeddedRootSF, nselected, selecte… in PetscSFCreateEmbeddedRootSF()
1369 PetscCall(PetscSFGetLeafRange(sf, &minleaf, &maxleaf)); in PetscSFCreateEmbeddedRootSF()
1375 PetscCall(PetscSFBcastBegin(sf, MPI_SIGNED_CHAR, rootdata, leafdata, MPI_REPLACE)); in PetscSFCreateEmbeddedRootSF()
1376 PetscCall(PetscSFBcastEnd(sf, MPI_SIGNED_CHAR, rootdata, leafdata, MPI_REPLACE)); in PetscSFCreateEmbeddedRootSF()
1403 PetscCall(PetscLogEventEnd(PETSCSF_EmbedSF, sf, 0, 0, 0)); in PetscSFCreateEmbeddedRootSF()
1424 PetscErrorCode PetscSFCreateEmbeddedLeafSF(PetscSF sf, PetscInt nselected, const PetscInt selected[… in PetscSFCreateEmbeddedLeafSF() argument
1433 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFCreateEmbeddedLeafSF()
1434 PetscSFCheckGraphSet(sf, 1); in PetscSFCreateEmbeddedLeafSF()
1439 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFCreateEmbeddedLeafSF()
1443 …sf->nleaves), comm, PETSC_ERR_ARG_OUTOFRANGE, "Min/Max leaf indices %" PetscInt_FMT "/%" PetscInt_… in PetscSFCreateEmbeddedLeafSF()
1446 …if (sf->setupcalled && sf->ops->CreateEmbeddedLeafSF) PetscUseTypeMethod(sf, CreateEmbeddedLeafSF,… in PetscSFCreateEmbeddedLeafSF()
1448 PetscCall(PetscSFGetGraph(sf, &nroots, NULL, &ilocal, &iremote)); in PetscSFCreateEmbeddedLeafSF()
1457 PetscCall(PetscSFDuplicate(sf, PETSCSF_DUPLICATE_CONFONLY, newsf)); in PetscSFCreateEmbeddedLeafSF()
1487 PetscErrorCode PetscSFBcastBegin(PetscSF sf, MPI_Datatype unit, const void *rootdata, void *leafdat… in PetscSFBcastBegin() argument
1492 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFBcastBegin()
1493 PetscCall(PetscSFSetUp(sf)); in PetscSFBcastBegin()
1494 if (!sf->vscat.logging) PetscCall(PetscLogEventBegin(PETSCSF_BcastBegin, sf, 0, 0, 0)); in PetscSFBcastBegin()
1497 PetscUseTypeMethod(sf, BcastBegin, unit, rootmtype, rootdata, leafmtype, leafdata, op); in PetscSFBcastBegin()
1498 if (!sf->vscat.logging) PetscCall(PetscLogEventEnd(PETSCSF_BcastBegin, sf, 0, 0, 0)); in PetscSFBcastBegin()
1523 PetscErrorCode PetscSFBcastWithMemTypeBegin(PetscSF sf, MPI_Datatype unit, PetscMemType rootmtype, … in PetscSFBcastWithMemTypeBegin() argument
1526 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFBcastWithMemTypeBegin()
1527 PetscCall(PetscSFSetUp(sf)); in PetscSFBcastWithMemTypeBegin()
1528 if (!sf->vscat.logging) PetscCall(PetscLogEventBegin(PETSCSF_BcastBegin, sf, 0, 0, 0)); in PetscSFBcastWithMemTypeBegin()
1529 PetscUseTypeMethod(sf, BcastBegin, unit, rootmtype, rootdata, leafmtype, leafdata, op); in PetscSFBcastWithMemTypeBegin()
1530 if (!sf->vscat.logging) PetscCall(PetscLogEventEnd(PETSCSF_BcastBegin, sf, 0, 0, 0)); in PetscSFBcastWithMemTypeBegin()
1552 PetscErrorCode PetscSFBcastEnd(PetscSF sf, MPI_Datatype unit, const void *rootdata, void *leafdata,… in PetscSFBcastEnd() argument
1555 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFBcastEnd()
1556 if (!sf->vscat.logging) PetscCall(PetscLogEventBegin(PETSCSF_BcastEnd, sf, 0, 0, 0)); in PetscSFBcastEnd()
1557 PetscUseTypeMethod(sf, BcastEnd, unit, rootdata, leafdata, op); in PetscSFBcastEnd()
1558 if (!sf->vscat.logging) PetscCall(PetscLogEventEnd(PETSCSF_BcastEnd, sf, 0, 0, 0)); in PetscSFBcastEnd()
1585 PetscErrorCode PetscSFReduceBegin(PetscSF sf, MPI_Datatype unit, const void *leafdata, void *rootda… in PetscSFReduceBegin() argument
1590 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFReduceBegin()
1591 PetscCall(PetscSFSetUp(sf)); in PetscSFReduceBegin()
1592 if (!sf->vscat.logging) PetscCall(PetscLogEventBegin(PETSCSF_ReduceBegin, sf, 0, 0, 0)); in PetscSFReduceBegin()
1595 PetscCall(sf->ops->ReduceBegin(sf, unit, leafmtype, leafdata, rootmtype, rootdata, op)); in PetscSFReduceBegin()
1596 if (!sf->vscat.logging) PetscCall(PetscLogEventEnd(PETSCSF_ReduceBegin, sf, 0, 0, 0)); in PetscSFReduceBegin()
1620 PetscErrorCode PetscSFReduceWithMemTypeBegin(PetscSF sf, MPI_Datatype unit, PetscMemType leafmtype,… in PetscSFReduceWithMemTypeBegin() argument
1623 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFReduceWithMemTypeBegin()
1624 PetscCall(PetscSFSetUp(sf)); in PetscSFReduceWithMemTypeBegin()
1625 if (!sf->vscat.logging) PetscCall(PetscLogEventBegin(PETSCSF_ReduceBegin, sf, 0, 0, 0)); in PetscSFReduceWithMemTypeBegin()
1626 PetscCall(sf->ops->ReduceBegin(sf, unit, leafmtype, leafdata, rootmtype, rootdata, op)); in PetscSFReduceWithMemTypeBegin()
1627 if (!sf->vscat.logging) PetscCall(PetscLogEventEnd(PETSCSF_ReduceBegin, sf, 0, 0, 0)); in PetscSFReduceWithMemTypeBegin()
1649 PetscErrorCode PetscSFReduceEnd(PetscSF sf, MPI_Datatype unit, const void *leafdata, void *rootdata… in PetscSFReduceEnd() argument
1652 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFReduceEnd()
1653 if (!sf->vscat.logging) PetscCall(PetscLogEventBegin(PETSCSF_ReduceEnd, sf, 0, 0, 0)); in PetscSFReduceEnd()
1654 PetscUseTypeMethod(sf, ReduceEnd, unit, leafdata, rootdata, op); in PetscSFReduceEnd()
1655 if (!sf->vscat.logging) PetscCall(PetscLogEventEnd(PETSCSF_ReduceEnd, sf, 0, 0, 0)); in PetscSFReduceEnd()
1685 PetscErrorCode PetscSFFetchAndOpBegin(PetscSF sf, MPI_Datatype unit, void *rootdata, const void *le… in PetscSFFetchAndOpBegin() argument
1690 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFFetchAndOpBegin()
1691 PetscCall(PetscSFSetUp(sf)); in PetscSFFetchAndOpBegin()
1692 PetscCall(PetscLogEventBegin(PETSCSF_FetchAndOpBegin, sf, 0, 0, 0)); in PetscSFFetchAndOpBegin()
1697 …PetscUseTypeMethod(sf, FetchAndOpBegin, unit, rootmtype, rootdata, leafmtype, leafdata, leafupdate… in PetscSFFetchAndOpBegin()
1698 PetscCall(PetscLogEventEnd(PETSCSF_FetchAndOpBegin, sf, 0, 0, 0)); in PetscSFFetchAndOpBegin()
1728 PetscErrorCode PetscSFFetchAndOpWithMemTypeBegin(PetscSF sf, MPI_Datatype unit, PetscMemType rootmt… in PetscSFFetchAndOpWithMemTypeBegin() argument
1731 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFFetchAndOpWithMemTypeBegin()
1732 PetscCall(PetscSFSetUp(sf)); in PetscSFFetchAndOpWithMemTypeBegin()
1733 PetscCall(PetscLogEventBegin(PETSCSF_FetchAndOpBegin, sf, 0, 0, 0)); in PetscSFFetchAndOpWithMemTypeBegin()
1735 …PetscUseTypeMethod(sf, FetchAndOpBegin, unit, rootmtype, rootdata, leafmtype, leafdata, leafupdate… in PetscSFFetchAndOpWithMemTypeBegin()
1736 PetscCall(PetscLogEventEnd(PETSCSF_FetchAndOpBegin, sf, 0, 0, 0)); in PetscSFFetchAndOpWithMemTypeBegin()
1760 PetscErrorCode PetscSFFetchAndOpEnd(PetscSF sf, MPI_Datatype unit, void *rootdata, const void *leaf… in PetscSFFetchAndOpEnd() argument
1763 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFFetchAndOpEnd()
1764 PetscCall(PetscLogEventBegin(PETSCSF_FetchAndOpEnd, sf, 0, 0, 0)); in PetscSFFetchAndOpEnd()
1765 PetscUseTypeMethod(sf, FetchAndOpEnd, unit, rootdata, leafdata, leafupdate, op); in PetscSFFetchAndOpEnd()
1766 PetscCall(PetscLogEventEnd(PETSCSF_FetchAndOpEnd, sf, 0, 0, 0)); in PetscSFFetchAndOpEnd()
1788 PetscErrorCode PetscSFComputeDegreeBegin(PetscSF sf, const PetscInt *degree[]) in PetscSFComputeDegreeBegin() argument
1791 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFComputeDegreeBegin()
1792 PetscSFCheckGraphSet(sf, 1); in PetscSFComputeDegreeBegin()
1794 if (!sf->degreeknown) { in PetscSFComputeDegreeBegin()
1795 PetscInt i, nroots = sf->nroots, maxlocal; in PetscSFComputeDegreeBegin()
1796 …PetscCheck(!sf->degree, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Calls to PetscSFComputeDegreeB… in PetscSFComputeDegreeBegin()
1797 maxlocal = sf->maxleaf - sf->minleaf + 1; in PetscSFComputeDegreeBegin()
1798 PetscCall(PetscMalloc1(nroots, &sf->degree)); in PetscSFComputeDegreeBegin()
1799 …PetscCall(PetscMalloc1(PetscMax(maxlocal, 1), &sf->degreetmp)); /* allocate at least one entry, se… in PetscSFComputeDegreeBegin()
1800 for (i = 0; i < nroots; i++) sf->degree[i] = 0; in PetscSFComputeDegreeBegin()
1801 for (i = 0; i < maxlocal; i++) sf->degreetmp[i] = 1; in PetscSFComputeDegreeBegin()
1802 PetscCall(PetscSFReduceBegin(sf, MPIU_INT, sf->degreetmp - sf->minleaf, sf->degree, MPI_SUM)); in PetscSFComputeDegreeBegin()
1826 PetscErrorCode PetscSFComputeDegreeEnd(PetscSF sf, const PetscInt *degree[]) in PetscSFComputeDegreeEnd() argument
1829 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFComputeDegreeEnd()
1830 PetscSFCheckGraphSet(sf, 1); in PetscSFComputeDegreeEnd()
1832 if (!sf->degreeknown) { in PetscSFComputeDegreeEnd()
1833 …PetscCheck(sf->degreetmp, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Must call PetscSFComputeDegr… in PetscSFComputeDegreeEnd()
1834 PetscCall(PetscSFReduceEnd(sf, MPIU_INT, sf->degreetmp - sf->minleaf, sf->degree, MPI_SUM)); in PetscSFComputeDegreeEnd()
1835 PetscCall(PetscFree(sf->degreetmp)); in PetscSFComputeDegreeEnd()
1836 sf->degreeknown = PETSC_TRUE; in PetscSFComputeDegreeEnd()
1838 *degree = sf->degree; in PetscSFComputeDegreeEnd()
1863 PetscErrorCode PetscSFComputeMultiRootOriginalNumbering(PetscSF sf, const PetscInt degree[], PetscI… in PetscSFComputeMultiRootOriginalNumbering() argument
1869 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFComputeMultiRootOriginalNumbering()
1870 PetscCall(PetscSFGetGraph(sf, &nroots, NULL, NULL, NULL)); in PetscSFComputeMultiRootOriginalNumbering()
1874 PetscCall(PetscSFGetMultiSF(sf, &msf)); in PetscSFComputeMultiRootOriginalNumbering()
1903 PetscErrorCode PetscSFGatherBegin(PetscSF sf, MPI_Datatype unit, const void *leafdata, void *multir… in PetscSFGatherBegin() argument
1908 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGatherBegin()
1909 PetscCall(PetscSFSetUp(sf)); in PetscSFGatherBegin()
1910 PetscCall(PetscSFGetMultiSF(sf, &multi)); in PetscSFGatherBegin()
1932 PetscErrorCode PetscSFGatherEnd(PetscSF sf, MPI_Datatype unit, const void *leafdata, void *multiroo… in PetscSFGatherEnd() argument
1937 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFGatherEnd()
1938 PetscCall(PetscSFGetMultiSF(sf, &multi)); in PetscSFGatherEnd()
1960 PetscErrorCode PetscSFScatterBegin(PetscSF sf, MPI_Datatype unit, const void *multirootdata, void *… in PetscSFScatterBegin() argument
1965 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFScatterBegin()
1966 PetscCall(PetscSFSetUp(sf)); in PetscSFScatterBegin()
1967 PetscCall(PetscSFGetMultiSF(sf, &multi)); in PetscSFScatterBegin()
1989 PetscErrorCode PetscSFScatterEnd(PetscSF sf, MPI_Datatype unit, const void *multirootdata, void *le… in PetscSFScatterEnd() argument
1994 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFScatterEnd()
1995 PetscCall(PetscSFGetMultiSF(sf, &multi)); in PetscSFScatterEnd()
2000 static PetscErrorCode PetscSFCheckLeavesUnique_Private(PetscSF sf) in PetscSFCheckLeavesUnique_Private() argument
2008 PetscCall(PetscSFGetGraph(sf, NULL, &nleaves, &ilocal, NULL)); in PetscSFCheckLeavesUnique_Private()
2239 PetscErrorCode PetscSFCreateLocalSF_Private(PetscSF sf, PetscSF *out) in PetscSFCreateLocalSF_Private() argument
2250 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFCreateLocalSF_Private()
2251 if (sf->ops->CreateLocalSF) PetscUseTypeMethod(sf, CreateLocalSF, out); in PetscSFCreateLocalSF_Private()
2256 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFCreateLocalSF_Private()
2260 PetscCall(PetscSFGetGraph(sf, &nroots, &nleaves, &ilocal, &iremote)); in PetscSFCreateLocalSF_Private()
2287 PetscErrorCode PetscSFBcastToZero_Private(PetscSF sf, MPI_Datatype unit, const void *rootdata, void… in PetscSFBcastToZero_Private() argument
2292 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFBcastToZero_Private()
2293 PetscCall(PetscSFSetUp(sf)); in PetscSFBcastToZero_Private()
2294 PetscCall(PetscLogEventBegin(PETSCSF_BcastBegin, sf, 0, 0, 0)); in PetscSFBcastToZero_Private()
2297 PetscUseTypeMethod(sf, BcastToZero, unit, rootmtype, rootdata, leafmtype, leafdata); in PetscSFBcastToZero_Private()
2298 PetscCall(PetscLogEventEnd(PETSCSF_BcastBegin, sf, 0, 0, 0)); in PetscSFBcastToZero_Private()
2681 PetscErrorCode PetscSFRegisterPersistent(PetscSF sf, MPI_Datatype unit, const void *rootdata, const… in PetscSFRegisterPersistent() argument
2684 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFRegisterPersistent()
2685 …PetscTryMethod(sf, "PetscSFRegisterPersistent_C", (PetscSF, MPI_Datatype, const void *, const void… in PetscSFRegisterPersistent()
2707 PetscErrorCode PetscSFDeregisterPersistent(PetscSF sf, MPI_Datatype unit, const void *rootdata, con… in PetscSFDeregisterPersistent() argument
2710 PetscValidHeaderSpecific(sf, PETSCSF_CLASSID, 1); in PetscSFDeregisterPersistent()
2711 …PetscTryMethod(sf, "PetscSFDeregisterPersistent_C", (PetscSF, MPI_Datatype, const void *, const vo… in PetscSFDeregisterPersistent()