Skip to content

Commit f020ebb

Browse files
committed
Refactored and update the way algorithms are updated.
The way algorithms were updated (made to execute) with request meta-data (such as update extent) was very error prone and counter-intuitive. Added new methods to make updating with meta-data easier. I also deprecated a number of methods to set request meta-data. This will encourage developers to migrate to the new API which is less error- prone.
1 parent 4aeff3b commit f020ebb

File tree

104 files changed

+782
-698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+782
-698
lines changed

Accelerators/Piston/Testing/Cxx/TestDMPFiltering.cxx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ void SetIsoValueRMI(void *localArg, void *vtkNotUsed(remoteArg),
7373

7474
float val;
7575

76+
vtkMultiProcessController *contrl = args->Controller;
77+
7678
vtkPistonContour *iso = args->ContourFilter;
7779
val = iso->GetIsoValue();
7880
iso->SetIsoValue(val + ISO_STEP);
79-
args->elev->Update();
81+
args->elev->Update(contrl->GetLocalProcessId(),
82+
contrl->GetNumberOfProcesses(), 0);
8083

81-
vtkMultiProcessController *contrl = args->Controller;
8284
contrl->Send(args->elev->GetOutput(), 0, ISO_OUTPUT_TAG);
8385
}
8486

@@ -113,14 +115,8 @@ void MyMain(vtkMultiProcessController *controller, void *arg)
113115
val = (myid+1) / static_cast<float>(numProcs);
114116
elev->SetScalarRange(val, val+0.001);
115117

116-
// Tell the pipeline which piece we want to update.
117-
vtkStreamingDemandDrivenPipeline *exec =
118-
vtkStreamingDemandDrivenPipeline::SafeDownCast(elev->GetExecutive());
119-
exec->SetUpdateNumberOfPieces(exec->GetOutputInformation(0), numProcs);
120-
exec->SetUpdatePiece(exec->GetOutputInformation(0), myid);
121-
122118
// Make sure all processes update at the same time.
123-
elev->Update();
119+
elev->Update(myid, numProcs, 0);
124120

