sfutils.c (be37439ebbbdb2f81c3420c175a94aa72e59929c) sfutils.c (e91c04dfc8a52dee1965211bb1cc8e5bf775178f)
1#include <petsc/private/sfimpl.h> /*I "petscsf.h" I*/
2#include <petsc/private/sectionimpl.h>
3
4/*@
5 PetscSFSetGraphLayout - Set a parallel star forest via global indices and a `PetscLayout`
6
7 Collective
8

--- 215 unchanged lines hidden (view full) ---

224@*/
225PetscErrorCode PetscSFDistributeSection(PetscSF sf, PetscSection rootSection, PetscInt **remoteOffsets, PetscSection leafSection)
226{
227 PetscSF embedSF;
228 const PetscInt *indices;
229 IS selected;
230 PetscInt numFields, nroots, rpStart, rpEnd, lpStart = PETSC_INT_MAX, lpEnd = -1, f, c;
231 PetscBool *sub, hasc;
1#include <petsc/private/sfimpl.h> /*I "petscsf.h" I*/
2#include <petsc/private/sectionimpl.h>
3
4/*@
5 PetscSFSetGraphLayout - Set a parallel star forest via global indices and a `PetscLayout`
6
7 Collective
8

--- 215 unchanged lines hidden (view full) ---

224@*/
225PetscErrorCode PetscSFDistributeSection(PetscSF sf, PetscSection rootSection, PetscInt **remoteOffsets, PetscSection leafSection)
226{
227 PetscSF embedSF;
228 const PetscInt *indices;
229 IS selected;
230 PetscInt numFields, nroots, rpStart, rpEnd, lpStart = PETSC_INT_MAX, lpEnd = -1, f, c;
231 PetscBool *sub, hasc;
232 PetscMPIInt msize;
233
234 PetscFunctionBegin;
235 PetscCall(PetscLogEventBegin(PETSCSF_DistSect, sf, 0, 0, 0));
236 PetscCall(PetscSectionGetNumFields(rootSection, &numFields));
237 if (numFields) {
238 IS perm;
239
240 /* PetscSectionSetNumFields() calls PetscSectionReset(), which destroys

--- 28 unchanged lines hidden (view full) ---

269 }
270 }
271 PetscCall(PetscSectionGetChart(rootSection, &rpStart, &rpEnd));
272 PetscCall(PetscSFGetGraph(sf, &nroots, NULL, NULL, NULL));
273 rpEnd = PetscMin(rpEnd, nroots);
274 rpEnd = PetscMax(rpStart, rpEnd);
275 /* see if we can avoid creating the embedded SF, since it can cost more than an allreduce */
276 sub[0] = (PetscBool)(nroots != rpEnd - rpStart);
232
233 PetscFunctionBegin;
234 PetscCall(PetscLogEventBegin(PETSCSF_DistSect, sf, 0, 0, 0));
235 PetscCall(PetscSectionGetNumFields(rootSection, &numFields));
236 if (numFields) {
237 IS perm;
238
239 /* PetscSectionSetNumFields() calls PetscSectionReset(), which destroys

--- 28 unchanged lines hidden (view full) ---

268 }
269 }
270 PetscCall(PetscSectionGetChart(rootSection, &rpStart, &rpEnd));
271 PetscCall(PetscSFGetGraph(sf, &nroots, NULL, NULL, NULL));
272 rpEnd = PetscMin(rpEnd, nroots);
273 rpEnd = PetscMax(rpStart, rpEnd);
274 /* see if we can avoid creating the embedded SF, since it can cost more than an allreduce */
275 sub[0] = (PetscBool)(nroots != rpEnd - rpStart);
277 PetscCall(PetscMPIIntCast(2 + numFields, &msize));
278 PetscCallMPI(MPIU_Allreduce(MPI_IN_PLACE, sub, msize, MPIU_BOOL, MPI_LOR, PetscObjectComm((PetscObject)sf)));
276 PetscCallMPI(MPIU_Allreduce(MPI_IN_PLACE, sub, 2 + numFields, MPIU_BOOL, MPI_LOR, PetscObjectComm((PetscObject)sf)));
279 if (sub[0]) {
280 PetscCall(ISCreateStride(PETSC_COMM_SELF, rpEnd - rpStart, rpStart, 1, &selected));
281 PetscCall(ISGetIndices(selected, &indices));
282 PetscCall(PetscSFCreateEmbeddedRootSF(sf, rpEnd - rpStart, indices, &embedSF));
283 PetscCall(ISRestoreIndices(selected, &indices));
284 PetscCall(ISDestroy(&selected));
285 } else {
286 PetscCall(PetscObjectReference((PetscObject)sf));

--- 678 unchanged lines hidden ---
277 if (sub[0]) {
278 PetscCall(ISCreateStride(PETSC_COMM_SELF, rpEnd - rpStart, rpStart, 1, &selected));
279 PetscCall(ISGetIndices(selected, &indices));
280 PetscCall(PetscSFCreateEmbeddedRootSF(sf, rpEnd - rpStart, indices, &embedSF));
281 PetscCall(ISRestoreIndices(selected, &indices));
282 PetscCall(ISDestroy(&selected));
283 } else {
284 PetscCall(PetscObjectReference((PetscObject)sf));

--- 678 unchanged lines hidden ---