Commit 4d1da547 authored by Kenneth Moreland's avatar Kenneth Moreland

Fix ArrayHandleZip::PrepareForInPlace

The implementation was calling PrepareForOutput on the delegate arrays
rather than PrepareForInPlace, do when used with CUDA you did not get
the data on the device.

Also added a regression test to check this.
parent f0413c48
Pipeline #43188 passed with stage
......@@ -253,9 +253,8 @@ public:
VTKM_CONT
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData)) {
const vtkm::Id numberOfValues = this->GetNumberOfValues();
return PortalExecution(this->FirstArray.PrepareForOutput(numberOfValues, Device()),
this->SecondArray.PrepareForOutput(numberOfValues, Device()));
return PortalExecution(this->FirstArray.PrepareForInPlace(Device()),
this->SecondArray.PrepareForInPlace(Device()));
}
VTKM_CONT
......
......@@ -105,7 +105,7 @@ struct TestingArrayHandles
{
ExecutionPortalType Portal;
VTKM_CONT
InplaceFunctor(ExecutionPortalType p): Portal(p) {}
InplaceFunctor(const ExecutionPortalType &p): Portal(p) {}
VTKM_EXEC
void operator()(vtkm::Id index) const
......
......@@ -125,6 +125,19 @@ public:
};
struct InplaceFunctorPair : public vtkm::worklet::WorkletMapField
{
typedef void ControlSignature(FieldInOut<>);
typedef void ExecutionSignature(_1);
template<typename T>
VTKM_EXEC
void operator()(vtkm::Pair<T,T> &value) const
{
value.second = value.first;
}
};
#ifndef VTKM_CUDA
private:
......@@ -875,6 +888,26 @@ private:
}
};
struct TestZipAsInPlace
{
template<typename ValueType>
VTKM_CONT
void operator()(ValueType) const
{
vtkm::cont::ArrayHandle<ValueType> inputValues;
inputValues.Allocate(ARRAY_SIZE);
SetPortal(inputValues.GetPortalControl());
vtkm::cont::ArrayHandle<ValueType> outputValues;
outputValues.Allocate(ARRAY_SIZE);
vtkm::worklet::DispatcherMapField<InplaceFunctorPair,DeviceAdapterTag> dispatcher;
dispatcher.Invoke(vtkm::cont::make_ArrayHandleZip(inputValues,outputValues));
CheckPortal(outputValues.GetPortalConstControl());
}
};
struct ScalarTypesToTest
: vtkm::ListTagBase<vtkm::UInt8, vtkm::FloatDefault>
{ };
......@@ -1009,6 +1042,12 @@ private:
TestingFancyArrayHandles<DeviceAdapterTag>::TestZipAsOutput(),
ZipTypesToTest());
std::cout << "-------------------------------------------" << std::endl;
std::cout << "Testing ArrayHandleZip as In Place" << std::endl;
vtkm::testing::Testing::TryTypes(
TestingFancyArrayHandles<DeviceAdapterTag>::TestZipAsInPlace(),
HandleTypesToTest());
std::cout << "-------------------------------------------" << std::endl;
std::cout << "Testing ArrayHandleConcatenate as Input" << std::endl;
vtkm::testing::Testing::TryTypes(
......
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