Viskores  1.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
viskores::cont::RuntimeDeviceTracker Class Reference

RuntimeDeviceTracker is the central location for determining which device adapter will be active for algorithm execution. More...

#include <RuntimeDeviceTracker.h>

Inheritance diagram for viskores::cont::RuntimeDeviceTracker:
viskores::cont::ScopedRuntimeDeviceTracker

Public Member Functions

 ~RuntimeDeviceTracker ()
 
bool CanRunOn (DeviceAdapterId deviceId) const
 Returns true if the given device adapter is supported on the current machine. More...
 
void ReportAllocationFailure (viskores::cont::DeviceAdapterId deviceId, const viskores::cont::ErrorBadAllocation &)
 Report a failure to allocate memory on a device, this will flag the device as being unusable for all future invocations. More...
 
void ReportBadDeviceFailure (viskores::cont::DeviceAdapterId deviceId, const viskores::cont::ErrorBadDevice &)
 Report a ErrorBadDevice failure and flag the device as unusable. More...
 
void ResetDevice (viskores::cont::DeviceAdapterId deviceId)
 Reset the tracker for the given device. More...
 
void Reset ()
 Reset the tracker to its default state for default devices. More...
 
void DisableDevice (DeviceAdapterId deviceId)
 Disable the given device. More...
 
void ForceDevice (DeviceAdapterId deviceId)
 Disable all devices except the specified one. More...
 
bool GetThreadFriendlyMemAlloc () const
 Get/Set use of thread-friendly memory allocation for a device. More...
 
void SetThreadFriendlyMemAlloc (bool state)
 Get/Set use of thread-friendly memory allocation for a device. More...
 
void CopyStateFrom (const viskores::cont::RuntimeDeviceTracker &tracker)
 Copies the state from the given device. More...
 
void SetAbortChecker (const std::function< bool()> &func)
 Set/Clear the abort checker functor. More...
 
void ClearAbortChecker ()
 Set/Clear the abort checker functor. More...
 
bool CheckForAbortRequest () const
 
void PrintSummary (std::ostream &out) const
 Produce a human-readable report on the state of the runtime device tracker. More...
 

Private Member Functions

 RuntimeDeviceTracker (detail::RuntimeDeviceTrackerInternals *details, bool reset)
 
 RuntimeDeviceTracker (const RuntimeDeviceTracker &)=delete
 
RuntimeDeviceTrackeroperator= (const RuntimeDeviceTracker &)=delete
 
void CheckDevice (viskores::cont::DeviceAdapterId deviceId) const
 
void SetDeviceState (viskores::cont::DeviceAdapterId deviceId, bool state)
 
void LogEnabledDevices () const
 

Private Attributes

detail::RuntimeDeviceTrackerInternals * Internals
 

Friends

class ScopedRuntimeDeviceTracker
 
viskores::cont::RuntimeDeviceTrackerGetRuntimeDeviceTracker ()
 Get the RuntimeDeviceTracker for the current thread. More...
 

Detailed Description

RuntimeDeviceTracker is the central location for determining which device adapter will be active for algorithm execution.

Many features in Viskores will attempt to run algorithms on the "best available device." This generally is determined at runtime as some backends require specific hardware, or failures in one device are recorded and that device is disabled.

While viskores::cont::RunimeDeviceInformation reports on the existence of a device being supported, this tracks on a per-thread basis when worklets fail, why the fail, and will update the list of valid runtime devices based on that information.

Constructor & Destructor Documentation

◆ ~RuntimeDeviceTracker()

viskores::cont::RuntimeDeviceTracker::~RuntimeDeviceTracker ( )

◆ RuntimeDeviceTracker() [1/2]

viskores::cont::RuntimeDeviceTracker::RuntimeDeviceTracker ( detail::RuntimeDeviceTrackerInternals *  details,
bool  reset 
)
private

◆ RuntimeDeviceTracker() [2/2]

viskores::cont::RuntimeDeviceTracker::RuntimeDeviceTracker ( const RuntimeDeviceTracker )
privatedelete

Member Function Documentation

◆ CanRunOn()

bool viskores::cont::RuntimeDeviceTracker::CanRunOn ( DeviceAdapterId  deviceId) const

Returns true if the given device adapter is supported on the current machine.

◆ CheckDevice()

void viskores::cont::RuntimeDeviceTracker::CheckDevice ( viskores::cont::DeviceAdapterId  deviceId) const
private

◆ CheckForAbortRequest()

bool viskores::cont::RuntimeDeviceTracker::CheckForAbortRequest ( ) const

◆ ClearAbortChecker()

void viskores::cont::RuntimeDeviceTracker::ClearAbortChecker ( )

Set/Clear the abort checker functor.

