[petsc-users] counter->tag = *maxval - 128

Junchao Zhang junchao.zhang at gmail.com
Tue Jan 12 15:51:07 CST 2021


I think you can, if you always use PetscCommGetNewTag() to get a tag for
use with a PetscComm.

The -128 is to avoid wrong usages that someone provided their own tag from
the maximal.

--Junchao Zhang


On Tue, Jan 12, 2021 at 10:42 AM Fande Kong <fdkong.jd at gmail.com> wrote:

> Hi All,
>
> I am curious about why we subtract 128 from the max value of tag? Can we
> directly use the max tag value?
>
> Thanks,
>
> Fande,
>
>
> PetscErrorCode  PetscCommGetNewTag(MPI_Comm comm,PetscMPIInt *tag)
> {
>   PetscErrorCode   ierr;
>   PetscCommCounter *counter;
>    PetscMPIInt      *maxval,flg;
>
>
>   MPI_Comm_get_attr(comm,Petsc_Counter_keyval,&counter,&flg);
>   if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_CORRUPT,"Bad MPI
> communicator supplied; must be a PETSc communicator");
>
>  if (counter->tag < 1) {
>   PetscInfo1(NULL,"Out of tags for object, starting to recycle. Comm
> reference count %d\n",counter->refcount);
>   MPI_Comm_get_attr(MPI_COMM_WORLD,MPI_TAG_UB,&maxval,&flg);
>     if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"MPI error:
> MPI_Comm_get_attr() is not returning a MPI_TAG_UB");
>     counter->tag = *maxval - 128; /* hope that any still active tags were
> issued right at the beginning of the run */
>   }
>
>   *tag = counter->tag--;
>    if (PetscDefined(USE_DEBUG)) {
>      /*
>      Hanging here means that some processes have called
> PetscCommGetNewTag() and others have not.
>       */
>     MPI_Barrier(comm);
>   }
>   return(0);
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210112/62d85f59/attachment.html>


More information about the petsc-users mailing list