Commit 59dc78fd authored by Sujin Philip's avatar Sujin Philip

Add ErrorBadDevice

parent 4810cef7
......@@ -68,6 +68,7 @@ set(headers
EnvironmentTracker.h
Error.h
ErrorBadAllocation.h
ErrorBadDevice.h
ErrorBadType.h
ErrorBadValue.h
ErrorExecution.h
......
//============================================================================
// 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 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 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.
//============================================================================
#ifndef vtk_m_cont_ErrorBadDevice_h
#define vtk_m_cont_ErrorBadDevice_h
#include <vtkm/cont/Error.h>
namespace vtkm
{
namespace cont
{
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// This class is thrown when VTK-m performs an operation that is not supported
/// on the current device.
///
class VTKM_ALWAYS_EXPORT ErrorBadDevice : public Error
{
public:
ErrorBadDevice(const std::string& message)
: Error(message)
{
}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::cont
#endif // vtk_m_cont_ErrorBadDevice_h
......@@ -22,6 +22,7 @@
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/ErrorBadDevice.h>
#include <vtkm/cont/RuntimeDeviceInformation.h>
namespace vtkm
......@@ -85,6 +86,23 @@ public:
this->SetDeviceState(deviceId, name, false);
}
//@{
/// Report a ErrorBadDevice failure and flag the device as unusable.
template <typename DeviceAdapterTag>
VTKM_CONT void ReportBadDeviceFailure(DeviceAdapterTag, const vtkm::cont::ErrorBadDevice&)
{
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
this->SetDeviceState(Traits::GetId(), Traits::GetName(), false);
}
VTKM_CONT void ReportBadDeviceFailure(vtkm::Int8 deviceId,
const std::string& name,
const vtkm::cont::ErrorBadDevice&)
{
this->SetDeviceState(deviceId, name, false);
}
//@}
/// Reset the tracker for the given device. This will discard any updates
/// caused by reported failures
///
......
......@@ -46,6 +46,11 @@ void HandleTryExecuteException(vtkm::Int8 deviceId,
//than we fallback to another device
tracker.ReportAllocationFailure(deviceId, name, e);
}
catch (vtkm::cont::ErrorBadDevice& e)
{
std::cerr << "caught ErrorBadDevice: " << e.GetMessage() << std::endl;
tracker.ReportBadDeviceFailure(deviceId, name, e);
}
catch (vtkm::cont::ErrorBadType& e)
{
//should bad type errors should stop the execution, instead of
......
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