Commit 7c258410 authored by Haocheng LIU's avatar Haocheng LIU Committed by Kitware Robot

Merge topic 'Add-unload-execution-resources-CellSet'

86f22bf4 Add a release resources API to CellSet and its derived classes
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1238
parents 15f0c9e2 86f22bf4
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment