[vtkusers] How to use OpenMP with VTK

David E DeMarle dave.demarle at kitware.com
Mon Mar 17 16:59:34 EDT 2014


I recommend you follow the pattern of the filters Filters/SMP (first
appearing vtk 6.1).
OpenMP is one of the threading back ends that these filters can use
efficiently.

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


On Mon, Mar 17, 2014 at 4:35 PM, Sunrise <helios.corona at gmail.com> wrote:

>  Hello,
>
> I would like to parallelize the vtk filter that I wrote using OpenMP, and
> I just started learning OpenMP on a need basis. A part of code is a forloop over tuples of a
> vtkDoubleArray. Each tuple is associated with a point on Data. The
> computation for each point is totally independent and embarrassingly
> parallelize-able. A short version of part of the code is
>
> vtkDoubleArray *InputArray = ... // Get it from Input Data
> vtkDoubleArray *OutputArray = ... // Define new array
>
> #pragma omp parallel for
> for(int PointId = 0; PointId < InputArray->GetNumberOfTuples(); PointId++)
> {
>     double InputValue = InputArray->GetTuple1(PointId);
>     double OutputValue = DoSomething(InputValue,OtherParameters);
>     OutputArray->SetTuple1(OutputValue);
> }
>
> However, I am getting the following error for GetTuple1() method:
>
> ERROR: In
> /SomePath/paraview/ParaView-4.1.0-source/VTK/Common/Core/vtkDataArrayTemplate.txx,
> line 598
> vtkDoubleArray (0x14bf6808): Unable to allocate 1 elements of size 8
> bytes.
>
> Aborted
>
> Could anyone help me to use OpenMP within my filter?
>
> Thank you,
> -Sia
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140317/76868454/attachment.html>


More information about the vtkusers mailing list