From 86f3ffa76e5607a52578837e8dd573ffa14368b8 Mon Sep 17 00:00:00 2001 From: Matthew Letter Date: Tue, 15 May 2018 16:47:22 -0600 Subject: [PATCH] Updated gradient scalar output to use new execution obejct gradient scalar output now has a prepare for execution function for creating the execution object based on the device adaptor. --- vtkm/worklet/Gradient.h | 23 ++-- vtkm/worklet/gradient/GradientOutput.h | 153 +++++++++++++++++++------ 2 files changed, 128 insertions(+), 48 deletions(-) diff --git a/vtkm/worklet/Gradient.h b/vtkm/worklet/Gradient.h index fd888d7d7..e003cf87e 100644 --- a/vtkm/worklet/Gradient.h +++ b/vtkm/worklet/Gradient.h @@ -129,7 +129,7 @@ struct GradientOutputFields : public vtkm::cont::ExecutionObjectBase template struct ExecutionTypes { - using Portal = vtkm::exec::GradientOutput; + using Portal = vtkm::exec::GradientOutput; }; GradientOutputFields() @@ -181,18 +181,17 @@ struct GradientOutputFields : public vtkm::cont::ExecutionObjectBase bool GetComputeGradient() const { return StoreGradient; } //todo fix this for scalar - template - vtkm::exec::GradientOutput PrepareForOutput(vtkm::Id size, DeviceAdapter) + vtkm::exec::GradientOutput PrepareForOutput(vtkm::Id size) { - vtkm::exec::GradientOutput portal(this->StoreGradient, - this->ComputeDivergence, - this->ComputeVorticity, - this->ComputeQCriterion, - this->Gradient, - this->Divergence, - this->Vorticity, - this->QCriterion, - size); + vtkm::exec::GradientOutput portal(this->StoreGradient, + this->ComputeDivergence, + this->ComputeVorticity, + this->ComputeQCriterion, + this->Gradient, + this->Divergence, + this->Vorticity, + this->QCriterion, + size); return portal; } diff --git a/vtkm/worklet/gradient/GradientOutput.h b/vtkm/worklet/gradient/GradientOutput.h index cdaa544b7..dedc468aa 100644 --- a/vtkm/worklet/gradient/GradientOutput.h +++ b/vtkm/worklet/gradient/GradientOutput.h @@ -37,9 +37,8 @@ namespace vtkm { namespace exec { - template -struct GradientScalarOutput : public vtkm::cont::ExecutionObjectBase +struct GradientScalarOutputExecutionObject { using ValueType = vtkm::Vec; using BaseTType = typename vtkm::BaseComponent::Type; @@ -51,17 +50,9 @@ struct GradientScalarOutput : public vtkm::cont::ExecutionObjectBase using Portal = typename ExecutionTypes::Portal; }; - GradientScalarOutput() = default; + GradientScalarOutputExecutionObject() = default; - GradientScalarOutput(bool, - bool, - bool, - bool, - vtkm::cont::ArrayHandle& gradient, - vtkm::cont::ArrayHandle&, - vtkm::cont::ArrayHandle>&, - vtkm::cont::ArrayHandle&, - vtkm::Id size) + GradientScalarOutputExecutionObject(vtkm::cont::ArrayHandle gradient, vtkm::Id size) { this->GradientPortal = gradient.PrepareForOutput(size, DeviceAdapter()); } @@ -76,8 +67,40 @@ struct GradientScalarOutput : public vtkm::cont::ExecutionObjectBase typename PortalTypes::Portal GradientPortal; }; +template +struct GradientScalarOutput : public vtkm::cont::ExecutionObjectBase +{ + using ValueType = vtkm::Vec; + using BaseTType = typename vtkm::BaseComponent::Type; + template + + VTKM_CONT vtkm::exec::GradientScalarOutputExecutionObject PrepareForExecution( + Device) const + { + return vtkm::exec::GradientScalarOutputExecutionObject(this->Gradient, this->Size); + } + + GradientScalarOutput() = default; + + GradientScalarOutput(bool, + bool, + bool, + bool, + vtkm::cont::ArrayHandle& gradient, + vtkm::cont::ArrayHandle&, + vtkm::cont::ArrayHandle>&, + vtkm::cont::ArrayHandle&, + vtkm::Id size) + : Size(size) + , Gradient(gradient) + { + } + vtkm::Id Size; + vtkm::cont::ArrayHandle Gradient; +}; + template -struct GradientVecOutput : public vtkm::cont::ExecutionObjectBase +struct GradientVecOutputExecutionObject { using ValueType = vtkm::Vec; using BaseTType = typename vtkm::BaseComponent::Type; @@ -90,17 +113,17 @@ struct GradientVecOutput : public vtkm::cont::ExecutionObjectBase using Portal = typename ExecutionTypes::Portal; }; - GradientVecOutput() = default; + GradientVecOutputExecutionObject() = default; - GradientVecOutput(bool g, - bool d, - bool v, - bool q, - vtkm::cont::ArrayHandle& gradient, - vtkm::cont::ArrayHandle& divergence, - vtkm::cont::ArrayHandle>& vorticity, - vtkm::cont::ArrayHandle& qcriterion, - vtkm::Id size) + GradientVecOutputExecutionObject(bool g, + bool d, + bool v, + bool q, + vtkm::cont::ArrayHandle gradient, + vtkm::cont::ArrayHandle divergence, + vtkm::cont::ArrayHandle> vorticity, + vtkm::cont::ArrayHandle qcriterion, + vtkm::Id size) { this->SetGradient = g; this->SetDivergence = d; @@ -168,24 +191,79 @@ struct GradientVecOutput : public vtkm::cont::ExecutionObjectBase typename PortalTypes::Portal QCriterionPortal; }; -template -struct GradientOutput : public GradientScalarOutput +template +struct GradientVecOutput : public vtkm::cont::ExecutionObjectBase { - using GradientScalarOutput::GradientScalarOutput; + using ValueType = vtkm::Vec; + using BaseTType = typename vtkm::BaseComponent::Type; + + template + VTKM_CONT vtkm::exec::GradientVecOutputExecutionObject PrepareForExecution( + Device) const + { + return vtkm::exec::GradientVecOutputExecutionObject(this->G, + this->D, + this->V, + this->Q, + this->Gradient, + this->Divergence, + this->Vorticity, + this->Qcriterion, + this->Size); + } + + GradientVecOutput() = default; + + GradientVecOutput(bool g, + bool d, + bool v, + bool q, + vtkm::cont::ArrayHandle& gradient, + vtkm::cont::ArrayHandle& divergence, + vtkm::cont::ArrayHandle>& vorticity, + vtkm::cont::ArrayHandle& qcriterion, + vtkm::Id size) + { + this->G = g; + this->D = d; + this->V = v; + this->Q = q; + this->Gradient = gradient; + this->Divergence = divergence; + this->Vorticity = vorticity; + this->Qcriterion = qcriterion; + this->Size = size; + } + + bool G; + bool D; + bool V; + bool Q; + vtkm::cont::ArrayHandle Gradient; + vtkm::cont::ArrayHandle Divergence; + vtkm::cont::ArrayHandle> Vorticity; + vtkm::cont::ArrayHandle Qcriterion; + vtkm::Id Size; }; -template -struct GradientOutput, DeviceAdapter> - : public GradientVecOutput, DeviceAdapter> +template +struct GradientOutput : public GradientScalarOutput { - using GradientVecOutput, DeviceAdapter>::GradientVecOutput; + using GradientScalarOutput::GradientScalarOutput; }; -template -struct GradientOutput, DeviceAdapter> - : public GradientVecOutput, DeviceAdapter> +template <> +struct GradientOutput> + : public GradientVecOutput> { - using GradientVecOutput, DeviceAdapter>::GradientVecOutput; + using GradientVecOutput>::GradientVecOutput; +}; + +template <> +struct GradientOutput> + : public GradientVecOutput> +{ + using GradientVecOutput>::GradientVecOutput; }; } } // namespace vtkm::exec @@ -210,7 +288,9 @@ struct TransportTagGradientOut template struct Transport { - using ExecObjectType = vtkm::exec::GradientOutput; + using ExecObjectFacotryType = vtkm::exec::GradientOutput; + using ExecObjectType = + decltype(std::declval().PrepareForExecution(Device())); template VTKM_CONT ExecObjectType operator()(ContObjectType object, @@ -218,7 +298,8 @@ struct Transport