[vtkusers] thread safety

Lodron, Gerald Gerald.Lodron at joanneum.at
Mon Sep 3 05:10:19 EDT 2012

I only want to tell:

I copied code from vtkMarchingCubes and its used member variable of vtkMergePoints and programmed it multithreaded of a blockwise calculation of the input image (subblocks of the whole input image are generated), without gradient and normal vector stuff, so that in the multithreading part no vtk variables/objects are used. In the end all results of the threads are merged (single threaded in main thread) into a vtkPolyData object, which is then the output (in my case the input is an image of our internal software lib so not directly a vtkImageData object, but things should be straight forward) of my filter. 

On my Intel Quadcore i7 with Hyperthreadding enabled ( so there are 8 cores) I got a speed improvement of factor 5 on a 512^3 floating point image with one contour value (0,2s instead of 1s).

So maybe VTK developers are thinking to make this filter in a multithreaded fashion too, I could share code but as I said I do not directly set a vtkImageData as input, I am not very familiar with pipeline settings and do not exactly know how the blockstream a vtkImageData into multiple threads... (is there anywhere a good doku for that vtkInformation and exact Pipeline stuff, I searched the web and also have that VTK book but this part seems to be a big secret of kitware..., I am using vtk for 3 years and do not completely understand this still now...). Would be great if someone could give me some links if they exist...

Best regards

-----Ursprüngliche Nachricht-----
Von: David E DeMarle [mailto:dave.demarle at kitware.com] 
Gesendet: Mittwoch, 29. August 2012 18:15
An: Lodron, Gerald
Cc: (vtkusers at vtk.org)
Betreff: Re: [vtkusers] thread safety

Unfortunately, VTK isn't thread safe, with the exception being operations (mostly limited to array access methods that are declared to be thread safe in doxygen) that take place in the Threaded* methods in subclasses of vtkThreadedImageAlgorithm.

Berk is working on more wide scale thread/SMP parallel support, but that won't be in until after 6.0.

If anyone on the list has had success in writing multithreaded VTK programs, I'ld like to see examples along with descriptions of what your approach was and what you had to mutex protect.

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Wed, Aug 29, 2012 at 2:47 AM, Lodron, Gerald <Gerald.Lodron at joanneum.at> wrote:
> Hi
> I programmed an own vtk Filter which internally has multiple threads. 
> In each thread I create a vtkImageData object using
> vtkSmartPointer<vtkImageData>       oImage = vtkImageData::New();
> the problem is that sometimes the New() operator crashes, I debugged 
> it the the line 61 of vtkImageData.cxx:
> this->Information->Set(vtkDataObject::DATA_EXTENT(), this->Extent, 6);
> whereby the exact crash is in vtkInformationIntegerPointerKey.cxx on 
> line
> 58:
> if(this->RequiredLength >= 0 && length != this->RequiredLength)
> wherehy the "this" pointer is zero. I am not so deep familiar with 
> that, any suggestions?
> DI Gerald Lodron
> Machine Vision Applications
> DIGITAL - Institute for Information and Communication Technologies
> JOANNEUM RESEARCH Forschungsgesellschaft mbH Steyrergasse 17, 8010 
> phone:   +43-316-876-1751       personal fax: +43-316-876-91751
> mobile:   +43-699-1876-1751      general fax: +43-316-876-1720
> web: http://www.joanneum.at/digital
> e-mail: gerald.lodron at joanneum.at
> _______________________________________________
> Powered by www.kitware.com
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

More information about the vtkusers mailing list