Commit d0fa70de authored by Allison Vacanti's avatar Allison Vacanti

Reduce overhead and fix bugs in device adapter benchmarks.

parent 05419719
......@@ -269,17 +269,18 @@ private:
VTKM_CONT
BenchCopy()
{
ValueHandle_src.PrepareForOutput(Config.ComputeSize<Value>(), DeviceAdapterTag());
ValueHandle_dst.PrepareForOutput(Config.ComputeSize<Value>(), DeviceAdapterTag());
vtkm::Id arraySize = Config.ComputeSize<Value>();
this->ValueHandle_src.Allocate(arraySize);
auto portal = this->ValueHandle_src.GetPortalControl();
for (vtkm::Id i = 0; i < portal.GetNumberOfValues(); ++i)
{
portal.Set(vtkm::Id(i), TestValue(vtkm::Id(Rng()), Value()));
}
}
VTKM_CONT
vtkm::Float64 operator()()
{
for (vtkm::Id i = 0; i < ValueHandle_src.GetNumberOfValues(); ++i)
{
ValueHandle_src.GetPortalControl().Set(vtkm::Id(i), TestValue(vtkm::Id(Rng()), Value()));
}
Timer timer;
Algorithm::Copy(ValueHandle_src, ValueHandle_dst);
return timer.GetElapsedTime();
......@@ -593,17 +594,24 @@ private:
std::mt19937 Rng;
VTKM_CONT
BenchSort() { ValueHandle.PrepareForOutput(Config.ComputeSize<Value>(), DeviceAdapterTag()); }
BenchSort()
{
this->ValueHandle.Allocate(Config.ComputeSize<Value>());
auto portal = this->ValueHandle.GetPortalControl();
for (vtkm::Id i = 0; i < portal.GetNumberOfValues(); ++i)
{
portal.Set(vtkm::Id(i), TestValue(vtkm::Id(Rng()), Value()));
}
}
VTKM_CONT
vtkm::Float64 operator()()
{
for (vtkm::Id i = 0; i < ValueHandle.GetNumberOfValues(); ++i)
{
ValueHandle.GetPortalControl().Set(vtkm::Id(i), TestValue(vtkm::Id(Rng()), Value()));
}
ValueArrayHandle array;
Algorithm::Copy(this->ValueHandle, array);
Timer timer;
Algorithm::Sort(ValueHandle);
Algorithm::Sort(array);
return timer.GetElapsedTime();
}
......@@ -635,22 +643,28 @@ private:
: N_KEYS((Config.ComputeSize<Value>() * percent_key) / 100)
, PERCENT_KEYS(percent_key)
{
ValueHandle.PrepareForOutput(Config.ComputeSize<Value>(), DeviceAdapterTag());
}
VTKM_CONT
vtkm::Float64 operator()()
{
for (vtkm::Id i = 0; i < ValueHandle.GetNumberOfValues(); ++i)
vtkm::Id arraySize = Config.ComputeSize<Value>();
this->ValueHandle.Allocate(arraySize);
auto portal = this->ValueHandle.GetPortalControl();
for (vtkm::Id i = 0; i < portal.GetNumberOfValues(); ++i)
{
ValueHandle.GetPortalControl().Set(vtkm::Id(i), TestValue(vtkm::Id(Rng()), Value()));
portal.Set(vtkm::Id(i), TestValue(vtkm::Id(Rng()), Value()));
}
vtkm::Id arraySize = Config.ComputeSize<Value>();
Algorithm::Schedule(FillModuloTestValueKernel<vtkm::Id>(
N_KEYS, KeyHandle.PrepareForOutput(arraySize, DeviceAdapterTag())),
arraySize);
}
VTKM_CONT
vtkm::Float64 operator()()
{
IdArrayHandle keys;
ValueArrayHandle values;
Algorithm::Copy(this->KeyHandle, keys);
Algorithm::Copy(this->ValueHandle, values);
Timer timer;
Algorithm::SortByKey(ValueHandle, KeyHandle);
Algorithm::SortByKey(keys, values);
return timer.GetElapsedTime();
}
......@@ -792,19 +806,22 @@ private:
BenchUnique(vtkm::Id percent_valid)
: N_VALID((Config.ComputeSize<Value>() * percent_valid) / 100)
, PERCENT_VALID(percent_valid)
{
}
VTKM_CONT
vtkm::Float64 operator()()
{
vtkm::Id arraySize = Config.ComputeSize<Value>();
Algorithm::Schedule(FillModuloTestValueKernel<Value>(
N_VALID, ValueHandle.PrepareForOutput(arraySize, DeviceAdapterTag())),
arraySize);
Algorithm::Sort(ValueHandle);
}
VTKM_CONT
vtkm::Float64 operator()()
{
ValueArrayHandle array;
Algorithm::Copy(this->ValueHandle, array);
Timer timer;
Algorithm::Unique(ValueHandle);
Algorithm::Unique(array);
return timer.GetElapsedTime();
}
......
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