Discussion on vtkSmpTools improvement

Hi all,

I’ve been using vtkSMPTools a bit lately and have some comments. They may be tangential to what you are aiming to do, but here they are anyway:

  • Sometimes, I want to pass numbers other than vtkIdType to vtkSMPTools::For(). For example, I have a sparse set or map whose keys (perhaps hashes for unordered sets/maps) are uint64_t and want to pass a range of keys to consider. Casting to vtkIdType won’t work since vtkSMPTools::For() does math on its arguments.
  • Sometimes I want to invoke a “for” loop on every thread without providing work. Is the correct thing to do to call vtkSMPTools::For(0, vtkSMPTools::GetEstimatedNumberOfThreads(), functor)? If so, that should be documented. If not, can we add a new way to invoke a worklet? An example use-case: I have a functor that does flood-filling and want threads to steal seeds from and insert seeds into a single queue until it is empty.
  • For the use case above, it would also be nice if there was a way for a thread to ask for its rank and the pool size (similar to MPI_Comm_rank and MPI_Comm_size). This would allow worklets to do fancier things like lockless writes to a shared queue.

[edit: removed a comment because I confused vtkSMPTools::Initialize() with the functor’s Initialize() method in the discussion above.]