From 40896e2babff64051b46b7412db27feacc91bc98 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 15 Mar 2016 13:13:34 -0400 Subject: [PATCH 1/3] Allocate the scatter arrays to be proper length. The previous code would over allocate all the scatter arrays since it was computing the output range, than using that as the input range. --- vtkm/worklet/internal/DispatcherBase.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/vtkm/worklet/internal/DispatcherBase.h b/vtkm/worklet/internal/DispatcherBase.h index 3beb5f50b..503adeabd 100644 --- a/vtkm/worklet/internal/DispatcherBase.h +++ b/vtkm/worklet/internal/DispatcherBase.h @@ -445,6 +445,7 @@ protected: { this->InvokeTransportParameters( invocation, + numInstances, this->Worklet.GetScatter().GetOutputRange(numInstances), device); } @@ -469,6 +470,7 @@ protected: { this->InvokeTransportParameters( invocation, + dimensions, this->Worklet.GetScatter().GetOutputRange(dimensions), device); } @@ -480,10 +482,11 @@ private: DispatcherBase(const MyType &); void operator=(const MyType &); - template + template VTKM_CONT_EXPORT void InvokeTransportParameters(const Invocation &invocation, - RangeType range, + const InputRangeType& inputRange, + const OutputRangeType& outputRange, DeviceAdapter device) const { // The first step in invoking a worklet is to transport the arguments to @@ -504,13 +507,13 @@ private: TransportFunctorType>::type ExecObjectParameters; ExecObjectParameters execObjectParameters = - parameters.StaticTransformCont(TransportFunctorType(range)); + parameters.StaticTransformCont(TransportFunctorType(outputRange)); // Get the arrays used for scattering input to output. typename WorkletType::ScatterType::OutputToInputMapType outputToInputMap = - this->Worklet.GetScatter().GetOutputToInputMap(range); + this->Worklet.GetScatter().GetOutputToInputMap(inputRange); typename WorkletType::ScatterType::VisitArrayType visitArray = - this->Worklet.GetScatter().GetVisitArray(range); + this->Worklet.GetScatter().GetVisitArray(inputRange); // Replace the parameters in the invocation with the execution object and // pass to next step of Invoke. Also add the scatter information. @@ -519,7 +522,7 @@ private: .ChangeParameters(execObjectParameters) .ChangeOutputToInputMap(outputToInputMap.PrepareForInput(device)) .ChangeVisitArray(visitArray.PrepareForInput(device)), - range, + outputRange, device); } From 86ecad659a3cabf78152af31284cb5af9cb461fc Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 15 Mar 2016 16:20:37 -0400 Subject: [PATCH 2/3] ScatterIdentity::GetOutputToInputMap parameters are now named properly Now it is clear you pass in the input range and you will get the output range. --- vtkm/worklet/ScatterIdentity.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vtkm/worklet/ScatterIdentity.h b/vtkm/worklet/ScatterIdentity.h index 49b2d488c..7865f19ef 100644 --- a/vtkm/worklet/ScatterIdentity.h +++ b/vtkm/worklet/ScatterIdentity.h @@ -40,15 +40,15 @@ struct ScatterIdentity { typedef vtkm::cont::ArrayHandleIndex OutputToInputMapType; VTKM_CONT_EXPORT - OutputToInputMapType GetOutputToInputMap(vtkm::Id outputRange) const + OutputToInputMapType GetOutputToInputMap(vtkm::Id inputRange) const { - return OutputToInputMapType(outputRange); + return OutputToInputMapType(inputRange); } VTKM_CONT_EXPORT - OutputToInputMapType GetOutputToInputMap(vtkm::Id3 outputRange) const + OutputToInputMapType GetOutputToInputMap(vtkm::Id3 inputRange) const { return this->GetOutputToInputMap( - outputRange[0]*outputRange[1]*outputRange[2]); + inputRange[0]*inputRange[1]*inputRange[2]); } typedef vtkm::cont::ArrayHandleConstant VisitArrayType; From 85084f2ca11c0e3166bc76f9bc7c0e87379f9f33 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 15 Mar 2016 16:49:36 -0400 Subject: [PATCH 3/3] ScatterIdentity::GetVisitArray parameters are now named properly Now it is clear you pass in the input range and you will get the output range --- vtkm/worklet/ScatterIdentity.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vtkm/worklet/ScatterIdentity.h b/vtkm/worklet/ScatterIdentity.h index 7865f19ef..e103c85f4 100644 --- a/vtkm/worklet/ScatterIdentity.h +++ b/vtkm/worklet/ScatterIdentity.h @@ -53,14 +53,14 @@ struct ScatterIdentity typedef vtkm::cont::ArrayHandleConstant VisitArrayType; VTKM_CONT_EXPORT - VisitArrayType GetVisitArray(vtkm::Id outputRange) const + VisitArrayType GetVisitArray(vtkm::Id inputRange) const { - return VisitArrayType(1, outputRange); + return VisitArrayType(1, inputRange); } VTKM_CONT_EXPORT - VisitArrayType GetVisitArray(vtkm::Id3 outputRange) const + VisitArrayType GetVisitArray(vtkm::Id3 inputRange) const { - return this->GetVisitArray(outputRange[0]*outputRange[1]*outputRange[2]); + return this->GetVisitArray(inputRange[0]*inputRange[1]*inputRange[2]); } template