Commit 415252c6 authored by Haocheng LIU's avatar Haocheng LIU

Introduce asynchronous and device independent timer

The timer class now is asynchronous and device independent. it's using an
similiar API as vtkOpenGLRenderTimer with Start(), Stop(), Reset(), Ready(),
and GetElapsedTime() function. For convenience and backward compability, Each
Start() function call will call Reset() internally and each GetElapsedTime()
function call will call Stop() function if it hasn't been called yet for keeping
backward compatibility purpose.

Bascially it can be used in two modes:

* Create a Timer without any device info. vtkm::cont::Timer time;

  * It would enable timers for all enabled devices on the machine. Users can get a
specific elapsed time by passing a device id into the GetElapsedtime function.
If no device is provided, it would pick the maximum of all timer results - the
logic behind this decision is that if cuda is disabled, openmp, serial and tbb
roughly give the same results; if cuda is enabled it's safe to return the
maximum elapsed time since users are more interested in the device execution
time rather than the kernal launch time. The Ready function can be handy here
to query the status of the timer.

* Create a Timer with a device id. vtkm::cont::Timer time((vtkm::cont::DeviceAdapterTagCuda()));

  * It works as the old timer that times for a specific device id.
parent 610bfc21
......@@ -45,7 +45,7 @@ struct BenchmarkArrayTransfer
{
using Algo = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
using StorageTag = vtkm::cont::StorageTagBasic;
using Timer = vtkm::cont::Timer<DeviceAdapter>;
using Timer = vtkm::cont::Timer;
//------------- Functors for benchmarks --------------------------------------
......@@ -171,7 +171,8 @@ struct BenchmarkArrayTransfer
ArrayType array = vtkm::cont::make_ArrayHandle(vec);
// Time the copy:
Timer timer;
Timer timer{ DeviceAdapter() };
timer.Start();
ReadValues<PortalType> functor(array.PrepareForInput(DeviceAdapter()),
ValueTypeTraits::ZeroInitialization());
Algo::Schedule(functor, this->NumValues);
......@@ -212,9 +213,11 @@ struct BenchmarkArrayTransfer
ArrayType array;
// Time the write:
Timer timer;
Timer timer{ DeviceAdapter() };
timer.Start();
WriteValues<PortalType> functor(array.PrepareForOutput(this->NumValues, DeviceAdapter()));
Algo::Schedule(functor, this->NumValues);
return timer.GetElapsedTime();
}
};
......@@ -254,7 +257,8 @@ struct BenchmarkArrayTransfer
ArrayType array = vtkm::cont::make_ArrayHandle(vec);
// Time the copy:
Timer timer;
Timer timer{ DeviceAdapter() };
timer.Start();
ReadWriteValues<PortalType> functor(array.PrepareForInPlace(DeviceAdapter()));
Algo::Schedule(functor, this->NumValues);
return timer.GetElapsedTime();
......@@ -301,7 +305,8 @@ struct BenchmarkArrayTransfer
array.ReleaseResourcesExecution();
// Time the copy:
Timer timer;
Timer timer{ DeviceAdapter() };
timer.Start();
// Copy to device:
ReadValues<PortalExecType> functor(array.PrepareForInput(DeviceAdapter()),
......@@ -360,7 +365,8 @@ struct BenchmarkArrayTransfer
array.ReleaseResourcesExecution();
// Time the copy:
Timer timer;
Timer timer{ DeviceAdapter() };
timer.Start();
// Do work on device:
ReadWriteValues<PortalExecType> functor(array.PrepareForInPlace(DeviceAdapter()));
......@@ -411,7 +417,8 @@ struct BenchmarkArrayTransfer
ArrayType array;
// Time the copy:
Timer timer;
Timer timer{ DeviceAdapter() };
timer.Start();
// Allocate/write data on device
WriteValues<PortalExecType> functor(array.PrepareForOutput(this->NumValues, DeviceAdapter()));
......@@ -464,7 +471,8 @@ struct BenchmarkArrayTransfer
ArrayType array;
// Time the copy:
Timer timer;
Timer timer{ DeviceAdapter() };
timer.Start();
// Allocate/write data on device
WriteValues<PortalExecType> functor(array.PrepareForOutput(this->NumValues, DeviceAdapter()));
......@@ -516,7 +524,8 @@ struct BenchmarkArrayTransfer
ArrayType array;
// Time the copy:
Timer timer;
Timer timer{ DeviceAdapter() };
timer.Start();
// Allocate/write data on device
WriteValues<PortalExecType> functor(array.PrepareForOutput(this->NumValues, DeviceAdapter()));
......
......@@ -62,7 +62,7 @@ class BenchmarkAtomicArray
{
public:
using Algo = vtkm::cont::DeviceAdapterAlgorithm<Device>;
using Timer = vtkm::cont::Timer<Device>;
using Timer = vtkm::cont::Timer;
// Benchmarks AtomicArray::Add such that each work index writes to adjacent
// indices.
......@@ -102,8 +102,10 @@ public:
auto portal = array.PrepareForExecution(Device{});
Worker<decltype(portal)> worker{ this->ArraySize, portal };
Timer timer;
Timer timer{ Device() };
timer.Start();
Algo::Schedule(worker, NumWrites);
return timer.GetElapsedTime();
}
......@@ -156,8 +158,10 @@ public:
auto portal = this->Data.PrepareForOutput(this->ArraySize, Device{});
Worker<decltype(portal)> worker{ this->ArraySize, portal };
Timer timer;
Timer timer{ Device() };
timer.Start();
Algo::Schedule(worker, NumWrites);
return timer.GetElapsedTime();
}
......@@ -217,8 +221,10 @@ public:
auto portal = array.PrepareForExecution(Device{});
Worker<decltype(portal)> worker{ this->ArraySize, this->Stride, portal };
Timer timer;
Timer timer{ Device() };
timer.Start();
Algo::Schedule(worker, NumWrites);
return timer.GetElapsedTime();
}
......@@ -276,8 +282,10 @@ public:
auto portal = this->Data.PrepareForOutput(this->ArraySize, Device{});
Worker<decltype(portal)> worker{ this->ArraySize, this->Stride, portal };
Timer timer;
Timer timer{ Device() };
timer.Start();
Algo::Schedule(worker, NumWrites);
return timer.GetElapsedTime();
}
......@@ -342,8 +350,10 @@ public:
auto portal = array.PrepareForExecution(Device{});
Worker<decltype(portal)> worker{ this->ArraySize, portal };
Timer timer;
Timer timer{ Device() };
timer.Start();
Algo::Schedule(worker, NumWrites);
return timer.GetElapsedTime();
}
......@@ -398,7 +408,8 @@ public:
auto portal = this->Data.PrepareForOutput(this->ArraySize, Device{});
Worker<decltype(portal)> worker{ this->ArraySize, portal };
Timer timer;
Timer timer{ Device() };
timer.Start();
Algo::Schedule(worker, NumWrites);
return timer.GetElapsedTime();
}
......@@ -468,8 +479,10 @@ public:
auto portal = array.PrepareForExecution(Device{});
Worker<decltype(portal)> worker{ this->ArraySize, this->Stride, portal };
Timer timer;
Timer timer{ Device() };
timer.Start();
Algo::Schedule(worker, NumWrites);
return timer.GetElapsedTime();
}
......@@ -529,8 +542,10 @@ public:
auto portal = this->Data.PrepareForOutput(this->ArraySize, Device{});
Worker<decltype(portal)> worker{ this->ArraySize, this->Stride, portal };
Timer timer;
Timer timer{ Device() };
timer.Start();
Algo::Schedule(worker, NumWrites);
return timer.GetElapsedTime();
}
......
......@@ -74,8 +74,10 @@ struct MeasureCopySpeed
VTKM_CONT vtkm::Float64 operator()()
{
vtkm::cont::Timer<DeviceAdapter> timer;
vtkm::cont::Timer timer{ DeviceAdapter() };
timer.Start();
Algo::Copy(this->Source, this->Destination);
return timer.GetElapsedTime();
}
......
......@@ -177,7 +177,7 @@ class BenchmarkDeviceAdapter
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>;
using Timer = vtkm::cont::Timer<DeviceAdapterTag>;
using Timer = vtkm::cont::Timer;
public:
// Various kernels used by the different benchmarks to accelerate
......@@ -284,8 +284,10 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Algorithm::Copy(ValueHandle_src, ValueHandle_dst);
return timer.GetElapsedTime();
}
......@@ -331,8 +333,10 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Algorithm::CopyIf(ValueHandle, StencilHandle, OutHandle);
return timer.GetElapsedTime();
}
......@@ -388,8 +392,10 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Algorithm::LowerBounds(InputHandle, ValueHandle, OutHandle);
return timer.GetElapsedTime();
}
......@@ -442,7 +448,8 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Value tmp = Algorithm::Reduce(InputHandle, vtkm::TypeTraits<Value>::ZeroInitialization());
vtkm::Float64 time = timer.GetElapsedTime();
if (tmp != this->Result)
......@@ -494,7 +501,8 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Algorithm::ReduceByKey(KeyHandle, ValueHandle, KeysOut, ValuesOut, vtkm::Add());
return timer.GetElapsedTime();
}
......@@ -542,7 +550,8 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Algorithm::ScanInclusive(ValueHandle, OutHandle);
return timer.GetElapsedTime();
}
......@@ -580,7 +589,8 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Algorithm::ScanExclusive(ValueHandle, OutHandle);
return timer.GetElapsedTime();
}
......@@ -624,7 +634,8 @@ private:
ValueArrayHandle array;
Algorithm::Copy(this->ValueHandle, array);
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Algorithm::Sort(array);
return timer.GetElapsedTime();
}
......@@ -679,7 +690,8 @@ private:
Algorithm::Copy(this->KeyHandle, keys);
Algorithm::Copy(this->ValueHandle, values);
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Algorithm::SortByKey(keys, values);
return timer.GetElapsedTime();
}
......@@ -737,7 +749,8 @@ private:
vtkm::cont::ArrayHandle<vtkm::Id> indices;
Algorithm::Copy(vtkm::cont::ArrayHandleIndex(arraySize), indices);
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
SSI::Sort(ValueHandle, indices);
return timer.GetElapsedTime();
}
......@@ -786,7 +799,8 @@ private:
{
IndexArrayHandle indices;
Algorithm::Copy(this->IndexHandle, indices);
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
SSI::Unique(this->ValueHandle, indices);
return timer.GetElapsedTime();
}
......@@ -843,7 +857,8 @@ private:
ValueArrayHandle array;
Algorithm::Copy(this->ValueHandle, array);
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Algorithm::Unique(array);
return timer.GetElapsedTime();
}
......@@ -900,7 +915,8 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
vtkm::cont::Timer timer;
timer.Start();
Algorithm::UpperBounds(InputHandle, ValueHandle, OutHandle);
return timer.GetElapsedTime();
}
......
......@@ -316,7 +316,7 @@ class BenchmarkFieldAlgorithms
{
using StorageTag = vtkm::cont::StorageTagBasic;
using Timer = vtkm::cont::Timer<DeviceAdapterTag>;
using Timer = vtkm::cont::Timer;
using ValueVariantHandle = vtkm::cont::VariantArrayHandleBase<ValueTypes>;
using InterpVariantHandle = vtkm::cont::VariantArrayHandleBase<InterpValueTypes>;
......@@ -366,7 +366,8 @@ private:
const Value RISKFREE = 0.02f;
const Value VOLATILITY = 0.30f;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
BlackScholes<Value> worklet(RISKFREE, VOLATILITY);
vtkm::worklet::DispatcherMapField<BlackScholes<Value>> dispatcher(worklet);
dispatcher.SetDevice(DeviceAdapterTag());
......@@ -405,7 +406,8 @@ private:
const Value RISKFREE = 0.02f;
const Value VOLATILITY = 0.30f;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
BlackScholes<Value> worklet(RISKFREE, VOLATILITY);
vtkm::worklet::DispatcherMapField<BlackScholes<Value>> dispatcher(worklet);
dispatcher.SetDevice(DeviceAdapterTag());
......@@ -448,7 +450,8 @@ private:
vtkm::cont::ArrayHandle<Value> tempHandle1;
vtkm::cont::ArrayHandle<Value> tempHandle2;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::Invoker invoke(DeviceAdapterTag{});
invoke(Mag{}, this->InputHandle, tempHandle1);
......@@ -487,7 +490,8 @@ private:
ValueVariantHandle dtemp1(temp1);
ValueVariantHandle dtemp2(temp2);
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::Invoker invoke(DeviceAdapterTag{});
invoke(Mag{}, dinput, dtemp1);
......@@ -530,10 +534,12 @@ private:
{
vtkm::cont::ArrayHandle<Value> result;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::DispatcherMapField<FusedMath> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->InputHandle, result);
return timer.GetElapsedTime();
}
......@@ -563,10 +569,12 @@ private:
vtkm::cont::ArrayHandle<Value, StorageTag> result;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::DispatcherMapField<FusedMath> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(dinput, result);
return timer.GetElapsedTime();
}
......@@ -633,10 +641,12 @@ private:
{
vtkm::cont::ArrayHandle<Value> result;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::DispatcherMapField<InterpolateField> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->EdgePairHandle, this->WeightHandle, this->FieldHandle, result);
return timer.GetElapsedTime();
}
......@@ -666,10 +676,12 @@ private:
EdgeIdVariantHandle dedges(this->EdgePairHandle);
vtkm::cont::ArrayHandle<Value> result;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::DispatcherMapField<InterpolateField> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(dedges, dweight, dfield, result);
return timer.GetElapsedTime();
}
......@@ -731,10 +743,12 @@ private:
static_cast<const vtkm::Sphere*>(handle.PrepareForExecution(DeviceAdapterTag()));
EvalWorklet eval(function);
vtkm::cont::Timer<DeviceAdapterTag> timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
return timer.GetElapsedTime();
}
......@@ -767,10 +781,12 @@ private:
auto sphere = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
EvalWorklet eval(sphere.PrepareForExecution(DeviceAdapterTag()));
vtkm::cont::Timer<DeviceAdapterTag> timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
return timer.GetElapsedTime();
}
......@@ -806,10 +822,12 @@ private:
auto f2 = static_cast<const vtkm::Sphere*>(h2.PrepareForExecution(DeviceAdapterTag()));
EvalWorklet eval(f1, f2);
vtkm::cont::Timer<DeviceAdapterTag> timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
return timer.GetElapsedTime();
}
......@@ -845,10 +863,12 @@ private:
EvalWorklet eval(s1.PrepareForExecution(DeviceAdapterTag()),
s2.PrepareForExecution(DeviceAdapterTag()));
vtkm::cont::Timer<DeviceAdapterTag> timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
return timer.GetElapsedTime();
}
......
......@@ -172,7 +172,7 @@ public:
template <class DeviceAdapterTag>
class BenchmarkFilters
{
using Timer = vtkm::cont::Timer<DeviceAdapterTag>;
using Timer = vtkm::cont::Timer;
enum GradOpts
{
......@@ -229,7 +229,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -316,7 +317,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -354,7 +356,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -379,7 +382,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -403,7 +407,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -430,7 +435,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -456,7 +462,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -498,7 +505,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -542,7 +550,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -576,7 +585,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -601,7 +611,8 @@ class BenchmarkFilters
VTKM_CONT
vtkm::Float64 operator()()
{
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
return timer.GetElapsedTime();
}
......@@ -650,7 +661,8 @@ class BenchmarkFilters
vtkm::TopologyElementTagPoint{});
}
vtkm::cont::Timer<Device> timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
cellSet.PrepareForInput(
Device{}, vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{});
this->Time = timer.GetElapsedTime();
......
......@@ -114,7 +114,8 @@ struct BenchRayTracing
VTKM_CONT
vtkm::Float64 operator()()
{
vtkm::cont::Timer<VTKM_DEFAULT_DEVICE_ADAPTER_TAG> timer;
vtkm::cont::Timer timer;
timer.Start();
RayCamera.CreateRays(Rays, Coords.GetBounds());
Tracer.Render(Rays);
......
......@@ -140,7 +140,7 @@ class BenchmarkTopologyAlgorithms
{
using StorageTag = vtkm::cont::StorageTagBasic;
using Timer = vtkm::cont::Timer<DeviceAdapterTag>;
using Timer = vtkm::cont::Timer;
using ValueVariantHandle = vtkm::cont::VariantArrayHandleBase<ValueTypes>;
......@@ -205,7 +205,8 @@ private:
cellSet.SetPointDimensions(vtkm::Id3(CUBE_SIZE, CUBE_SIZE, CUBE_SIZE));
vtkm::cont::ArrayHandle<Value, StorageTag> result;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::DispatcherMapTopology<AverageCellToPoint> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
......@@ -241,7 +242,8 @@ private:
ValueVariantHandle dinput(this->InputHandle);
vtkm::cont::ArrayHandle<Value, StorageTag> result;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::DispatcherMapTopology<AverageCellToPoint> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
......@@ -284,7 +286,8 @@ private:
cellSet.SetPointDimensions(vtkm::Id3(CUBE_SIZE, CUBE_SIZE, CUBE_SIZE));
vtkm::cont::ArrayHandle<Value, StorageTag> result;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::DispatcherMapTopology<AveragePointToCell> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
......@@ -320,7 +323,8 @@ private:
ValueVariantHandle dinput(this->InputHandle);
vtkm::cont::ArrayHandle<Value, StorageTag> result;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
vtkm::worklet::DispatcherMapTopology<AveragePointToCell> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
......@@ -367,7 +371,8 @@ private:
ValueVariantHandle dinput(this->InputHandle);
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Classification<Value> worklet(this->IsoValue);
vtkm::worklet::DispatcherMapTopology<Classification<Value>> dispatcher(worklet);
......@@ -401,13 +406,15 @@ private:
cellSet.SetPointDimensions(vtkm::Id3(CUBE_SIZE, CUBE_SIZE, CUBE_SIZE));
vtkm::cont::ArrayHandle<vtkm::IdComponent, StorageTag> result;
Timer timer;
Timer timer{ DeviceAdapterTag() };
timer.Start();
Classification<Value> worklet(this->IsoValue);
vtkm::worklet::DispatcherMapTopology<Classification<Value>> dispatcher(worklet);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->InputHandle, cellSet, result);
timer.Stop();
return timer.GetElapsedTime();
}
......
# Introduce asynchronous and device independent timer
The timer class now is asynchronous and device independent. it's using an
similiar API as vtkOpenGLRenderTimer with Start(), Stop(), Reset(), Ready(),
and GetElapsedTime() function. For convenience and backward compability, Each
Start() function call will call Reset() internally. GetElapsedTime() function
can be used multiple times to time sequential operations and Stop() function
can be helpful when you want to get the elapsed time latter.
Bascially it can be used in two modes:
* Create a Timer without any device info.
* It would enable the timer for all enabled devices on the machine. Users can get a