Commit 80d622cd authored by Kenneth Moreland's avatar Kenneth Moreland Committed by Kitware Robot
Browse files

Merge topic 'unknown-array-better-allocate'

8d7cf2c8

 Support all Allocate flags in UnknownArrayHandle
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Li-Ta Lo's avatarLi-Ta Lo <ollie@lanl.gov>
Merge-request: !2522
parents 22ee5f11 8d7cf2c8
...@@ -237,11 +237,13 @@ VTKM_CONT vtkm::IdComponent UnknownArrayHandle::GetNumberOfComponentsFlat() cons ...@@ -237,11 +237,13 @@ VTKM_CONT vtkm::IdComponent UnknownArrayHandle::GetNumberOfComponentsFlat() cons
} }
} }
VTKM_CONT void UnknownArrayHandle::Allocate(vtkm::Id numValues) const VTKM_CONT void UnknownArrayHandle::Allocate(vtkm::Id numValues,
vtkm::CopyFlag preserve,
vtkm::cont::Token& token) const
{ {
if (this->Container) if (this->Container)
{ {
this->Container->Allocate(this->Container->ArrayHandlePointer, numValues); this->Container->Allocate(this->Container->ArrayHandlePointer, numValues, preserve, token);
} }
else else
{ {
...@@ -250,6 +252,12 @@ VTKM_CONT void UnknownArrayHandle::Allocate(vtkm::Id numValues) const ...@@ -250,6 +252,12 @@ VTKM_CONT void UnknownArrayHandle::Allocate(vtkm::Id numValues) const
} }
} }
VTKM_CONT void UnknownArrayHandle::Allocate(vtkm::Id numValues, vtkm::CopyFlag preserve) const
{
vtkm::cont::Token token;
this->Allocate(numValues, preserve, token);
}
VTKM_CONT void UnknownArrayHandle::ReleaseResourcesExecution() const VTKM_CONT void UnknownArrayHandle::ReleaseResourcesExecution() const
{ {
if (this->Container) if (this->Container)
......
...@@ -93,11 +93,14 @@ static vtkm::IdComponent UnknownAHNumberOfComponentsFlat() ...@@ -93,11 +93,14 @@ static vtkm::IdComponent UnknownAHNumberOfComponentsFlat()
} }
template <typename T, typename S> template <typename T, typename S>
static void UnknownAHAllocate(void* mem, vtkm::Id numValues) static void UnknownAHAllocate(void* mem,
vtkm::Id numValues,
vtkm::CopyFlag preserve,
vtkm::cont::Token& token)
{ {
using AH = vtkm::cont::ArrayHandle<T, S>; using AH = vtkm::cont::ArrayHandle<T, S>;
AH* arrayHandle = reinterpret_cast<AH*>(mem); AH* arrayHandle = reinterpret_cast<AH*>(mem);
arrayHandle->Allocate(numValues); arrayHandle->Allocate(numValues, preserve, token);
} }
template <typename T, typename S> template <typename T, typename S>
...@@ -205,7 +208,7 @@ struct VTKM_CONT_EXPORT UnknownAHContainer ...@@ -205,7 +208,7 @@ struct VTKM_CONT_EXPORT UnknownAHContainer
NumberOfComponentsType* NumberOfComponents; NumberOfComponentsType* NumberOfComponents;
NumberOfComponentsType* NumberOfComponentsFlat; NumberOfComponentsType* NumberOfComponentsFlat;
using AllocateType = void(void*, vtkm::Id); using AllocateType = void(void*, vtkm::Id, vtkm::CopyFlag, vtkm::cont::Token&);
AllocateType* Allocate; AllocateType* Allocate;
using ExtractComponentType = std::vector<vtkm::cont::internal::Buffer>(void*, using ExtractComponentType = std::vector<vtkm::cont::internal::Buffer>(void*,
...@@ -538,7 +541,14 @@ public: ...@@ -538,7 +541,14 @@ public:
/// \brief Reallocate the data in the array. /// \brief Reallocate the data in the array.
/// ///
VTKM_CONT void Allocate(vtkm::Id numValues) const; /// The allocation works the same as the `Allocate` method of `vtkm::cont::ArrayHandle`.
///
/// @{
VTKM_CONT void Allocate(vtkm::Id numValues,
vtkm::CopyFlag preserve,
vtkm::cont::Token& token) const;
VTKM_CONT void Allocate(vtkm::Id numValues, vtkm::CopyFlag preserve = vtkm::CopyFlag::Off) const;
/// @}
/// \brief Determine if the contained array can be passed to the given array type. /// \brief Determine if the contained array can be passed to the given array type.
/// ///
......
Supports Markdown
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