[MOAB-dev] thread safety

Tim Tautges timothy.tautges at cd-adapco.com
Tue Oct 7 10:11:07 CDT 2014


Great.  Definitely submit a PR if you get it working.

- tim

On 10/07/2014 09:59 AM, Lorenzo Alessio Botti wrote:
> Thanks Tim,
> good to know that you are planning to work on this feature.
> I’m also modifying my code to get a thread safe implementation with (possibly more than) decent performance.
>
> Thanks everybody for the heads up.
> Best regards.
> Lorenzo
>
> On 03 Oct 2014, at 21:36, Tim Tautges <timothy.tautges at cd-adapco.com> wrote:
>
>> The code isn't thread safe because, for efficiency purposes, MOAB keeps track of the "last" sequence it was in, so that on subsequent calls querying an entity, it starts in that last sequence.  For typical applications where you're iterating through the entities in handle order, this will be fastest.  Of course, for unstructured meshes, there are some operations (e.g. iterate through the vertices comprising this element, in their canonical order in the element) that doesn't really help you.  There are several places like that in the guts of MOAB.  Fortunately, UW (Paul Wilson & co.) has an item in their current contract to investigate that very issue.
>>
>> - tim
>>
>> On 10/03/2014 02:06 PM, Grindeanu, Iulian R. wrote:
>>>
>>> ------------------------------------------------------------------------------------------------------------------------
>>> *From:* Grindeanu, Iulian R.
>>> *Sent:* Friday, October 03, 2014 2:05 PM
>>> *To:* Lorenzo Alessio Botti
>>> *Subject:* RE: [MOAB-dev] thread safety
>>>
>>> yes, seq would be filled by multiple threads
>>> (this is simplified, there are other local variables in this method tag_get_data, there are several cascading calls to
>>> get to actual getting/setting the tag)
>>>
>>> I am not sure I understand what you try to say.
>>> Are you suggesting to use another class/structure ?
>>>
>>> an *_iterate example is here:
>>> http://ftp.mcs.anl.gov/pub/fathom/moab-docs/DirectAccessNoHoles_8cpp-example.html
>>>
>>> basically, you get a pointer in memory (if contiguous) for every tag, or connectivity array
>>>
>>> These *_iterate calls should be made in a loop if the sequences are broken
>>> http://ftp.mcs.anl.gov/pub/fathom/moab-docs/classmoab_1_1Interface.html#ae287e8e24aefae7b16902affe185fae8
>>>
>>> Hope this helps.
>>>
>>> Iulian
>>>
>>> ------------------------------------------------------------------------------------------------------------------------
>>> *From:* Lorenzo Alessio Botti [bottilorenzo at gmail.com]
>>> *Sent:* Friday, October 03, 2014 1:54 PM
>>> *To:* Grindeanu, Iulian R.
>>> *Subject:* Re: [MOAB-dev] thread safety
>>>
>>> Iulian, I don’t understand why this code is not thread safe
>>>
>>>>   get_tag_data (entity, *value)
>>>> {
>>>>     SequenceData  * seq = find_sequence(entity)
>>>>     *value = seq->value_for_entity(entity)
>>>> }
>>>
>>> While the following is not thread safe because different threads would try to fill seq at the same time.
>>> some class
>>> {
>>>      SequenceData  * seq;
>>>      get_tag_data (entity, *value)
>>>     {
>>>          seq = find_sequence(entity)
>>>        *value = seq->value_for_entity(entity)
>>>     }
>>> };
>>>
>>> I am missing something?
>>>
>>> How can I use *_iterate methods? Can you please show me or point me to an example.
>>> Thanks a lot.
>>> Lorenzo
>>>
>>>
>>
>> --
>> Timothy J. Tautges
>> Manager, Directed Meshing, CD-adapco
>> Phone: 608-354-1459
>> timothy.tautges at cd-adapco.com
>

-- 
Timothy J. Tautges
Manager, Directed Meshing, CD-adapco
Phone: 608-354-1459
timothy.tautges at cd-adapco.com


More information about the moab-dev mailing list