<div dir="ltr">I think you can, if you always use PetscCommGetNewTag() to get a tag for use with a PetscComm.<div><br></div><div>The -128 is to avoid wrong usages that someone provided their own tag from the maximal. <br><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">--Junchao Zhang</div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 12, 2021 at 10:42 AM Fande Kong <<a href="mailto:fdkong.jd@gmail.com">fdkong.jd@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi All,<br><div><br></div><div>I am curious about why we subtract 128 from the max value of tag? Can we directly use the max tag value?</div><div><br></div><div>Thanks,</div><div><br></div><div>Fande,</div><div><br></div><div><br></div><div><div>PetscErrorCode PetscCommGetNewTag(MPI_Comm comm,PetscMPIInt *tag)</div><div>{</div><div> PetscErrorCode ierr;</div><div> PetscCommCounter *counter;</div><div> PetscMPIInt *maxval,flg;</div><div><br></div><div><br></div><div> MPI_Comm_get_attr(comm,Petsc_Counter_keyval,&counter,&flg);</div><div> if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_CORRUPT,"Bad MPI communicator supplied; must be a PETSc communicator");</div><div><br></div><div> if (counter->tag < 1) {</div><div> PetscInfo1(NULL,"Out of tags for object, starting to recycle. Comm reference count %d\n",counter->refcount);</div><div> MPI_Comm_get_attr(MPI_COMM_WORLD,MPI_TAG_UB,&maxval,&flg);</div><div> if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"MPI error: MPI_Comm_get_attr() is not returning a MPI_TAG_UB");</div><div> <font color="#ff0000"> counter->tag = *maxval - 128;</font> /* hope that any still active tags were issued right at the beginning of the run */</div><div> }</div><div><br></div><div> *tag = counter->tag--;</div><div> if (PetscDefined(USE_DEBUG)) {</div><div> /*</div><div> Hanging here means that some processes have called PetscCommGetNewTag() and others have not.</div><div> */</div><div> MPI_Barrier(comm);</div><div> }</div><div> return(0);</div><div>}</div></div></div></div>
</blockquote></div>