Commit dd4a9395 authored by Kenneth Moreland's avatar Kenneth Moreland

Enable initializing Timer with a DeviceAdapterId

Previously, a vtkm::cont::Timer had to be initialized with either no
device or with a device adapter tag. However, this precluded
initializing the timer with a DeviceAdapterId, which made it difficult
to create a timer at runtime. Instead, just accept a DeviceAdapterId
(which all device adapter tags inherit from) and do runtime checks.
parent 702e2276
......@@ -165,6 +165,22 @@ Timer::Timer()
this->Init();
}
Timer::Timer(vtkm::cont::DeviceAdapterId device)
: Device(device)
, DeviceForQuery(vtkm::cont::DeviceAdapterTagAny())
, Internal(nullptr)
{
vtkm::cont::RuntimeDeviceTracker tracker;
if (device != DeviceAdapterTagAny() && !tracker.CanRunOn(device))
{
VTKM_LOG_S(vtkm::cont::LogLevel::Error,
"Device '" << device.GetName() << "' can not run on current Device."
"Thus timer is not usable");
}
this->Init();
}
Timer::~Timer()
{
......
......@@ -57,16 +57,7 @@ public:
VTKM_CONT
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();
}
VTKM_CONT Timer(vtkm::cont::DeviceAdapterId device);
VTKM_CONT ~Timer();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment