[vtkusers] Speed up cell allocation

Oleg Krivosheev oleg.krivosheev at xcision.com
Mon Aug 3 11:27:36 EDT 2015


Hi,

> Do I have any options other than parallelizing the main loop?

yes, you do, but it will complicate your resource (memory) management

basically, separate allocation and initialization and use placement new

somewhere along the line

auto shex = sizeof(vtkHexahedron);
auto elems_mem = new char [numElems * shex];

        for(int i = 0; i < numElems; ++i) {
                elems[i] = new (elems_mem + i*shex)  vtkHexahedron();
        }

but you have to keep pointer to memory, not to forget to deallocate it etc

regards

OK

On Fri, Jul 31, 2015 at 10:18 AM, quadprob <gustav.lundin at saabgroup.com>
wrote:

> Hi,
> My program is suffering from very noticeable start up times even though
> rendering itself is quite smooth. From profiling I've learnt that what's
> taking up most of the time is the vtkCell constructor calls. So what I'm
> essentially looking for is to speed up something like this:
>
> public static void main(String []args) {
>         int numElems = 739872;
>         vtkCell[] elems = new vtkCell[numElems];
>
>         long startTime = System.nanoTime();
>         for(int i = 0; i < numElems; ++i) {
>                 elems[i] = new vtkHexahedron();
>         }
>         long stopTime = System.nanoTime();
>         System.out.printf("Took %dms\n", (stopTime-startTime)/1000000);
> }
>
> Do I have any options other than parallelizing the main loop?
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Speed-up-cell-allocation-tp5733208.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150803/8e7a5233/attachment.html>


More information about the vtkusers mailing list