[vtkusers] VTK in a multi-threaded program

Berk Geveci berk.geveci at kitware.com
Mon Mar 24 11:14:07 EDT 2014


Let me add my 2 cents.

First of all, make sure that you are using the latest VTK from Git. It
makes reference count management thread safe. As long as the reference does
not go to 0 while another thread is using an object, it will be fine. Using
smart pointers will also be OK. Git VTK has bunch of other thread safety
improvements by the way.

Second, when you hand data from the compute thread to the render thread, I
would use a shallow copy. Something like:

copyToRender = output->NewInstance();
copyToRender->ShallowCopy(output);

Make sure that this is protected by a mutex if the compute thread
eventually deletes "output". This would not be needed normally but there is
still some garbage collection left that may cause issues. This should make
it safe. It will be unnecessary in the future as we clean things more.

Finally, never connect a pipeline across threads. Render should cause
filters that belong to another to execute.

If you are still running into specific thread safety issue, try to trace
them with helgrind and please report them to this list or to me directly.

Best,
-berk





On Mon, Mar 24, 2014 at 11:00 AM, Aashish Chaudhary <
aashish.chaudhary at kitware.com> wrote:

> On Mon, Mar 24, 2014 at 10:53 AM, David Cole <dlrdave at aol.com> wrote:
>
>> Hi Aashish,
>>
>> The blog post you pointed to was published in October 2012, and
>> referenced releasing the source code by the end of 2013. Was the source
>> code released? Is there a public repo for it?
>>
>
> At the end of the blog, Rusty answered this question. Please have a look
> at it.
>
>>
>> I find it hard to believe that the only thing you had to do was "a
>> vtkSmartPointer trick"...
>>
>
> It was not just that but it was part of the core implementation.
>
>>
>> If there is a way to run, for example, the vtkMarchingCubes filter on a
>> large volumetric dataset, with a pipeline that's in a background non-GUI
>> thread, it sure would be useful to have a snippet of example code that
>> proves it. Or any other long running vtkAlgorithm, for that matter.
>>
>
> I don't remember what algorithms we ran but they were mostly image based
> or our own written in VTK.
>
> - Aashish
>
>>
>>
>> Thanks,
>> David
>>
>>
>
>
> --
> | Aashish Chaudhary
> | R&D Engineer
> | Kitware Inc.
> | www.kitware.com
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140324/c5807e7b/attachment.html>


More information about the vtkusers mailing list