Commit 58509f64 authored by Allison Vacanti's avatar Allison Vacanti

Store return value after parameters.

This allows execution signatures like

using ExecutionSignature = _1(_1, ...)

to work as expected.
parent 376ef07f
......@@ -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();
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment