Build Python wheels with SMP tools for runtime backend selection

I think you can also set the environment variable VTK_SMP_BACKEND_IN_USE="STDThread" to get the same effect, without changing any Python code. In that case VTK will select the maximum available number of threads on your system.

How this behave on a specific system can be tested by making a small script:

import vtk

tool = vtk.vtkSMPTools()
print(f"Present backend: {tool.GetBackend()}")
print(f"Est. number of threads: {tool.GetEstimatedNumberOfThreads()}")

and running it with the variable set:

$ VTK_SMP_BACKEND_IN_USE="STDThread" python3 vtk-smp-backend.py 
Present backend: STDThread
Est. number of threads: 32
2 Likes