<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">   Fande,</div><div class=""><br class=""></div>   /* hope that any still active tags were issued right at the beginning of the run */<div class=""><br class=""></div><div class="">   PETSc actually starts with *maxval (see line 130). It is only when it runs out that it does this silly thing for the reason indicated in the comment. </div><div class=""><br class=""></div><div class="">   PETSc should actually keep track which of which tags have been "returned" and if the counter gets to zero use those returned tags instead of starting again at the top which could clash with the same value used for another reason. In other words the current code is buggy,  but it has always been "good enough".</div><div class=""><br class=""></div><div class="">  Barry</div><div class=""><br class=""></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 12, 2021, at 10:41 AM, Fande Kong <<a href="mailto:fdkong.jd@gmail.com" class="">fdkong.jd@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class="">Hi All,<br class=""><div class=""><br class=""></div><div class="">I am curious about why we subtract 128 from the max value of tag? Can we directly use the max tag value?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Fande,</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">PetscErrorCode  PetscCommGetNewTag(MPI_Comm comm,PetscMPIInt *tag)</div><div class="">{</div><div class="">  PetscErrorCode   ierr;</div><div class="">  PetscCommCounter *counter;</div><div class="">   PetscMPIInt      *maxval,flg;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">  MPI_Comm_get_attr(comm,Petsc_Counter_keyval,&counter,&flg);</div><div class="">  if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_CORRUPT,"Bad MPI communicator supplied; must be a PETSc communicator");</div><div class=""><br class=""></div><div class=""> if (counter->tag < 1) {</div><div class="">  PetscInfo1(NULL,"Out of tags for object, starting to recycle. Comm reference count %d\n",counter->refcount);</div><div class="">  MPI_Comm_get_attr(MPI_COMM_WORLD,MPI_TAG_UB,&maxval,&flg);</div><div class="">    if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"MPI error: MPI_Comm_get_attr() is not returning a MPI_TAG_UB");</div><div class="">   <font color="#ff0000" class=""> counter->tag = *maxval - 128;</font> /* hope that any still active tags were issued right at the beginning of the run */</div><div class="">  }</div><div class=""><br class=""></div><div class="">  *tag = counter->tag--;</div><div class="">   if (PetscDefined(USE_DEBUG)) {</div><div class="">     /*</div><div class="">     Hanging here means that some processes have called PetscCommGetNewTag() and others have not.</div><div class="">      */</div><div class="">    MPI_Barrier(comm);</div><div class="">  }</div><div class="">  return(0);</div><div class="">}</div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>