[MOAB-dev] Question about reduce_tags behavior

Lorenzo Alessio Botti ihabiamx at yahoo.it
Wed May 9 08:28:58 CDT 2012


Dear all, dear Tim,
I've seen that you updated the ParallelComm implementation and I've done a few more tests... 

It seems that the code I sent is failing because the GLOBAL_ID tag has been created by MOAB without a default value and I'm not able to set it
without removing the tag.
I added the following lines before calling tag_get_handle (GLOBAL_ID,...)

  std::vector<Tag> tags;
  instance.tag_get_tags(tags);
  for (unsigned int i = 0; i < tags.size(); i++)
  {
    std::string name;
    instance.tag_get_name(tags[i], name);
    if (name == "GLOBAL_ID")
    {
      std::vector<unsigned char> vals(sizeof(int));
      result = instance.tag_get_default_value(tags[i], &vals[0]);
      if (result != MB_SUCCESS)
      {
        std::cout<<"faile to get globalid tag def value, deleting tag... "<<std::endl;
        instance.tag_delete(tags[i]);
      }
    }
  }

and know it works as follows...

pcomm->reduce_tags(gid_tag_vec, gid_tag_vec, MPI_SUM, sharedFaces);
provides in gid_tag_vec the sum of the tag values on shared faces, so it sums the value of the tag on the owned and on the not_owned entity. This is what I need in my code.

pcomm->reduce_tags(gid_tag_vec, gid_sum_tag_vec, MPI_OP_NULL, sharedFaces);
provides in gid_sum_tag_vec the values of gid_tag_vec on the owned ents, so this call replicates the behavior of exchange_tags.

As you pointed out there is an issue when you want the result in a different tag, in particular
pcomm->reduce_tags(gid_tag_vec, gid_sum_tag_vec, MPI_SUM, sharedFaces);
returns an error in ParallelComm::unpack_tags() if the tags have different default values.

Moreover I don't understand if the behavior of 
pcomm->reduce_tags(gid_tag_vec, gid_sum_tag_vec, MPI_SUM, sharedFaces);
is correct.
This call provides in gid_sum_tag_vec the sum of the gid_tag on the owned entity and the gid_sum_tag on the not_owned entity.
If gid_sum_tag has values on the owned entity these are ignored. 

Thanks for help.
Lorenzo


> 
> On May 4, 2012, at 5:46 PM, Tautges wrote:
> 
>> If I read your message right, it's a bug with when you want the result in a different tag?  Will fix this soon, should be easy. 
>> 
>> On your msg about mbzoltan, the fix is much appreciated, we'll definitely get that in the code base. Dont know yet about the option string, haven't looked at code yet. 
>> 
>> - tim 
>> 
>> (Sent from an Androd that dosnt autocorect as wel as an ipone) 
>> 
>> 
>> 
>> -------- Original message --------
>> Subject: Re: question about reduce_tags behavior 
>> From: Lorenzo Alessio Botti <ihabiamx at yahoo.it> 
>> To: Tim Tautges <tautges at mcs.anl.gov>,MOAB-dev at mcs.anl.gov 
>> CC: 
>> 
>> 
>> Hi Tim,
>> I've found the bug in my code...
>> To get the sum of a tag on shared entities I need to call
>> 
>> pcomm->reduce_tags(gid_tag_vec, gid_tag_vec, MPI_SUM, sharedFaces);
>> and not
>> pcomm->reduce_tags(gid_tag_vec, gid_sum_tag_vec, MPI_SUM, sharedFaces);
>> 
>> Here is the new version, now it works...
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20120509/a4ae2037/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: partcheck.cpp
Type: application/octet-stream
Size: 5738 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20120509/a4ae2037/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20120509/a4ae2037/attachment-0001.htm>


More information about the moab-dev mailing list