Lines Matching refs:sf
4 PETSC_INTERN PetscErrorCode PetscSFGetGraph_Allgatherv(PetscSF sf, PetscInt *nroots, PetscInt *nlea… in PetscSFGetGraph_Allgatherv() argument
11 PetscCallMPI(MPI_Comm_size(PetscObjectComm((PetscObject)sf), &size)); in PetscSFGetGraph_Allgatherv()
12 if (nroots) *nroots = sf->nroots; in PetscSFGetGraph_Allgatherv()
13 if (nleaves) *nleaves = sf->nleaves; in PetscSFGetGraph_Allgatherv()
16 …if (!sf->remote && sf->nleaves) { /* The && sf->nleaves makes sfgatherv able to inherit this routi… in PetscSFGetGraph_Allgatherv()
17 PetscCall(PetscLayoutGetRanges(sf->map, &range)); in PetscSFGetGraph_Allgatherv()
18 PetscCall(PetscMalloc1(sf->nleaves, &sf->remote)); in PetscSFGetGraph_Allgatherv()
19 sf->remote_alloc = sf->remote; in PetscSFGetGraph_Allgatherv()
22 sf->remote[j].rank = i; in PetscSFGetGraph_Allgatherv()
23 sf->remote[j].index = k; in PetscSFGetGraph_Allgatherv()
27 *iremote = sf->remote; in PetscSFGetGraph_Allgatherv()
32 PETSC_INTERN PetscErrorCode PetscSFSetUp_Allgatherv(PetscSF sf) in PetscSFSetUp_Allgatherv() argument
34 PetscSF_Allgatherv *dat = (PetscSF_Allgatherv *)sf->data; in PetscSFSetUp_Allgatherv()
41 PetscCall(PetscSFSetUp_Allgather(sf)); in PetscSFSetUp_Allgatherv()
42 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFSetUp_Allgatherv()
44 if (sf->nleaves) { /* This if (sf->nleaves) test makes sfgatherv able to inherit this routine */ in PetscSFSetUp_Allgatherv()
49 PetscCall(PetscLayoutGetRanges(sf->map, &range)); in PetscSFSetUp_Allgatherv()
57 PetscCall(PetscObjectTypeCompare((PetscObject)sf, PETSCSFALLGATHERV, &isallgatherv)); in PetscSFSetUp_Allgatherv()
61 nRanksWithZeroRoots = (sf->nroots == 0) ? 1 : 0; /* I have no roots */ in PetscSFSetUp_Allgatherv()
66 dat->bcast_root = sf->nroots > 0 ? rank : -1; in PetscSFSetUp_Allgatherv()
74 PETSC_INTERN PetscErrorCode PetscSFReset_Allgatherv(PetscSF sf) in PetscSFReset_Allgatherv() argument
76 PetscSF_Allgatherv *dat = (PetscSF_Allgatherv *)sf->data; in PetscSFReset_Allgatherv()
85 …PetscCheck(!dat->inuse, PetscObjectComm((PetscObject)sf), PETSC_ERR_ARG_WRONGSTATE, "Outstanding o… in PetscSFReset_Allgatherv()
88 PetscCall(PetscSFLinkDestroy(sf, link)); in PetscSFReset_Allgatherv()
94 PETSC_INTERN PetscErrorCode PetscSFDestroy_Allgatherv(PetscSF sf) in PetscSFDestroy_Allgatherv() argument
97 PetscCall(PetscSFReset_Allgatherv(sf)); in PetscSFDestroy_Allgatherv()
98 PetscCall(PetscFree(sf->data)); in PetscSFDestroy_Allgatherv()
102 static PetscErrorCode PetscSFBcastBegin_Allgatherv(PetscSF sf, MPI_Datatype unit, PetscMemType root… in PetscSFBcastBegin_Allgatherv() argument
109 PetscSF_Allgatherv *dat = (PetscSF_Allgatherv *)sf->data; in PetscSFBcastBegin_Allgatherv()
112 …PetscCall(PetscSFLinkCreate(sf, unit, rootmtype, rootdata, leafmtype, leafdata, op, PETSCSF_BCAST,… in PetscSFBcastBegin_Allgatherv()
113 PetscCall(PetscSFLinkPackRootData(sf, link, PETSCSF_REMOTE, rootdata)); in PetscSFBcastBegin_Allgatherv()
114 …PetscCall(PetscSFLinkCopyRootBufferInCaseNotUseGpuAwareMPI(sf, link, PETSC_TRUE /* device2host bef… in PetscSFBcastBegin_Allgatherv()
115 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFBcastBegin_Allgatherv()
117 PetscCall(PetscMPIIntCast(sf->nroots, &sendcount)); in PetscSFBcastBegin_Allgatherv()
118 …PetscCall(PetscSFLinkGetMPIBuffersAndRequests(sf, link, PETSCSF_ROOT2LEAF, &rootbuf, &leafbuf, &re… in PetscSFBcastBegin_Allgatherv()
122 PetscCall(PetscSFLinkSyncStreamBeforeCallMPI(sf, link)); in PetscSFBcastBegin_Allgatherv()
123 PetscCall(PetscMPIIntCast(sf->nleaves, &nleaves)); in PetscSFBcastBegin_Allgatherv()
129 static PetscErrorCode PetscSFReduceBegin_Allgatherv(PetscSF sf, MPI_Datatype unit, PetscMemType lea… in PetscSFReduceBegin_Allgatherv() argument
132 PetscSF_Allgatherv *dat = (PetscSF_Allgatherv *)sf->data; in PetscSFReduceBegin_Allgatherv()
140 …PetscCall(PetscSFLinkCreate(sf, unit, rootmtype, rootdata, leafmtype, leafdata, op, PETSCSF_REDUCE… in PetscSFReduceBegin_Allgatherv()
143 PetscCall(PetscLayoutGetRange(sf->map, &rstart, NULL)); in PetscSFReduceBegin_Allgatherv()
144 …fmtype, (const char *)leafdata + (size_t)rstart * link->unitbytes, (size_t)sf->nroots * link->unit… in PetscSFReduceBegin_Allgatherv()
147 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFReduceBegin_Allgatherv()
148 PetscCall(PetscSFLinkPackLeafData(sf, link, PETSCSF_REMOTE, leafdata)); in PetscSFReduceBegin_Allgatherv()
149 …PetscCall(PetscSFLinkCopyLeafBufferInCaseNotUseGpuAwareMPI(sf, link, PETSC_TRUE /* device2host bef… in PetscSFReduceBegin_Allgatherv()
150 …PetscCall(PetscSFLinkGetMPIBuffersAndRequests(sf, link, PETSCSF_LEAF2ROOT, &rootbuf, &leafbuf, &re… in PetscSFReduceBegin_Allgatherv()
151 PetscCall(PetscSFLinkSyncStreamBeforeCallMPI(sf, link)); in PetscSFReduceBegin_Allgatherv()
153 PetscInt nleaves = sf->nleaves; in PetscSFReduceBegin_Allgatherv()
184 …[PETSCSF_REMOTE][link->leafmtype_mpi]) PetscCall(PetscSFMalloc(sf, link->leafmtype_mpi, sf->leafbu… in PetscSFReduceBegin_Allgatherv()
187 PetscCall(PetscMPIIntCast(sf->nleaves * link->bs, &count)); in PetscSFReduceBegin_Allgatherv()
195 PETSC_INTERN PetscErrorCode PetscSFReduceEnd_Allgatherv(PetscSF sf, MPI_Datatype unit, const void *… in PetscSFReduceEnd_Allgatherv() argument
207 PetscCall(PetscSFLinkGetInUse(sf, unit, rootdata, leafdata, PETSC_OWN_POINTER, &link)); in PetscSFReduceEnd_Allgatherv()
208 PetscCall(PetscSFLinkReclaim(sf, &link)); in PetscSFReduceEnd_Allgatherv()
210 PetscCall(PetscSFReduceEnd_Basic(sf, unit, leafdata, rootdata, op)); in PetscSFReduceEnd_Allgatherv()
215 static PetscErrorCode PetscSFBcastToZero_Allgatherv(PetscSF sf, MPI_Datatype unit, PetscMemType roo… in PetscSFBcastToZero_Allgatherv() argument
221 PetscSF_Allgatherv *dat = (PetscSF_Allgatherv *)sf->data; in PetscSFBcastToZero_Allgatherv()
226 …PetscCall(PetscSFLinkCreate(sf, unit, rootmtype, rootdata, leafmtype, leafdata, MPI_REPLACE, PETSC… in PetscSFBcastToZero_Allgatherv()
227 PetscCall(PetscSFLinkPackRootData(sf, link, PETSCSF_REMOTE, rootdata)); in PetscSFBcastToZero_Allgatherv()
228 …PetscCall(PetscSFLinkCopyRootBufferInCaseNotUseGpuAwareMPI(sf, link, PETSC_TRUE /* device2host bef… in PetscSFBcastToZero_Allgatherv()
229 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFBcastToZero_Allgatherv()
230 PetscCall(PetscMPIIntCast(sf->nroots, &sendcount)); in PetscSFBcastToZero_Allgatherv()
231 …PetscCall(PetscSFLinkGetMPIBuffersAndRequests(sf, link, PETSCSF_ROOT2LEAF, &rootbuf, &leafbuf, &re… in PetscSFBcastToZero_Allgatherv()
232 PetscCall(PetscSFLinkSyncStreamBeforeCallMPI(sf, link)); in PetscSFBcastToZero_Allgatherv()
235 PetscCall(PetscSFLinkGetInUse(sf, unit, rootdata, leafdata, PETSC_OWN_POINTER, &link)); in PetscSFBcastToZero_Allgatherv()
236 PetscCall(PetscSFLinkFinishCommunication(sf, link, PETSCSF_ROOT2LEAF)); in PetscSFBcastToZero_Allgatherv()
237 PetscCallMPI(MPI_Comm_rank(PetscObjectComm((PetscObject)sf), &rank)); in PetscSFBcastToZero_Allgatherv()
238 …&& !sf->use_gpu_aware_mpi) PetscCall((*link->Memcpy)(link, PETSC_MEMTYPE_DEVICE, leafdata, PETSC_M… in PetscSFBcastToZero_Allgatherv()
239 PetscCall(PetscSFLinkReclaim(sf, &link)); in PetscSFBcastToZero_Allgatherv()
281 PETSC_INTERN PetscErrorCode PetscSFFetchAndOpBegin_Allgatherv(PetscSF sf, MPI_Datatype unit, PetscM… in PetscSFFetchAndOpBegin_Allgatherv() argument
288 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFFetchAndOpBegin_Allgatherv()
291 …PetscCall(PetscSFLinkCreate(sf, unit, rootmtype, rootdata, leafmtype, leafdata, op, PETSCSF_FETCH,… in PetscSFFetchAndOpBegin_Allgatherv()
292 PetscCall(PetscSFLinkPackLeafData(sf, link, PETSCSF_REMOTE, leafdata)); /* Sync the device */ in PetscSFFetchAndOpBegin_Allgatherv()
293 …PetscCall((*link->Memcpy)(link, leafmtype, leafupdate, leafmtype, leafdata, sf->nleaves * link->un… in PetscSFFetchAndOpBegin_Allgatherv()
294 PetscCall(PetscSFLinkGetInUse(sf, unit, rootdata, leafdata, PETSC_OWN_POINTER, &link)); in PetscSFFetchAndOpBegin_Allgatherv()
303 PetscCall(PetscMPIIntCast(sf->nleaves, &count)); in PetscSFFetchAndOpBegin_Allgatherv()
306 PetscCall(PetscMPIIntCast(sf->nleaves * link->bs, &count)); in PetscSFFetchAndOpBegin_Allgatherv()
309 PetscCall(PetscSFLinkReclaim(sf, &link)); in PetscSFFetchAndOpBegin_Allgatherv()
310 PetscCall(PetscSFBcastBegin(sf, unit, rootdata, leafupdate, op)); in PetscSFFetchAndOpBegin_Allgatherv()
311 PetscCall(PetscSFBcastEnd(sf, unit, rootdata, leafupdate, op)); in PetscSFFetchAndOpBegin_Allgatherv()
314 …PetscCall(PetscSFBcastToZero_Private(sf, unit, rootdata, leafupdate)); /* Using this line makes Al… in PetscSFFetchAndOpBegin_Allgatherv()
317 PetscCall(PetscSFReduceBegin(sf, unit, leafdata, rootdata, op)); in PetscSFFetchAndOpBegin_Allgatherv()
321 PETSC_INTERN PetscErrorCode PetscSFFetchAndOpEnd_Allgatherv(PetscSF sf, MPI_Datatype unit, void *ro… in PetscSFFetchAndOpEnd_Allgatherv() argument
324 PetscCall(PetscSFReduceEnd(sf, unit, leafdata, rootdata, op)); in PetscSFFetchAndOpEnd_Allgatherv()
329 PETSC_INTERN PetscErrorCode PetscSFGetRootRanks_Allgatherv(PetscSF sf, PetscMPIInt *nranks, const P… in PetscSFGetRootRanks_Allgatherv() argument
336 …if (sf->nranks && !sf->ranks) { /* On rank!=0, sf->nranks=0. The sf->nranks test makes this routin… in PetscSFGetRootRanks_Allgatherv()
337 size = sf->nranks; in PetscSFGetRootRanks_Allgatherv()
338 PetscCall(PetscLayoutGetRanges(sf->map, &range)); in PetscSFGetRootRanks_Allgatherv()
339 …PetscCall(PetscMalloc4(size, &sf->ranks, size + 1, &sf->roffset, sf->nleaves, &sf->rmine, sf->nlea… in PetscSFGetRootRanks_Allgatherv()
340 for (PetscMPIInt i = 0; i < size; i++) sf->ranks[i] = i; in PetscSFGetRootRanks_Allgatherv()
341 PetscCall(PetscArraycpy(sf->roffset, range, size + 1)); in PetscSFGetRootRanks_Allgatherv()
342 …for (PetscInt i = 0; i < sf->nleaves; i++) sf->rmine[i] = i; /*rmine are never NULL even for conti… in PetscSFGetRootRanks_Allgatherv()
344 for (j = range[i], k = 0; j < range[i + 1]; j++, k++) sf->rremote[j] = k; in PetscSFGetRootRanks_Allgatherv()
348 if (nranks) *nranks = sf->nranks; in PetscSFGetRootRanks_Allgatherv()
349 if (ranks) *ranks = sf->ranks; in PetscSFGetRootRanks_Allgatherv()
350 if (roffset) *roffset = sf->roffset; in PetscSFGetRootRanks_Allgatherv()
351 if (rmine) *rmine = sf->rmine; in PetscSFGetRootRanks_Allgatherv()
352 if (rremote) *rremote = sf->rremote; in PetscSFGetRootRanks_Allgatherv()
357 PETSC_INTERN PetscErrorCode PetscSFGetLeafRanks_Allgatherv(PetscSF sf, PetscMPIInt *niranks, const … in PetscSFGetLeafRanks_Allgatherv() argument
359 PetscSF_Allgatherv *dat = (PetscSF_Allgatherv *)sf->data; in PetscSFGetLeafRanks_Allgatherv()
365 PetscCall(PetscObjectGetComm((PetscObject)sf, &comm)); in PetscSFGetLeafRanks_Allgatherv()
388 for (PetscMPIInt i = 0; i <= size; i++) dat->ioffset[i] = i * sf->nroots; in PetscSFGetLeafRanks_Allgatherv()
395 PetscCall(PetscMalloc1(sf->nleaves, &dat->irootloc)); in PetscSFGetLeafRanks_Allgatherv()
397 for (PetscInt j = 0; j < sf->nroots; j++) dat->irootloc[i * sf->nroots + j] = j; in PetscSFGetLeafRanks_Allgatherv()
405 PETSC_INTERN PetscErrorCode PetscSFCreateLocalSF_Allgatherv(PetscSF sf, PetscSF *out) in PetscSFCreateLocalSF_Allgatherv() argument
412 nleaves = sf->nleaves ? sf->nroots : 0; /* sf->nleaves can be zero with SFGather(v) */ in PetscSFCreateLocalSF_Allgatherv()
416 PetscCall(PetscLayoutGetRange(sf->map, &rstart, NULL)); in PetscSFCreateLocalSF_Allgatherv()
431 PETSC_INTERN PetscErrorCode PetscSFCreate_Allgatherv(PetscSF sf) in PetscSFCreate_Allgatherv() argument
433 PetscSF_Allgatherv *dat = (PetscSF_Allgatherv *)sf->data; in PetscSFCreate_Allgatherv()
436 sf->ops->BcastEnd = PetscSFBcastEnd_Basic; in PetscSFCreate_Allgatherv()
437 sf->ops->ReduceEnd = PetscSFReduceEnd_Allgatherv; in PetscSFCreate_Allgatherv()
439 sf->ops->SetUp = PetscSFSetUp_Allgatherv; in PetscSFCreate_Allgatherv()
440 sf->ops->Reset = PetscSFReset_Allgatherv; in PetscSFCreate_Allgatherv()
441 sf->ops->Destroy = PetscSFDestroy_Allgatherv; in PetscSFCreate_Allgatherv()
442 sf->ops->GetRootRanks = PetscSFGetRootRanks_Allgatherv; in PetscSFCreate_Allgatherv()
443 sf->ops->GetLeafRanks = PetscSFGetLeafRanks_Allgatherv; in PetscSFCreate_Allgatherv()
444 sf->ops->GetGraph = PetscSFGetGraph_Allgatherv; in PetscSFCreate_Allgatherv()
445 sf->ops->BcastBegin = PetscSFBcastBegin_Allgatherv; in PetscSFCreate_Allgatherv()
446 sf->ops->ReduceBegin = PetscSFReduceBegin_Allgatherv; in PetscSFCreate_Allgatherv()
447 sf->ops->FetchAndOpBegin = PetscSFFetchAndOpBegin_Allgatherv; in PetscSFCreate_Allgatherv()
448 sf->ops->FetchAndOpEnd = PetscSFFetchAndOpEnd_Allgatherv; in PetscSFCreate_Allgatherv()
449 sf->ops->CreateLocalSF = PetscSFCreateLocalSF_Allgatherv; in PetscSFCreate_Allgatherv()
450 sf->ops->BcastToZero = PetscSFBcastToZero_Allgatherv; in PetscSFCreate_Allgatherv()
452 sf->collective = PETSC_TRUE; in PetscSFCreate_Allgatherv()
456 sf->data = (void *)dat; in PetscSFCreate_Allgatherv()