How to select Serial/TBB/CUDA devices when using the vtkm Accelerators in vtk?


I’m using the vtkm Accelerators in vtk but I can’t find a way to select which device (Serial/TBB/Cuda) the filters should use.

In vtkm I use the following approach (The code snipped below shows how I select the Cuda device for example)


How can I achieve this when using the vtkm Accelerators in vtk?



You can choose SMP backend (sequential, tbb, …) when you configure your project in CMake using VTK_SMP_IMPLEMENTATION_TYPE CMake variable.


Thanks for the reply. I can only do this when I build vtk right? I can’t do this on a project by project basis for my projects that are referencing vtk?

Should I think about building two versions of vtk - one one with TBB (No Cuda) and the other with Cuda (No TBB)? And then configuring my application projects against one or the other?

Or is there a better way?



I’m not aware of any incompatibilities between TBB and Cuda, so using TBB and/or Cuda are probably two independent decisions. You cannot change the SMP backend after you have built VTK. I don’t know if you can enable/disable Cuda support in VTK-m at runtime.

Thanks Andreas,

Unless I hear a better solution I’m going to create two builds of vtk - one with Cuda and one with TBB and then just create two builds of my projects - one building against vtk_cuda and the other against vtk_tbb. Should be a one line change in my cmake file.

I prefer working with the vtkm accelerators in vtk because I can operate directly on vtk data structures and use all of the readers and it’s way easier to display the output compared with vtkm.

Right now I’m trying to compare the serial vtk filters with the TBB and Cuda versions from vtkm so that’s problematic right now because I don’t have the same control of the backend in vtk that I do in vtkm.

So I’d vote for providing this level of control as a short term priority for vtk. Although adding support for the higher order cell types would get my first vote…


Hello, Douglas,

Maybe you can try something called dynamic loading, when the executable loads a shared library manually during runtime instead of linking against it during build. You can build both versions of VTK, identify which libraries are different and dynamic load them depending on some kind of settings or command-line parameters.

Or, to take a more modern approach, you can create a plug-in infrastructure in your program and write two plug-ins: one with CUDA backend and the other with TBB backend. Then, to choose between them is just a matter of choosing an option in the load screen or something like that.

all the best,