Commit 8d7cf2c8 authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Support all Allocate flags in UnknownArrayHandle

`UnknownArrayHandle` supported an `Allocate` method to change
the size of the underlying array without knowing its type.
However, it did not give all the features of `ArrayHandle`'s
allocate. Namely, you could not specify that the data should
be preserved and you could not provide a `Token` object. This
change adds these (optional) parameters.
parent 6c2b0dc4
......@@ -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)
{
this->Container->Allocate(this->Container->ArrayHandlePointer, numValues);
this->Container->Allocate(this->Container->ArrayHandlePointer, numValues, preserve, token);
}
else
{
......@@ -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
{
if (this->Container)
......
......@@ -93,11 +93,14 @@ static vtkm::IdComponent UnknownAHNumberOfComponentsFlat()
}
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>;
AH* arrayHandle = reinterpret_cast<AH*>(mem);
arrayHandle->Allocate(numValues);
arrayHandle->Allocate(numValues, preserve, token);
}
template <typename T, typename S>
......@@ -205,7 +208,7 @@ struct VTKM_CONT_EXPORT UnknownAHContainer
NumberOfComponentsType* NumberOfComponents;
NumberOfComponentsType* NumberOfComponentsFlat;
using AllocateType = void(void*, vtkm::Id);
using AllocateType = void(void*, vtkm::Id, vtkm::CopyFlag, vtkm::cont::Token&);
AllocateType* Allocate;
using ExtractComponentType = std::vector<vtkm::cont::internal::Buffer>(void*,
......@@ -538,7 +541,14 @@ public:
/// \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.
///
......
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