Commit 65d96ae8 authored by Allison Vacanti's avatar Allison Vacanti Committed by Kitware Robot

Merge topic 'use_rt_dev_name'

a8fa8d91 Use device id names where possible.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard's avatarRobert Maynard <robert.maynard@kitware.com>
Merge-request: !1393
parents 4e0e829b a8fa8d91
......@@ -32,7 +32,7 @@ void throwFailedRuntimeDeviceTransfer(const std::string& className,
vtkm::cont::DeviceAdapterId deviceId)
{ //Should we support typeid() instead of className?
const std::string msg = "VTK-m was unable to transfer " + className + " to DeviceAdapter[id=" +
std::to_string(deviceId.GetValue()) +
std::to_string(deviceId.GetValue()) + ", name=" + deviceId.GetName() +
"]. This is generally caused by asking for execution on a DeviceAdapter that "
"isn't compiled into VTK-m. In the case of CUDA it can also be caused by accidentally "
"compiling source files as C++ files instead of CUDA.";
......
......@@ -93,31 +93,28 @@ RuntimeDeviceTracker::~RuntimeDeviceTracker()
}
VTKM_CONT
void RuntimeDeviceTracker::CheckDevice(vtkm::cont::DeviceAdapterId deviceId,
const vtkm::cont::DeviceAdapterNameType& deviceName) const
void RuntimeDeviceTracker::CheckDevice(vtkm::cont::DeviceAdapterId deviceId) const
{
if (!deviceId.IsValueValid())
{
std::stringstream message;
message << "Device '" << deviceName << "' has invalid ID of " << (int)deviceId.GetValue();
message << "Device '" << deviceId.GetName() << "' has invalid ID of "
<< (int)deviceId.GetValue();
throw vtkm::cont::ErrorBadValue(message.str());
}
}
VTKM_CONT
bool RuntimeDeviceTracker::CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId,
const vtkm::cont::DeviceAdapterNameType& deviceName) const
bool RuntimeDeviceTracker::CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId) const
{
this->CheckDevice(deviceId, deviceName);
this->CheckDevice(deviceId);
return this->Internals->RuntimeValid[deviceId.GetValue()];
}
VTKM_CONT
void RuntimeDeviceTracker::SetDeviceState(vtkm::cont::DeviceAdapterId deviceId,
const vtkm::cont::DeviceAdapterNameType& deviceName,
bool state)
void RuntimeDeviceTracker::SetDeviceState(vtkm::cont::DeviceAdapterId deviceId, bool state)
{
this->CheckDevice(deviceId, deviceName);
this->CheckDevice(deviceId);
this->Internals->RuntimeValid[deviceId.GetValue()] = state;
}
......@@ -167,18 +164,16 @@ void RuntimeDeviceTracker::DeepCopy(const vtkm::cont::RuntimeDeviceTracker& src)
}
VTKM_CONT
void RuntimeDeviceTracker::ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId,
const vtkm::cont::DeviceAdapterNameType& deviceName,
bool runtimeExists)
void RuntimeDeviceTracker::ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId, bool runtimeExists)
{
if (!runtimeExists)
{
std::stringstream message;
message << "Cannot force to device '" << deviceName
message << "Cannot force to device '" << deviceId.GetName()
<< "' because that device is not available on this system";
throw vtkm::cont::ErrorBadValue(message.str());
}
this->CheckDevice(deviceId, deviceName);
this->CheckDevice(deviceId);
std::fill_n(this->Internals->RuntimeValid, VTKM_MAX_DEVICE_ADAPTER_ID, false);
......
......@@ -64,8 +64,7 @@ public:
template <typename DeviceAdapterTag>
VTKM_CONT bool CanRunOn(DeviceAdapterTag device) const
{
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
return this->CanRunOnImpl(device, Traits::GetName());
return this->CanRunOnImpl(device);
}
/// Report a failure to allocate memory on a device, this will flag the
......@@ -76,8 +75,7 @@ public:
VTKM_CONT void ReportAllocationFailure(DeviceAdapterTag device,
const vtkm::cont::ErrorBadAllocation&)
{
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
this->SetDeviceState(device, Traits::GetName(), false);
this->SetDeviceState(device, false);
}
/// Report a failure to allocate memory on a device, this will flag the
......@@ -85,10 +83,9 @@ public:
/// the filter.
///
VTKM_CONT void ReportAllocationFailure(vtkm::cont::DeviceAdapterId deviceId,
const std::string& name,
const vtkm::cont::ErrorBadAllocation&)
{
this->SetDeviceState(deviceId, name, false);
this->SetDeviceState(deviceId, false);
}
//@{
......@@ -96,15 +93,13 @@ public:
template <typename DeviceAdapterTag>
VTKM_CONT void ReportBadDeviceFailure(DeviceAdapterTag device, const vtkm::cont::ErrorBadDevice&)
{
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
this->SetDeviceState(device, Traits::GetName(), false);
this->SetDeviceState(device, false);
}
VTKM_CONT void ReportBadDeviceFailure(vtkm::cont::DeviceAdapterId deviceId,
const std::string& name,
const vtkm::cont::ErrorBadDevice&)
{
this->SetDeviceState(deviceId, name, false);
this->SetDeviceState(deviceId, false);
}
//@}
......@@ -114,9 +109,8 @@ public:
template <typename DeviceAdapterTag>
VTKM_CONT void ResetDevice(DeviceAdapterTag device)
{
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
vtkm::cont::RuntimeDeviceInformation<DeviceAdapterTag> runtimeDevice;
this->SetDeviceState(device, Traits::GetName(), runtimeDevice.Exists());
this->SetDeviceState(device, runtimeDevice.Exists());
}
/// Reset the tracker to its default state for default devices.
......@@ -180,8 +174,7 @@ public:
template <typename DeviceAdapterTag>
VTKM_CONT void DisableDevice(DeviceAdapterTag device)
{
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
this->SetDeviceState(device, Traits::GetName(), false);
this->SetDeviceState(device, false);
}
/// \brief Disable all devices except the specified one.
......@@ -199,9 +192,8 @@ public:
template <typename DeviceAdapterTag>
VTKM_CONT void ForceDevice(DeviceAdapterTag device)
{
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
vtkm::cont::RuntimeDeviceInformation<DeviceAdapterTag> runtimeDevice;
this->ForceDeviceImpl(device, Traits::GetName(), runtimeDevice.Exists());
this->ForceDeviceImpl(device, runtimeDevice.Exists());
}
VTKM_CONT_EXPORT
......@@ -213,25 +205,19 @@ private:
VTKM_CONT_EXPORT
VTKM_CONT
void CheckDevice(vtkm::cont::DeviceAdapterId deviceId,
const vtkm::cont::DeviceAdapterNameType& deviceName) const;
void CheckDevice(vtkm::cont::DeviceAdapterId deviceId) const;
VTKM_CONT_EXPORT
VTKM_CONT
bool CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId,
const vtkm::cont::DeviceAdapterNameType& deviceName) const;
bool CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId) const;
VTKM_CONT_EXPORT
VTKM_CONT
void SetDeviceState(vtkm::cont::DeviceAdapterId deviceId,
const vtkm::cont::DeviceAdapterNameType& deviceName,
bool state);
void SetDeviceState(vtkm::cont::DeviceAdapterId deviceId, bool state);
VTKM_CONT_EXPORT
VTKM_CONT
void ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId,
const vtkm::cont::DeviceAdapterNameType& deviceName,
bool runtimeExists);
void ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId, bool runtimeExists);
};
/// \brief Get the \c RuntimeDeviceTracker for the current thread.
......
......@@ -32,7 +32,6 @@ namespace detail
{
void HandleTryExecuteException(vtkm::cont::DeviceAdapterId deviceId,
const std::string& name,
vtkm::cont::RuntimeDeviceTracker& tracker)
{
try
......@@ -45,12 +44,12 @@ void HandleTryExecuteException(vtkm::cont::DeviceAdapterId deviceId,
std::cerr << "caught ErrorBadAllocation " << e.GetMessage() << std::endl;
//currently we only consider OOM errors worth disabling a device for
//than we fallback to another device
tracker.ReportAllocationFailure(deviceId, name, e);
tracker.ReportAllocationFailure(deviceId, e);
}
catch (vtkm::cont::ErrorBadDevice& e)
{
std::cerr << "caught ErrorBadDevice: " << e.GetMessage() << std::endl;
tracker.ReportBadDeviceFailure(deviceId, name, e);
tracker.ReportBadDeviceFailure(deviceId, e);
}
catch (vtkm::cont::ErrorBadType& e)
{
......
......@@ -33,7 +33,6 @@ namespace detail
{
VTKM_CONT_EXPORT void HandleTryExecuteException(vtkm::cont::DeviceAdapterId,
const std::string&,
vtkm::cont::RuntimeDeviceTracker&);
template <typename DeviceTag, typename Functor, typename... Args>
......@@ -52,8 +51,7 @@ inline bool TryExecuteIfValid(std::true_type,
}
catch (...)
{
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceTag>;
detail::HandleTryExecuteException(tag, Traits::GetName(), tracker);
detail::HandleTryExecuteException(tag, tracker);
}
}
......
......@@ -131,9 +131,9 @@ public:
if (!this->Internals->Transfers[static_cast<std::size_t>(deviceId.GetValue())])
{
std::string msg =
"VTK-m was asked to transfer a VirtualObjectHandle for execution on DeviceAdapter " +
std::to_string(deviceId.GetValue()) +
". It can't as this VirtualObjectHandle was not constructed/bound with this "
"VTK-m was asked to transfer a VirtualObjectHandle for execution on DeviceAdapter '" +
deviceId.GetName() + "' (" + std::to_string(deviceId.GetValue()) +
"). It can't as this VirtualObjectHandle was not constructed/bound with this "
"DeviceAdapter in the list of valid DeviceAdapters.";
throw vtkm::cont::ErrorBadDevice(msg);
}
......
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