[vtkusers] Potential bug in graph pedigreeId handling / AbstractArray::LookupValue

Adrian Friebel friebel at izbi.uni-leipzig.de
Thu Aug 28 07:21:47 EDT 2014


Thank you for the clarification!
Indeed I tried the Modified call on the graph object during my testing. 
Still no rebuild of lookup. I now just tried Modified calls on 
VertexData and directly on the PedigreeID Array after adding the 
vertices. Still no rebuild of lookup. The DataChanged() call did the 
job. (In 5.10.1)
In any case, I think it would be preferable if the graph method 
AddVertex(pedId) would trigger the lookup rebuild. Or at least the 
graph->Modified() call. An update of the corresponding API docs should 
be considered also. Otherwise migration to newer vtk versions might give 
some people serious headaches. It took me half a day to track the 
strange behaviour of my graphs down to this change. ;)

Best,
Adrian.


Am 28.08.2014 02:19, schrieb Berk Geveci:
> Ah interesting. Note that I plan to remove DataChanged() in the 
> future. It is a serious performance bottleneck when multiple threads 
> are setting different parts of an array because it causes all threads 
> to write to the same memory location where that flag is stored. The 
> right way of doing this is to call Modified() after doing a set of 
> changes to notify whatever may depend on an array.
>
> Best,
> -berk
>
>
> On Wed, Aug 27, 2014 at 5:30 PM, Jeff Baumes <jeff.baumes at kitware.com 
> <mailto:jeff.baumes at kitware.com>> wrote:
>
>     It is unclear what changed exactly, but the current behavior is
>     that for numeric arrays, setting data with SetValue() (which is
>     what AddVertex ultimately does to the pedigree ID array), does not
>     in fact invoke DataChanged() on the array which would signal the
>     lookup to rebuild on the next LookupValue() call (which is what
>     FindVertex() performs). This was done for performance reasons, and
>     perhaps this change was made between 5.8 and 5.10.
>
>     If you call pedigreeIds->DataChanged() just before the call to
>     FindVertex(), the issue should be resolved.
>
>
>     On Wed, Aug 27, 2014 at 9:28 AM, Adrian Friebel
>     <friebel at izbi.uni-leipzig.de <mailto:friebel at izbi.uni-leipzig.de>>
>     wrote:
>
>         Hey,
>         so far I compiled my software against vtk 5.8. Recently I
>         tried to compile it against 5.10.1 and noticed unexpected
>         behaviour while adding vertices to a graph while passing
>         pedigree ids.
>         Below a minimal example and its output:
>
>         #include <stdio.h>
>         #include <iostream>
>
>         #include <vtkDataSetAttributes.h>
>         #include <vtkMutableUndirectedGraph.h>
>         #include <vtkSmartPointer.h>
>         #include <vtkUnsignedLongArray.h>
>
>         int  main(int argc, char **argv)
>         {
>             vtkSmartPointer<vtkMutableUndirectedGraph> graph =
>         vtkSmartPointer<vtkMutableUndirectedGraph>::New();
>
>             vtkSmartPointer<vtkUnsignedLongArray> pedigreeIds =
>         vtkSmartPointer<vtkUnsignedLongArray>::New();
>             pedigreeIds->Initialize();
>             pedigreeIds->SetName("Pedigree IDs");
>
>             graph->GetVertexData()->SetPedigreeIds(pedigreeIds);
>
>             for(unsigned int i=0; i<10; ++i) {
>                 vtkIdType v = graph->AddVertex(i*100);
>                 std::cout << "i = " << i << ": v = " << v <<
>                         ", graph->GetVertex[..]->GetVariantValue( " <<
>         v << ") = " <<
>         graph->GetVertexData()->GetPedigreeIds()->GetVariantValue(v) <<
>                         ", graph->FindVertex(" << i << "*100) = " <<
>         graph->FindVertex(i*100) << std::endl;
>             }
>             return 0;
>         }
>
>         VTK-5.8:
>         i = 0: v = 0, graph->GetVertex[..]->GetVariantValue( 0) = 0,
>         graph->FindVertex(0*100) = 0
>         i = 1: v = 1, graph->GetVertex[..]->GetVariantValue( 1) = 100,
>         graph->FindVertex(1*100) = 1
>         i = 2: v = 2, graph->GetVertex[..]->GetVariantValue( 2) = 200,
>         graph->FindVertex(2*100) = 2
>         i = 3: v = 3, graph->GetVertex[..]->GetVariantValue( 3) = 300,
>         graph->FindVertex(3*100) = 3
>         i = 4: v = 4, graph->GetVertex[..]->GetVariantValue( 4) = 400,
>         graph->FindVertex(4*100) = 4
>         i = 5: v = 5, graph->GetVertex[..]->GetVariantValue( 5) = 500,
>         graph->FindVertex(5*100) = 5
>         i = 6: v = 6, graph->GetVertex[..]->GetVariantValue( 6) = 600,
>         graph->FindVertex(6*100) = 6
>         i = 7: v = 7, graph->GetVertex[..]->GetVariantValue( 7) = 700,
>         graph->FindVertex(7*100) = 7
>         i = 8: v = 8, graph->GetVertex[..]->GetVariantValue( 8) = 800,
>         graph->FindVertex(8*100) = 8
>         i = 9: v = 9, graph->GetVertex[..]->GetVariantValue( 9) = 900,
>         graph->FindVertex(9*100) = 9
>
>         VTK-5.10.1:
>         i = 0: v = 0, graph->GetVertex[..]->GetVariantValue( 0) = 0,
>         graph->FindVertex(0*100) = 0
>         i = 1: v = 1, graph->GetVertex[..]->GetVariantValue( 1) = 100,
>         graph->FindVertex(1*100) = 1
>         i = 2: v = 2, graph->GetVertex[..]->GetVariantValue( 2) = 200,
>         graph->FindVertex(2*100) = -1
>         i = 3: v = 3, graph->GetVertex[..]->GetVariantValue( 3) = 300,
>         graph->FindVertex(3*100) = 3
>         i = 4: v = 4, graph->GetVertex[..]->GetVariantValue( 4) = 400,
>         graph->FindVertex(4*100) = -1
>         i = 5: v = 5, graph->GetVertex[..]->GetVariantValue( 5) = 500,
>         graph->FindVertex(5*100) = -1
>         i = 6: v = 6, graph->GetVertex[..]->GetVariantValue( 6) = 600,
>         graph->FindVertex(6*100) = -1
>         i = 7: v = 7, graph->GetVertex[..]->GetVariantValue( 7) = 700,
>         graph->FindVertex(7*100) = 7
>         i = 8: v = 8, graph->GetVertex[..]->GetVariantValue( 8) = 800,
>         graph->FindVertex(8*100) = -1
>         i = 9: v = 9, graph->GetVertex[..]->GetVariantValue( 9) = 900,
>         graph->FindVertex(9*100) = -1
>
>
>         It seems that there is something wrong with the
>         AbstractArray::LookupValue in 5.10.1, since the array entries
>         value->pedId are made.
>         I am aware that 6.1 was released some time ago. Maybe the
>         issue was solved already, but since I couldn't find any
>         reports on this I thought I might inform you guys.
>         Or am I just missing some newly introduced update call?
>
>         Best,
>         Adrian.
>
>         -- 
>         Dipl.-Inform. Adrian Friebel
>         Research Group for Multicellular Systems Biology
>         Interdisciplinary Centre for BioInformatics
>         University of Leipzig
>         Haertelstrasse 16-18
>         04107 Leipzig
>         Germany
>         Tel.: +49 341 97-16627 <tel:%2B49%20341%2097-16627>
>         email: adrian.friebel at uni-leipzig.de
>         <mailto:adrian.friebel at uni-leipzig.de>
>
>         _______________________________________________
>         Powered by www.kitware.com <http://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://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
>     _______________________________________________
>     Powered by www.kitware.com <http://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://public.kitware.com/mailman/listinfo/vtkusers
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140828/58cdf896/attachment.html>


More information about the vtkusers mailing list