mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merge topic 'better_scoped_rt_dt'
bcaf7d9be ScopedRuntimeDeviceTracker have better controls of setting devices. 4212d0c04 RuntimeDeviceInformation now says the AnyTag exists. fa03dc664 ScopedRuntimeDeviceTracker requires a device to execute on when constructed. 4020f5198 RuntimeDeviceTracker can't be copied and is only accessible via reference. e9482018e ScopedRuntimeDeviceTracker has the same API as RuntimeDeviceTracker Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Kenneth Moreland <kmorel@sandia.gov> Merge-request: !1676
This commit is contained in:
commit
095e288383
@ -8,7 +8,7 @@ vtkm::cont::DeviceAdapterId id1 = vtkm::cont::make_DeviceAdapterId("cuda");
|
||||
vtkm::cont::DeviceAdapterId id2 = vtkm::cont::make_DeviceAdapterId("CUDA");
|
||||
vtkm::cont::DeviceAdapterId id3 = vtkm::cont::make_DeviceAdapterId("Cuda");
|
||||
|
||||
auto tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker();
|
||||
vtkm::cont::DeviceAdapterId id4 = tracker.GetDeviceAdapterId("cuda");
|
||||
vtkm::cont::DeviceAdapterId id5 = tracker.GetDeviceAdapterId("CUDA");
|
||||
vtkm::cont::DeviceAdapterId id6 = tracker.GetDeviceAdapterId("Cuda");
|
||||
|
@ -4,3 +4,87 @@ The device tracking infrastructure in VTK-m has been redesigned to
|
||||
remove multiple redundant codes paths and to simplify reasoning
|
||||
about around what an instance of RuntimeDeviceTracker will modify.
|
||||
|
||||
`vtkm::cont::RuntimeDeviceTracker` tracks runtime information on
|
||||
a per-user thread basis. This is done to allow multiple calling
|
||||
threads to use different vtk-m backends such as seen in this
|
||||
example:
|
||||
|
||||
```cpp
|
||||
vtkm::cont::DeviceAdapterTagCuda cuda;
|
||||
vtkm::cont::DeviceAdapterTagOpenMP openmp;
|
||||
{ // thread 1
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker->ForceDevice(cuda);
|
||||
vtkm::worklet::Invoker invoke;
|
||||
invoke(LightTask{}, input, output);
|
||||
vtkm::cont::Algorithm::Sort(output);
|
||||
invoke(HeavyTask{}, output);
|
||||
}
|
||||
|
||||
{ // thread 2
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker->ForceDevice(openmp);
|
||||
vtkm::worklet::Invoker invoke;
|
||||
invoke(LightTask{}, input, output);
|
||||
vtkm::cont::Algorithm::Sort(output);
|
||||
invoke(HeavyTask{}, output);
|
||||
}
|
||||
```
|
||||
|
||||
While this address the ability for threads to specify what
|
||||
device they should run on. It doesn't make it easy to toggle
|
||||
the status of a device in a programmatic way, for example
|
||||
the following block forces execution to only occur on
|
||||
`cuda` and doesn't restore previous active devices after
|
||||
|
||||
```cpp
|
||||
{
|
||||
vtkm::cont::DeviceAdapterTagCuda cuda;
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker->ForceDevice(cuda);
|
||||
vtkm::worklet::Invoker invoke;
|
||||
invoke(LightTask{}, input, output);
|
||||
}
|
||||
//openmp/tbb/... still inactive
|
||||
```
|
||||
|
||||
To resolve those issues we have `vtkm::cont::ScopedRuntimeDeviceTracker` which
|
||||
has the same interface as `vtkm::cont::RuntimeDeviceTracker` but additionally
|
||||
resets any per-user thread modifications when it goes out of scope. So by
|
||||
switching over the previous example to use `ScopedRuntimeDeviceTracker` we
|
||||
correctly restore the threads `RuntimeDeviceTracker` state when `tracker`
|
||||
goes out of scope.
|
||||
```cpp
|
||||
{
|
||||
vtkm::cont::DeviceAdapterTagCuda cuda;
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker(cuda);
|
||||
vtkm::worklet::Invoker invoke;
|
||||
invoke(LightTask{}, input, output);
|
||||
}
|
||||
//openmp/tbb/... are now again active
|
||||
```
|
||||
|
||||
The `vtkm::cont::ScopedRuntimeDeviceTracker` is not limited to forcing
|
||||
execution to occur on a single device. When constructed it can either force
|
||||
execution to a device, disable a device or enable a device. These options
|
||||
also work with the `DeviceAdapterTagAny`.
|
||||
|
||||
|
||||
```cpp
|
||||
{
|
||||
//enable all devices
|
||||
vtkm::cont::DeviceAdapterTagAny any;
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker(any,
|
||||
vtkm::cont::RuntimeDeviceTrackerMode::Enable);
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
//disable only cuda
|
||||
vtkm::cont::DeviceAdapterTagCuda cuda;
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker(cuda,
|
||||
vtkm::cont::RuntimeDeviceTrackerMode::Disable);
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
@ -126,7 +126,7 @@ VTKM_CONT MultiDeviceGradient::MultiDeviceGradient()
|
||||
, Workers()
|
||||
{
|
||||
//Step 1. Determine the number of workers we want
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
const bool runOnCuda = tracker.CanRunOn(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
const bool runOnOpenMP = tracker.CanRunOn(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
const bool runOnTbb = tracker.CanRunOn(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
|
@ -312,8 +312,7 @@ public:
|
||||
PortalConstType GetPortalConst() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker trackerScope;
|
||||
vtkm::cont::GetRuntimeDeviceTracker().ForceDevice(vtkm::cont::DeviceAdapterTagSerial());
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker trackerScope(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return PortalConstType(this->Array.GetPortalConstControl(), this->Functor.PrepareForControl());
|
||||
}
|
||||
|
||||
@ -404,8 +403,7 @@ public:
|
||||
PortalType GetPortal()
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker trackerScope;
|
||||
vtkm::cont::GetRuntimeDeviceTracker().ForceDevice(vtkm::cont::DeviceAdapterTagSerial());
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker trackerScope(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return PortalType(this->Array.GetPortalControl(),
|
||||
this->Functor.PrepareForControl(),
|
||||
this->InverseFunctor.PrepareForControl());
|
||||
@ -415,8 +413,7 @@ public:
|
||||
PortalConstType GetPortalConst() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker trackerScope;
|
||||
vtkm::cont::GetRuntimeDeviceTracker().ForceDevice(vtkm::cont::DeviceAdapterTagSerial());
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker trackerScope(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return PortalConstType(this->Array.GetPortalConstControl(),
|
||||
this->Functor.PrepareForControl(),
|
||||
this->InverseFunctor.PrepareForControl());
|
||||
|
@ -169,6 +169,11 @@ DeviceAdapterId RuntimeDeviceInformation::GetId(DeviceAdapterNameType name) cons
|
||||
VTKM_CONT
|
||||
bool RuntimeDeviceInformation::Exists(DeviceAdapterId id) const
|
||||
{
|
||||
if (id == vtkm::cont::DeviceAdapterTagAny{})
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
RuntimeDeviceInformationFunctor functor;
|
||||
vtkm::ListForEach(functor, VTKM_DEFAULT_DEVICE_ADAPTER_LIST_TAG(), id);
|
||||
return functor.Exists;
|
||||
|
@ -33,10 +33,14 @@ struct RuntimeDeviceTrackerInternals
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
RuntimeDeviceTracker::RuntimeDeviceTracker()
|
||||
: Internals(std::make_shared<detail::RuntimeDeviceTrackerInternals>())
|
||||
RuntimeDeviceTracker::RuntimeDeviceTracker(detail::RuntimeDeviceTrackerInternals* details,
|
||||
bool reset)
|
||||
: Internals(details)
|
||||
{
|
||||
this->Reset();
|
||||
if (reset)
|
||||
{
|
||||
this->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -57,10 +61,24 @@ void RuntimeDeviceTracker::CheckDevice(vtkm::cont::DeviceAdapterId deviceId) con
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
bool RuntimeDeviceTracker::CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId) const
|
||||
bool RuntimeDeviceTracker::CanRunOn(vtkm::cont::DeviceAdapterId deviceId) const
|
||||
{
|
||||
this->CheckDevice(deviceId);
|
||||
return this->Internals->RuntimeAllowed[deviceId.GetValue()];
|
||||
if (deviceId == vtkm::cont::DeviceAdapterTagAny{})
|
||||
{ //If at least a single device is enabled, than any device is enabled
|
||||
for (vtkm::Int8 i = 1; i < VTKM_MAX_DEVICE_ADAPTER_ID; ++i)
|
||||
{
|
||||
if (this->Internals->RuntimeAllowed[static_cast<std::size_t>(i)])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->CheckDevice(deviceId);
|
||||
return this->Internals->RuntimeAllowed[deviceId.GetValue()];
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -73,6 +91,21 @@ void RuntimeDeviceTracker::SetDeviceState(vtkm::cont::DeviceAdapterId deviceId,
|
||||
this->Internals->RuntimeAllowed[deviceId.GetValue()] = state;
|
||||
}
|
||||
|
||||
|
||||
VTKM_CONT void RuntimeDeviceTracker::ResetDevice(vtkm::cont::DeviceAdapterId deviceId)
|
||||
{
|
||||
if (deviceId == vtkm::cont::DeviceAdapterTagAny{})
|
||||
{
|
||||
this->Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::RuntimeDeviceInformation runtimeDevice;
|
||||
this->SetDeviceState(deviceId, runtimeDevice.Exists(deviceId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VTKM_CONT
|
||||
void RuntimeDeviceTracker::Reset()
|
||||
{
|
||||
@ -82,7 +115,7 @@ void RuntimeDeviceTracker::Reset()
|
||||
// when we use logging we get better messages stating we are reseting
|
||||
// the devices.
|
||||
vtkm::cont::RuntimeDeviceInformation runtimeDevice;
|
||||
for (vtkm::Int8 i = 0; i < VTKM_MAX_DEVICE_ADAPTER_ID; ++i)
|
||||
for (vtkm::Int8 i = 1; i < VTKM_MAX_DEVICE_ADAPTER_ID; ++i)
|
||||
{
|
||||
vtkm::cont::DeviceAdapterId device = vtkm::cont::make_DeviceAdapterId(i);
|
||||
if (device.IsValueValid())
|
||||
@ -95,53 +128,109 @@ void RuntimeDeviceTracker::Reset()
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::RuntimeDeviceTracker RuntimeDeviceTracker::DeepCopy() const
|
||||
VTKM_CONT void RuntimeDeviceTracker::DisableDevice(vtkm::cont::DeviceAdapterId deviceId)
|
||||
{
|
||||
return vtkm::cont::RuntimeDeviceTracker(this->Internals);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RuntimeDeviceTracker::DeepCopy(const vtkm::cont::RuntimeDeviceTracker& src)
|
||||
{
|
||||
std::copy_n(
|
||||
src.Internals->RuntimeAllowed, VTKM_MAX_DEVICE_ADAPTER_ID, this->Internals->RuntimeAllowed);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
RuntimeDeviceTracker::RuntimeDeviceTracker(
|
||||
const std::shared_ptr<detail::RuntimeDeviceTrackerInternals>& internals)
|
||||
: Internals(std::make_shared<detail::RuntimeDeviceTrackerInternals>())
|
||||
{
|
||||
std::copy_n(
|
||||
internals->RuntimeAllowed, VTKM_MAX_DEVICE_ADAPTER_ID, this->Internals->RuntimeAllowed);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RuntimeDeviceTracker::ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId, bool runtimeExists)
|
||||
{
|
||||
if (!runtimeExists)
|
||||
if (deviceId == vtkm::cont::DeviceAdapterTagAny{})
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "Cannot force to device '" << deviceId.GetName()
|
||||
<< "' because that device is not available on this system";
|
||||
throw vtkm::cont::ErrorBadValue(message.str());
|
||||
std::fill_n(this->Internals->RuntimeAllowed, VTKM_MAX_DEVICE_ADAPTER_ID, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SetDeviceState(deviceId, false);
|
||||
}
|
||||
this->CheckDevice(deviceId);
|
||||
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
|
||||
"Forcing execution to occur on device '" << deviceId.GetName() << "'");
|
||||
|
||||
std::fill_n(this->Internals->RuntimeAllowed, VTKM_MAX_DEVICE_ADAPTER_ID, false);
|
||||
|
||||
this->Internals->RuntimeAllowed[deviceId.GetValue()] = runtimeExists;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RuntimeDeviceTracker::ForceDevice(DeviceAdapterId deviceId)
|
||||
{
|
||||
vtkm::cont::RuntimeDeviceInformation runtimeDevice;
|
||||
this->ForceDeviceImpl(deviceId, runtimeDevice.Exists(deviceId));
|
||||
if (deviceId == vtkm::cont::DeviceAdapterTagAny{})
|
||||
{
|
||||
this->Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->CheckDevice(deviceId);
|
||||
vtkm::cont::RuntimeDeviceInformation runtimeDevice;
|
||||
const bool runtimeExists = runtimeDevice.Exists(deviceId);
|
||||
if (!runtimeExists)
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "Cannot force to device '" << deviceId.GetName()
|
||||
<< "' because that device is not available on this system";
|
||||
throw vtkm::cont::ErrorBadValue(message.str());
|
||||
}
|
||||
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
|
||||
"Forcing execution to occur on device '" << deviceId.GetName() << "'");
|
||||
|
||||
std::fill_n(this->Internals->RuntimeAllowed, VTKM_MAX_DEVICE_ADAPTER_ID, false);
|
||||
|
||||
this->Internals->RuntimeAllowed[deviceId.GetValue()] = runtimeExists;
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
ScopedRuntimeDeviceTracker::ScopedRuntimeDeviceTracker(vtkm::cont::DeviceAdapterId device,
|
||||
RuntimeDeviceTrackerMode mode)
|
||||
: RuntimeDeviceTracker(GetRuntimeDeviceTracker().Internals, false)
|
||||
, SavedState(new detail::RuntimeDeviceTrackerInternals())
|
||||
{
|
||||
std::copy_n(
|
||||
this->Internals->RuntimeAllowed, VTKM_MAX_DEVICE_ADAPTER_ID, this->SavedState->RuntimeAllowed);
|
||||
|
||||
if (mode == RuntimeDeviceTrackerMode::Force)
|
||||
{
|
||||
this->ForceDevice(device);
|
||||
}
|
||||
else if (mode == RuntimeDeviceTrackerMode::Enable)
|
||||
{
|
||||
this->ResetDevice(device);
|
||||
}
|
||||
else if (mode == RuntimeDeviceTrackerMode::Disable)
|
||||
{
|
||||
this->DisableDevice(device);
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
ScopedRuntimeDeviceTracker::ScopedRuntimeDeviceTracker(
|
||||
vtkm::cont::DeviceAdapterId device,
|
||||
RuntimeDeviceTrackerMode mode,
|
||||
const vtkm::cont::RuntimeDeviceTracker& tracker)
|
||||
: RuntimeDeviceTracker(tracker.Internals, false)
|
||||
, SavedState(new detail::RuntimeDeviceTrackerInternals())
|
||||
{
|
||||
std::copy_n(
|
||||
this->Internals->RuntimeAllowed, VTKM_MAX_DEVICE_ADAPTER_ID, this->SavedState->RuntimeAllowed);
|
||||
if (mode == RuntimeDeviceTrackerMode::Force)
|
||||
{
|
||||
this->ForceDevice(device);
|
||||
}
|
||||
else if (mode == RuntimeDeviceTrackerMode::Enable)
|
||||
{
|
||||
this->ResetDevice(device);
|
||||
}
|
||||
else if (mode == RuntimeDeviceTrackerMode::Disable)
|
||||
{
|
||||
this->DisableDevice(device);
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
ScopedRuntimeDeviceTracker::ScopedRuntimeDeviceTracker(
|
||||
const vtkm::cont::RuntimeDeviceTracker& tracker)
|
||||
: RuntimeDeviceTracker(tracker.Internals, false)
|
||||
, SavedState(new detail::RuntimeDeviceTrackerInternals())
|
||||
{
|
||||
std::copy_n(
|
||||
this->Internals->RuntimeAllowed, VTKM_MAX_DEVICE_ADAPTER_ID, this->SavedState->RuntimeAllowed);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
ScopedRuntimeDeviceTracker::~ScopedRuntimeDeviceTracker()
|
||||
{
|
||||
std::copy_n(
|
||||
this->SavedState->RuntimeAllowed, VTKM_MAX_DEVICE_ADAPTER_ID, this->Internals->RuntimeAllowed);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -150,6 +239,8 @@ vtkm::cont::RuntimeDeviceTracker& GetRuntimeDeviceTracker()
|
||||
#if defined(VTKM_CLANG) && defined(__apple_build_version__) && (__apple_build_version__ < 8000000)
|
||||
static std::mutex mtx;
|
||||
static std::map<std::thread::id, vtkm::cont::RuntimeDeviceTracker*> globalTrackers;
|
||||
static std::map<std::thread::id, vtkm::cont::detail::RuntimeDeviceTrackerInternals*>
|
||||
globalTrackerInternals;
|
||||
std::thread::id this_id = std::this_thread::get_id();
|
||||
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
@ -160,12 +251,15 @@ vtkm::cont::RuntimeDeviceTracker& GetRuntimeDeviceTracker()
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::RuntimeDeviceTracker* tracker = new vtkm::cont::RuntimeDeviceTracker();
|
||||
auto* details = new vtkm::cont::detail::RuntimeDeviceTrackerInternals();
|
||||
vtkm::cont::RuntimeDeviceTracker* tracker = new vtkm::cont::RuntimeDeviceTracker(details, true);
|
||||
globalTrackers[this_id] = tracker;
|
||||
globalTrackerInternals[this_id] = details;
|
||||
return *tracker;
|
||||
}
|
||||
#else
|
||||
static thread_local vtkm::cont::RuntimeDeviceTracker runtimeDeviceTracker;
|
||||
static thread_local vtkm::cont::detail::RuntimeDeviceTrackerInternals details;
|
||||
static thread_local vtkm::cont::RuntimeDeviceTracker runtimeDeviceTracker(&details, true);
|
||||
return runtimeDeviceTracker;
|
||||
#endif
|
||||
}
|
||||
|
@ -28,11 +28,18 @@ namespace detail
|
||||
|
||||
struct RuntimeDeviceTrackerInternals;
|
||||
}
|
||||
struct ScopedRuntimeDeviceTracker;
|
||||
|
||||
/// A class that can be used to determine if a given device adapter
|
||||
/// is supported on the current machine at runtime. This is a more
|
||||
/// complex version of vtkm::cont::RunimeDeviceInformation, as this can
|
||||
/// also track when worklets fail, why the fail, and will update the list
|
||||
/// RuntimeDeviceTracker is the central location for determining
|
||||
/// which device adapter will be active for algorithm execution.
|
||||
/// Many features in VTK-m 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 vtkm::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.
|
||||
///
|
||||
///
|
||||
@ -47,11 +54,10 @@ public:
|
||||
/// Returns true if the given device adapter is supported on the current
|
||||
/// machine.
|
||||
///
|
||||
VTKM_CONT bool CanRunOn(DeviceAdapterId device) const { return this->CanRunOnImpl(device); }
|
||||
VTKM_CONT bool CanRunOn(DeviceAdapterId deviceId) const;
|
||||
|
||||
/// Report a failure to allocate memory on a device, this will flag the
|
||||
/// device as being unusable for all future invocations of the instance of
|
||||
/// the filter.
|
||||
/// device as being unusable for all future invocations.
|
||||
///
|
||||
VTKM_CONT void ReportAllocationFailure(vtkm::cont::DeviceAdapterId deviceId,
|
||||
const vtkm::cont::ErrorBadAllocation&)
|
||||
@ -68,13 +74,10 @@ public:
|
||||
}
|
||||
|
||||
/// Reset the tracker for the given device. This will discard any updates
|
||||
/// caused by reported failures
|
||||
/// caused by reported failures. Passing DeviceAdapterTagAny to this will
|
||||
/// reset all devices ( same as \c Reset ).
|
||||
///
|
||||
VTKM_CONT void ResetDevice(vtkm::cont::DeviceAdapterId device)
|
||||
{
|
||||
vtkm::cont::RuntimeDeviceInformation runtimeDevice;
|
||||
this->SetDeviceState(device, runtimeDevice.Exists(device));
|
||||
}
|
||||
VTKM_CONT void ResetDevice(vtkm::cont::DeviceAdapterId deviceId);
|
||||
|
||||
/// Reset the tracker to its default state for default devices.
|
||||
/// Will discard any updates caused by reported failures.
|
||||
@ -82,48 +85,6 @@ public:
|
||||
VTKM_CONT
|
||||
void Reset();
|
||||
|
||||
/// \brief Perform a deep copy of the \c RuntimeDeviceTracker state.
|
||||
///
|
||||
/// Normally when you assign or copy a \c RuntimeDeviceTracker, they share
|
||||
/// state so that when you change the state of one (for example, find a
|
||||
/// device that does not work), the other is also implicitly updated. This
|
||||
/// important so that when you use the global runtime device tracker the
|
||||
/// state is synchronized across all the units using it.
|
||||
///
|
||||
/// If you want a \c RuntimeDeviceTracker with independent state, just create
|
||||
/// one independently. If you want to start with the state of a source
|
||||
/// \c RuntimeDeviceTracker but update the state independently, you can use
|
||||
/// \c DeepCopy method to get the initial state. Further changes will
|
||||
/// not be shared.
|
||||
///
|
||||
/// This version of \c DeepCopy creates a whole new \c RuntimeDeviceTracker
|
||||
/// with a state that is not shared with any other object.
|
||||
///
|
||||
VTKM_CONT
|
||||
vtkm::cont::RuntimeDeviceTracker DeepCopy() const;
|
||||
|
||||
/// \brief Perform a deep copy of the \c RuntimeDeviceTracker state.
|
||||
///
|
||||
/// Normally when you assign or copy a \c RuntimeDeviceTracker, they share
|
||||
/// state so that when you change the state of one (for example, find a
|
||||
/// device that does not work), the other is also implicitly updated. This
|
||||
/// important so that when you use the global runtime device tracker the
|
||||
/// state is synchronized across all the units using it.
|
||||
///
|
||||
/// If you want a \c RuntimeDeviceTracker with independent state, just create
|
||||
/// one independently. If you want to start with the state of a source
|
||||
/// \c RuntimeDeviceTracker but update the state independently, you can use
|
||||
/// \c DeepCopy method to get the initial state. Further changes will
|
||||
/// not be shared.
|
||||
///
|
||||
/// This version of \c DeepCopy sets the state of the current object to
|
||||
/// the one given in the argument. Any other \c RuntimeDeviceTrackers sharing
|
||||
/// state with this object will also get updated. This method is good for
|
||||
/// restoring a state that was previously saved.
|
||||
///
|
||||
VTKM_CONT
|
||||
void DeepCopy(const vtkm::cont::RuntimeDeviceTracker& src);
|
||||
|
||||
/// \brief Disable the given device
|
||||
///
|
||||
/// The main intention of \c RuntimeDeviceTracker is to keep track of what
|
||||
@ -131,43 +92,119 @@ public:
|
||||
/// devices on and off. Use this method to disable (turn off) a given device.
|
||||
/// Use \c ResetDevice to turn the device back on (if it is supported).
|
||||
///
|
||||
VTKM_CONT void DisableDevice(DeviceAdapterId device) { this->SetDeviceState(device, false); }
|
||||
/// Passing DeviceAdapterTagAny to this will disable all devices
|
||||
///
|
||||
VTKM_CONT void DisableDevice(DeviceAdapterId deviceId);
|
||||
|
||||
/// \brief Disable all devices except the specified one.
|
||||
///
|
||||
/// The main intention of \c RuntimeDeviceTracker is to keep track of what
|
||||
/// devices are working for VTK-m. However, it can also be used to turn
|
||||
/// devices on and off. Use this method to disable all devices except one
|
||||
/// to effectively force VTK-m to use that device. Use \c Reset restore
|
||||
/// all devices to their default values. You can also use the \c DeepCopy
|
||||
/// methods to save and restore the state.
|
||||
/// to effectively force VTK-m to use that device. Either pass the
|
||||
/// DeviceAdapterTagAny to this function or call \c Reset to restore
|
||||
/// all devices to their default state.
|
||||
///
|
||||
/// This method will throw a \c ErrorBadValue if the given device does not
|
||||
/// exist on the system.
|
||||
///
|
||||
VTKM_CONT void ForceDevice(DeviceAdapterId id);
|
||||
VTKM_CONT void ForceDevice(DeviceAdapterId deviceId);
|
||||
|
||||
private:
|
||||
std::shared_ptr<detail::RuntimeDeviceTrackerInternals> Internals;
|
||||
friend struct ScopedRuntimeDeviceTracker;
|
||||
|
||||
detail::RuntimeDeviceTrackerInternals* Internals;
|
||||
|
||||
VTKM_CONT
|
||||
RuntimeDeviceTracker();
|
||||
RuntimeDeviceTracker(detail::RuntimeDeviceTrackerInternals* details, bool reset);
|
||||
|
||||
// Deep Copy constructor.
|
||||
VTKM_CONT
|
||||
RuntimeDeviceTracker(const std::shared_ptr<detail::RuntimeDeviceTrackerInternals>& internals);
|
||||
RuntimeDeviceTracker(const RuntimeDeviceTracker&) = delete;
|
||||
|
||||
VTKM_CONT
|
||||
RuntimeDeviceTracker& operator=(const RuntimeDeviceTracker&) = delete;
|
||||
|
||||
VTKM_CONT
|
||||
void CheckDevice(vtkm::cont::DeviceAdapterId deviceId) const;
|
||||
|
||||
VTKM_CONT
|
||||
bool CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId) const;
|
||||
|
||||
VTKM_CONT
|
||||
void SetDeviceState(vtkm::cont::DeviceAdapterId deviceId, bool state);
|
||||
};
|
||||
|
||||
VTKM_CONT
|
||||
void ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId, bool runtimeExists);
|
||||
|
||||
enum struct RuntimeDeviceTrackerMode
|
||||
{
|
||||
Force,
|
||||
Enable,
|
||||
Disable
|
||||
};
|
||||
|
||||
/// A class that can be used to determine or modify which device adapter
|
||||
/// VTK-m algorithms should be run on. This class captures the state
|
||||
/// of the per-thread device adapter and will revert any changes applied
|
||||
/// during its lifetime on destruction.
|
||||
///
|
||||
///
|
||||
struct VTKM_CONT_EXPORT ScopedRuntimeDeviceTracker : public vtkm::cont::RuntimeDeviceTracker
|
||||
{
|
||||
/// Construct a ScopedRuntimeDeviceTracker where the state of the active devices
|
||||
/// for the current thread are determined by the parameters to the constructor.
|
||||
///
|
||||
/// 'Force'
|
||||
/// - Force-Enable the provided single device adapter
|
||||
/// - Force-Enable all device adapters when using vtkm::cont::DeviceAdaterTagAny
|
||||
/// 'Enable'
|
||||
/// - Enable the provided single device adapter if it was previously disabled
|
||||
/// - Enable all device adapters that are currently disabled when using
|
||||
/// vtkm::cont::DeviceAdaterTagAny
|
||||
/// 'Disable'
|
||||
/// - Disable the provided single device adapter
|
||||
/// - Disable all device adapters when using vtkm::cont::DeviceAdaterTagAny
|
||||
///
|
||||
/// Constructor is not thread safe
|
||||
VTKM_CONT ScopedRuntimeDeviceTracker(
|
||||
vtkm::cont::DeviceAdapterId device,
|
||||
RuntimeDeviceTrackerMode mode = RuntimeDeviceTrackerMode::Force);
|
||||
|
||||
/// Construct a ScopedRuntimeDeviceTracker associated with the thread
|
||||
/// associated with the provided tracker. The active devices
|
||||
/// for the current thread are determined by the parameters to the constructor.
|
||||
///
|
||||
/// 'Force'
|
||||
/// - Force-Enable the provided single device adapter
|
||||
/// - Force-Enable all device adapters when using vtkm::cont::DeviceAdaterTagAny
|
||||
/// 'Enable'
|
||||
/// - Enable the provided single device adapter if it was previously disabled
|
||||
/// - Enable all device adapters that are currently disabled when using
|
||||
/// vtkm::cont::DeviceAdaterTagAny
|
||||
/// 'Disable'
|
||||
/// - Disable the provided single device adapter
|
||||
/// - Disable all device adapters when using vtkm::cont::DeviceAdaterTagAny
|
||||
///
|
||||
/// Any modifications to the ScopedRuntimeDeviceTracker will effect what
|
||||
/// ever thread the \c tracker is associated with, which might not be
|
||||
/// the thread which ScopedRuntimeDeviceTracker was constructed on.
|
||||
///
|
||||
/// Constructor is not thread safe
|
||||
VTKM_CONT ScopedRuntimeDeviceTracker(vtkm::cont::DeviceAdapterId device,
|
||||
RuntimeDeviceTrackerMode mode,
|
||||
const vtkm::cont::RuntimeDeviceTracker& tracker);
|
||||
|
||||
/// Construct a ScopedRuntimeDeviceTracker associated with the thread
|
||||
/// associated with the provided tracker.
|
||||
///
|
||||
/// Any modifications to the ScopedRuntimeDeviceTracker will effect what
|
||||
/// ever thread the \c tracker is associated with, which might not be
|
||||
/// the thread which ScopedRuntimeDeviceTracker was constructed on.
|
||||
///
|
||||
/// Constructor is not thread safe
|
||||
VTKM_CONT ScopedRuntimeDeviceTracker(const vtkm::cont::RuntimeDeviceTracker& tracker);
|
||||
|
||||
/// Destructor is not thread safe
|
||||
VTKM_CONT ~ScopedRuntimeDeviceTracker();
|
||||
|
||||
private:
|
||||
std::unique_ptr<detail::RuntimeDeviceTrackerInternals> SavedState;
|
||||
};
|
||||
|
||||
/// \brief Get the \c RuntimeDeviceTracker for the current thread.
|
||||
@ -178,33 +215,9 @@ private:
|
||||
/// to check over and over again, VTK-m uses per thread runtime device tracker
|
||||
/// so that these choices are marked and shared.
|
||||
///
|
||||
/// Xcode's clang only supports thread_local from version 8
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::cont::RuntimeDeviceTracker& GetRuntimeDeviceTracker();
|
||||
|
||||
struct ScopedRuntimeDeviceTracker
|
||||
{
|
||||
vtkm::cont::RuntimeDeviceTracker SavedTracker;
|
||||
|
||||
VTKM_CONT ScopedRuntimeDeviceTracker()
|
||||
: SavedTracker(vtkm::cont::GetRuntimeDeviceTracker().DeepCopy())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT ScopedRuntimeDeviceTracker(vtkm::cont::RuntimeDeviceTracker tracker)
|
||||
: SavedTracker(vtkm::cont::GetRuntimeDeviceTracker().DeepCopy())
|
||||
{
|
||||
vtkm::cont::GetRuntimeDeviceTracker().DeepCopy(tracker);
|
||||
}
|
||||
|
||||
VTKM_CONT ~ScopedRuntimeDeviceTracker()
|
||||
{
|
||||
vtkm::cont::GetRuntimeDeviceTracker().DeepCopy(this->SavedTracker);
|
||||
}
|
||||
|
||||
ScopedRuntimeDeviceTracker(const ScopedRuntimeDeviceTracker&) = delete;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace detail
|
||||
{
|
||||
|
||||
VTKM_CONT_EXPORT void HandleTryExecuteException(vtkm::cont::DeviceAdapterId deviceId,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker,
|
||||
vtkm::cont::RuntimeDeviceTracker& tracker,
|
||||
const std::string& functorName)
|
||||
{
|
||||
try
|
||||
|
@ -25,7 +25,7 @@ namespace detail
|
||||
{
|
||||
|
||||
VTKM_CONT_EXPORT void HandleTryExecuteException(vtkm::cont::DeviceAdapterId,
|
||||
vtkm::cont::RuntimeDeviceTracker,
|
||||
vtkm::cont::RuntimeDeviceTracker&,
|
||||
const std::string& functorName);
|
||||
|
||||
template <typename DeviceTag, typename Functor, typename... Args>
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestCudaArrayHandle(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::TestingArrayHandles<vtkm::cont::DeviceAdapterTagCuda>::Run(argc,
|
||||
argv);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
int UnitTestCudaArrayHandleFancy(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
int result = vtkm::cont::testing::TestingFancyArrayHandles<vtkm::cont::DeviceAdapterTagCuda>::Run(
|
||||
argc, argv);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestCudaArrayHandleVirtualCoordinates(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::TestingArrayHandleVirtualCoordinates<
|
||||
vtkm::cont::DeviceAdapterTagCuda>::Run(argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestCudaBitField(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::TestingBitField<vtkm::cont::DeviceAdapterTagCuda>::Run(argc, argv);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestCudaCellLocatorRectilinearGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorRectilinearGrid<vtkm::cont::DeviceAdapterTagCuda>(), argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestCudaCellLocatorUniformBins(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorUniformBins<vtkm::cont::DeviceAdapterTagCuda>, argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestCudaCellLocatorUniformGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorUniformGrid<vtkm::cont::DeviceAdapterTagCuda>(), argc, argv);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestCudaColorTable(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::TestingColorTable<vtkm::cont::DeviceAdapterTagCuda>::Run(argc, argv);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
int UnitTestCudaComputeRange(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
int result =
|
||||
vtkm::cont::testing::TestingComputeRange<vtkm::cont::DeviceAdapterTagCuda>::Run(argc, argv);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestCudaDataSetExplicit(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
int result =
|
||||
vtkm::cont::testing::TestingDataSetExplicit<vtkm::cont::DeviceAdapterTagCuda>::Run(argc, argv);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
int UnitTestCudaDataSetSingleType(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
int result = vtkm::cont::testing::TestingDataSetSingleType<vtkm::cont::DeviceAdapterTagCuda>::Run(
|
||||
argc, argv);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
int UnitTestCudaDeviceAdapter(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
int result =
|
||||
vtkm::cont::testing::TestingDeviceAdapter<vtkm::cont::DeviceAdapterTagCuda>::Run(argc, argv);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestCudaGeometry(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
UnitTestGeometryNamespace::RunGeometryTests<vtkm::cont::DeviceAdapterTagCuda>, argc, argv);
|
||||
|
@ -23,7 +23,7 @@ void TestImplicitFunctions()
|
||||
|
||||
int UnitTestCudaImplicitFunction(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::Testing::Run(TestImplicitFunctions, argc, argv);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ void RunEdgeCases()
|
||||
|
||||
int UnitTestCudaMath(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
int tests_valid = vtkm::cont::testing::Testing::Run(
|
||||
UnitTestMathNamespace::RunMathTests<vtkm::cont::DeviceAdapterTagCuda>, argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestCudaPointLocatorUniformGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingPointLocatorUniformGrid<vtkm::cont::DeviceAdapterTagCuda>(), argc, argv);
|
||||
|
@ -267,7 +267,7 @@ void Launch()
|
||||
|
||||
int UnitTestCudaShareUserProvidedManagedMemory(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
int ret = vtkm::cont::testing::Testing::Run(Launch, argc, argv);
|
||||
return vtkm::cont::cuda::internal::Testing::CheckCudaBeforeExit(ret);
|
||||
|
@ -15,7 +15,7 @@ namespace
|
||||
|
||||
void TestVirtualObjectHandle()
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagCuda{});
|
||||
using DeviceAdapterList = vtkm::ListTagBase<vtkm::cont::DeviceAdapterTagCuda>;
|
||||
|
@ -35,7 +35,7 @@ struct ExecuteIfValidDeviceTag
|
||||
typename EnableIfValid<DeviceAdapter>::type operator()(
|
||||
DeviceAdapter device,
|
||||
Functor&& f,
|
||||
const vtkm::cont::RuntimeDeviceTracker tracker,
|
||||
const vtkm::cont::RuntimeDeviceTracker& tracker,
|
||||
Args&&... args) const
|
||||
{
|
||||
if (tracker.CanRunOn(device))
|
||||
@ -56,7 +56,7 @@ struct ExecuteIfValidDeviceTag
|
||||
template <typename DeviceList, typename Functor, typename... Args>
|
||||
VTKM_CONT void ForEachValidDevice(DeviceList devices, Functor&& functor, Args&&... args)
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
vtkm::ListForEach(
|
||||
ExecuteIfValidDeviceTag{}, devices, functor, tracker, std::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPArrayHandle(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::TestingArrayHandles<vtkm::cont::DeviceAdapterTagOpenMP>::Run(argc,
|
||||
argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPArrayHandleFancy(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::TestingFancyArrayHandles<vtkm::cont::DeviceAdapterTagOpenMP>::Run(
|
||||
argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPArrayHandleVirtualCoordinates(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::TestingArrayHandleVirtualCoordinates<
|
||||
vtkm::cont::DeviceAdapterTagOpenMP>::Run(argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPBitField(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::TestingBitField<vtkm::cont::DeviceAdapterTagOpenMP>::Run(argc, argv);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPCellLocatorRectilinearGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorRectilinearGrid<vtkm::cont::DeviceAdapterTagSerial>(), argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPCellLocatorUniformBins(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorUniformBins<vtkm::cont::DeviceAdapterTagOpenMP>, argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPCellLocatorUniformGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorUniformGrid<vtkm::cont::DeviceAdapterTagSerial>(), argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPColorTable(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::TestingColorTable<vtkm::cont::DeviceAdapterTagOpenMP>::Run(argc,
|
||||
argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPComputeRange(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::TestingComputeRange<vtkm::cont::DeviceAdapterTagOpenMP>::Run(argc,
|
||||
argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPDataSetExplicit(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::TestingDataSetExplicit<vtkm::cont::DeviceAdapterTagOpenMP>::Run(argc,
|
||||
argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPDataSetSingleType(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::TestingDataSetSingleType<vtkm::cont::DeviceAdapterTagOpenMP>::Run(
|
||||
argc, argv);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestOpenMPDeviceAdapter(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::TestingDeviceAdapter<vtkm::cont::DeviceAdapterTagOpenMP>::Run(argc,
|
||||
argv);
|
||||
|
@ -15,7 +15,7 @@ namespace
|
||||
|
||||
void TestImplicitFunctions()
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
|
||||
vtkm::cont::testing::TestingImplicitFunction testing;
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestOpenMPPointLocatorUniformGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingPointLocatorUniformGrid<vtkm::cont::DeviceAdapterTagOpenMP>(), argc, argv);
|
||||
|
@ -20,7 +20,7 @@ void TestVirtualObjectHandle()
|
||||
using DeviceAdapterList2 =
|
||||
vtkm::ListTagBase<vtkm::cont::DeviceAdapterTagSerial, vtkm::cont::DeviceAdapterTagOpenMP>;
|
||||
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagOpenMP{});
|
||||
vtkm::cont::testing::TestingVirtualObjectHandle<DeviceAdapterList>::Run();
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestSerialArrayHandle(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::TestingArrayHandles<vtkm::cont::DeviceAdapterTagSerial>::Run(argc,
|
||||
argv);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestSerialArrayHandleFancy(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::TestingFancyArrayHandles<vtkm::cont::DeviceAdapterTagSerial>::Run(
|
||||
argc, argv);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestSerialArrayHandleVirtualCoordinates(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::TestingArrayHandleVirtualCoordinates<
|
||||
vtkm::cont::DeviceAdapterTagSerial>::Run(argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestSerialBitField(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::TestingBitField<vtkm::cont::DeviceAdapterTagSerial>::Run(argc, argv);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestSerialCellLocatorRectilinearGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorRectilinearGrid<vtkm::cont::DeviceAdapterTagSerial>(), argc, argv);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestSerialCellLocatorUniformBins(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorUniformBins<vtkm::cont::DeviceAdapterTagSerial>, argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestSerialCellLocatorUniformGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorUniformGrid<vtkm::cont::DeviceAdapterTagSerial>(), argc, argv);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestSerialDataSetExplicit(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::TestingDataSetExplicit<vtkm::cont::DeviceAdapterTagSerial>::Run(argc,
|
||||
argv);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestSerialDataSetSingleType(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::TestingDataSetSingleType<vtkm::cont::DeviceAdapterTagSerial>::Run(
|
||||
argc, argv);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestSerialDeviceAdapter(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::TestingDeviceAdapter<vtkm::cont::DeviceAdapterTagSerial>::Run(argc,
|
||||
argv);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestSerialGeometry(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
UnitTestGeometryNamespace::RunGeometryTests<vtkm::cont::DeviceAdapterTagSerial>, argc, argv);
|
||||
|
@ -23,7 +23,7 @@ void TestImplicitFunctions()
|
||||
|
||||
int UnitTestSerialImplicitFunction(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::Testing::Run(TestImplicitFunctions, argc, argv);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestSerialPointLocatorUniformGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingPointLocatorUniformGrid<vtkm::cont::DeviceAdapterTagSerial>(), argc, argv);
|
||||
|
@ -24,7 +24,7 @@ void TestVirtualObjectHandle()
|
||||
|
||||
int UnitTestSerialVirtualObjectHandle(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
return vtkm::cont::testing::Testing::Run(TestVirtualObjectHandle, argc, argv);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestTBBArrayHandle(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::TestingArrayHandles<vtkm::cont::DeviceAdapterTagTBB>::Run(argc, argv);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestTBBArrayHandleFancy(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::TestingFancyArrayHandles<vtkm::cont::DeviceAdapterTagTBB>::Run(argc,
|
||||
argv);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
int UnitTestTBBArrayHandleVirtualCoordinates(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::TestingArrayHandleVirtualCoordinates<
|
||||
vtkm::cont::DeviceAdapterTagTBB>::Run(argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestTBBBitField(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::TestingBitField<vtkm::cont::DeviceAdapterTagTBB>::Run(argc, argv);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestTBBCellLocatorRectilinearGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorRectilinearGrid<vtkm::cont::DeviceAdapterTagTBB>(), argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestTBBCellLocatorUniformBins(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorUniformBins<vtkm::cont::DeviceAdapterTagTBB>, argc, argv);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestTBBCellLocatorUniformGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingCellLocatorUniformGrid<vtkm::cont::DeviceAdapterTagTBB>(), argc, argv);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestTBBColorTable(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::TestingColorTable<vtkm::cont::DeviceAdapterTagTBB>::Run(argc, argv);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestTBBComputeRange(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::TestingComputeRange<vtkm::cont::DeviceAdapterTagTBB>::Run(argc, argv);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestTBBDataSetExplicit(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::TestingDataSetExplicit<vtkm::cont::DeviceAdapterTagTBB>::Run(argc,
|
||||
argv);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestTBBDataSetSingleType(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::TestingDataSetSingleType<vtkm::cont::DeviceAdapterTagTBB>::Run(argc,
|
||||
argv);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
int UnitTestTBBDeviceAdapter(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::TestingDeviceAdapter<vtkm::cont::DeviceAdapterTagTBB>::Run(argc,
|
||||
argv);
|
||||
|
@ -23,7 +23,7 @@ void TestImplicitFunctions()
|
||||
|
||||
int UnitTestTBBImplicitFunction(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::Testing::Run(TestImplicitFunctions, argc, argv);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
int UnitTestTBBPointLocatorUniformGrid(int argc, char* argv[])
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingPointLocatorUniformGrid<vtkm::cont::DeviceAdapterTagTBB>(), argc, argv);
|
||||
|
@ -16,7 +16,7 @@ namespace
|
||||
|
||||
void TestVirtualObjectHandle()
|
||||
{
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
|
||||
tracker.ForceDevice(vtkm::cont::DeviceAdapterTagTBB{});
|
||||
using DeviceAdapterList = vtkm::ListTagBase<vtkm::cont::DeviceAdapterTagTBB>;
|
||||
|
@ -71,6 +71,7 @@ set(unit_tests
|
||||
UnitTestMultiBlock.cxx
|
||||
UnitTestRuntimeDeviceInformation.cxx
|
||||
UnitTestRuntimeDeviceNames.cxx
|
||||
UnitTestScopedRuntimeDeviceTracker.cxx
|
||||
UnitTestStorageBasic.cxx
|
||||
UnitTestStorageImplicit.cxx
|
||||
UnitTestStorageListTag.cxx
|
||||
|
@ -579,7 +579,7 @@ private:
|
||||
{
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Timer" << std::endl;
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
if (tracker.CanRunOn(DeviceAdapterTag()))
|
||||
{
|
||||
vtkm::cont::Timer timer{ DeviceAdapterTag() };
|
||||
|
@ -160,9 +160,9 @@ struct TransformExecObject : public vtkm::cont::ExecutionAndControlObjectBase
|
||||
VTKM_CONT TransformExecObject(const FunctorType& functor)
|
||||
{
|
||||
// Need to make sure the serial device is supported, since that is what is used on the
|
||||
// control side.
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker scopedTracker;
|
||||
vtkm::cont::GetRuntimeDeviceTracker().ResetDevice(vtkm::cont::DeviceAdapterTagSerial());
|
||||
// control side. Therefore we reset to all supported devices.
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker scopedTracker(
|
||||
vtkm::cont::DeviceAdapterTagSerial{}, vtkm::cont::RuntimeDeviceTrackerMode::Enable);
|
||||
this->VirtualFunctor.Reset(new VirtualTransformFunctor<ValueType, FunctorType>(functor));
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ int UnitTestDeviceAdapterAlgorithmGeneral(int argc, char* argv[])
|
||||
{
|
||||
//need to enable DeviceAdapterTagTestAlgorithmGeneral as it
|
||||
//is not part of the default set of devices
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ResetDevice(vtkm::cont::DeviceAdapterTagTestAlgorithmGeneral{});
|
||||
|
||||
return vtkm::cont::testing::TestingDeviceAdapter<
|
||||
|
121
vtkm/cont/testing/UnitTestScopedRuntimeDeviceTracker.cxx
Normal file
121
vtkm/cont/testing/UnitTestScopedRuntimeDeviceTracker.cxx
Normal file
@ -0,0 +1,121 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||
|
||||
//include all backends
|
||||
#include <vtkm/cont/cuda/DeviceAdapterCuda.h>
|
||||
#include <vtkm/cont/openmp/DeviceAdapterOpenMP.h>
|
||||
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
||||
#include <vtkm/cont/tbb/DeviceAdapterTBB.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
template <typename DeviceAdapterTag>
|
||||
void verify_state(DeviceAdapterTag tag, std::array<bool, VTKM_MAX_DEVICE_ADAPTER_ID>& defaults)
|
||||
{
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
// presumable all other devices match the defaults
|
||||
for (vtkm::Int8 i = 1; i < VTKM_MAX_DEVICE_ADAPTER_ID; ++i)
|
||||
{
|
||||
const auto deviceId = vtkm::cont::make_DeviceAdapterId(i);
|
||||
if (deviceId != tag)
|
||||
{
|
||||
VTKM_TEST_ASSERT(defaults[static_cast<std::size_t>(i)] == tracker.CanRunOn(deviceId),
|
||||
"ScopedRuntimeDeviceTracker didn't properly setup state correctly");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename DeviceAdapterTag>
|
||||
void verify_srdt_support(DeviceAdapterTag tag,
|
||||
std::array<bool, VTKM_MAX_DEVICE_ADAPTER_ID>& force,
|
||||
std::array<bool, VTKM_MAX_DEVICE_ADAPTER_ID>& enable,
|
||||
std::array<bool, VTKM_MAX_DEVICE_ADAPTER_ID>& disable)
|
||||
{
|
||||
vtkm::cont::RuntimeDeviceInformation runtime;
|
||||
const bool haveSupport = runtime.Exists(tag);
|
||||
if (haveSupport)
|
||||
{
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker(tag,
|
||||
vtkm::cont::RuntimeDeviceTrackerMode::Force);
|
||||
VTKM_TEST_ASSERT(tracker.CanRunOn(tag) == haveSupport, "");
|
||||
verify_state(tag, force);
|
||||
}
|
||||
|
||||
if (haveSupport)
|
||||
{
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker(tag,
|
||||
vtkm::cont::RuntimeDeviceTrackerMode::Enable);
|
||||
VTKM_TEST_ASSERT(tracker.CanRunOn(tag) == haveSupport);
|
||||
verify_state(tag, enable);
|
||||
}
|
||||
|
||||
{
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker(tag,
|
||||
vtkm::cont::RuntimeDeviceTrackerMode::Disable);
|
||||
VTKM_TEST_ASSERT(tracker.CanRunOn(tag) == false, "");
|
||||
verify_state(tag, disable);
|
||||
}
|
||||
}
|
||||
|
||||
void VerifyScopedRuntimeDeviceTracker()
|
||||
{
|
||||
std::array<bool, VTKM_MAX_DEVICE_ADAPTER_ID> all_off;
|
||||
std::array<bool, VTKM_MAX_DEVICE_ADAPTER_ID> all_on;
|
||||
std::array<bool, VTKM_MAX_DEVICE_ADAPTER_ID> defaults;
|
||||
|
||||
all_off.fill(false);
|
||||
vtkm::cont::RuntimeDeviceInformation runtime;
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
for (vtkm::Int8 i = 1; i < VTKM_MAX_DEVICE_ADAPTER_ID; ++i)
|
||||
{
|
||||
auto deviceId = vtkm::cont::make_DeviceAdapterId(i);
|
||||
defaults[static_cast<std::size_t>(i)] = tracker.CanRunOn(deviceId);
|
||||
all_on[static_cast<std::size_t>(i)] = runtime.Exists(deviceId);
|
||||
}
|
||||
|
||||
using SerialTag = ::vtkm::cont::DeviceAdapterTagSerial;
|
||||
using OpenMPTag = ::vtkm::cont::DeviceAdapterTagOpenMP;
|
||||
using TBBTag = ::vtkm::cont::DeviceAdapterTagTBB;
|
||||
using CudaTag = ::vtkm::cont::DeviceAdapterTagCuda;
|
||||
using AnyTag = ::vtkm::cont::DeviceAdapterTagAny;
|
||||
|
||||
//Verify that for each device adapter we compile code for, that it
|
||||
//has valid runtime support.
|
||||
verify_srdt_support(SerialTag(), all_off, all_on, defaults);
|
||||
verify_srdt_support(OpenMPTag(), all_off, all_on, defaults);
|
||||
verify_srdt_support(CudaTag(), all_off, all_on, defaults);
|
||||
verify_srdt_support(TBBTag(), all_off, all_on, defaults);
|
||||
|
||||
// Verify that all the ScopedRuntimeDeviceTracker changes
|
||||
// have been reverted
|
||||
verify_state(AnyTag(), defaults);
|
||||
|
||||
|
||||
verify_srdt_support(AnyTag(), all_on, all_on, all_off);
|
||||
|
||||
// Verify that all the ScopedRuntimeDeviceTracker changes
|
||||
// have been reverted
|
||||
verify_state(AnyTag(), defaults);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestScopedRuntimeDeviceTracker(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(VerifyScopedRuntimeDeviceTracker, argc, argv);
|
||||
}
|
@ -131,7 +131,6 @@ void TryExecuteAllEdgeCases()
|
||||
{
|
||||
using ValidDevice = vtkm::cont::DeviceAdapterTagSerial;
|
||||
using SingleValidList = vtkm::ListTagBase<ValidDevice>;
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
|
||||
std::cout << "TryExecute no Runtime, no Device, no parameters." << std::endl;
|
||||
vtkm::cont::TryExecute(EdgeCaseFunctor());
|
||||
@ -158,8 +157,7 @@ void RunErrorTest(bool shouldFail, bool shouldThrow, bool shouldDisable)
|
||||
bool threw = false;
|
||||
bool disabled = false;
|
||||
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
tracker.ForceDevice(Device{});
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker scopedTracker(Device{});
|
||||
|
||||
try
|
||||
{
|
||||
@ -171,8 +169,8 @@ void RunErrorTest(bool shouldFail, bool shouldThrow, bool shouldDisable)
|
||||
threw = true;
|
||||
}
|
||||
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
disabled = !tracker.CanRunOn(Device{});
|
||||
tracker.Reset();
|
||||
|
||||
std::cout << "Failed: " << !succeeded << " "
|
||||
<< "Threw: " << threw << " "
|
||||
|
@ -420,8 +420,7 @@ void Canvas::AddColorBar(const vtkm::Bounds& bounds,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>> colorMap;
|
||||
|
||||
{
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker;
|
||||
vtkm::cont::GetRuntimeDeviceTracker().ForceDevice(vtkm::cont::DeviceAdapterTagSerial());
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
colorTable.Sample(static_cast<vtkm::Int32>(numSamples), colorMap);
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,7 @@ void Mapper::SetActiveColorTable(const vtkm::cont::ColorTable& colorTable)
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>> temp;
|
||||
|
||||
{
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker;
|
||||
vtkm::cont::GetRuntimeDeviceTracker().ForceDevice(vtkm::cont::DeviceAdapterTagSerial());
|
||||
vtkm::cont::ScopedRuntimeDeviceTracker tracker(vtkm::cont::DeviceAdapterTagSerial{});
|
||||
colorTable.Sample(1024, temp);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
int UnitTestExceptions(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::Initialize(argc, argv);
|
||||
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
|
||||
|
||||
try
|
||||
{
|
||||
|
4
vtkm/thirdparty/diy/update.sh
vendored
4
vtkm/thirdparty/diy/update.sh
vendored
@ -7,8 +7,8 @@ shopt -s dotglob
|
||||
readonly name="diy"
|
||||
readonly ownership="Diy Upstream <kwrobot@kitware.com>"
|
||||
readonly subtree="vtkm/thirdparty/$name/vtkm$name"
|
||||
readonly repo="https://gitlab.kitware.com/third-party/diy2.git"
|
||||
readonly tag="for/vtk-m"
|
||||
readonly repo="https://gitlab.kitware.com/robertmaynard/diy2.git"
|
||||
readonly tag="for_vtkm_updated"
|
||||
readonly paths="
|
||||
include
|
||||
LEGAL.txt
|
||||
|
Loading…
Reference in New Issue
Block a user