125121
if (myid != 0)
126122
{
@@ -168,7 +164,7 @@ void MyMain(vtkMultiProcessController *controller, void *arg)
168164
{
169165
// Set the local value
170166
contour->SetIsoValue(contour->GetIsoValue() + ISO_STEP);
171-
elev->Update();
167+
elev->Update(myid, numProcs, 0);
172168

173169
for (int i = 1; i < numProcs; ++i)
174170
{

Accelerators/Piston/vtkPistonMapper.cxx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,18 +588,18 @@ void vtkPistonMapper::Update()
588588
{
589589
this->UpdateInformation();
590590

591-
vtkInformation* inInfo = this->GetInputInformation();
591+
// vtkInformation* inInfo = this->GetInputInformation();
592592

593593
// If the estimated pipeline memory usage is larger than
594594
// the memory limit, break the current piece into sub-pieces.
595-
if (inInfo)
596-
{
597-
vtkStreamingDemandDrivenPipeline::SetUpdateExtent(
598-
inInfo,
599-
this->Piece,
600-
this->NumberOfPieces,
601-
this->GhostLevel);
602-
}
595+
// if (inInfo)
596+
// {
597+
// vtkStreamingDemandDrivenPipeline::SetUpdateExtent(
598+
// inInfo,
599+
// this->Piece,
600+
// this->NumberOfPieces,
601+
// this->GhostLevel);
602+
// }
603603

604604
this->vtkMapper::Update();
605605
}

Common/Core/vtkInformation.cxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ void vtkInformation::Copy(vtkInformation* from, int deep)
214214
delete oldInternal;
215215
}
216216

217+
//----------------------------------------------------------------------------
218+
void vtkInformation::Append(vtkInformation* from, int deep)
219+
{
220+
if(from)
221+
{
222+
typedef vtkInformationInternals::MapType MapType;
223+
for(MapType::const_iterator i = from->Internal->Map.begin();
224+
i != from->Internal->Map.end(); ++i)
225+
{
226+
this->CopyEntry(from, i->first, deep);
227+
}
228+
}
229+
}
230+
217231
//----------------------------------------------------------------------------
218232
void vtkInformation::CopyEntry(vtkInformation* from,
219233
vtkInformationKey* key, int deep)

Common/Core/vtkInformation.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ class VTK_INFORMATION_EXPORT vtkInformation : public vtkObject
107107
// objects are created).
108108
VTKCOMMONCORE_EXPORT void Copy(vtkInformation* from, int deep=0);
109109

110+
// Description:
111+
// Append all information entries from the given vtkInformation
112+
// instance. If deep==1, a deep copy of the information structure is performed
113+
// (new instances of any contained vtkInformation and vtkInformationVector
114+
// objects are created).
115+
VTKCOMMONCORE_EXPORT void Append(vtkInformation* from, int deep=0);
116+
110117
// Description:
111118
// Copy the key/value pair associated with the given key in the
112119
// given information object. If deep=1, a deep copy of the information

Common/ExecutionModel/Testing/Cxx/TestCopyAttributeData.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ int TestCopyAttributeData(int,char *[])
138138

139139
for (int r = 0; r < 2; r++)
140140
{
141-
filter->UpdateInformation();
142-
filter->SetUpdateExtent(outExt);
143-
filter->Update();
141+
filter->UpdateExtent(outExt);
144142

145143
vtkImageData *output = filter->GetOutput();
146144

Common/ExecutionModel/vtkAlgorithm.cxx

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "vtkCompositeDataPipeline.h"
4242
#include "vtkTable.h"
4343
#include "vtkTrivialProducer.h"
44+
#include "vtkNew.h"
4445

4546
#include <set>
4647
#include <vector>
@@ -1455,6 +1456,77 @@ void vtkAlgorithm::Update(int port)
14551456
this->GetExecutive()->Update(port);
14561457
}
14571458

1459+
//----------------------------------------------------------------------------
1460+
int vtkAlgorithm::Update(int port, vtkInformationVector* requests)
1461+
{
1462+
vtkStreamingDemandDrivenPipeline* sddp =
1463+
vtkStreamingDemandDrivenPipeline::SafeDownCast(this->GetExecutive());
1464+
if (sddp)
1465+
{
1466+
return sddp->Update(port, requests);
1467+
}
1468+
else
1469+
{
1470+
return this->GetExecutive()->Update(port);
1471+
}
1472+
}
1473+
1474+
//----------------------------------------------------------------------------
1475+
int vtkAlgorithm::Update(vtkInformation* requests)
1476+
{
1477+
vtkNew<vtkInformationVector> reqs;
1478+
reqs->SetInformationObject(0, requests);
1479+
return this->Update(0, reqs.GetPointer());
1480+
}
1481+
1482+
//----------------------------------------------------------------------------
1483+
int vtkAlgorithm::UpdatePiece(
1484+
int piece, int numPieces, int ghostLevels, int* extents)
1485+
{
1486+
typedef vtkStreamingDemandDrivenPipeline vtkSDDP;
1487+
1488+
vtkNew<vtkInformation> reqs;
1489+
reqs->Set(vtkSDDP::UPDATE_PIECE_NUMBER(), piece);
1490+
reqs->Set(vtkSDDP::UPDATE_NUMBER_OF_PIECES(), numPieces);
1491+
reqs->Set(vtkSDDP::UPDATE_NUMBER_OF_GHOST_LEVELS(), ghostLevels);
1492+
if (extents)
1493+
{
1494+
reqs->Set(vtkSDDP::UPDATE_EXTENT(), extents, 6);
1495+
}
1496+
return this->Update(reqs.GetPointer());
1497+
}
1498+
1499+
//----------------------------------------------------------------------------
1500+
int vtkAlgorithm::UpdateExtent(int* extents)
1501+
{
1502+
typedef vtkStreamingDemandDrivenPipeline vtkSDDP;
1503+
1504+
vtkNew<vtkInformation> reqs;
1505+
reqs->Set(vtkSDDP::UPDATE_EXTENT(), extents, 6);
1506+
return this->Update(reqs.GetPointer());
1507+
}
1508+
1509+
//----------------------------------------------------------------------------
1510+
int vtkAlgorithm::UpdateTimeStep(
1511+
double time, int piece, int numPieces, int ghostLevels, int* extents)
1512+
{
1513+
typedef vtkStreamingDemandDrivenPipeline vtkSDDP;
1514+
1515+
vtkNew<vtkInformation> reqs;
1516+
reqs->Set(vtkSDDP::UPDATE_TIME_STEP(), time);
1517+
if (piece >= 0)
1518+
{
1519+
reqs->Set(vtkSDDP::UPDATE_PIECE_NUMBER(), piece);
1520+
reqs->Set(vtkSDDP::UPDATE_NUMBER_OF_PIECES(), numPieces);
1521+
reqs->Set(vtkSDDP::UPDATE_NUMBER_OF_GHOST_LEVELS(), ghostLevels);
1522+
}
1523+
if (extents)
1524+
{
1525+
reqs->Set(vtkSDDP::UPDATE_EXTENT(), extents, 6);
1526+
}
1527+
return this->Update(reqs.GetPointer());
1528+
}
1529+
14581530
//----------------------------------------------------------------------------
14591531
void vtkAlgorithm::PropagateUpdateExtent()
14601532
{
@@ -1490,7 +1562,6 @@ void vtkAlgorithm::UpdateDataObject()
14901562
}
14911563
}
14921564

1493-
14941565
//----------------------------------------------------------------------------
14951566
void vtkAlgorithm::UpdateWholeExtent()
14961567
{
@@ -1658,9 +1729,17 @@ void vtkAlgorithm::SetProgressText(const char* ptext)
16581729
}
16591730
}
16601731

