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

Berk Geveci berk.geveci at kitware.com
Wed May 28 17:54:53 EDT 2014


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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140528/ba5212ea/attachment-0002.html>


More information about the vtk-developers mailing list