[vtkusers] VTK pipeline thread safety

Allie Vacanti allison.vacanti at kitware.com
Tue Mar 6 11:51:02 EST 2018


Hi Kit,

You are correct, you will run into issues trying to share the filter
between threads since they are stateful. You'll need to manually create and
configure a new filter for each thread.

The VruiVTK project has done something similar, but it executes isolated
data pipelines in a single background thread while doing threaded rendering
to multiple OpenGL contexts, including thread safe data transfer between
data<->render pipelines. Might be worth poking around in it and see if
anything useful pops out.

VruiVTK library: https://github.com/VruiVTK/vtkVRUI
MooseViewer (uses VruiVTK, the "mvClassName" classes are relevant to
threading): https://github.com/VruiVTK/MooseViewer

Be warned that there are dragons lurking -- the pipeline/filter system
itself is thread safe when done carefully, but some utilities in VTK (e.g.
text rendering) use single-threaded external libraries or process-wide
globals that can bite you. For just crunching some data, though, you should
be fine.

HTH,
Allie

On Mon, Mar 5, 2018 at 11:39 AM, Kit Chambers <kit.chambers.kc at gmail.com>
wrote:

> Hi,
>
> I am looking to write a VTK filter which contains a series of sub filters
> which are executed in parallel inside an OpenMP loop. The RequestData would
> look something like this:
>
> 1- Set up the the filters (filter1 -> filter2 -> filter3), this sequence
> might change between different usages.
> 2- Start threading / create the parallel region
> 3- Parallel loop over some different inputs
>         3a - Set filter1 input
>         3b - Execute the filter series
>         3c - Add the result to output
>
> Would I be correct in thinking that the above will result in a conflict
> where filter inputs and outputs get over written by successive threads? If
> so then is there a handy way to create a thread local copy of the VTK
> filters between steps 2 and 3?
>
> Any help would be appreciated.
>
> Kit
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180306/96da4db1/attachment.html>


More information about the vtkusers mailing list