# Using TBB with VTK

**URL:** https://discourse.vtk.org/t/using-tbb-with-vtk/1958
**Category:** Support
**Created:** [October 21, 2019, 1:12pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958 "2019-10-21T13:12:52Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Seun](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seun/32/767_2.png) [@Seun](https://discourse.vtk.org/u/Seun)
#### Post date: [October 21, 2019, 1:12pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/1 "2019-10-21T13:12:52Z")

</div>

Hello everyone,  
I was wondering if someone could point me in the right direction as to how to use TBB with VTK correctly. I managed to build VTK with TBB using cmake (if am correct, I had the VTK\_SMP\_IMPLEMENTATION\_TYPE set to TBB, with the necessary directories and includes to the required libraries .dylib), built and compiled.  
Everything seems to work properly, however I don’t notice any difference in performance. It’s worth mentioning that I’m using vtkProbeFilter which I was under the impression takes advantage of TBB’s capabilities from the thread below

[How to evaluate TBB with VTK](https://discourse.vtk.org/t/how-to-evaluate-if-id-benefit-from-using-intel-tbb-with-vtk/736)

```
Is there something I'm missing, something I ought to be doing that am not?
```

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 21, 2019, 4:07pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/2 "2019-10-21T16:07:53Z")

</div>

I looked at the code for vtkProbeFilter.cxx (which is really the only way to know for certain how any VTK filters are implemented), and SMP is only used when probing with a vtkImageData. The Input must be vtkImageData, but the Source can be any kind of data.

---

<div class="post-metadata">

### Author: ![Seun](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seun/32/767_2.png) [@Seun](https://discourse.vtk.org/u/Seun)
#### Post date: [October 21, 2019, 5:07pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/3 "2019-10-21T17:07:37Z")

</div>

Thanks for the detailed response.  
It’s rather unfortunate that it functions that way. Am feeding in a poly data as the input data and a vtkImageBlend’s output as the source connection, I guess that explains why I’m not seeing any benefits. By the way, I noticed a vtkPProbeFilter is of no benefit either. Although it’s worth mentioning I was using the vtkPProbeFilter without a MPI Controller setup (does that matter)?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 21, 2019, 5:31pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/4 "2019-10-21T17:31:02Z")

</div>

I don’t think that vtkPProbeFilter is what you want, since MPI does its parallelization across processes (using network sockets so that it can work across multiple computers), while SMP does its parallelization via threads (and therefore has minimal overhead).

The vtkProbeFilter’s image SMP code was probably added because someone had a specific application that needed it. Adding SMP code to vtkProbeFilter for use with a vtkPolyData input should be straightforward, if you want to give it a go.

---

<div class="post-metadata">

### Author: ![Seun](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seun/32/767_2.png) [@Seun](https://discourse.vtk.org/u/Seun)
#### Post date: [October 21, 2019, 5:55pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/5 "2019-10-21T17:55:38Z")

</div>

Oh I see, thanks for clarifying that. Is there any sample code for SMP with vtkProbeFilter? I can’t seem to find any out there.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 21, 2019, 6:06pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/6 "2019-10-21T18:06:06Z")

</div>

You mean for using SMP with vtkProbeFilter with a vtkPolyData input? I just said that such code does not exist, someone would have to add it to vtkProbeFilter.

---

<div class="post-metadata">

### Author: ![Seun](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seun/32/767_2.png) [@Seun](https://discourse.vtk.org/u/Seun)
#### Post date: [October 21, 2019, 6:30pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/7 "2019-10-21T18:30:48Z")

</div>

My bad, you are right. It’s the vtkProbeFilter’s image SMP code that was added, read that wrong. Thanks, I’ll try and give it a go at my end.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 21, 2019, 7:11pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/8 "2019-10-21T19:11:04Z")

</div>

There is also a [vtkmProbe](https://vtk.org/doc/nightly/html/classvtkmProbe.html), if you want to try using TBB through [VTK-m](http://m.vtk.org/documentation/). I have no experience with it.

---

<div class="post-metadata">

### Author: ![Seun](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seun/32/767_2.png) [@Seun](https://discourse.vtk.org/u/Seun)
#### Post date: [October 22, 2019, 11:36am UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/9 "2019-10-22T11:36:02Z")

</div>

Oh nice, I was never aware of vtkmProbe. I’ll check it out if all else fails.  
Huge thanks.

---

<div class="post-metadata">

### Author: ![Seun](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seun/32/767_2.png) [@Seun](https://discourse.vtk.org/u/Seun)
#### Post date: [November 1, 2019, 1:24pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/10 "2019-11-01T13:24:17Z")

</div>

Hi David,

I had a look at vtkProbeFilter with the intention of getting a vtkPolyData input take advantage of SMP and as I’m not that versed with the class It doesn’t seem to be clear to me on how to achieve this. There’s a different path specifically for vtkImageData that as you mentioned earlier makes use of SMP with the other branch just processing empty points.  
An idea that occurred to me was the possibility of converting a poly data to an image data and feeding that in as the input thus taking the SMP route but am not quite sure if that’s even worth it without any overhead or drawbacks. I guess my question is is there any straight forward approach to getting a vtkPolyData to work.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [November 1, 2019, 2:57pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/11 "2019-11-01T14:57:02Z")

</div>

> [@Seun](#):
>
> An idea that occurred to me was the possibility of converting a poly data to an image data and feeding that in as the input thus taking the SMP route but am not quite sure if that’s even worth it without any overhead or drawbacks.

With vtkProbeFilter, it doesn’t make sense to convert the “Source” data to a different format, because you want to probe at the original point locations.

If you are interested, for a fee I could write you a VTK filter that probes a vtkImageData with a polydata and that uses SMP. I’m very familiar with the vtkSMPTools and with the VTK pipeline architecture. You can PM me by clicking on my icon (the sushi roll) and clicking the “Message” button.

---

<div class="post-metadata">

### Author: ![Seun](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seun/32/767_2.png) [@Seun](https://discourse.vtk.org/u/Seun)
#### Post date: [November 1, 2019, 3:56pm UTC](https://discourse.vtk.org/t/using-tbb-with-vtk/1958/12 "2019-11-01T15:56:00Z")

</div>

You are right, converting the source data to a different format is a bad idea hence why I didn’t go that route but I mentioned it so you could confirm my thinking. Sure, we (me & my team) would be interested in getting a poly data probed using SMP but I’ll have to get back to you on that after consulting with others at my end. Thank you so much for helping, will get back to you soon.
