Lines Matching refs:link

8 …PetscSFDataLink         link;   /* List of MPI data types, lazily constructed for each data type */  member
73 PetscSFDataLink link; in PetscSFWindowGetDataTypes() local
79 for (link = w->link; link; link = link->next) { in PetscSFWindowGetDataTypes()
82 PetscCall(MPIPetsc_Type_compare(unit, link->unit, &match)); in PetscSFWindowGetDataTypes()
84 *localtypes = link->mine; in PetscSFWindowGetDataTypes()
85 *remotetypes = link->remote; in PetscSFWindowGetDataTypes()
92 PetscCall(PetscNew(&link)); in PetscSFWindowGetDataTypes()
93 PetscCallMPI(MPI_Type_dup(unit, &link->unit)); in PetscSFWindowGetDataTypes()
94 PetscCall(PetscMalloc2(nranks, &link->mine, nranks, &link->remote)); in PetscSFWindowGetDataTypes()
111 PetscCallMPI(MPI_Type_create_indexed_block(rcount, 1, rmine, link->unit, &link->mine[i])); in PetscSFWindowGetDataTypes()
112 PetscCallMPI(MPI_Type_create_indexed_block(rcount, 1, rremote, link->unit, &link->remote[i])); in PetscSFWindowGetDataTypes()
116 PetscCallMPI(MPI_Type_commit(&link->mine[i])); in PetscSFWindowGetDataTypes()
117 PetscCallMPI(MPI_Type_commit(&link->remote[i])); in PetscSFWindowGetDataTypes()
119 link->next = w->link; in PetscSFWindowGetDataTypes()
120 w->link = link; in PetscSFWindowGetDataTypes()
122 *localtypes = link->mine; in PetscSFWindowGetDataTypes()
123 *remotetypes = link->remote; in PetscSFWindowGetDataTypes()
374 static PetscErrorCode PetscSFWindowAttach(PetscSF sf, PetscSFWinLink link, void *rootdata, size_t w… in PetscSFWindowAttach() argument
386 if (addr != NULL) PetscCallMPI(MPI_Win_attach(link->win, addr, wsize)); in PetscSFWindowAttach()
387 link->addr = addr; in PetscSFWindowAttach()
391 if (!link->dyn_target_addr) PetscCall(PetscMalloc1(nranks, &link->dyn_target_addr)); in PetscSFWindowAttach()
392 PetscCall(PetscSFBcastBegin(w->dynsf, MPI_AINT, &winaddr, link->dyn_target_addr, MPI_REPLACE)); in PetscSFWindowAttach()
393 PetscCall(PetscSFBcastEnd(w->dynsf, MPI_AINT, &winaddr, link->dyn_target_addr, MPI_REPLACE)); in PetscSFWindowAttach()
431 PetscSFWinLink link; in PetscSFGetWindow() local
451 for (link = w->wins; reuse && link; link = link->next) { in PetscSFGetWindow()
454 if (!link->persistent) continue; in PetscSFGetWindow()
455 …match = (link->flavor == w->flavor && link->rootdata == rootdata && link->leafdata == leafdata) ? … in PetscSFGetWindow()
470 …PetscCheck(!link->inuse, wcomm, PETSC_ERR_ARG_WRONGSTATE, "Communication already in progress on pe… in PetscSFGetWindow()
471 …PetscCheck(!epoch || !link->epoch, wcomm, PETSC_ERR_ARG_WRONGSTATE, "Communication epoch already o… in PetscSFGetWindow()
472 …PetscCheck(bytes == link->bytes, wcomm, PETSC_ERR_ARG_WRONGSTATE, "Wrong data type for persistent … in PetscSFGetWindow()
473 *win = link->win; in PetscSFGetWindow()
478 for (link = w->wins; reuse && link; link = link->next) { in PetscSFGetWindow()
479 if (w->flavor != link->flavor) continue; in PetscSFGetWindow()
483 if (!link->inuse && (!epoch || !link->epoch) && bytes == (MPI_Aint)link->bytes) { in PetscSFGetWindow()
485 PetscCall(PetscSFWindowAttach(sf, link, rootdata, wsize)); in PetscSFGetWindow()
489 link->rootdata = rootdata; in PetscSFGetWindow()
490 link->leafdata = leafdata; in PetscSFGetWindow()
491 … " of flavor %d for comm %" PETSC_INTPTR_T_FMT "\n", (PETSC_INTPTR_T)link->win, link->flavor, (PET… in PetscSFGetWindow()
492 *win = link->win; in PetscSFGetWindow()
497 PetscCall(PetscNew(&link)); in PetscSFGetWindow()
498 link->bytes = bytes; in PetscSFGetWindow()
499 link->next = w->wins; in PetscSFGetWindow()
500 link->flavor = w->flavor; in PetscSFGetWindow()
501 link->dyn_target_addr = NULL; in PetscSFGetWindow()
502 link->reqs = NULL; in PetscSFGetWindow()
503 w->wins = link; in PetscSFGetWindow()
504 link->rootdata = rootdata; in PetscSFGetWindow()
505 link->leafdata = leafdata; in PetscSFGetWindow()
507 PetscCall(PetscMalloc1(sf->nranks, &link->reqs)); in PetscSFGetWindow()
508 for (PetscMPIInt i = 0; i < sf->nranks; i++) link->reqs[i] = MPI_REQUEST_NULL; in PetscSFGetWindow()
512 PetscCallMPI(MPI_Win_create(rootdata, wsize, (PetscMPIInt)bytes, w->info, wcomm, &link->win)); in PetscSFGetWindow()
513 link->addr = rootdata; in PetscSFGetWindow()
517 PetscCallMPI(MPI_Win_create_dynamic(w->info, wcomm, &link->win)); in PetscSFGetWindow()
518 PetscCall(PetscSFWindowAttach(sf, link, rootdata, wsize)); in PetscSFGetWindow()
521 …PetscCallMPI(MPI_Win_allocate(wsize, (PetscMPIInt)bytes, w->info, wcomm, &link->addr, &link->win)); in PetscSFGetWindow()
527 …llMPI(MPI_Win_allocate_shared(wsize, (PetscMPIInt)bytes, w->info, wcomm, &link->addr, &link->win)); in PetscSFGetWindow()
534 … " of flavor %d for comm %" PETSC_INTPTR_T_FMT "\n", (PETSC_INTPTR_T)link->win, link->flavor, (PET… in PetscSFGetWindow()
535 *win = link->win; in PetscSFGetWindow()
539 if (target_disp) *target_disp = link->dyn_target_addr; in PetscSFGetWindow()
540 if (reqs) *reqs = link->reqs; in PetscSFGetWindow()
546 PetscCall(PetscMemcpy(link->addr, rootdata, sf->nroots * bytes)); in PetscSFGetWindow()
552 link->inuse = PETSC_TRUE; in PetscSFGetWindow()
553 link->epoch = epoch; in PetscSFGetWindow()
608 PetscSFWinLink link; in PetscSFFindWindow() local
621 for (link = w->wins; link; link = link->next) { in PetscSFFindWindow()
622 if (rootdata == link->rootdata && leafdata == link->leafdata && bytes == link->bytes) { in PetscSFFindWindow()
623 … " of flavor %d for comm %" PETSC_INTPTR_T_FMT "\n", (PETSC_INTPTR_T)link->win, link->flavor, (PET… in PetscSFFindWindow()
624 *win = link->win; in PetscSFFindWindow()
625 *reqs = link->reqs; in PetscSFFindWindow()
653 PetscSFWinLink *p, link; in PetscSFRestoreWindow() local
664 link = *p; in PetscSFRestoreWindow()
665 if (*win == link->win) { in PetscSFRestoreWindow()
666 …PetscCheck(array == link->rootdata, PETSC_COMM_SELF, PETSC_ERR_ARG_INCOMP, "Matched window, but no… in PetscSFRestoreWindow()
667 if (epoch != link->epoch) { in PetscSFRestoreWindow()
671 laddr = link->addr; in PetscSFRestoreWindow()
672 flavor = link->flavor; in PetscSFRestoreWindow()
673 bytes = link->bytes; in PetscSFRestoreWindow()
676 *p = link->next; in PetscSFRestoreWindow()
685 … " of flavor %d for comm %" PETSC_INTPTR_T_FMT "\n", (PETSC_INTPTR_T)link->win, link->flavor, (PET… in PetscSFRestoreWindow()
715 if (link->flavor == PETSCSF_WINDOW_FLAVOR_DYNAMIC && !link->persistent) { in PetscSFRestoreWindow()
716 if (link->addr != NULL) PetscCallMPI(MPI_Win_detach(link->win, link->addr)); in PetscSFRestoreWindow()
717 link->addr = NULL; in PetscSFRestoreWindow()
724 link->epoch = PETSC_FALSE; in PetscSFRestoreWindow()
725 link->inuse = PETSC_FALSE; in PetscSFRestoreWindow()
726 if (!link->persistent) { in PetscSFRestoreWindow()
727 link->rootdata = NULL; in PetscSFRestoreWindow()
728 link->leafdata = NULL; in PetscSFRestoreWindow()
731 PetscCall(PetscFree(link->dyn_target_addr)); in PetscSFRestoreWindow()
732 PetscCall(PetscFree(link->reqs)); in PetscSFRestoreWindow()
733 PetscCallMPI(MPI_Win_free(&link->win)); in PetscSFRestoreWindow()
734 PetscCall(PetscFree(link)); in PetscSFRestoreWindow()
823 PetscSFDataLink link, next; in PetscSFReset_Window() local
830 for (link = w->link; link; link = next) { in PetscSFReset_Window()
831 next = link->next; in PetscSFReset_Window()
832 PetscCallMPI(MPI_Type_free(&link->unit)); in PetscSFReset_Window()
834 PetscCallMPI(MPI_Type_free(&link->mine[i])); in PetscSFReset_Window()
835 PetscCallMPI(MPI_Type_free(&link->remote[i])); in PetscSFReset_Window()
837 PetscCall(PetscFree2(link->mine, link->remote)); in PetscSFReset_Window()
838 PetscCall(PetscFree(link)); in PetscSFReset_Window()
840 w->link = NULL; in PetscSFReset_Window()
866 PetscSFWinLink link; in PetscSFRegisterPersistent_Window() local
875 PetscCall(PetscNew(&link)); in PetscSFRegisterPersistent_Window()
876 link->flavor = w->flavor; in PetscSFRegisterPersistent_Window()
877 link->next = w->wins; in PetscSFRegisterPersistent_Window()
881 PetscCallMPI(MPI_Win_create_dynamic(w->info, wcomm, &link->win)); in PetscSFRegisterPersistent_Window()
884 PetscCall(PetscSFWindowAttach(sf, link, (void *)rootdata, wsize)); in PetscSFRegisterPersistent_Window()
885 link->rootdata = (void *)rootdata; in PetscSFRegisterPersistent_Window()
886 link->leafdata = (void *)leafdata; in PetscSFRegisterPersistent_Window()
887 link->bytes = bytes; in PetscSFRegisterPersistent_Window()
888 link->epoch = PETSC_FALSE; in PetscSFRegisterPersistent_Window()
889 link->inuse = PETSC_FALSE; in PetscSFRegisterPersistent_Window()
890 link->persistent = PETSC_TRUE; in PetscSFRegisterPersistent_Window()
891 w->wins = link; in PetscSFRegisterPersistent_Window()
895 PetscCall(PetscMalloc1(sf->nranks, &link->reqs)); in PetscSFRegisterPersistent_Window()
896 for (i = 0; i < sf->nranks; i++) link->reqs[i] = MPI_REQUEST_NULL; in PetscSFRegisterPersistent_Window()
917 PetscSFWinLink link = *p; in PetscSFDeregisterPersistent_Window() local
918 …if (link->flavor == w->flavor && link->persistent && link->rootdata == rootdata && link->leafdata … in PetscSFDeregisterPersistent_Window()
919 …PetscCheck(!link->inuse, wcomm, PETSC_ERR_ARG_WRONGSTATE, "Deregistering a window when communicati… in PetscSFDeregisterPersistent_Window()
920 …PetscCheck(!link->epoch, wcomm, PETSC_ERR_ARG_WRONGSTATE, "Deregistering a window with an unconclu… in PetscSFDeregisterPersistent_Window()
922 PetscCallMPI(MPI_Win_detach(link->win, link->addr)); in PetscSFDeregisterPersistent_Window()
923 link->addr = NULL; in PetscSFDeregisterPersistent_Window()
925 PetscCall(PetscFree(link->dyn_target_addr)); in PetscSFDeregisterPersistent_Window()
926 PetscCall(PetscFree(link->reqs)); in PetscSFDeregisterPersistent_Window()
927 PetscCallMPI(MPI_Win_free(&link->win)); in PetscSFDeregisterPersistent_Window()
928 *p = link->next; in PetscSFDeregisterPersistent_Window()
929 PetscCall(PetscFree(link)); in PetscSFDeregisterPersistent_Window()