# std::thread as a new vtkSMPTools backend

**URL:** <https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525>\
**Category:** Development\
**Tags:** proposal\
**Created:** [April 9, 2021, 2:15pm UTC](https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525 "2021-04-09T14:15:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timothee\_Couble](https://discourse.vtk.org/user_avatar/discourse.vtk.org/timothee_couble/32/3086_2.png) [@Timothee\_Couble](https://discourse.vtk.org/u/Timothee_Couble)\
**Post date:** [April 9, 2021, 2:15pm UTC](https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525/1 "2021-04-09T14:15:56Z")

</div>

Hi everyone,

We would like to introduce std::thread as a new backend in the vtkSMPTools backend.  
As it won’t add any external dependencies it can be useful for user who can’t use directly OpenMP or TBB (for example on Windows).  
We do not expect the same performance as with OpenMP or TBB, but this version should be used as replacement of the Sequential backend for architectures with limited access to third party.

Let us know if you have any feedback about this new change,

Timothée

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)\
**Post date:** [April 9, 2021, 3:22pm UTC](https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525/2 "2021-04-09T15:22:52Z")

</div>

That sounds great Timothée, thanks!

BTW/FYI: OpenMP is not convenient on macOS either, since the AppleClang compiler, unlike the regular open source Clang, does not support OpenMP. ☹

---

<div class="post-metadata">

**Author:** ![estan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/estan/32/460_2.png) [@estan](https://discourse.vtk.org/u/estan)\
**Post date:** [April 9, 2021, 4:22pm UTC](https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525/3 "2021-04-09T16:22:42Z")

</div>

Sounds great to me too. Could this conceivably be enabled for the binary Python wheels on PyPI? (what compilers are used for those?). I imagine they are currently built with serial backend due to difficulties of getting/bundling e.g. TBB?

---

<div class="post-metadata">

**Author:** ![shogarth](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@shogarth](https://discourse.vtk.org/u/shogarth)\
**Post date:** [April 9, 2021, 7:03pm UTC](https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525/4 "2021-04-09T19:03:05Z")

</div>

Adding more multithreading by default sounds like a good idea.

Could this be added as a new backend processor which is used by default instead of a replacement for the sequential backend? Sometimes it can be useful when developing new filters, or in detailed debugging, to be able to run a debugger sequentially without any multithreading.

---

<div class="post-metadata">

**Author:** ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)\
**Post date:** [April 10, 2021, 9:55am UTC](https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525/5 "2021-04-10T09:55:56Z")

</div>

> Sometimes it can be useful when developing new filters, or in detailed debugging, to be able to run a debugger sequentially without any multithreading.

+1 this is very important

---

<div class="post-metadata">

**Author:** ![Charles\_Gueunet](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charles_gueunet/32/239_2.png) [@Charles\_Gueunet](https://discourse.vtk.org/u/Charles_Gueunet)\
**Post date:** [April 13, 2021, 11:29am UTC](https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525/6 "2021-04-13T11:29:25Z")

</div>

The Native back-end will indeed be an additional one. We won’t remove the Sequential option.

---

<div class="post-metadata">

**Author:** ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)\
**Post date:** [April 13, 2021, 11:39am UTC](https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525/7 "2021-04-13T11:39:10Z")

</div>

Most excellent, I am really looking forward to what you come up with!

---

<div class="post-metadata">

**Author:** ![Timothee\_Couble](https://discourse.vtk.org/user_avatar/discourse.vtk.org/timothee_couble/32/3086_2.png) [@Timothee\_Couble](https://discourse.vtk.org/u/Timothee_Couble)\
**Post date:** [April 19, 2021, 2:58pm UTC](https://discourse.vtk.org/t/std-thread-as-a-new-vtksmptools-backend/5525/8 "2021-04-19T14:58:57Z")

</div>

Hey all!

FYI: I opened this [MR:7850](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7850) to add std::thread as a new vtkSMPTools backend.
