mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Determine ExecObject type directly from PrepareForExecution
Rather than require all ExecutionObjectFactoryBase classes to declare a templated ExecObjectType type, get the type of the execution object directly from the result of the PrepareForExecution method.
This commit is contained in:
parent
7c3342c1d8
commit
9127029fbb
@ -613,12 +613,10 @@ public:
|
||||
struct TwoLevelUniformGridExecutionObjectFactory : public vtkm::cont::ExecutionObjectFactoryBase
|
||||
{
|
||||
template <typename DeviceAdapter>
|
||||
using ExecObjectType = TwoLevelUniformGridExecution<DeviceAdapter>;
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
VTKM_CONT ExecObjectType<DeviceAdapter> PrepareForExecution(DeviceAdapter device) const
|
||||
VTKM_CONT TwoLevelUniformGridExecution<DeviceAdapter> PrepareForExecution(
|
||||
DeviceAdapter device) const
|
||||
{
|
||||
ExecObjectType<DeviceAdapter> deviceObject;
|
||||
TwoLevelUniformGridExecution<DeviceAdapter> deviceObject;
|
||||
deviceObject.TopLevel = this->TopLevel;
|
||||
deviceObject.LeafDimensions = this->LeafDimensions.PrepareForInput(device);
|
||||
deviceObject.LeafStartIndex = this->LeafStartIndex.PrepareForInput(device);
|
||||
|
@ -47,16 +47,14 @@ struct TransportTagExecObject
|
||||
template <typename ContObjectType, typename Device>
|
||||
struct Transport<vtkm::cont::arg::TransportTagExecObject, ContObjectType, Device>
|
||||
{
|
||||
// If you get a compile error here, it means you tried to use an object that
|
||||
// is not an execution object as an argument that is expected to be one. All
|
||||
// execution objects are expected to inherit from
|
||||
// vtkm::exec::ExecutionObjectBase.
|
||||
// If you get a compile error here, it means you tried to use an object that is not an execution
|
||||
// object as an argument that is expected to be one. All execution objects are expected to
|
||||
// inherit from vtkm::exec::ExecutionObjectFactoryBase.
|
||||
VTKM_STATIC_ASSERT_MSG(
|
||||
(std::is_base_of<vtkm::cont::ExecutionObjectFactoryBase, ContObjectType>::value),
|
||||
"All execution objects are expected to inherit from vtkm::exec::ExecutionObjectBase");
|
||||
|
||||
// using ExecObjectType = typename ContObjectType::template ExecObjectType<Device>;
|
||||
using ExecObjectType = typename ContObjectType::template ExecObjectType<Device>;
|
||||
using ExecObjectType = decltype(std::declval<ContObjectType>().PrepareForExecution(Device()));
|
||||
template <typename InputDomainType>
|
||||
VTKM_CONT ExecObjectType
|
||||
operator()(const ContObjectType& object, const InputDomainType&, vtkm::Id, vtkm::Id) const
|
||||
|
@ -44,12 +44,9 @@ struct TestExecutionObject : public vtkm::cont::ExecutionObjectFactoryBase
|
||||
vtkm::Int32 Number;
|
||||
|
||||
template <typename Device>
|
||||
using ExecObjectType = ExecutionObject<Device>;
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT ExecObjectType<Device> PrepareForExecution(Device) const
|
||||
VTKM_CONT ExecutionObject<Device> PrepareForExecution(Device) const
|
||||
{
|
||||
ExecObjectType<Device> object;
|
||||
ExecutionObject<Device> object;
|
||||
object.Number = this->Number;
|
||||
return object;
|
||||
}
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include <vtkm/exec/arg/AspectTagDefault.h>
|
||||
#include <vtkm/exec/arg/Fetch.h>
|
||||
|
||||
#include <vtkm/cont/ExecutionObjectFactoryBase.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace vtkm
|
||||
@ -51,14 +49,6 @@ struct Fetch<vtkm::exec::arg::FetchTagExecObject,
|
||||
ThreadIndicesType,
|
||||
ExecObjectType>
|
||||
{
|
||||
// If you get a compile error here, it means you tried to use an object that
|
||||
// is not an execution object as an argument that is expected to be one. All
|
||||
// execution objects are expected to inherit from
|
||||
// vtkm::exec::ExecutionObjectFactoryBase.
|
||||
static_assert(
|
||||
std::is_base_of<vtkm::cont::ExecutionObjectFactoryBase, ExecObjectType>::value,
|
||||
"All execution objects are expected to inherit from vtkm::cont::ExecutionObjectFactoryBase");
|
||||
|
||||
using ValueType = ExecObjectType;
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
|
Loading…
Reference in New Issue
Block a user