Add a release resources API to CellSet and its derived classes

This commit is contained in:
Haocheng LIU 2018-05-30 14:32:06 -04:00
parent 3126037306
commit 86f22bf47f
7 changed files with 40 additions and 0 deletions

@ -70,6 +70,8 @@ public:
virtual void PrintSummary(std::ostream&) const = 0;
virtual void ReleaseResourcesExecution() = 0;
protected:
std::string Name;
};

@ -111,6 +111,7 @@ public:
vtkm::Id GetNumberOfFaces() const override;
vtkm::Id GetNumberOfEdges() const override;
void PrintSummary(std::ostream& out) const override;
void ReleaseResourcesExecution() override;
VTKM_CONT vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagCell) const;
VTKM_CONT vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagPoint) const;

@ -101,6 +101,19 @@ void CellSetExplicit<ShapeStorageTag,
this->CellToPoint.PrintSummary(out);
}
template <typename ShapeStorageTag,
typename NumIndicesStorageTag,
typename ConnectivityStorageTag,
typename OffsetStorageTag>
void CellSetExplicit<ShapeStorageTag,
NumIndicesStorageTag,
ConnectivityStorageTag,
OffsetStorageTag>::ReleaseResourcesExecution()
{
this->PointToCell.ReleaseResourcesExecution();
this->CellToPoint.ReleaseResourcesExecution();
}
//----------------------------------------------------------------------------
template <typename ShapeStorageTag,

@ -205,6 +205,15 @@ public:
VTKM_CONT
vtkm::Id GetNumberOfEdges() const override { return -1; }
VTKM_CONT
void ReleaseResourcesExecution() override
{
this->ValidCellIds.ReleaseResourcesExecution();
this->FullCellSet.ReleaseResourcesExecution();
this->CellToPoint.ReleaseResourcesExecution();
}
VTKM_CONT
vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id cellIndex) const
{

@ -63,6 +63,9 @@ public:
virtual vtkm::Id GetNumberOfEdges() const { return -1; }
// Since the entire topology is defined by by three integers, nothing to do here.
virtual void ReleaseResourcesExecution() override {}
void SetPointDimensions(SchedulingRangeType dimensions)
{
this->Structure.SetPointDimensions(dimensions);

@ -153,6 +153,12 @@ void TestCellSetExplicit()
{
VTKM_TEST_ASSERT(result.GetPortalConstControl().Get(i) == expected2[i], "incorrect result");
}
std::cout << "Testing resource releasing in CellSetExplicit:\n";
cellset.ReleaseResourcesExecution();
VTKM_TEST_ASSERT(cellset.GetNumberOfCells() == ArrayLength(g_numIndices) / 2,
"release execution resources should not change the number of cells");
VTKM_TEST_ASSERT(cellset.GetNumberOfPoints() == ArrayLength(expected2),
"release execution resources should not change the number of points");
}
} // anonymous namespace

@ -151,6 +151,12 @@ vtkm::cont::CellSetPermutation<CellSetType, vtkm::cont::ArrayHandleCounting<vtkm
VTKM_TEST_ASSERT(result.GetPortalConstControl().Get(i) == expected[static_cast<std::size_t>(i)],
"incorrect result");
}
std::cout << "Testing resource releasing in CellSetPermutation:\n";
cs.ReleaseResourcesExecution();
VTKM_TEST_ASSERT(cs.GetNumberOfCells() == cellset.GetNumberOfCells() / 2,
"release execution resources should not change the number of cells");
VTKM_TEST_ASSERT(cs.GetNumberOfPoints() == cellset.GetNumberOfPoints(),
"release execution resources should not change the number of points");
return cs;
}