Store return value after parameters.

This allows execution signatures like

using ExecutionSignature = _1(_1, ...)

to work as expected.
This commit is contained in:
Allison Vacanti 2018-12-21 11:11:57 -05:00
parent 376ef07fa3
commit 58509f647e
3 changed files with 112 additions and 108 deletions

@ -132,14 +132,14 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1));
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
}
template <typename WorkletType,
@ -246,17 +246,17 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
fetch2.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo2::ControlParameterIndex>(),
p2);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -382,11 +382,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -396,6 +391,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch3.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo3::ControlParameterIndex>(),
p3);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -540,11 +540,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -557,6 +552,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch4.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo4::ControlParameterIndex>(),
p4);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -720,11 +720,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -740,6 +735,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch5.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo5::ControlParameterIndex>(),
p5);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -922,11 +922,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -945,6 +940,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch6.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo6::ControlParameterIndex>(),
p6);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -1146,11 +1146,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -1172,6 +1167,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch7.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo7::ControlParameterIndex>(),
p7);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -1392,11 +1392,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -1421,6 +1416,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch8.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo8::ControlParameterIndex>(),
p8);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -1660,11 +1660,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -1692,6 +1687,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch9.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo9::ControlParameterIndex>(),
p9);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -1950,11 +1950,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -1985,6 +1980,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch10.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo10::ControlParameterIndex>(),
p10);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -2262,11 +2262,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -2300,6 +2295,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch11.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo11::ControlParameterIndex>(),
p11);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -2596,11 +2596,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -2637,6 +2632,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch12.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo12::ControlParameterIndex>(),
p12);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -2952,11 +2952,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -2996,6 +2991,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch13.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo13::ControlParameterIndex>(),
p13);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -3330,11 +3330,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -3377,6 +3372,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch14.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo14::ControlParameterIndex>(),
p14);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -3730,11 +3730,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -3780,6 +3775,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch15.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo15::ControlParameterIndex>(),
p15);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -4152,11 +4152,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -4205,6 +4200,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch16.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo16::ControlParameterIndex>(),
p16);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -4596,11 +4596,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -4652,6 +4647,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch17.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo17::ControlParameterIndex>(),
p17);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -5062,11 +5062,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -5121,6 +5116,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch18.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo18::ControlParameterIndex>(),
p18);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -5550,11 +5550,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -5612,6 +5607,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch19.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo19::ControlParameterIndex>(),
p19);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,
@ -6060,11 +6060,6 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
// parameter is wrong and the types that did not match.
auto r = typename ReturnFetchType::ValueType(worklet(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
fetch1.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo1::ControlParameterIndex>(),
p1);
@ -6125,6 +6120,11 @@ VTKM_EXEC void DoWorkletInvokeFunctor(
fetch20.Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo20::ControlParameterIndex>(),
p20);
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
r);
}
template <typename WorkletType,

@ -195,16 +195,16 @@ $endfor\
// parameter is wrong and the types that did not match.
auto $pname(0) = typename ReturnFetchType::ValueType(worklet($arg_list(num_params)));
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
$pname(0));
$for(param_index in range(1, num_params+1))\
fetch$(param_index).Store(threadIndices,
invocation.Parameters.template GetParameter<FetchInfo$(param_index)::ControlParameterIndex>(),
$pname(param_index));
$endfor\
returnFetch.Store(
threadIndices,
invocation.Parameters.template GetParameter<FetchInfo0::ControlParameterIndex>(),
$pname(0));
}
template <typename WorkletType,

@ -31,10 +31,10 @@ class TestMapFieldWorklet : public vtkm::worklet::WorkletMapField
{
public:
using ControlSignature = void(FieldIn<>, FieldOut<>, FieldInOut<>);
using ExecutionSignature = void(_1, _2, _3, WorkIndex);
using ExecutionSignature = _3(_1, _2, _3, WorkIndex);
template <typename T>
VTKM_EXEC void operator()(const T& in, T& out, T& inout, vtkm::Id workIndex) const
VTKM_EXEC T operator()(const T& in, T& out, T& inout, vtkm::Id workIndex) const
{
if (!test_equal(in, TestValue(workIndex, T()) + T(100)))
{
@ -45,13 +45,17 @@ public:
{
this->RaiseError("Got wrong in-out value.");
}
inout = inout - T(100);
// We return the new value of inout. Since _3 is both an arg and return,
// this tests that the return value is set after updating the arg values.
return inout - T(100);
}
template <typename T1, typename T2, typename T3>
VTKM_EXEC void operator()(const T1&, const T2&, const T3&, vtkm::Id) const
VTKM_EXEC T3 operator()(const T1&, const T2&, const T3&, vtkm::Id) const
{
this->RaiseError("Cannot call this worklet with different types.");
return vtkm::TypeTraits<T3>::ZeroInitialization();
}
};