From 9127029fbbea7b39dcb587ba1118c503d39d1cb0 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Wed, 28 Feb 2018 13:18:45 -0700 Subject: [PATCH] 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. --- vtkm/cont/CellLocatorTwoLevelUniformGrid.h | 8 +++----- vtkm/cont/arg/TransportTagExecObject.h | 10 ++++------ vtkm/cont/arg/testing/UnitTestTransportExecObject.cxx | 7 ++----- vtkm/exec/arg/FetchTagExecObject.h | 10 ---------- 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/vtkm/cont/CellLocatorTwoLevelUniformGrid.h b/vtkm/cont/CellLocatorTwoLevelUniformGrid.h index 1f9490614..35a17bf41 100644 --- a/vtkm/cont/CellLocatorTwoLevelUniformGrid.h +++ b/vtkm/cont/CellLocatorTwoLevelUniformGrid.h @@ -613,12 +613,10 @@ public: struct TwoLevelUniformGridExecutionObjectFactory : public vtkm::cont::ExecutionObjectFactoryBase { template - using ExecObjectType = TwoLevelUniformGridExecution; - - template - VTKM_CONT ExecObjectType PrepareForExecution(DeviceAdapter device) const + VTKM_CONT TwoLevelUniformGridExecution PrepareForExecution( + DeviceAdapter device) const { - ExecObjectType deviceObject; + TwoLevelUniformGridExecution deviceObject; deviceObject.TopLevel = this->TopLevel; deviceObject.LeafDimensions = this->LeafDimensions.PrepareForInput(device); deviceObject.LeafStartIndex = this->LeafStartIndex.PrepareForInput(device); diff --git a/vtkm/cont/arg/TransportTagExecObject.h b/vtkm/cont/arg/TransportTagExecObject.h index f60341700..ad9325c80 100644 --- a/vtkm/cont/arg/TransportTagExecObject.h +++ b/vtkm/cont/arg/TransportTagExecObject.h @@ -47,16 +47,14 @@ struct TransportTagExecObject template struct Transport { - // 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::value), "All execution objects are expected to inherit from vtkm::exec::ExecutionObjectBase"); - // using ExecObjectType = typename ContObjectType::template ExecObjectType; - using ExecObjectType = typename ContObjectType::template ExecObjectType; + using ExecObjectType = decltype(std::declval().PrepareForExecution(Device())); template VTKM_CONT ExecObjectType operator()(const ContObjectType& object, const InputDomainType&, vtkm::Id, vtkm::Id) const diff --git a/vtkm/cont/arg/testing/UnitTestTransportExecObject.cxx b/vtkm/cont/arg/testing/UnitTestTransportExecObject.cxx index bc70a1c26..ead30de79 100644 --- a/vtkm/cont/arg/testing/UnitTestTransportExecObject.cxx +++ b/vtkm/cont/arg/testing/UnitTestTransportExecObject.cxx @@ -44,12 +44,9 @@ struct TestExecutionObject : public vtkm::cont::ExecutionObjectFactoryBase vtkm::Int32 Number; template - using ExecObjectType = ExecutionObject; - - template - VTKM_CONT ExecObjectType PrepareForExecution(Device) const + VTKM_CONT ExecutionObject PrepareForExecution(Device) const { - ExecObjectType object; + ExecutionObject object; object.Number = this->Number; return object; } diff --git a/vtkm/exec/arg/FetchTagExecObject.h b/vtkm/exec/arg/FetchTagExecObject.h index b59ff5c25..8028cee00 100644 --- a/vtkm/exec/arg/FetchTagExecObject.h +++ b/vtkm/exec/arg/FetchTagExecObject.h @@ -23,8 +23,6 @@ #include #include -#include - #include namespace vtkm @@ -51,14 +49,6 @@ struct Fetch { - // 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::value, - "All execution objects are expected to inherit from vtkm::cont::ExecutionObjectFactoryBase"); - using ValueType = ExecObjectType; VTKM_SUPPRESS_EXEC_WARNINGS