If set the abort checker functor is called by viskores::cont::TryExecute() before scheduling a task on a device from the associated the thread. If the functor returns true, an exception is thrown.

◆ CopyStateFrom()

void viskores::cont::RuntimeDeviceTracker::CopyStateFrom ( const viskores::cont::RuntimeDeviceTracker tracker)

Copies the state from the given device.

This is a convenient way to allow the RuntimeDeviceTracker on one thread copy the behavior from another thread.

◆ DisableDevice()

void viskores::cont::RuntimeDeviceTracker::DisableDevice ( DeviceAdapterId  deviceId)

Disable the given device.

The main intention of RuntimeDeviceTracker is to keep track of what devices are working for Viskores. However, it can also be used to turn devices on and off. Use this method to disable (turn off) a given device. Use ResetDevice() to turn the device back on (if it is supported).

Passing DeviceAdapterTagAny to this will disable all devices.

◆ ForceDevice()

void viskores::cont::RuntimeDeviceTracker::ForceDevice ( DeviceAdapterId  deviceId)

Disable all devices except the specified one.

The main intention of RuntimeDeviceTracker is to keep track of what devices are working for Viskores. However, it can also be used to turn devices on and off. Use this method to disable all devices except one to effectively force Viskores to use that device. Either pass the DeviceAdapterTagAny to this function or call Reset() to restore all devices to their default state.

This method will throw a viskores::cont::ErrorBadValue if the given device does not exist on the system.

◆ GetThreadFriendlyMemAlloc()

bool viskores::cont::RuntimeDeviceTracker::GetThreadFriendlyMemAlloc ( ) const

Get/Set use of thread-friendly memory allocation for a device.

◆ LogEnabledDevices()

void viskores::cont::RuntimeDeviceTracker::LogEnabledDevices ( ) const
private

◆ operator=()

RuntimeDeviceTracker& viskores::cont::RuntimeDeviceTracker::operator= ( const RuntimeDeviceTracker )
privatedelete

◆ PrintSummary()

void viskores::cont::RuntimeDeviceTracker::PrintSummary ( std::ostream &  out) const

Produce a human-readable report on the state of the runtime device tracker.

◆ ReportAllocationFailure()

void viskores::cont::RuntimeDeviceTracker::ReportAllocationFailure ( viskores::cont::DeviceAdapterId  deviceId,
const viskores::cont::ErrorBadAllocation  
)
inline

Report a failure to allocate memory on a device, this will flag the device as being unusable for all future invocations.

◆ ReportBadDeviceFailure()

void viskores::cont::RuntimeDeviceTracker::ReportBadDeviceFailure ( viskores::cont::DeviceAdapterId  deviceId,
const viskores::cont::ErrorBadDevice  
)
inline

Report a ErrorBadDevice failure and flag the device as unusable.

◆ Reset()

void viskores::cont::RuntimeDeviceTracker::Reset ( )

Reset the tracker to its default state for default devices.

Will discard any updates caused by reported failures.

◆ ResetDevice()

void viskores::cont::RuntimeDeviceTracker::ResetDevice ( viskores::cont::DeviceAdapterId  deviceId)

Reset the tracker for the given device.

This will discard any updates caused by reported failures. Passing DeviceAdapterTagAny to this will reset all devices (same as Reset()).

◆ SetAbortChecker()

void viskores::cont::RuntimeDeviceTracker::SetAbortChecker ( const std::function< bool()> &  func)

Set/Clear the abort checker functor.

If set the abort checker functor is called by viskores::cont::TryExecute() before scheduling a task on a device from the associated the thread. If the functor returns true, an exception is thrown.

◆ SetDeviceState()

void viskores::cont::RuntimeDeviceTracker::SetDeviceState ( viskores::cont::DeviceAdapterId  deviceId,
bool  state 
)
private

◆ SetThreadFriendlyMemAlloc()

void viskores::cont::RuntimeDeviceTracker::SetThreadFriendlyMemAlloc ( bool  state)

Get/Set use of thread-friendly memory allocation for a device.

Friends And Related Function Documentation

◆ GetRuntimeDeviceTracker

viskores::cont::RuntimeDeviceTracker& GetRuntimeDeviceTracker ( )
friend

Get the RuntimeDeviceTracker for the current thread.


Many features in Viskores will attempt to run algorithms on the "best available device." This often is determined at runtime as failures in one device are recorded and that device is disabled. To prevent having to check over and over again, Viskores uses per thread runtime device tracker so that these choices are marked and shared.

◆ ScopedRuntimeDeviceTracker

friend class ScopedRuntimeDeviceTracker
friend

Member Data Documentation

◆ Internals

detail::RuntimeDeviceTrackerInternals* viskores::cont::RuntimeDeviceTracker::Internals
private

The documentation for this class was generated from the following file: