[vtkusers] [Paraview] making vtkGaussianSplatter multi-threaded
David Gobbi
david.gobbi at gmail.com
Mon Jan 12 08:55:33 EST 2015
On Mon, Jan 12, 2015 at 3:56 AM, Dr. Roman Grothausmann <
grothausmann.roman at mh-hannover.de> wrote:
> Dear mailing list members,
>
> Since I already started to create and use a modified version of
> vtkGaussianSplatter I now wonder if it were possible to make
> vtkGaussianSplatter run multi-threaded. I'd expect that this is possible if
> getting and setting pixel values is thread-safe. In vtkGaussianSplatter
> pixel values are stored in a vtkDoubleArray and read with GetValue and
> written with SetTuple. There is no info in the docs whether SetTuple (in
> the way used) is thread-safe. Although GetValue seems to exist, I cannot
> find any hint in the docs that vtkDoubleArray offers this function, however
> a thread-safe version of GetTuple exists.
> So is there any reason vtkGaussianSplatter cannot be made multi-threaded
> with VTK6?
>
The SetTuple/GetTuple methods don't lock the array, so they equivalent to
(but slower than) raw memory reads and writes. And writing memory is not
thread safe if threads can write to the same memory address or (depending
on alignment) to adjacent addresses.
For vtkGaussianSplatter, any performance gains that could be had by
multi-threading would depend on the threads all being able to write at the
same time, therefore any sort of "lock" would kill the performance by
essentially serializing the writes. Hence, in order for
vtkGaussianSplatter to be properly multi-threaded, each thread must write
to its own block of output memory. After the splatting is done these must
be composited together.
I wrote a multi-threaded splatting filter once (for ultrasound
reconstruction), and in that case I divided my input points such that each
thread would write to different (but adjacent) memory regions within the
output. It performed well but wasn't completely thread-safe, because it
was possible for memory collisions to occur on the border between the
regions.
In summary: properly multi-threading vtkGaussianSplatter would be a
moderately difficult task. I haven't heard of anyone who has done it yet.
- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150112/0e8b493b/attachment.html>
More information about the vtkusers
mailing list