Commit 51c954c8 authored by Kenneth Moreland's avatar Kenneth Moreland Committed by Kitware Robot

Merge topic 'arrayhandledecorator-use-buffer'

f8007189 Convert ArrayHandleDecorator to new buffer-style arrays
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarRobert Maynard <robert.maynard@kitware.com>
Merge-request: !2324
parents ff7de5a7 f8007189
Pipeline #201523 passed with stages
in 23 minutes and 51 seconds
......@@ -1109,7 +1109,7 @@ public:
return true; // different valuetype and/or storage
}
VTKM_CONT constexpr vtkm::IdComponent GetNumberOfBuffers() const
VTKM_CONT static constexpr vtkm::IdComponent GetNumberOfBuffers()
{
return StorageType::GetNumberOfBuffers();
}
......
This diff is collapsed.
......@@ -261,17 +261,14 @@ struct DecoratorTests
// Resize methods:
template <typename Array1T, typename Array2T>
VTKM_CONT void AllocateSourceArrays(vtkm::Id numVals, Array1T&& array1, Array2T&& array2) const
VTKM_CONT void AllocateSourceArrays(vtkm::Id numVals,
vtkm::CopyFlag preserve,
vtkm::cont::Token& token,
Array1T&& array1,
Array2T&& array2) const
{
array1.Allocate(numVals);
array2.Allocate(numVals);
}
template <typename Array1T, typename Array2T>
VTKM_CONT void ShrinkSourceArrays(vtkm::Id numVals, Array1T&& array1, Array2T&& array2) const
{
array1.Shrink(numVals);
array2.Shrink(numVals);
array1.Allocate(numVals, preserve, token);
array2.Allocate(numVals, preserve, token);
}
};
......@@ -521,7 +518,7 @@ struct DecoratorTests
}
};
// ArrayHandleDecorator that implements AllocateSourceArrays and ShrinkSourceArrays, thus allowing
// ArrayHandleDecorator that implements AllocateSourceArrays, thus allowing
// it to be resized.
struct ResizableDecorImpl
{
......@@ -538,29 +535,32 @@ struct ResizableDecorImpl
}
template <typename Array1T, typename Array2T>
void ShrinkSourceArrays(vtkm::Id newSize, Array1T& a1, Array2T& a2) const
void AllocateSourceArrays(vtkm::Id newSize,
vtkm::CopyFlag preserve,
vtkm::cont::Token& token,
Array1T& a1,
Array2T& a2) const
{
VTKM_IS_ARRAY_HANDLE(Array1T);
VTKM_IS_ARRAY_HANDLE(Array2T);
// Resize each to 2*newSize:
a1.Shrink(2 * newSize);
a2.Shrink(2 * newSize);
}
template <typename Array1T, typename Array2T>
void AllocateSourceArrays(vtkm::Id newSize, Array1T& a1, Array2T& a2) const
{
VTKM_IS_ARRAY_HANDLE(Array1T);
VTKM_IS_ARRAY_HANDLE(Array2T);
// Resize each to 3*newSize:
a1.Allocate(3 * newSize);
a2.Allocate(3 * newSize);
// Resize differently based on preserve to verify the flag is correct.
if (preserve == vtkm::CopyFlag::Off)
{
// Resize each to 3*newSize:
a1.Allocate(3 * newSize, preserve, token);
a2.Allocate(3 * newSize, preserve, token);
}
else
{
// Resize each to 2*newSize:
a1.Shrink(2 * newSize);
a2.Shrink(2 * newSize);
}
}
};
// ArrayHandleDecorator that implements AllocateSourceArrays and ShrinkSourceArrays, thus allowing
// ArrayHandleDecorator that does not implement AllocateSourceArrays, thus not allowing
// it to be resized.
struct NonResizableDecorImpl
{
......@@ -591,7 +591,7 @@ void ResizeTest()
VTKM_TEST_ASSERT(a1.GetNumberOfValues() == 30);
VTKM_TEST_ASSERT(a2.GetNumberOfValues() == 30);
VTKM_TEST_ASSERT(decor.GetNumberOfValues() == 10);
decor.Shrink(3); // Should resize a1&a2 to have 6 values:
decor.Allocate(3, vtkm::CopyFlag::On); // Should resize a1&a2 to have 6 values:
VTKM_TEST_ASSERT(a1.GetNumberOfValues() == 6);
VTKM_TEST_ASSERT(a2.GetNumberOfValues() == 6);
VTKM_TEST_ASSERT(decor.GetNumberOfValues() == 3);
......
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