Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit e0296a24 authored by Abhishek Yenpure's avatar Abhishek Yenpure Committed by Abhishek Yenpure

Fixes for resolving Rob's suggestions

- Releasing GPU resources when not needed.
- Adding VTK_EXEC to TreeNode and SplitProperties constructors
parent dcbb444a
......@@ -84,6 +84,8 @@ public:
BoundingIntervalHierarchy(vtkm::IdComponent numPlanes = 4, vtkm::IdComponent maxLeafSize = 5)
: NumPlanes(numPlanes)
, MaxLeafSize(maxLeafSize)
, Nodes()
, ProcessedCellIds()
{
}
......
......@@ -155,20 +155,27 @@ VTKM_CONT void BoundingIntervalHierarchy::CalculatePlaneSplitCost(
vtkm::cont::ArrayHandle<vtkm::Id> pointsToRight;
Algorithms::ReduceByKey(segmentIds, isROfSplitPlane, discardKeys, pointsToRight, vtkm::Add());
// Calculate Lmax and Rmin
vtkm::cont::ArrayHandle<vtkm::Range> leqRanges;
vtkm::cont::ArrayHandle<vtkm::Range> rRanges;
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::FilterRanges<true>>().Invoke(
coords, splitPlanes, ranges, leqRanges);
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::FilterRanges<false>>().Invoke(
coords, splitPlanes, ranges, rRanges);
isLEQOfSplitPlane.ReleaseResourcesExecution();
isROfSplitPlane.ReleaseResourcesExecution();
// Calculate Lmax and Rmin
vtkm::cont::ArrayHandle<vtkm::Range> lMaxRanges;
{
vtkm::cont::ArrayHandle<vtkm::Range> leqRanges;
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::FilterRanges<true>>().Invoke(
coords, splitPlanes, ranges, leqRanges);
Algorithms::ReduceByKey(
segmentIds, leqRanges, discardKeys, lMaxRanges, vtkm::worklet::spatialstructure::RangeAdd());
}
vtkm::cont::ArrayHandle<vtkm::Range> rMinRanges;
Algorithms::ReduceByKey(
segmentIds, leqRanges, discardKeys, lMaxRanges, vtkm::worklet::spatialstructure::RangeAdd());
Algorithms::ReduceByKey(
segmentIds, rRanges, discardKeys, rMinRanges, vtkm::worklet::spatialstructure::RangeAdd());
{
vtkm::cont::ArrayHandle<vtkm::Range> rRanges;
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::FilterRanges<false>>()
.Invoke(coords, splitPlanes, ranges, rRanges);
Algorithms::ReduceByKey(
segmentIds, rRanges, discardKeys, rMinRanges, vtkm::worklet::spatialstructure::RangeAdd());
}
vtkm::cont::ArrayHandle<vtkm::FloatDefault> segmentedSplitPlanes;
Algorithms::ReduceByKey(
......@@ -177,6 +184,7 @@ VTKM_CONT void BoundingIntervalHierarchy::CalculatePlaneSplitCost(
// Calculate costs
vtkm::worklet::spatialstructure::SplitPropertiesCalculator splitPropertiesCalculator(
index, NumPlanes + 1);
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::SplitPropertiesCalculator>(
splitPropertiesCalculator)
.Invoke(pointsToLeft, pointsToRight, lMaxRanges, rMinRanges, segmentedSplitPlanes, splits);
......@@ -313,6 +321,10 @@ public:
segmentZRanges, zRanges, centerZs, segmentIds, zSplits, DeviceAdapter());
//PRINT_TIMER("2.2", s22);
segmentXRanges.ReleaseResourcesExecution();
segmentYRanges.ReleaseResourcesExecution();
segmentZRanges.ReleaseResourcesExecution();
//START_TIMER(s23);
// Select best split plane and dimension across X, Y, Z dimension, per segment
SplitArrayHandle segmentSplits;
......
......@@ -51,6 +51,7 @@ struct TreeNode
vtkm::FloatDefault RMin;
vtkm::IdComponent Dimension;
VTKM_EXEC
TreeNode()
: LMax()
, RMin()
......@@ -68,6 +69,7 @@ struct SplitProperties
vtkm::FloatDefault RMin;
vtkm::FloatDefault Cost;
VTKM_EXEC
SplitProperties()
: Plane()
, NumLeftPoints()
......@@ -138,7 +140,10 @@ public:
}; // struct LEQWorklet
template <bool LEQ>
struct FilterRanges : public vtkm::worklet::WorkletMapField
struct FilterRanges;
template <>
struct FilterRanges<true> : public vtkm::worklet::WorkletMapField
{
public:
typedef void ControlSignature(FieldIn<>, FieldIn<>, FieldIn<>, FieldOut<>);
......@@ -151,14 +156,25 @@ public:
const vtkm::Range& cellBounds,
vtkm::Range& outBounds) const
{
if (LEQ)
{
outBounds = (value <= planeValue) ? cellBounds : vtkm::Range();
}
else
{
outBounds = (value > planeValue) ? cellBounds : vtkm::Range();
}
outBounds = (value <= planeValue) ? cellBounds : vtkm::Range();
}
}; // struct FilterRanges
template <>
struct FilterRanges<false> : public vtkm::worklet::WorkletMapField
{
public:
typedef void ControlSignature(FieldIn<>, FieldIn<>, FieldIn<>, FieldOut<>);
typedef void ExecutionSignature(_1, _2, _3, _4);
using InputDomain = _1;
VTKM_EXEC
void operator()(const vtkm::FloatDefault& value,
const vtkm::FloatDefault& planeValue,
const vtkm::Range& cellBounds,
vtkm::Range& outBounds) const
{
outBounds = (value > planeValue) ? cellBounds : vtkm::Range();
}
}; // struct FilterRanges
......
......@@ -100,7 +100,7 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet, vtkm::IdComponen
std::cout << "Default stack size " << stackSizeBackup << "\n";
cudaDeviceSetLimit(cudaLimitStackSize, 1024 * 200);
cudaDeviceSetLimit(cudaLimitStackSize, 1024 * 50);
#endif
vtkm::worklet::DispatcherMapField<BoundingIntervalHierarchyTester>().Invoke(
......
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