mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
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.
This commit is contained in:
parent
610bfc21ee
commit
415252c662
@ -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();
|
||||
}
|
||||
|
||||
|
65
docs/changelog/asynchronize-device-independent-timer.md
Normal file
65
docs/changelog/asynchronize-device-independent-timer.md
Normal file
@ -0,0 +1,65 @@
|
||||
# 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
|
||||
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.
|
||||
|
||||
``` Construct a generic timer
|
||||
// Assume CUDA is enabled on the machine
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
// Run the algorithm
|
||||
|
||||
auto timeHost = timer.GetElapsedTime(vtkm::cont::DeviceAdapterTagSerial());
|
||||
// To avoid the expensive device synchronization, we query is ready here.
|
||||
if (timer.IsReady())
|
||||
{
|
||||
auto timeDevice = timer.GetElapsedTime(vtkm::cont::DeviceAdapterTagCuda());
|
||||
}
|
||||
// Force the synchronization. Ideally device execution time would be returned
|
||||
which takes longer time than ther kernal call
|
||||
auto timeGeneral = timer.GetElapsedTime();
|
||||
```
|
||||
|
||||
* Create a Timer with a specific device.
|
||||
* It works as the old timer that times for a specific device id.
|
||||
``` Construct a device specific timer
|
||||
// Assume TBB is enabled on the machine
|
||||
vtkm::cont::Timer timer{vtkm::cont::DeviceAdaptertagTBB()};
|
||||
timer.Start(); // t0
|
||||
// Run the algorithm
|
||||
|
||||
// Timer would just return 0 and warn the user in the logger that an invalid
|
||||
// device is used to query elapsed time
|
||||
auto timeInvalid = timer.GetElapsedTime(vtkm::cont::DeviceAdapterTagSerial());
|
||||
if timer.IsReady()
|
||||
{
|
||||
// Either will work and mark t1, return t1-t0
|
||||
auto time1TBB = timer.GetElapsedTime(vtkm::cont::DeviceAdapterTagTBB());
|
||||
auto time1General = timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
// Do something
|
||||
auto time2 = timer.GetElapsedTime(); // t2 will be marked and t2-t0 will be returned
|
||||
|
||||
// Do something
|
||||
timer.Stop() // t3 marked
|
||||
|
||||
// Do something then summarize latter
|
||||
auto timeFinal = timer.GetElapsedTime(); // t3-t0
|
||||
```
|
@ -85,8 +85,10 @@ int main(int argc, char* argv[])
|
||||
vtkm::Float32 clipValue = std::stof(argv[argc - 2]);
|
||||
vtkm::worklet::Clip clip;
|
||||
|
||||
vtkm::cont::Timer<> total;
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer total;
|
||||
total.Start();
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
bool invertClip = false;
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||
clip.Run(input.GetCellSet(0),
|
||||
@ -100,12 +102,12 @@ int main(int argc, char* argv[])
|
||||
|
||||
|
||||
auto inCoords = input.GetCoordinateSystem(0).GetData();
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
auto outCoords = clip.ProcessCellField(inCoords);
|
||||
vtkm::Float64 processCoordinatesTime = timer.GetElapsedTime();
|
||||
output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", outCoords));
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
for (vtkm::Id i = 0; i < input.GetNumberOfFields(); ++i)
|
||||
{
|
||||
vtkm::cont::Field inField = input.GetField(i);
|
||||
|
@ -145,8 +145,8 @@ private:
|
||||
// Compute and render an isosurface for a uniform grid example
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// TODO: Change timing to use logging in vtkm/cont/Logging.h
|
||||
vtkm::cont::Timer<> totalTime;
|
||||
vtkm::cont::Timer totalTime;
|
||||
totalTime.Start();
|
||||
vtkm::Float64 prevTime = 0;
|
||||
vtkm::Float64 currTime = 0;
|
||||
std::cout << "ContourTreePPP2Mesh <options> <fileName>" << std::endl;
|
||||
|
@ -250,7 +250,8 @@ struct RenderGameOfLife
|
||||
}
|
||||
};
|
||||
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> gTimer;
|
||||
vtkm::cont::Timer gTimer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
gTimer.Start();
|
||||
vtkm::cont::DataSet* gData = nullptr;
|
||||
GameOfLife* gFilter = nullptr;
|
||||
RenderGameOfLife* gRenderer = nullptr;
|
||||
|
@ -59,7 +59,7 @@ struct HelloVTKMInterop
|
||||
vtkm::interop::BufferState VBOState;
|
||||
vtkm::interop::BufferState ColorState;
|
||||
|
||||
vtkm::cont::Timer<> Timer;
|
||||
vtkm::cont::Timer Timer;
|
||||
|
||||
std::vector<vtkm::Vec<T, 3>> InputData;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>> InHandle;
|
||||
@ -78,6 +78,7 @@ struct HelloVTKMInterop
|
||||
, OutCoords()
|
||||
, OutColors()
|
||||
{
|
||||
Timer.Start();
|
||||
int dim = 256;
|
||||
this->InputData.reserve(static_cast<std::size_t>(dim * dim));
|
||||
for (int i = 0; i < dim; ++i)
|
||||
|
@ -84,7 +84,8 @@ int main(int argc, char* argv[])
|
||||
//run once to get the CUDA code warmed up
|
||||
dispatcher.Invoke(input, output);
|
||||
|
||||
vtkm::cont::Timer<DeviceTag> timer;
|
||||
vtkm::cont::Timer timer{ DeviceTag() };
|
||||
timer.Start();
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
@ -117,7 +118,8 @@ int main(int argc, char* argv[])
|
||||
//run once to get the CUDA code warmed up
|
||||
dispatcher.Invoke(input, output);
|
||||
|
||||
vtkm::cont::Timer<DeviceTag> timer;
|
||||
vtkm::cont::Timer timer{ DeviceTag() };
|
||||
timer.Start();
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
|
@ -171,6 +171,7 @@ set(device_sources
|
||||
ArrayRangeCompute.cxx
|
||||
CellSetExplicit.cxx
|
||||
CoordinateSystem.cxx
|
||||
Timer.cxx
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <vtkm/cont/Logging.h>
|
||||
#include <vtkm/cont/internal/ArrayManagerExecution.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
|
||||
@ -539,6 +540,11 @@ template <class DeviceAdapterTag>
|
||||
class DeviceAdapterTimerImplementation
|
||||
{
|
||||
public:
|
||||
struct TimeStamp
|
||||
{
|
||||
vtkm::Int64 Seconds;
|
||||
vtkm::Int64 Microseconds;
|
||||
};
|
||||
/// When a timer is constructed, all threads are synchronized and the
|
||||
/// current time is marked so that GetElapsedTime returns the number of
|
||||
/// seconds elapsed since the construction.
|
||||
@ -548,7 +554,30 @@ public:
|
||||
/// number of seconds elapsed since the call to this. This method
|
||||
/// synchronizes all asynchronous operations.
|
||||
///
|
||||
VTKM_CONT void Reset() { this->StartTime = this->GetCurrentTime(); }
|
||||
VTKM_CONT void Reset()
|
||||
{
|
||||
this->StartReady = false;
|
||||
this->StopReady = false;
|
||||
}
|
||||
|
||||
VTKM_CONT void Start()
|
||||
{
|
||||
this->Reset();
|
||||
this->StartTime = this->GetCurrentTime();
|
||||
this->StartReady = true;
|
||||
}
|
||||
|
||||
VTKM_CONT void Stop()
|
||||
{
|
||||
this->StopTime = this->GetCurrentTime();
|
||||
this->StopReady = true;
|
||||
}
|
||||
|
||||
VTKM_CONT bool Started() { return this->StartReady; }
|
||||
|
||||
VTKM_CONT bool Stopped() { return this->StopReady; }
|
||||
|
||||
VTKM_CONT bool Ready() { return true; }
|
||||
|
||||
/// Returns the elapsed time in seconds between the construction of this
|
||||
/// class or the last call to Reset and the time this function is called. The
|
||||
@ -558,21 +587,29 @@ public:
|
||||
///
|
||||
VTKM_CONT vtkm::Float64 GetElapsedTime()
|
||||
{
|
||||
TimeStamp currentTime = this->GetCurrentTime();
|
||||
assert(this->StartReady);
|
||||
if (!this->StartReady)
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Error,
|
||||
"Start() function should be called first then trying to call GetElapsedTime().");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool manualStop = true;
|
||||
if (!this->StopReady)
|
||||
{
|
||||
manualStop = false;
|
||||
this->Stop();
|
||||
}
|
||||
vtkm::Float64 elapsedTime;
|
||||
elapsedTime = vtkm::Float64(currentTime.Seconds - this->StartTime.Seconds);
|
||||
elapsedTime += (vtkm::Float64(currentTime.Microseconds - this->StartTime.Microseconds) /
|
||||
elapsedTime = vtkm::Float64(this->StopTime.Seconds - this->StartTime.Seconds);
|
||||
elapsedTime += (vtkm::Float64(this->StopTime.Microseconds - this->StartTime.Microseconds) /
|
||||
vtkm::Float64(1000000));
|
||||
// Reset StopReady flag to its original state
|
||||
this->StopReady = manualStop;
|
||||
|
||||
return elapsedTime;
|
||||
}
|
||||
struct TimeStamp
|
||||
{
|
||||
vtkm::Int64 Seconds;
|
||||
vtkm::Int64 Microseconds;
|
||||
};
|
||||
TimeStamp StartTime;
|
||||
|
||||
VTKM_CONT TimeStamp GetCurrentTime()
|
||||
{
|
||||
@ -592,6 +629,11 @@ public:
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool StartReady;
|
||||
bool StopReady;
|
||||
TimeStamp StartTime;
|
||||
TimeStamp StopTime;
|
||||
};
|
||||
|
||||
/// \brief Class providing a device-specific runtime support detector.
|
||||
|
254
vtkm/cont/Timer.cxx
Normal file
254
vtkm/cont/Timer.cxx
Normal file
@ -0,0 +1,254 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2016 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||
// Copyright 2016 UT-Battelle, LLC.
|
||||
// Copyright 2016 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#include <vtkm/cont/Logging.h>
|
||||
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||
#include <vtkm/cont/Timer.h>
|
||||
|
||||
#include <vtkm/internal/brigand.hpp>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename State, typename T>
|
||||
struct RemoveDisabledDevice
|
||||
{
|
||||
using type = typename std::conditional<T::IsEnabled, brigand::push_back<State, T>, State>::type;
|
||||
};
|
||||
|
||||
/// TMP code to generate enabled device timer container
|
||||
using AllDeviceList = DeviceAdapterListTagCommon::list;
|
||||
using EnabledDeviceList =
|
||||
brigand::fold<AllDeviceList,
|
||||
brigand::list<>,
|
||||
detail::RemoveDisabledDevice<brigand::_state, brigand::_element>>;
|
||||
struct EnabledDeviceListTag : vtkm::ListTagBase<>
|
||||
{
|
||||
using list = EnabledDeviceList;
|
||||
};
|
||||
using EnabledTimerImpls =
|
||||
brigand::transform<EnabledDeviceList,
|
||||
brigand::bind<DeviceAdapterTimerImplementation, brigand::_1>>;
|
||||
using EnabledTimerImplTuple = brigand::as_tuple<EnabledTimerImpls>;
|
||||
}
|
||||
|
||||
enum class TimerDispatchTag : int
|
||||
{
|
||||
Reset,
|
||||
Start,
|
||||
Stop,
|
||||
Started,
|
||||
Stopped,
|
||||
Ready,
|
||||
GetElapsedTime
|
||||
};
|
||||
|
||||
class EnabledDeviceTimerImpls
|
||||
{
|
||||
public:
|
||||
EnabledDeviceTimerImpls() {}
|
||||
~EnabledDeviceTimerImpls() {}
|
||||
// A tuple of enabled timer implementations
|
||||
detail::EnabledTimerImplTuple timerImplTuple;
|
||||
};
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// C++11 does not support get tuple element by type. C++14 does support that.
|
||||
// Get the index of a type in tuple elements
|
||||
template <class T, class Tuple>
|
||||
struct Index;
|
||||
|
||||
template <class T, template <typename...> class Container, class... Types>
|
||||
struct Index<T, Container<T, Types...>>
|
||||
{
|
||||
static const std::size_t value = 0;
|
||||
};
|
||||
|
||||
template <class T, class U, template <typename...> class Container, class... Types>
|
||||
struct Index<T, Container<U, Types...>>
|
||||
{
|
||||
static const std::size_t value = 1 + Index<T, Container<Types...>>::value;
|
||||
};
|
||||
|
||||
struct TimerFunctor
|
||||
{
|
||||
TimerFunctor()
|
||||
: elapsedTime(0)
|
||||
, value(true)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
VTKM_CONT void operator()(DeviceAdapter device, Timer* timer, TimerDispatchTag tag)
|
||||
{
|
||||
if (timer->Device == device || timer->Device == DeviceAdapterTagAny())
|
||||
{
|
||||
auto& timerImpl = std::get<Index<DeviceAdapter, detail::EnabledDeviceList>::value>(
|
||||
timer->Internal->timerImplTuple);
|
||||
switch (tag)
|
||||
{
|
||||
case TimerDispatchTag::Reset:
|
||||
timerImpl.Reset();
|
||||
break;
|
||||
case TimerDispatchTag::Start:
|
||||
timerImpl.Start();
|
||||
break;
|
||||
case TimerDispatchTag::Stop:
|
||||
timerImpl.Stop();
|
||||
break;
|
||||
case TimerDispatchTag::Started:
|
||||
value &= timerImpl.Started();
|
||||
break;
|
||||
case TimerDispatchTag::Stopped:
|
||||
value &= timerImpl.Stopped();
|
||||
break;
|
||||
case TimerDispatchTag::Ready:
|
||||
value &= timerImpl.Ready();
|
||||
break;
|
||||
case TimerDispatchTag::GetElapsedTime:
|
||||
{
|
||||
if (timer->Device == DeviceAdapterTagAny() &&
|
||||
timer->DeviceForQuery == DeviceAdapterTagAny())
|
||||
{ // Just want to do timing jobs
|
||||
elapsedTime = std::max(elapsedTime, timerImpl.GetElapsedTime());
|
||||
break;
|
||||
}
|
||||
else if (timer->Device == DeviceAdapterTagAny() && timer->DeviceForQuery == device)
|
||||
{ // Given a generic timer, querying for a specific device time
|
||||
elapsedTime = timerImpl.GetElapsedTime();
|
||||
break;
|
||||
}
|
||||
else if (timer->Device == device && (timer->DeviceForQuery == DeviceAdapterTagAny() ||
|
||||
timer->Device == timer->DeviceForQuery))
|
||||
{ // Given a specific timer, querying its elapsed time
|
||||
elapsedTime = timerImpl.GetElapsedTime();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vtkm::Float64 elapsedTime;
|
||||
bool value;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Timer::Timer()
|
||||
: Device(vtkm::cont::DeviceAdapterTagAny())
|
||||
, DeviceForQuery(vtkm::cont::DeviceAdapterTagAny())
|
||||
, Internal(nullptr)
|
||||
{
|
||||
this->Init();
|
||||
}
|
||||
|
||||
|
||||
Timer::~Timer()
|
||||
{
|
||||
delete this->Internal;
|
||||
}
|
||||
|
||||
void Timer::Init()
|
||||
{
|
||||
if (!this->Internal)
|
||||
{
|
||||
this->Internal = new EnabledDeviceTimerImpls();
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::Reset()
|
||||
{
|
||||
detail::TimerFunctor functor;
|
||||
vtkm::ListForEach(functor, detail::EnabledDeviceListTag(), this, TimerDispatchTag::Reset);
|
||||
}
|
||||
|
||||
void Timer::Start()
|
||||
{
|
||||
|
||||
detail::TimerFunctor functor;
|
||||
vtkm::ListForEach(functor, detail::EnabledDeviceListTag(), this, TimerDispatchTag::Start);
|
||||
}
|
||||
|
||||
void Timer::Stop()
|
||||
{
|
||||
detail::TimerFunctor functor;
|
||||
vtkm::ListForEach(functor, detail::EnabledDeviceListTag(), this, TimerDispatchTag::Stop);
|
||||
}
|
||||
|
||||
bool Timer::Started()
|
||||
{
|
||||
detail::TimerFunctor functor;
|
||||
vtkm::ListForEach(functor, detail::EnabledDeviceListTag(), this, TimerDispatchTag::Started);
|
||||
return functor.value;
|
||||
}
|
||||
|
||||
bool Timer::Stopped()
|
||||
{
|
||||
detail::TimerFunctor functor;
|
||||
vtkm::ListForEach(functor, detail::EnabledDeviceListTag(), this, TimerDispatchTag::Stopped);
|
||||
return functor.value;
|
||||
}
|
||||
|
||||
bool Timer::Ready()
|
||||
{
|
||||
detail::TimerFunctor functor;
|
||||
vtkm::ListForEach(functor, detail::EnabledDeviceListTag(), this, TimerDispatchTag::Ready);
|
||||
return functor.value;
|
||||
}
|
||||
|
||||
vtkm::Float64 Timer::GetElapsedTime(DeviceAdapterId id)
|
||||
{
|
||||
// Timer is constructed with a specific device. Only querying this device is allowed.
|
||||
if (this->Device != DeviceAdapterTagAny() && (id != DeviceAdapterTagAny() && this->Device != id))
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Error,
|
||||
"Device '" << id.GetName() << "' is not supported for current timer"
|
||||
<< "("
|
||||
<< this->Device.GetName()
|
||||
<< ")");
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// Timer is constructed with any device. Only querying enabled device is allowed.
|
||||
vtkm::cont::RuntimeDeviceTracker tracker;
|
||||
if (this->Device == DeviceAdapterTagAny() &&
|
||||
(id != DeviceAdapterTagAny() && !tracker.CanRunOn(id)))
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Error,
|
||||
"Device '" << id.GetName() << "' can not run on current Device."
|
||||
"Thus timer is not usable");
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
this->DeviceForQuery = id;
|
||||
detail::TimerFunctor functor;
|
||||
vtkm::ListForEach(
|
||||
functor, detail::EnabledDeviceListTag(), this, TimerDispatchTag::GetElapsedTime);
|
||||
|
||||
return functor.elapsedTime;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
@ -20,56 +20,85 @@
|
||||
#ifndef vtk_m_cont_Timer_h
|
||||
#define vtk_m_cont_Timer_h
|
||||
|
||||
#include <vtkm/ListTag.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/DeviceAdapterListTag.h>
|
||||
|
||||
#include <vtkm/cont/vtkm_cont_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
struct TimerFunctor;
|
||||
}
|
||||
class EnabledDeviceTimerImpls;
|
||||
|
||||
/// A class that can be used to time operations in VTK-m that might be occurring
|
||||
/// in parallel. You should make sure that the device adapter for the timer
|
||||
/// matches that being used to execute algorithms to ensure that the thread
|
||||
/// synchronization is correct.
|
||||
/// A class that can be used to time operations in VTK-m that might be occuring
|
||||
/// in parallel. Users are recommended to provide a device adapter at construction
|
||||
/// time which matches the one being used to execute algorithms to ensure that thread
|
||||
/// synchronization is correct and accurate.
|
||||
/// If no device adapter is provided at construction time, the maximum
|
||||
/// elapsed time of all enabled deivces will be returned. Normally cuda is expected to
|
||||
/// have the longest execution time if enabled.
|
||||
/// Per device adapter time query is also supported. It's useful when users want to reuse
|
||||
/// the same timer to measure the cuda kernal call as well as the cuda device execution.
|
||||
///
|
||||
/// The there is no guaranteed resolution of the time but should generally be
|
||||
/// good to about a millisecond.
|
||||
///
|
||||
template <class Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
||||
class Timer
|
||||
class VTKM_CONT_EXPORT Timer
|
||||
{
|
||||
friend struct detail::TimerFunctor;
|
||||
|
||||
public:
|
||||
/// When a timer is constructed, all threads are synchronized and the
|
||||
/// current time is marked so that GetElapsedTime returns the number of
|
||||
/// seconds elapsed since the construction.
|
||||
VTKM_CONT
|
||||
Timer()
|
||||
: TimerImplementation()
|
||||
Timer();
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
VTKM_CONT Timer(DeviceAdapter id)
|
||||
: Device(id)
|
||||
, DeviceForQuery(DeviceAdapterTagAny())
|
||||
, Internal(nullptr)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter);
|
||||
static_assert(DeviceAdapter::IsEnabled, "A disabled device is passed to the Timer");
|
||||
this->Init();
|
||||
}
|
||||
|
||||
/// Resets the timer. All further calls to GetElapsedTime will report the
|
||||
/// number of seconds elapsed since the call to this. This method
|
||||
/// synchronizes all asynchronous operations.
|
||||
///
|
||||
VTKM_CONT
|
||||
void Reset() { this->TimerImplementation.Reset(); }
|
||||
VTKM_CONT ~Timer();
|
||||
|
||||
/// Returns the elapsed time in seconds between the construction of this
|
||||
/// class or the last call to Reset and the time this function is called. The
|
||||
/// time returned is measured in wall time. GetElapsedTime may be called any
|
||||
/// number of times to get the progressive time. This method synchronizes all
|
||||
/// asynchronous operations.
|
||||
///
|
||||
/// Resets the timer.
|
||||
VTKM_CONT void Reset();
|
||||
|
||||
/// Start would call Reset function before starting the timer for convenience
|
||||
VTKM_CONT void Start();
|
||||
|
||||
VTKM_CONT void Stop();
|
||||
|
||||
VTKM_CONT bool Started();
|
||||
|
||||
VTKM_CONT bool Stopped();
|
||||
|
||||
/// Used to check if Timer has finished the synchronization to get the result from the device.
|
||||
VTKM_CONT bool Ready();
|
||||
|
||||
/// Get the elapsed time measured by the given device adapter. If no device is
|
||||
/// specified, the max time of all device measurements will be returned.
|
||||
VTKM_CONT
|
||||
vtkm::Float64 GetElapsedTime() { return this->TimerImplementation.GetElapsedTime(); }
|
||||
vtkm::Float64 GetElapsedTime(DeviceAdapterId id = DeviceAdapterTagAny());
|
||||
|
||||
private:
|
||||
VTKM_CONT void Init();
|
||||
/// Some timers are ill-defined when copied, so disallow that for all timers.
|
||||
VTKM_CONT Timer(const Timer<Device>&) = delete;
|
||||
VTKM_CONT void operator=(const Timer<Device>&) = delete;
|
||||
VTKM_CONT Timer(const Timer&) = delete;
|
||||
VTKM_CONT void operator=(const Timer&) = delete;
|
||||
|
||||
vtkm::cont::DeviceAdapterTimerImplementation<Device> TimerImplementation;
|
||||
DeviceAdapterId Device;
|
||||
DeviceAdapterId DeviceForQuery;
|
||||
EnabledDeviceTimerImpls* Internal;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
@ -33,7 +33,7 @@ DeviceAdapterTimerImplementation<
|
||||
vtkm::cont::DeviceAdapterTagCuda>::DeviceAdapterTimerImplementation()
|
||||
{
|
||||
VTKM_CUDA_CALL(cudaEventCreate(&this->StartEvent));
|
||||
VTKM_CUDA_CALL(cudaEventCreate(&this->EndEvent));
|
||||
VTKM_CUDA_CALL(cudaEventCreate(&this->StopEvent));
|
||||
this->Reset();
|
||||
}
|
||||
|
||||
@ -45,21 +45,72 @@ DeviceAdapterTimerImplementation<
|
||||
// VTKM_CUDA_CHECK_ASYNCHRONOUS_ERROR catching any issues from these calls
|
||||
// later.
|
||||
cudaEventDestroy(this->StartEvent);
|
||||
cudaEventDestroy(this->EndEvent);
|
||||
cudaEventDestroy(this->StopEvent);
|
||||
}
|
||||
|
||||
void DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>::Reset()
|
||||
{
|
||||
this->StartReady = false;
|
||||
this->StopReady = false;
|
||||
}
|
||||
|
||||
void DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>::Start()
|
||||
{
|
||||
VTKM_CUDA_CALL(cudaEventRecord(this->StartEvent, cudaStreamPerThread));
|
||||
VTKM_CUDA_CALL(cudaEventSynchronize(this->StartEvent));
|
||||
this->StartReady = true;
|
||||
}
|
||||
|
||||
void DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>::Stop()
|
||||
{
|
||||
VTKM_CUDA_CALL(cudaEventRecord(this->StopEvent, cudaStreamPerThread));
|
||||
this->StopReady = true;
|
||||
}
|
||||
|
||||
bool DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>::Started()
|
||||
{
|
||||
return this->StartReady;
|
||||
}
|
||||
|
||||
bool DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>::Stopped()
|
||||
{
|
||||
return this->StopReady;
|
||||
}
|
||||
|
||||
// Callbacks without a mandated order(in independent streams) execute in undefined
|
||||
// order and maybe serialized. So Instead CudaEventQuery is used here.
|
||||
// Ref link: https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html
|
||||
bool DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>::Ready()
|
||||
{
|
||||
if (cudaEventQuery(this->StopEvent) == cudaSuccess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
vtkm::Float64 DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>::GetElapsedTime()
|
||||
{
|
||||
VTKM_CUDA_CALL(cudaEventRecord(this->EndEvent, cudaStreamPerThread));
|
||||
VTKM_CUDA_CALL(cudaEventSynchronize(this->EndEvent));
|
||||
assert(this->StartReady);
|
||||
if (!this->StartReady)
|
||||
{
|
||||
VTKM_LOG_F(vtkm::cont::LogLevel::Error,
|
||||
"Start() function should be called first then trying to call GetElapsedTime().");
|
||||
return 0;
|
||||
}
|
||||
bool manualStop = true;
|
||||
if (!this->StopReady)
|
||||
{
|
||||
manualStop = false;
|
||||
this->Stop();
|
||||
}
|
||||
|
||||
VTKM_CUDA_CALL(cudaEventSynchronize(this->StopEvent));
|
||||
float elapsedTimeMilliseconds;
|
||||
VTKM_CUDA_CALL(cudaEventElapsedTime(&elapsedTimeMilliseconds, this->StartEvent, this->EndEvent));
|
||||
VTKM_CUDA_CALL(cudaEventElapsedTime(&elapsedTimeMilliseconds, this->StartEvent, this->StopEvent));
|
||||
// Reset Stop flag to its original state
|
||||
this->StopReady = manualStop;
|
||||
return static_cast<vtkm::Float64>(0.001f * elapsedTimeMilliseconds);
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,16 @@ public:
|
||||
|
||||
VTKM_CONT void Reset();
|
||||
|
||||
VTKM_CONT void Start();
|
||||
|
||||
VTKM_CONT void Stop();
|
||||
|
||||
VTKM_CONT bool Started();
|
||||
|
||||
VTKM_CONT bool Stopped();
|
||||
|
||||
VTKM_CONT bool Ready();
|
||||
|
||||
VTKM_CONT vtkm::Float64 GetElapsedTime();
|
||||
|
||||
private:
|
||||
@ -59,8 +69,10 @@ private:
|
||||
void operator=(const DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>&) =
|
||||
delete;
|
||||
|
||||
bool StartReady;
|
||||
bool StopReady;
|
||||
cudaEvent_t StartEvent;
|
||||
cudaEvent_t EndEvent;
|
||||
cudaEvent_t StopEvent;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
@ -336,21 +336,63 @@ class DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagTBB>
|
||||
{
|
||||
public:
|
||||
VTKM_CONT DeviceAdapterTimerImplementation() { this->Reset(); }
|
||||
|
||||
VTKM_CONT void Reset()
|
||||
{
|
||||
vtkm::cont::DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagTBB>::Synchronize();
|
||||
this->StartTime = ::tbb::tick_count::now();
|
||||
this->StartReady = false;
|
||||
this->StopReady = false;
|
||||
}
|
||||
|
||||
VTKM_CONT void Start()
|
||||
{
|
||||
this->Reset();
|
||||
this->StartTime = ::tbb::tick_count::now();
|
||||
this->StartReady = true;
|
||||
}
|
||||
|
||||
VTKM_CONT void Stop()
|
||||
{
|
||||
this->StopTime = ::tbb::tick_count::now();
|
||||
this->StopReady = true;
|
||||
}
|
||||
|
||||
VTKM_CONT bool Started() { return this->StartReady; }
|
||||
|
||||
VTKM_CONT bool Stopped() { return this->StopReady; }
|
||||
|
||||
VTKM_CONT bool Ready() { return true; }
|
||||
|
||||
VTKM_CONT vtkm::Float64 GetElapsedTime()
|
||||
{
|
||||
assert(this->StartReady);
|
||||
if (!this->StartReady)
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Error,
|
||||
"Start() function should be called first then trying to call Stop() and"
|
||||
" GetElapsedTime().");
|
||||
return 0;
|
||||
}
|
||||
bool manualStop = true;
|
||||
if (!this->StopReady)
|
||||
{
|
||||
manualStop = false;
|
||||
this->Stop();
|
||||
}
|
||||
vtkm::cont::DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagTBB>::Synchronize();
|
||||
::tbb::tick_count currentTime = ::tbb::tick_count::now();
|
||||
::tbb::tick_count::interval_t elapsedTime = currentTime - this->StartTime;
|
||||
::tbb::tick_count::interval_t elapsedTime = this->StopTime - this->StartTime;
|
||||
|
||||
// Reset StopReady flag to its original state
|
||||
this->StopReady = manualStop;
|
||||
|
||||
return static_cast<vtkm::Float64>(elapsedTime.seconds());
|
||||
}
|
||||
|
||||
private:
|
||||
bool StartReady;
|
||||
bool StopReady;
|
||||
::tbb::tick_count StartTime;
|
||||
::tbb::tick_count StopTime;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -584,11 +584,15 @@ private:
|
||||
|
||||
VTKM_CONT
|
||||
static void TestTimer()
|
||||
{
|
||||
auto tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker();
|
||||
if (tracker.CanRunOn(DeviceAdapterTag()))
|
||||
{
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Timer" << std::endl;
|
||||
|
||||
vtkm::cont::Timer<DeviceAdapterTag> timer;
|
||||
vtkm::cont::Timer timer{ DeviceAdapterTag() };
|
||||
timer.Start();
|
||||
|
||||
std::cout << "Timer started. Sleeping..." << std::endl;
|
||||
|
||||
@ -600,6 +604,7 @@ private:
|
||||
|
||||
std::cout << "Woke up. Check time." << std::endl;
|
||||
|
||||
timer.Stop();
|
||||
vtkm::Float64 elapsedTime = timer.GetElapsedTime();
|
||||
|
||||
std::cout << "Elapsed time: " << elapsedTime << std::endl;
|
||||
@ -607,6 +612,7 @@ private:
|
||||
VTKM_TEST_ASSERT(elapsedTime > 0.999, "Timer did not capture full second wait.");
|
||||
VTKM_TEST_ASSERT(elapsedTime < 2.0, "Timer counted too far or system really busy.");
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
static void TestVirtualObjectTransfer()
|
||||
|
@ -18,8 +18,13 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||
#include <vtkm/cont/Timer.h>
|
||||
|
||||
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
|
||||
#include <vtkm/cont/openmp/internal/DeviceAdapterTagOpenMP.h>
|
||||
#include <vtkm/cont/serial/internal/DeviceAdapterTagSerial.h>
|
||||
#include <vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/internal/Windows.h>
|
||||
@ -28,7 +33,10 @@ namespace
|
||||
|
||||
void Time()
|
||||
{
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
VTKM_TEST_ASSERT(timer.Started(), "Timer fails to track started status");
|
||||
VTKM_TEST_ASSERT(!timer.Stopped(), "Timer fails to track non stopped status");
|
||||
|
||||
#ifdef VTKM_WINDOWS
|
||||
Sleep(1000);
|
||||
@ -37,11 +45,85 @@ void Time()
|
||||
#endif
|
||||
|
||||
vtkm::Float64 elapsedTime = timer.GetElapsedTime();
|
||||
VTKM_TEST_ASSERT(!timer.Stopped(), "Timer fails to track stopped status");
|
||||
|
||||
std::cout << "Elapsed time: " << elapsedTime << std::endl;
|
||||
std::cout << "Elapsed time measured by any Tag: " << elapsedTime << std::endl;
|
||||
VTKM_TEST_ASSERT(elapsedTime > 0.999, "General Timer did not capture full second wait.");
|
||||
VTKM_TEST_ASSERT(elapsedTime < 2.0, "General Timer counted too far or system really busy.");
|
||||
|
||||
VTKM_TEST_ASSERT(elapsedTime > 0.999, "Timer did not capture full second wait.");
|
||||
VTKM_TEST_ASSERT(elapsedTime < 2.0, "Timer counted too far or system really busy.");
|
||||
vtkm::cont::RuntimeDeviceTracker tracker;
|
||||
|
||||
vtkm::Float64 elapsedTimeCuda = timer.GetElapsedTime(vtkm::cont::DeviceAdapterTagCuda());
|
||||
if (tracker.CanRunOn(vtkm::cont::DeviceAdapterTagCuda()))
|
||||
{
|
||||
std::cout << " can on run cuda?: true" << std::endl;
|
||||
std::cout << "Elapsed time measured by cuda Tag: " << elapsedTime << std::endl;
|
||||
VTKM_TEST_ASSERT(elapsedTimeCuda > 0.999, "Cuda Timer did not capture full second wait.");
|
||||
VTKM_TEST_ASSERT(elapsedTimeCuda < 2.0, "Cuda Timer counted too far or system really busy.");
|
||||
}
|
||||
else
|
||||
{
|
||||
VTKM_TEST_ASSERT(elapsedTimeCuda == 0.0, "Disabled Cuda Timer should return nothing.");
|
||||
}
|
||||
|
||||
vtkm::Float64 elapsedTimeSerial = timer.GetElapsedTime(vtkm::cont::DeviceAdapterTagSerial());
|
||||
std::cout << "Elapsed time measured by serial Tag: " << elapsedTime << std::endl;
|
||||
VTKM_TEST_ASSERT(elapsedTimeSerial > 0.999, "Serial Timer did not capture full second wait.");
|
||||
VTKM_TEST_ASSERT(elapsedTimeSerial < 2.0, "Serial Timer counted too far or system really busy.");
|
||||
|
||||
vtkm::Float64 elapsedTimeOpenMP = timer.GetElapsedTime(vtkm::cont::DeviceAdapterTagOpenMP());
|
||||
if (vtkm::cont::DeviceAdapterTagOpenMP::IsEnabled)
|
||||
{
|
||||
std::cout << "Elapsed time measured by openmp Tag: " << elapsedTime << std::endl;
|
||||
VTKM_TEST_ASSERT(elapsedTimeOpenMP > 0.999, "OpenMP Timer did not capture full second wait.");
|
||||
VTKM_TEST_ASSERT(elapsedTimeOpenMP < 2.0,
|
||||
"OpenMP Timer counted too far or system really busy.");
|
||||
}
|
||||
else
|
||||
{
|
||||
VTKM_TEST_ASSERT(elapsedTimeOpenMP == 0.0, "Disabled OpenMP Timer should return nothing.");
|
||||
}
|
||||
|
||||
vtkm::Float64 elapsedTimeTBB = timer.GetElapsedTime(vtkm::cont::DeviceAdapterTagTBB());
|
||||
if (vtkm::cont::DeviceAdapterTagTBB::IsEnabled)
|
||||
{
|
||||
std::cout << "Elapsed time measured by tbb Tag: " << elapsedTime << std::endl;
|
||||
VTKM_TEST_ASSERT(elapsedTimeTBB > 0.999, "TBB Timer did not capture full second wait.");
|
||||
VTKM_TEST_ASSERT(elapsedTimeTBB < 2.0, "TBB Timer counted too far or system really busy.");
|
||||
}
|
||||
else
|
||||
{
|
||||
VTKM_TEST_ASSERT(elapsedTimeOpenMP == 0.0, "Disabled TBB Timer should return nothing.");
|
||||
}
|
||||
|
||||
std::cout << "Reuse the timer to test continuous timing." << std::endl;
|
||||
#ifdef VTKM_WINDOWS
|
||||
Sleep(1000);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
|
||||
elapsedTime = timer.GetElapsedTime();
|
||||
|
||||
std::cout << "Elapsed time measured by any Tag: " << elapsedTime << std::endl;
|
||||
VTKM_TEST_ASSERT(elapsedTime > 1.999,
|
||||
"General Timer did not capture two full seconds wait in second launch.");
|
||||
VTKM_TEST_ASSERT(elapsedTime < 3.0,
|
||||
"General Timer counted too far or system really busy in second launch.");
|
||||
|
||||
timer.Stop();
|
||||
VTKM_TEST_ASSERT(timer.Stopped(), "Timer fails to track stopped status");
|
||||
#ifdef VTKM_WINDOWS
|
||||
Sleep(1000);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
|
||||
std::cout << "Elapsed time measured by any Tag with an early stop: " << elapsedTime << std::endl;
|
||||
VTKM_TEST_ASSERT(elapsedTime > 1.999,
|
||||
"General Timer did not capture two full seconds wait in second launch.");
|
||||
VTKM_TEST_ASSERT(elapsedTime < 3.0,
|
||||
"General Timer counted too far or system really busy in second launch.");
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -109,7 +109,8 @@ vtkm::cont::DataSet ContourTreePPP2::DoExecute(const vtkm::cont::DataSet& input,
|
||||
{
|
||||
// TODO: This should be switched to use the logging macros defined in vtkm/cont/logging.h
|
||||
// Start the timer
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
Timings.clear();
|
||||
|
||||
// Check that the field is Ok
|
||||
@ -153,7 +154,7 @@ vtkm::cont::DataSet ContourTreePPP2::DoExecute(const vtkm::cont::DataSet& input,
|
||||
vtkm::Float64 totalTimeWorklet = 0;
|
||||
for (std::vector<std::pair<std::string, vtkm::Float64>>::size_type i = 0; i < Timings.size(); i++)
|
||||
totalTimeWorklet += Timings[i].second;
|
||||
//std::cout<<"Total time measured by worklet: "<<totalTimeWorklet<<std::endl;
|
||||
std::cout << "Total time measured by worklet: " << totalTimeWorklet << std::endl;
|
||||
Timings.push_back(std::pair<std::string, vtkm::Float64>(
|
||||
"Others (ContourTreePPP2 Filter): ", timer.GetElapsedTime() - totalTimeWorklet));
|
||||
|
||||
|
@ -136,8 +136,9 @@ void MapperCylinder::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
{
|
||||
raytracing::Logger* logger = raytracing::Logger::GetInstance();
|
||||
logger->OpenLogEntry("mapper_cylinder");
|
||||
vtkm::cont::Timer<> tot_timer;
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer tot_timer;
|
||||
tot_timer.Start();
|
||||
vtkm::cont::Timer timer;
|
||||
|
||||
|
||||
vtkm::Bounds shapeBounds;
|
||||
@ -207,7 +208,7 @@ void MapperCylinder::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
this->Internals->Tracer.SetColorMap(this->ColorMap);
|
||||
this->Internals->Tracer.Render(this->Internals->Rays);
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
this->Internals->Canvas->WriteToCanvas(
|
||||
this->Internals->Rays, this->Internals->Rays.Buffers.at(0).Buffer, camera);
|
||||
|
||||
|
@ -131,8 +131,9 @@ void MapperPoint::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
this->Internals->Tracer.Clear();
|
||||
|
||||
logger->OpenLogEntry("mapper_ray_tracer");
|
||||
vtkm::cont::Timer<> tot_timer;
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer tot_timer;
|
||||
tot_timer.Start();
|
||||
vtkm::cont::Timer timer;
|
||||
|
||||
vtkm::Bounds coordBounds = coords.GetBounds();
|
||||
vtkm::Float32 baseRadius = this->Internals->PointRadius;
|
||||
@ -206,7 +207,7 @@ void MapperPoint::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
this->Internals->Tracer.SetColorMap(this->ColorMap);
|
||||
this->Internals->Tracer.Render(this->Internals->Rays);
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
this->Internals->Canvas->WriteToCanvas(
|
||||
this->Internals->Rays, this->Internals->Rays.Buffers.at(0).Buffer, camera);
|
||||
|
||||
|
@ -91,8 +91,9 @@ void MapperQuad::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
{
|
||||
raytracing::Logger* logger = raytracing::Logger::GetInstance();
|
||||
logger->OpenLogEntry("mapper_ray_tracer");
|
||||
vtkm::cont::Timer<> tot_timer;
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer tot_timer;
|
||||
tot_timer.Start();
|
||||
vtkm::cont::Timer timer;
|
||||
|
||||
|
||||
//
|
||||
@ -128,7 +129,7 @@ void MapperQuad::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
this->Internals->Tracer.SetColorMap(this->ColorMap);
|
||||
this->Internals->Tracer.Render(this->Internals->Rays);
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
this->Internals->Canvas->WriteToCanvas(
|
||||
this->Internals->Rays, this->Internals->Rays.Buffers.at(0).Buffer, camera);
|
||||
|
||||
|
@ -94,8 +94,9 @@ void MapperRayTracer::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
{
|
||||
raytracing::Logger* logger = raytracing::Logger::GetInstance();
|
||||
logger->OpenLogEntry("mapper_ray_tracer");
|
||||
vtkm::cont::Timer<> tot_timer;
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer tot_timer;
|
||||
tot_timer.Start();
|
||||
vtkm::cont::Timer timer;
|
||||
|
||||
// make sure we start fresh
|
||||
this->Internals->Tracer.Clear();
|
||||
@ -133,7 +134,7 @@ void MapperRayTracer::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
this->Internals->Tracer.SetShadingOn(this->Internals->Shade);
|
||||
this->Internals->Tracer.Render(this->Internals->Rays);
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
this->Internals->Canvas->WriteToCanvas(
|
||||
this->Internals->Rays, this->Internals->Rays.Buffers.at(0).Buffer, camera);
|
||||
|
||||
|
@ -104,8 +104,9 @@ void MapperVolume::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
{
|
||||
raytracing::Logger* logger = raytracing::Logger::GetInstance();
|
||||
logger->OpenLogEntry("mapper_volume");
|
||||
vtkm::cont::Timer<> tot_timer;
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer tot_timer;
|
||||
tot_timer.Start();
|
||||
vtkm::cont::Timer timer;
|
||||
|
||||
vtkm::rendering::raytracing::VolumeRendererStructured tracer;
|
||||
|
||||
@ -130,7 +131,7 @@ void MapperVolume::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
|
||||
|
||||
tracer.Render(rays);
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
this->Internals->Canvas->WriteToCanvas(rays, rays.Buffers.at(0).Buffer, camera);
|
||||
|
||||
if (this->Internals->CompositeBackground)
|
||||
|
@ -641,7 +641,8 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
||||
Logger* logger = Logger::GetInstance();
|
||||
logger->OpenLogEntry("bvh_constuct");
|
||||
|
||||
vtkm::cont::Timer<Device> constructTimer;
|
||||
vtkm::cont::Timer constructTimer{ Device() };
|
||||
constructTimer.Start();
|
||||
//
|
||||
//
|
||||
// This algorithm needs at least 2 AABBs
|
||||
@ -683,7 +684,8 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
||||
BVHData bvh(numBBoxes, linearBVH.GetAABBs(), device);
|
||||
|
||||
|
||||
vtkm::cont::Timer<Device> timer;
|
||||
vtkm::cont::Timer timer{ Device() };
|
||||
timer.Start();
|
||||
// Find the extent of all bounding boxes to generate normalization for morton codes
|
||||
vtkm::Vec<vtkm::Float32, 3> minExtent(vtkm::Infinity32(), vtkm::Infinity32(), vtkm::Infinity32());
|
||||
vtkm::Vec<vtkm::Float32, 3> maxExtent(
|
||||
@ -710,7 +712,7 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
||||
|
||||
vtkm::Float64 time = timer.GetElapsedTime();
|
||||
logger->AddLogData("calc_extents", time);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
vtkm::Vec<vtkm::Float32, 3> deltaExtent = maxExtent - minExtent;
|
||||
vtkm::Vec<vtkm::Float32, 3> inverseExtent;
|
||||
@ -731,7 +733,7 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
||||
|
||||
time = timer.GetElapsedTime();
|
||||
logger->AddLogData("morton_codes", time);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
linearBVH.Allocate(bvh.GetNumberOfPrimitives(), device);
|
||||
|
||||
@ -739,7 +741,7 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
||||
|
||||
time = timer.GetElapsedTime();
|
||||
logger->AddLogData("sort_aabbs", time);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
invoke(TreeBuilder<Device>{ bvh.mortonCodes, bvh.parent, bvh.GetNumberOfPrimitives() },
|
||||
bvh.leftChild,
|
||||
@ -747,7 +749,7 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
||||
|
||||
time = timer.GetElapsedTime();
|
||||
logger->AddLogData("build_tree", time);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
const vtkm::Int32 primitiveCount = vtkm::Int32(bvh.GetNumberOfPrimitives());
|
||||
|
||||
@ -850,7 +852,8 @@ template <typename Device>
|
||||
void LinearBVH::ConstructOnDevice(Device device)
|
||||
{
|
||||
Logger* logger = Logger::GetInstance();
|
||||
vtkm::cont::Timer<Device> timer;
|
||||
vtkm::cont::Timer timer{ Device() };
|
||||
timer.Start();
|
||||
logger->OpenLogEntry("bvh");
|
||||
if (!CanConstruct)
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
|
@ -758,13 +758,15 @@ template <typename Precision>
|
||||
VTKM_CONT void Camera::CreateRaysImpl(Ray<Precision>& rays, const vtkm::Bounds boundingBox)
|
||||
{
|
||||
Logger* logger = Logger::GetInstance();
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> createTimer;
|
||||
vtkm::cont::Timer createTimer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
createTimer.Start();
|
||||
logger->OpenLogEntry("ray_camera");
|
||||
|
||||
bool ortho = this->CameraView.GetMode() == vtkm::rendering::Camera::MODE_2D;
|
||||
this->UpdateDimensions(rays, boundingBox, ortho);
|
||||
this->WriteSettingsToLog();
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
//Set the origin of the ray back to the camera position
|
||||
|
||||
Precision infinity;
|
||||
@ -782,7 +784,7 @@ VTKM_CONT void Camera::CreateRaysImpl(Ray<Precision>& rays, const vtkm::Bounds b
|
||||
|
||||
vtkm::Float64 time = timer.GetElapsedTime();
|
||||
logger->AddLogData("camera_memset", time);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
//Reset the camera look vector
|
||||
this->Look = this->LookAt - this->Position;
|
||||
|
@ -1134,7 +1134,8 @@ template <typename FloatType>
|
||||
void ConnectivityTracer::IntersectCell(Ray<FloatType>& rays,
|
||||
detail::RayTracking<FloatType>& tracker)
|
||||
{
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
vtkm::worklet::DispatcherMapField<LocateCell> locateDispatch;
|
||||
locateDispatch.Invoke(rays.HitIdx,
|
||||
this->Coords,
|
||||
@ -1163,7 +1164,8 @@ void ConnectivityTracer::AccumulatePathLengths(Ray<FloatType>& rays,
|
||||
template <typename FloatType>
|
||||
void ConnectivityTracer::FindLostRays(Ray<FloatType>& rays, detail::RayTracking<FloatType>& tracker)
|
||||
{
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
|
||||
vtkm::worklet::DispatcherMapField<RayBumper> bumpDispatch;
|
||||
bumpDispatch.Invoke(rays.HitIdx,
|
||||
@ -1184,7 +1186,8 @@ void ConnectivityTracer::SampleCells(Ray<FloatType>& rays, detail::RayTracking<F
|
||||
{
|
||||
using SampleP = SampleCellAssocPoints<FloatType>;
|
||||
using SampleC = SampleCellAssocCells<FloatType>;
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
|
||||
VTKM_ASSERT(rays.Buffers.at(0).GetNumChannels() == 4);
|
||||
|
||||
@ -1231,7 +1234,8 @@ template <typename FloatType>
|
||||
void ConnectivityTracer::IntegrateCells(Ray<FloatType>& rays,
|
||||
detail::RayTracking<FloatType>& tracker)
|
||||
{
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
if (HasEmission)
|
||||
{
|
||||
bool divideEmisByAbsorp = false;
|
||||
@ -1303,7 +1307,8 @@ void ConnectivityTracer::OffsetMinDistances(Ray<FloatType>& rays)
|
||||
template <typename FloatType>
|
||||
void ConnectivityTracer::FindMeshEntry(Ray<FloatType>& rays)
|
||||
{
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> entryTimer;
|
||||
vtkm::cont::Timer entryTimer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
entryTimer.Start();
|
||||
//
|
||||
// if ray misses the external face it will be marked RAY_EXITED_MESH
|
||||
//
|
||||
|
@ -533,7 +533,8 @@ VTKM_CONT void GenerateFaceConnnectivity(
|
||||
vtkm::cont::ArrayHandle<vtkm::Int32>& uniqueFaces)
|
||||
{
|
||||
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
|
||||
vtkm::Id numCells = shapes.GetNumberOfValues();
|
||||
|
||||
@ -622,7 +623,8 @@ VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Vec<Id, 4>> ExtractFaces(
|
||||
const OffsetsHandleType& shapeOffsets)
|
||||
{
|
||||
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 3>> externalFacePairs;
|
||||
vtkm::cont::Algorithm::CopyIf(cellFaceId, uniqueFaces, externalFacePairs, IsUnique());
|
||||
|
||||
@ -678,7 +680,8 @@ void MeshConnectivityBuilder::BuildConnectivity(
|
||||
Logger* logger = Logger::GetInstance();
|
||||
logger->OpenLogEntry("mesh_conn");
|
||||
//logger->AddLogData("device", GetDeviceString(DeviceAdapter()));
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
|
||||
vtkm::Float32 BoundingBox[6];
|
||||
BoundingBox[0] = vtkm::Float32(coordsBounds.X.Min);
|
||||
@ -738,7 +741,8 @@ void MeshConnectivityBuilder::BuildConnectivity(
|
||||
{
|
||||
Logger* logger = Logger::GetInstance();
|
||||
logger->OpenLogEntry("meah_conn");
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
|
||||
vtkm::Float32 BoundingBox[6];
|
||||
BoundingBox[0] = vtkm::Float32(coordsBounds.X.Min);
|
||||
@ -813,7 +817,8 @@ vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>>
|
||||
MeshConnectivityBuilder::ExternalTrianglesStructured(
|
||||
vtkm::cont::CellSetStructured<3>& cellSetStructured)
|
||||
{
|
||||
vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
|
||||
vtkm::Id3 cellDims = cellSetStructured.GetCellDimensions();
|
||||
vtkm::Id numFaces =
|
||||
@ -900,7 +905,8 @@ MeshConnContainer* MeshConnectivityBuilder::BuildConnectivity(
|
||||
logger->OpenLogEntry("mesh_conn_construction");
|
||||
|
||||
MeshConnContainer* meshConn = nullptr;
|
||||
vtkm::cont::Timer<cont::DeviceAdapterTagSerial> timer;
|
||||
vtkm::cont::Timer timer{ cont::DeviceAdapterTagSerial() };
|
||||
timer.Start();
|
||||
|
||||
if (type == Unstructured)
|
||||
{
|
||||
|
@ -192,7 +192,6 @@ UnstructuredSingleContainer::UnstructuredSingleContainer(
|
||||
|
||||
Logger* logger = Logger::GetInstance();
|
||||
logger->OpenLogEntry("mesh_conn_construction");
|
||||
vtkm::cont::Timer<cont::DeviceAdapterTagSerial> timer;
|
||||
|
||||
Intersector.SetData(Coords, Triangles);
|
||||
}
|
||||
|
@ -281,10 +281,11 @@ void RayTracer::Clear()
|
||||
template <typename Precision>
|
||||
void RayTracer::RenderOnDevice(Ray<Precision>& rays)
|
||||
{
|
||||
using Timer = vtkm::cont::Timer<vtkm::cont::DeviceAdapterTagSerial>;
|
||||
using Timer = vtkm::cont::Timer;
|
||||
|
||||
Logger* logger = Logger::GetInstance();
|
||||
Timer renderTimer;
|
||||
Timer renderTimer{ vtkm::cont::DeviceAdapterTagSerial() };
|
||||
renderTimer.Start();
|
||||
vtkm::Float64 time = 0.;
|
||||
logger->OpenLogEntry("ray_tracer");
|
||||
logger->AddLogData("device", GetDeviceString());
|
||||
@ -295,6 +296,7 @@ void RayTracer::RenderOnDevice(Ray<Precision>& rays)
|
||||
if (NumberOfShapes > 0)
|
||||
{
|
||||
Timer timer;
|
||||
timer.Start();
|
||||
|
||||
for (size_t i = 0; i < numShapes; ++i)
|
||||
{
|
||||
@ -302,11 +304,11 @@ void RayTracer::RenderOnDevice(Ray<Precision>& rays)
|
||||
time = timer.GetElapsedTime();
|
||||
logger->AddLogData("intersect", time);
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
Intersectors[i]->IntersectionData(rays, ScalarField, ScalarRange);
|
||||
time = timer.GetElapsedTime();
|
||||
logger->AddLogData("intersection_data", time);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
// Calculate the color at the intersection point
|
||||
detail::SurfaceColor surfaceColor;
|
||||
@ -314,7 +316,6 @@ void RayTracer::RenderOnDevice(Ray<Precision>& rays)
|
||||
|
||||
time = timer.GetElapsedTime();
|
||||
logger->AddLogData("shade", time);
|
||||
timer.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -793,7 +793,8 @@ template <typename Precision, typename Device>
|
||||
void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<Precision>& rays,
|
||||
Device)
|
||||
{
|
||||
vtkm::cont::Timer<Device> renderTimer;
|
||||
vtkm::cont::Timer renderTimer{ Device() };
|
||||
renderTimer.Start();
|
||||
Logger* logger = Logger::GetInstance();
|
||||
logger->OpenLogEntry("volume_render_structured");
|
||||
logger->AddLogData("device", GetDeviceString(Device()));
|
||||
@ -808,7 +809,8 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
|
||||
SampleDistance = vtkm::Magnitude(extent) / defaultNumberOfSamples;
|
||||
}
|
||||
|
||||
vtkm::cont::Timer<Device> timer;
|
||||
vtkm::cont::Timer timer{ Device() };
|
||||
timer.Start();
|
||||
vtkm::worklet::DispatcherMapField<CalcRayStart> calcRayStartDispatcher(
|
||||
CalcRayStart(this->SpatialExtent));
|
||||
calcRayStartDispatcher.SetDevice(Device());
|
||||
@ -817,7 +819,7 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
|
||||
|
||||
vtkm::Float64 time = timer.GetElapsedTime();
|
||||
logger->AddLogData("calc_ray_start", time);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
bool isSupportedField =
|
||||
(ScalarField->GetAssociation() == vtkm::cont::Field::Association::POINTS ||
|
||||
@ -908,7 +910,6 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
|
||||
|
||||
time = timer.GetElapsedTime();
|
||||
logger->AddLogData("sample", time);
|
||||
timer.Reset();
|
||||
|
||||
time = renderTimer.GetElapsedTime();
|
||||
logger->CloseLogEntry(time);
|
||||
|
@ -186,20 +186,17 @@ private:
|
||||
bool computeRegularStructure)
|
||||
{
|
||||
using namespace vtkm::worklet::contourtree_augmented;
|
||||
// TODO: This should be switched to use the logging macros defined in vtkm/cont/logging.h
|
||||
// Start the timer
|
||||
vtkm::cont::Timer<> totalTime;
|
||||
|
||||
// Stage 1: Load the data into the mesh. This is done in the Run() method above and accessible
|
||||
// here via the mesh parameter. The actual data load is performed outside of the
|
||||
// worklet in the example contour tree app (or whoever uses the worklet)
|
||||
|
||||
// Stage 2 : Sort the data on the mesh to initialize sortIndex & indexReverse on the mesh
|
||||
// Start the timer for the mesh sort
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
mesh.SortData(fieldArray);
|
||||
timings.push_back(std::pair<std::string, vtkm::Float64>("Sort Data", timer.GetElapsedTime()));
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
// Stage 3: Assign every mesh vertex to a peak
|
||||
MeshExtrema extrema(mesh.nVertices);
|
||||
@ -207,7 +204,7 @@ private:
|
||||
extrema.BuildRegularChains(true);
|
||||
timings.push_back(
|
||||
std::pair<std::string, vtkm::Float64>("Join Tree Regular Chains", timer.GetElapsedTime()));
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
// Stage 4: Identify join saddles & construct Active Join Graph
|
||||
MergeTree joinTree(mesh.nVertices, true);
|
||||
@ -220,7 +217,7 @@ private:
|
||||
joinGraph.DebugPrint("Active Graph Instantiated", __FILE__, __LINE__);
|
||||
joinGraph.DebugPrint("Active Graph Instantiated", __FILE__, __LINE__);
|
||||
#endif
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
// Stage 5: Compute Join Tree Hyperarcs from Active Join Graph
|
||||
joinGraph.MakeMergeTree(joinTree, extrema);
|
||||
@ -230,14 +227,14 @@ private:
|
||||
joinTree.DebugPrint("Join tree Computed", __FILE__, __LINE__);
|
||||
joinTree.DebugPrintTree("Join tree", __FILE__, __LINE__, mesh);
|
||||
#endif
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
// Stage 6: Assign every mesh vertex to a pit
|
||||
extrema.SetStarts(mesh, false);
|
||||
extrema.BuildRegularChains(false);
|
||||
timings.push_back(
|
||||
std::pair<std::string, vtkm::Float64>("Spit Tree Regular Chains", timer.GetElapsedTime()));
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
// Stage 7: Identify split saddles & construct Active Split Graph
|
||||
MergeTree splitTree(mesh.nVertices, false);
|
||||
@ -248,7 +245,7 @@ private:
|
||||
#ifdef DEBUG_PRINT
|
||||
splitGraph.DebugPrint("Active Graph Instantiated", __FILE__, __LINE__);
|
||||
#endif
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
// Stage 8: Compute Split Tree Hyperarcs from Active Split Graph
|
||||
splitGraph.MakeMergeTree(splitTree, extrema);
|
||||
@ -260,7 +257,7 @@ private:
|
||||
joinTree.DebugPrintTree("Join tree", __FILE__, __LINE__, mesh);
|
||||
splitTree.DebugPrintTree("Split tree", __FILE__, __LINE__, mesh);
|
||||
#endif
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
// Stage 9: Join & Split Tree are Augmented, then combined to construct Contour Tree
|
||||
contourTree.Init(mesh.nVertices);
|
||||
@ -269,7 +266,7 @@ private:
|
||||
treeMaker.ComputeHyperAndSuperStructure();
|
||||
timings.push_back(std::pair<std::string, vtkm::Float64>(
|
||||
"Contour Tree Hyper and Super Structure", timer.GetElapsedTime()));
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
|
||||
// 9.2 Then we compute the regular structure
|
||||
if (computeRegularStructure)
|
||||
@ -277,7 +274,6 @@ private:
|
||||
treeMaker.ComputeRegularStructure(extrema);
|
||||
timings.push_back(std::pair<std::string, vtkm::Float64>("Contour Tree Regular Structure",
|
||||
timer.GetElapsedTime()));
|
||||
timer.Reset();
|
||||
}
|
||||
|
||||
// Collect the output data
|
||||
|
@ -46,7 +46,9 @@
|
||||
//----------------------------------------------------------------------------
|
||||
#if defined(__VTKM_GAUSSIAN_SPLATTER_BENCHMARK) && !defined(START_TIMER_BLOCK)
|
||||
// start timer
|
||||
#define START_TIMER_BLOCK(name) vtkm::cont::Timer<DeviceAdapter> timer_##name;
|
||||
#define START_TIMER_BLOCK(name) \
|
||||
vtkm::cont::Timer timer_##name{ DeviceAdapter() }; \
|
||||
timer_##name.Start();
|
||||
|
||||
// stop timer
|
||||
#define END_TIMER_BLOCK(name) \
|
||||
@ -453,7 +455,7 @@ struct KernelSplatterFilterUniformGrid
|
||||
START_TIMER_BLOCK(numNeighborsExclusiveSum)
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::ScanExclusive(numNeighbors,
|
||||
numNeighborsExclusiveSum);
|
||||
END_TIMER_BLOCK(numNeighborsExclusiveSum)
|
||||
//END_TIMER_BLOCK(numNeighborsExclusiveSum)
|
||||
debug::OutputArrayDebug(numNeighborsExclusiveSum, "numNeighborsExclusiveSum");
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
@ -357,8 +357,10 @@ public:
|
||||
}
|
||||
|
||||
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
|
||||
vtkm::cont::Timer<> totalTimer;
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer totalTimer;
|
||||
totalTimer.Start();
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////
|
||||
@ -374,8 +376,9 @@ public:
|
||||
mapPointsDispatcher.Invoke(coordinates, pointCidArray);
|
||||
|
||||
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
|
||||
timer.stop();
|
||||
std::cout << "Time map points (s): " << timer.GetElapsedTime() << std::endl;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
#endif
|
||||
|
||||
/// pass 2 : Choose a representative point from each cluster for the output:
|
||||
@ -399,7 +402,7 @@ public:
|
||||
|
||||
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
|
||||
std::cout << "Time after reducing points (s): " << timer.GetElapsedTime() << std::endl;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
#endif
|
||||
|
||||
/// Pass 3 : Decimated mesh generation
|
||||
@ -415,7 +418,7 @@ public:
|
||||
|
||||
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
|
||||
std::cout << "Time after clustering cells (s): " << timer.GetElapsedTime() << std::endl;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
#endif
|
||||
|
||||
/// preparation: Get the indexes of the clustered points to prepare for new cell array
|
||||
@ -460,7 +463,7 @@ public:
|
||||
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
|
||||
std::cout << "Time before sort and unique with hashing (s): " << timer.GetElapsedTime()
|
||||
<< std::endl;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
#endif
|
||||
|
||||
this->CellIdMap = vtkm::worklet::StableSortIndices::Sort(pointId3HashArray);
|
||||
@ -469,7 +472,7 @@ public:
|
||||
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
|
||||
std::cout << "Time after sort and unique with hashing (s): " << timer.GetElapsedTime()
|
||||
<< std::endl;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
#endif
|
||||
|
||||
// Create a temporary permutation array and use that for unhashing.
|
||||
@ -485,7 +488,7 @@ public:
|
||||
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
|
||||
std::cout << "Time before sort and unique [no hashing] (s): " << timer.GetElapsedTime()
|
||||
<< std::endl;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
#endif
|
||||
|
||||
this->CellIdMap = vtkm::worklet::StableSortIndices::Sort(pointId3Array);
|
||||
@ -494,7 +497,7 @@ public:
|
||||
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
|
||||
std::cout << "Time after sort and unique [no hashing] (s): " << timer.GetElapsedTime()
|
||||
<< std::endl;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
#endif
|
||||
|
||||
// Permute the connectivity array into a basic array handle. Use a
|
||||
|
@ -72,8 +72,7 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet,
|
||||
vtkm::IdComponent numPlanes,
|
||||
const vtkm::cont::DeviceAdapterId& id)
|
||||
{
|
||||
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
|
||||
using Timer = vtkm::cont::Timer<DeviceAdapter>;
|
||||
using Timer = vtkm::cont::Timer;
|
||||
|
||||
vtkm::cont::DynamicCellSet cellSet = dataSet.GetCellSet();
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates vertices = dataSet.GetCoordinateSystem().GetData();
|
||||
@ -87,14 +86,17 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet,
|
||||
std::cout << "Built Bounding Interval Hierarchy Tree" << std::endl;
|
||||
|
||||
Timer centroidsTimer;
|
||||
centroidsTimer.Start();
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> centroids;
|
||||
vtkm::worklet::DispatcherMapTopology<CellCentroidCalculator>().Invoke(
|
||||
cellSet, vertices, centroids);
|
||||
//std::cout << "Centroids calculation time: " << centroidsTimer.GetElapsedTime() << "\n";
|
||||
centroidsTimer.Stop();
|
||||
std::cout << "Centroids calculation time: " << centroidsTimer.GetElapsedTime() << "\n";
|
||||
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> expectedCellIds(0, 1, cellSet.GetNumberOfCells());
|
||||
|
||||
Timer interpolationTimer;
|
||||
interpolationTimer.Start();
|
||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> results;
|
||||
#ifdef VTKM_CUDA
|
||||
//set up stack size for cuda envinroment
|
||||
@ -119,6 +121,7 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet,
|
||||
}
|
||||
#endif
|
||||
vtkm::Id numDiffs = vtkm::cont::Algorithm::Reduce(results, 0, vtkm::Add());
|
||||
interpolationTimer.Stop();
|
||||
vtkm::Float64 timeDiff = interpolationTimer.GetElapsedTime();
|
||||
std::cout << "No of interpolations: " << results.GetNumberOfValues() << "\n";
|
||||
std::cout << "Interpolation time: " << timeDiff << "\n";
|
||||
|
@ -209,7 +209,8 @@ void TestDecomposeReconstruct3D(vtkm::Float64 cratio)
|
||||
|
||||
// Decompose
|
||||
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
computationTime =
|
||||
compressor.WaveDecompose3D(inputArray, nLevels, sigX, sigY, sigZ, outputArray, false);
|
||||
elapsedTime1 = timer.GetElapsedTime();
|
||||
@ -217,14 +218,14 @@ void TestDecomposeReconstruct3D(vtkm::Float64 cratio)
|
||||
std::cout << " ->computation time = " << computationTime << std::endl;
|
||||
|
||||
// Squash small coefficients
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
compressor.SquashCoefficients(outputArray, cratio);
|
||||
elapsedTime2 = timer.GetElapsedTime();
|
||||
std::cout << "Squash time = " << elapsedTime2 << std::endl;
|
||||
|
||||
// Reconstruct
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> reconstructArray;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
computationTime =
|
||||
compressor.WaveReconstruct3D(outputArray, nLevels, sigX, sigY, sigZ, reconstructArray, false);
|
||||
elapsedTime3 = timer.GetElapsedTime();
|
||||
@ -237,7 +238,7 @@ void TestDecomposeReconstruct3D(vtkm::Float64 cratio)
|
||||
|
||||
compressor.EvaluateReconstruction(inputArray, reconstructArray);
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
for (vtkm::Id i = 0; i < reconstructArray.GetNumberOfValues(); i++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(reconstructArray.GetPortalConstControl().Get(i),
|
||||
@ -276,21 +277,22 @@ void TestDecomposeReconstruct2D(vtkm::Float64 cratio)
|
||||
vtkm::Float64 elapsedTime1, elapsedTime2, elapsedTime3;
|
||||
|
||||
// Decompose
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
computationTime = compressor.WaveDecompose2D(inputArray, nLevels, sigX, sigY, outputArray, L);
|
||||
elapsedTime1 = timer.GetElapsedTime();
|
||||
std::cout << "Decompose time = " << elapsedTime1 << std::endl;
|
||||
std::cout << " ->computation time = " << computationTime << std::endl;
|
||||
|
||||
// Squash small coefficients
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
compressor.SquashCoefficients(outputArray, cratio);
|
||||
elapsedTime2 = timer.GetElapsedTime();
|
||||
std::cout << "Squash time = " << elapsedTime2 << std::endl;
|
||||
|
||||
// Reconstruct
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> reconstructArray;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
computationTime =
|
||||
compressor.WaveReconstruct2D(outputArray, nLevels, sigX, sigY, reconstructArray, L);
|
||||
elapsedTime3 = timer.GetElapsedTime();
|
||||
@ -303,7 +305,7 @@ void TestDecomposeReconstruct2D(vtkm::Float64 cratio)
|
||||
|
||||
compressor.EvaluateReconstruction(inputArray, reconstructArray);
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
for (vtkm::Id i = 0; i < reconstructArray.GetNumberOfValues(); i++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(reconstructArray.GetPortalConstControl().Get(i),
|
||||
@ -342,28 +344,29 @@ void TestDecomposeReconstruct1D(vtkm::Float64 cratio)
|
||||
std::vector<vtkm::Id> L;
|
||||
|
||||
// Decompose
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
compressor.WaveDecompose(inputArray, nLevels, outputArray, L);
|
||||
|
||||
vtkm::Float64 elapsedTime = timer.GetElapsedTime();
|
||||
std::cout << "Decompose time = " << elapsedTime << std::endl;
|
||||
|
||||
// Squash small coefficients
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
compressor.SquashCoefficients(outputArray, cratio);
|
||||
elapsedTime = timer.GetElapsedTime();
|
||||
std::cout << "Squash time = " << elapsedTime << std::endl;
|
||||
|
||||
// Reconstruct
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> reconstructArray;
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
compressor.WaveReconstruct(outputArray, nLevels, L, reconstructArray);
|
||||
elapsedTime = timer.GetElapsedTime();
|
||||
std::cout << "Reconstruction time = " << elapsedTime << std::endl;
|
||||
|
||||
compressor.EvaluateReconstruction(inputArray, reconstructArray);
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
for (vtkm::Id i = 0; i < reconstructArray.GetNumberOfValues(); i++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(reconstructArray.GetPortalConstControl().Get(i),
|
||||
|
@ -42,7 +42,8 @@ struct WaveletGeneratorFunctor
|
||||
|
||||
void WaveletGeneratorTest()
|
||||
{
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
detail::WaveletGeneratorFunctor wgFunctor;
|
||||
vtkm::cont::TryExecute(wgFunctor);
|
||||
|
||||
|
@ -602,7 +602,7 @@ public:
|
||||
using TopDownDispatcherType = vtkm::worklet::DispatcherMapField<TopDownXFormType>;
|
||||
using FrontBackDispatcherType = vtkm::worklet::DispatcherMapField<FrontBackXFormType>;
|
||||
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
vtkm::Float64 computationTime = 0.0;
|
||||
|
||||
// First transform in X direction
|
||||
@ -646,7 +646,7 @@ public:
|
||||
sigPretendDimY,
|
||||
sigPretendDimZ);
|
||||
LeftRightDispatcherType dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(leftExt,
|
||||
sigIn,
|
||||
rightExt,
|
||||
@ -702,7 +702,7 @@ public:
|
||||
addLen,
|
||||
sigPretendDimZ);
|
||||
TopDownDispatcherType dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(topExt,
|
||||
afterX,
|
||||
bottomExt,
|
||||
@ -753,7 +753,7 @@ public:
|
||||
sigPretendDimY,
|
||||
addLen);
|
||||
FrontBackDispatcherType dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(frontExt,
|
||||
afterY,
|
||||
backExt,
|
||||
@ -795,7 +795,7 @@ public:
|
||||
using TopDownDispatcherType = vtkm::worklet::DispatcherMapField<TopDownXFormType>;
|
||||
using FrontBackDispatcherType = vtkm::worklet::DispatcherMapField<FrontBackXFormType>;
|
||||
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
vtkm::Float64 computationTime = 0.0;
|
||||
|
||||
// First, inverse transform in Z direction
|
||||
@ -854,7 +854,7 @@ public:
|
||||
inStartY,
|
||||
inStartZ); // coeffIn
|
||||
FrontBackDispatcherType dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
ext3,
|
||||
@ -927,7 +927,7 @@ public:
|
||||
0,
|
||||
0);
|
||||
TopDownDispatcherType dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
ext3,
|
||||
@ -995,7 +995,7 @@ public:
|
||||
0,
|
||||
0);
|
||||
LeftRightDispatcherType dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
ext3,
|
||||
@ -1489,7 +1489,8 @@ public:
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::wavelets::ForwardTransform> dispatcher(
|
||||
forwardTransform);
|
||||
// put a timer
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
dispatcher.Invoke(sigInExtended,
|
||||
WaveletBase::filter.GetLowDecomposeFilter(),
|
||||
WaveletBase::filter.GetHighDecomposeFilter(),
|
||||
@ -1643,7 +1644,8 @@ public:
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::wavelets::InverseTransformOdd> dispatcher(
|
||||
inverseXformOdd);
|
||||
// use a timer
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
dispatcher.Invoke(coeffInExtended,
|
||||
WaveletBase::filter.GetLowReconstructFilter(),
|
||||
WaveletBase::filter.GetHighReconstructFilter(),
|
||||
@ -1657,7 +1659,8 @@ public:
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::wavelets::InverseTransformEven> dispatcher(
|
||||
inverseXformEven);
|
||||
// use a timer
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
dispatcher.Invoke(coeffInExtended,
|
||||
WaveletBase::filter.GetLowReconstructFilter(),
|
||||
WaveletBase::filter.GetHighReconstructFilter(),
|
||||
@ -1728,7 +1731,7 @@ public:
|
||||
using ForwardXForm = vtkm::worklet::wavelets::ForwardTransform2D;
|
||||
using DispatcherType = typename vtkm::worklet::DispatcherMapField<ForwardXForm>;
|
||||
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
vtkm::Float64 computationTime = 0.0;
|
||||
|
||||
ArrayType afterX;
|
||||
@ -1767,7 +1770,7 @@ public:
|
||||
addLen,
|
||||
sigPretendDimY);
|
||||
DispatcherType dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(leftExt,
|
||||
sigIn,
|
||||
rightExt,
|
||||
@ -1811,7 +1814,7 @@ public:
|
||||
sigPretendDimX,
|
||||
addLen);
|
||||
DispatcherType dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(topExt,
|
||||
afterX,
|
||||
bottomExt,
|
||||
@ -1842,7 +1845,7 @@ public:
|
||||
using BasicArrayType = vtkm::cont::ArrayHandle<typename ArrayInType::ValueType>;
|
||||
using IDWT2DWorklet = vtkm::worklet::wavelets::InverseTransform2D;
|
||||
using Dispatcher = vtkm::worklet::DispatcherMapField<IDWT2DWorklet>;
|
||||
vtkm::cont::Timer<> timer;
|
||||
vtkm::cont::Timer timer;
|
||||
vtkm::Float64 computationTime = 0.0;
|
||||
|
||||
// First inverse transform on columns
|
||||
@ -1891,7 +1894,7 @@ public:
|
||||
inStartY, // coeffIn
|
||||
false); // top-down
|
||||
Dispatcher dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
ext3,
|
||||
@ -1947,7 +1950,7 @@ public:
|
||||
0,
|
||||
true); // left-right
|
||||
Dispatcher dispatcher(worklet);
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
ext3,
|
||||
|
Loading…
Reference in New Issue
Block a user