Commit f47b8760 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

BUG: Do not initialize the PI multiple times

parent 32e11d63
......@@ -305,13 +305,18 @@ class StaticPointLocator::PointIteratorMethods
public:
using CoordType = typename SearchStructureXOType::CoordArrayType::ValueType;
PointIteratorMethods(PointIteratorType* pi, const SearchStructureXOType* ss)
PointIteratorMethods(PointIteratorType* pi,
const SearchStructureXOType* ss,
bool initialize = true)
{
m_PIData = pi;
m_locator = ss;
m_PIData->m_pointIJK = m_locator->ComputeBucketIJK(m_PIData->m_point);
this->InitializeIteration();
if (initialize)
{
m_PIData->m_pointIJK = m_locator->ComputeBucketIJK(m_PIData->m_point);
this->InitializeIteration();
}
}
VTKM_EXEC
......@@ -703,8 +708,8 @@ public:
m_locator = search;
// Assumption is that the point is set already
m_PIData->m_pointIJK = m_locator->ComputeBucketIJK(m_PIData->m_point);
this->InitializeIteration();
//m_PIData->m_pointIJK = m_locator->ComputeBucketIJK(m_PIData->m_point);
//this->InitializeIteration();
}
/// Update (always decrease) the search distance.
......@@ -992,7 +997,7 @@ void StaticPointLocator::Run(vtkm::cont::ArrayHandle<CoordType, Storage> pointCo
// degenerate case where all the points are at (0., 0., 0.)
if (minNudge == std::numeric_limits<vtkm::FloatDefault>::max())
{
minNudge = 0.25;
minNudge = 0.25;
}
// edge cases
......@@ -1009,7 +1014,7 @@ void StaticPointLocator::Run(vtkm::cont::ArrayHandle<CoordType, Storage> pointCo
boxHi[ii] += nudge[ii];
}
}
// Construct the bucket offsets and point-ids arrays.
this->Run(pointCoords, boxLo, boxHi, divs, bucketPointIds, bucketIds, bucketOffsets, device);
......
......@@ -756,7 +756,7 @@ public:
const vtkm::Id4& counts) const
{
auto iter =
StaticPointLocator::PointIteratorMethods<SearchType, PointIterType>(&iterData, &locator);
StaticPointLocator::PointIteratorMethods<SearchType, PointIterType>(&iterData, &locator, false);
(void)generatorSrcId;
(void)counts;
......@@ -997,7 +997,7 @@ public:
Iter& iterData,
const Search& search) const
{
auto iter = StaticPointLocator::PointIteratorMethods<Search, Iter>(&iterData, &search);
auto iter = StaticPointLocator::PointIteratorMethods<Search, Iter>(&iterData, &search, false);
iter.SetLocator(&search);
state.m_complete.Set(generatorId, iter.IsValid() ? 0 : 1);
......@@ -1214,7 +1214,7 @@ public:
Iter& iterData,
const Search& search) const
{
auto iter = StaticPointLocator::PointIteratorMethods<Search, Iter>(&iterData, &search);
auto iter = StaticPointLocator::PointIteratorMethods<Search, Iter>(&iterData, &search, false);
// If we do not have a clipping plane, then we are done:
iter.SetLocator(&search);
......@@ -1776,7 +1776,7 @@ Voronoi::Diagram Voronoi::Construct(
// A. Update the per-Voronoi-cell blossom search radius every so often.
// This requires work linear in O(state.m_points) and we start with
// a valid value, so don't immediately update when iteration == 0.
if (iteration % 4 == 3)
//if (iteration % 4 == 3)
{
#ifdef VTKM_BENCHMARK_VORONOI
timer.Reset();
......@@ -1837,7 +1837,7 @@ Voronoi::Diagram Voronoi::Construct(
accumExtractComplete += elapsed;
#endif
std::cout << "Cell totals " << cellTotals << "\n";
std::cout << "Cell totals " << cellTotals << "\n\n" << std::endl;
if (cellTotals[3] > 0)
{
m_diagram.AddBlock(outputState.createOutput(DeviceAdapter()));
......@@ -1857,9 +1857,9 @@ Voronoi::Diagram Voronoi::Construct(
{
std::cout << " " << xx << " " << port.Get(xx) << "\n";
}
std::cout << "VI.E. Run PrepareToClip on " << inputPointIds.GetNumberOfValues()
std::cout << "Running PrepareToClip on " << inputPointIds.GetNumberOfValues()
<< " generators."
<< "\n";
<< "\n\n" << std::endl;
}
PrepareToClipCells<CoordType> prepareToClip;
......@@ -1867,6 +1867,9 @@ Voronoi::Diagram Voronoi::Construct(
prepareToClip);
prepareToClipDispatch.Invoke(inputPointIds, state, pointIters, search);
// F. Turn the counts into offsets and allocate new arrays to hold
// points, neighbors, and loop offsets.
{
std::cout << "VI.F. # " << iteration << " remain "
<< state.m_cellLoopNext.GetNumberOfValues() << "\n";
......@@ -1875,10 +1878,9 @@ Voronoi::Diagram Voronoi::Construct(
{
std::cout << " " << xx << " " << port.Get(xx) << "\n";
}
std::cout << "\n" << std::endl;
}
// F. Turn the counts into offsets and allocate new arrays to hold
// points, neighbors, and loop offsets.
vtkm::Id nextCellLoopOffsetsSize =
DeviceAlg::ScanExclusive(state.m_cellLoopNext, state.m_cellLoopNext);
state.m_nextLoopOffsets.Allocate(nextCellLoopOffsetsSize);
......@@ -1941,6 +1943,7 @@ Voronoi::Diagram Voronoi::Construct(
{
std::cout << " " << xx << " " << port.Get(xx) << "\n";
}
std::cout << "\n" << std::endl;
}
// Now trim completed stuff from input arrays
......@@ -1963,7 +1966,7 @@ Voronoi::Diagram Voronoi::Construct(
#endif
ng = inputPointIds.GetNumberOfValues();
std::cout << "----------------------------------------" << std::endl;
std::cout << "----------------------------------------\n\n" << std::endl;
}
#ifdef VTKM_BENCHMARK_VORONOI
std::cout << " Update blossom radii: " << accumBlossomUpdate << " ("
......
......@@ -38,7 +38,7 @@
namespace
{
static int npts = 1000;
static std::string distribution = "lissajous";//lissajous";
static std::string distribution = "two";//"lissajous";//lissajous";
static vtkm::Id singleGeneratorId = -1;
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
......@@ -128,7 +128,7 @@ void TestVoronoi()
coordinates.Allocate(2);
auto port = coordinates.GetPortalControl();
port.Set(0, PointType{ -1., 0., 0. });
port.Set(1, PointType{ 0., 0., 1. });
port.Set(1, PointType{ 1., 0., 0. });
vtkm::cont::ArrayHandle<vtkm::Id> conn;
conn.Allocate(2);
......
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