[vtk-developers] ComputeRange setting array's information object

David Gobbi david.gobbi at gmail.com
Wed May 28 18:32:05 EDT 2014


Hi Berk,

There already was an attempt to make a thread-safe version:

Date:   Wed Mar 13 12:06:47 2013 -0400
Make vtkDataArray::ComputeRange() thread-safe
http://review.source.kitware.com/#/c/10270/

The patch fell short of its goal, though.

Anyway, I don't think that a thread-safe version is necessarily the
right answer.  The problem is more with documentation than with code:
some GetRange() methods are documented as "THIS METHOD IS NOT
THREAD SAFE" while others are not.  If all GetRange() methods are equally
unsafe then they should all carry the same warning.  I can make up a
patch for this.

  David





On Wed, May 28, 2014 at 3:54 PM, Berk Geveci <berk.geveci at kitware.com> wrote:
> Hi David,
>
> As far as I know, ComputeRange always cached the result one way or another.
> It used to be in a data member I believe now it is in the information object
> (which I dislike but for other reasons). Given that it is a relatively
> heavy-weight operation, caching makes sense IMHO.  The alternative would be
> to use a mutex but that would kill the performance of GetRange(), specially
> when used in parallel. We could add a thread-safe version that always
> computed the range and stored it in the argument but I wouldn't recommend
> that people use it...
>
> Best,
> -berk
>
>
>
>
> On Tue, May 27, 2014 at 5:11 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> Hi All,
>>
>> I was looking at vtkDataArray's ComputeRange code, and saw these:
>>
>> void vtkDataArray::ComputeRange(double range[2], int comp)
>> line 1102:  info->Set( PER_COMPONENT(), infoVec );
>> line 1112:  infoVec->SetNumberOfInformationObjects(
>> this->NumberOfComponents );
>> line 1154:  info->Set( rkey, range, 2 );
>>
>> Now, I always understood that it was necessary to be careful with
>> calling GetRange() as far as thread safety is concerned.  However,
>> these info->Set... calls surprised me.  Their presence means that
>> ComputeRange() is non-reentrant in a very bad way.
>>
>> Is there a reason why ComputeRange() has to modify the array's
>> info object?
>>
>>   David
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>



More information about the vtk-developers mailing list