# Will VTK ever be thread-safe for parallel use ?

**URL:** <https://discourse.vtk.org/t/will-vtk-ever-be-thread-safe-for-parallel-use/871>\
**Category:** Development\
**Created:** [April 29, 2019, 8:44pm UTC](https://discourse.vtk.org/t/will-vtk-ever-be-thread-safe-for-parallel-use/871 "2019-04-29T20:44:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aravind90](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ba8739/32.png) [@aravind90](https://discourse.vtk.org/u/aravind90)\
**Post date:** [April 29, 2019, 8:44pm UTC](https://discourse.vtk.org/t/will-vtk-ever-be-thread-safe-for-parallel-use/871/1 "2019-04-29T20:44:43Z")

</div>

I’m looking for ways to parallelize VTK and there’s static data in VTK (the Executives classes in particular) that manage static data that can’t be called in parallel without corrupting the heap.

Also, I’ve noticed that the CPU usage goes from 70%-80% to single CPU - 12.5% once the VTK pipeline starts updating.

What is a good strategy to parallelize VTK? Does VTK use OpenMP to parallelize?

---

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)\
**Post date:** [April 29, 2019, 9:35pm UTC](https://discourse.vtk.org/t/will-vtk-ever-be-thread-safe-for-parallel-use/871/2 "2019-04-29T21:35:00Z")

</div>

Filters within a pipeline don’t run in parallel but you can make each filter multi-threaded using vtkMultiThreader, various SMP backends (OpenMP or Intel TBB), or [VTK-m](http://m.vtk.org/index.php/Main_Page)). You can find several examples for all of them in the VTK source code.

Are you trying to update multiple pipelines in different threads? Are the pipelines completely independent or they share some inputs or outputs? What static members did you find to cause trouble?

---

<div class="post-metadata">

**Author:** ![aravind90](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ba8739/32.png) [@aravind90](https://discourse.vtk.org/u/aravind90)\
**Post date:** [May 2, 2019, 2:09pm UTC](https://discourse.vtk.org/t/will-vtk-ever-be-thread-safe-for-parallel-use/871/3 "2019-05-02T14:09:27Z")

</div>

We have multiple independent pipelines, so if that could be multi-threaded, that would be great.

Calling Renderer::AddActor(), Update(), and SetInputConnection() must be protected by named OpenMP critical sections or it will crash. I believe that it’s because Update() uses the static vtkExecutive methods and data, which aren’t thread-safe.
