Use of Parallel.ForEach or Parallel.For for ActiViz data parallelism

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Use of Parallel.ForEach or Parallel.For for ActiViz data parallelism

This post has NOT been accepted by the mailing list yet.
I am trying to test whether or not it is possible to achieve multithreading simply by using Parallel.ForEach statement on VTK pipeline.

Just to test-out whether or not it is or not, I have created the class that takes-in vtkImageData and adds an arbitrary constant to the vtkImageData using vtkImageMathematics:

class vtkcalculation
            public void add_constant(vtkImageData dose3D, double constant)
                vtkImageMathematics dose_addC = vtkImageMathematics.New();

Then I'm trying to add different constants in parallel by using parallel.foreach:
            double[] numbers={1,2,3,4,5,6,7,8,9,10,12.3,34.4,1.3,1.5,6,3,16};
            Parallel.ForEach(numbers, (current_number, pls, index) =>
                vtkcalculation calc = new vtkcalculation();
                calc.add_constant(dose3D, current_number);

I would totally have given-up the idea, thinking it is too simple-minded...  only it "sometimes" works.  For the times that it does not work, I get the same exception at vtkImageMathmatics constructor line: "error: table already has a non-null entry at mteIndex"  

Is it possible to implement Parallel.ForEach or Parallel.For statements with VTK or would I have to resort to multithreading classes in VTK?  If latter is the case, would anyone know how to implement those for this case?

Thank you,