1732+
// This is here to shut off warnings about deprecated functions
1733+
// calling deprecated functions.
1734+
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
1735+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1736+
#endif
1737+
1738+
#ifndef VTK_LEGACY_REMOVE
16611739
//-------------------------------------------------------------
16621740
int vtkAlgorithm::SetUpdateExtentToWholeExtent(int port)
16631741
{
1742+
VTK_LEGACY_BODY(vtkAlgorithm::SetUpdateExtentToWholeExtent, "VTK 7.1");
16641743
if (this->GetOutputInformation(port))
16651744
{
16661745
return
@@ -1676,6 +1755,7 @@ int vtkAlgorithm::SetUpdateExtentToWholeExtent(int port)
16761755
//-------------------------------------------------------------
16771756
int vtkAlgorithm::SetUpdateExtentToWholeExtent()
16781757
{
1758+
VTK_LEGACY_BODY(vtkAlgorithm::SetUpdateExtentToWholeExtent, "VTK 7.1");
16791759
return this->SetUpdateExtentToWholeExtent(0);
16801760
}
16811761

@@ -1685,6 +1765,7 @@ void vtkAlgorithm::SetUpdateExtent(int port,
16851765
int numPieces,
16861766
int ghostLevel)
16871767
{
1768+
VTK_LEGACY_BODY(vtkAlgorithm::SetUpdateExtent, "VTK 7.1");
16881769
if (this->GetOutputInformation(port))
16891770
{
16901771
vtkStreamingDemandDrivenPipeline::SetUpdateExtent(
@@ -1695,10 +1776,20 @@ void vtkAlgorithm::SetUpdateExtent(int port,
16951776
}
16961777
}
16971778

1779+
//-------------------------------------------------------------
1780+
void vtkAlgorithm::SetUpdateExtent(int piece,
1781+
int numPieces,
1782+
int ghostLevel)
1783+
{
1784+
VTK_LEGACY_BODY(vtkAlgorithm::SetUpdateExtent, "VTK 7.1");
1785+
this->SetUpdateExtent(0, piece, numPieces, ghostLevel);
1786+
}
1787+
16981788
//-------------------------------------------------------------
16991789
void vtkAlgorithm::SetUpdateExtent(int port,
17001790
int extent[6])
17011791
{
1792+
VTK_LEGACY_BODY(vtkAlgorithm::SetUpdateExtent, "VTK 7.1");
17021793
if (this->GetOutputInformation(port))
17031794
{
17041795
vtkStreamingDemandDrivenPipeline::SetUpdateExtent(
@@ -1707,6 +1798,15 @@ void vtkAlgorithm::SetUpdateExtent(int port,
17071798
}
17081799
}
17091800

1801+
//-------------------------------------------------------------
1802+
void vtkAlgorithm::SetUpdateExtent(int extent[6])
1803+
{
1804+
VTK_LEGACY_BODY(vtkAlgorithm::SetUpdateExtent, "VTK 7.1");
1805+
this->SetUpdateExtent(0, extent);
1806+
}
1807+
1808+
#endif // VTK_LEGACY_REMOVE
1809+
17101810
//----------------------------------------------------------------------------
17111811
int* vtkAlgorithm::GetUpdateExtent(int port)
17121812
{

Common/ExecutionModel/vtkAlgorithm.h

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,56 @@ class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
459459
virtual void Update(int port);
460460
virtual void Update();
461461

462+
// Description:
463+
// This method enables the passing of data requests to the algorithm
464+
// to be used during execution (in addition to bringing a particular
465+
// port up-to-date). The requests argument should contain an information
466+
// object for each port that requests need to be passed. For each
467+
// of those, the pipeline will copy all keys to the output information
468+
// before execution. This is equivalent to:
469+
// \verbatim
470+
// algorithm->UpdateInformation();
471+
// for (int i=0; i<algorithm->GetNumberOfOutputPorts(); i++)
472+
// {
473+
// vtkInformation* portRequests = requests->GetInformationObject(i);
474+
// if (portRequests)
475+
// {
476+
// algorithm->GetOutputInformation(i)->Append(portRequests);
477+
// }
478+
// }
479+
// algorithm->Update();
480+
// \endverbatim
481+
// Available requests include UPDATE_PIECE_NUMBER(), UPDATE_NUMBER_OF_PIECES()
482+
// UPDATE_EXTENT() etc etc.
483+
virtual int Update(int port, vtkInformationVector* requests);
484+
485+
// Description:
486+
// Convenience method to update an algorithm after passing requests
487+
// to its first output port. See documentation for
488+
// Update(int port, vtkInformationVector* requests) for details.
489+
virtual int Update(vtkInformation* requests);
490+
491+
// Description:
492+
// Convenience method to update an algorithm after passing requests
493+
// to its first output port. See documentation for
494+
// Update(int port, vtkInformationVector* requests) for details.
495+
// Supports piece and extent (optional) requests.
496+
virtual int UpdatePiece(
497+
int piece, int numPieces, int ghostLevels, int* extents=0);
498+
499+
// Description:
500+
// Convenience method to update an algorithm after passing requests
501+
// to its first output port.
502+
// Supports extent request.
503+
virtual int UpdateExtent(int* extents);
504+
505+
// Description:
506+
// Convenience method to update an algorithm after passing requests
507+
// to its first output port. See documentation for
508+
// Update(int port, vtkInformationVector* requests) for details.
509+
// Supports time, piece (optional) and extent (optional) requests.
510+
virtual int UpdateTimeStep(double time,
511+
int piece=-1, int numPieces=1, int ghostLevels=0, int* extents=0);
462512

463513
// Description:
464514
// Bring the algorithm's information up-to-date.
@@ -513,37 +563,32 @@ class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
513563
// If the whole output extent is required, this method can be called to set
514564
// the output update extent to the whole extent. This method assumes that
515565
// the whole extent is known (that UpdateInformation has been called).
516-
int SetUpdateExtentToWholeExtent(int port);
566+
VTK_LEGACY(int SetUpdateExtentToWholeExtent(int port));
517567

518568
// Description:
519569
// Convenience function equivalent to SetUpdateExtentToWholeExtent(0)
520570
// This method assumes that the whole extent is known (that UpdateInformation
521571
// has been called).
522-
int SetUpdateExtentToWholeExtent();
572+
VTK_LEGACY(int SetUpdateExtentToWholeExtent());
523573

524574
// Description:
525575
// Set the output update extent in terms of piece and ghost levels.
526-
void SetUpdateExtent(int port,
527-
int piece,int numPieces, int ghostLevel);
576+
VTK_LEGACY(void SetUpdateExtent(int port,
577+
int piece,int numPieces, int ghostLevel));
528578

529579
// Description:
530580
// Convenience function equivalent to SetUpdateExtent(0, piece,
531581
// numPieces, ghostLevel)
532-
void SetUpdateExtent(int piece,int numPieces, int ghostLevel)
533-
{
534-
this->SetUpdateExtent(0, piece, numPieces, ghostLevel);
535-
}
582+
VTK_LEGACY(void SetUpdateExtent(
583+
int piece,int numPieces, int ghostLevel));
536584

537585
// Description:
538586
// Set the output update extent for data objects that use 3D extents
539-
void SetUpdateExtent(int port, int extent[6]);
587+
VTK_LEGACY(void SetUpdateExtent(int port, int extent[6]));
540588

541589
// Description:
542590
// Convenience function equivalent to SetUpdateExtent(0, extent)
543-
void SetUpdateExtent(int extent[6])
544-
{
545-
this->SetUpdateExtent(0, extent);
546-
}
591+
VTK_LEGACY(void SetUpdateExtent(int extent[6]));
547592

548593
// Description:
549594
// These functions return the update extent for output ports that

0 commit comments

Comments
 (0)