Commit 0571c633 authored by Kenneth Moreland's avatar Kenneth Moreland

Add missing allocation methods to ArrayHandleVirtual

parent 68b2e5e6
...@@ -71,14 +71,14 @@ StorageVirtual::~StorageVirtual() ...@@ -71,14 +71,14 @@ StorageVirtual::~StorageVirtual()
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
void StorageVirtual::ReleaseResourcesExecution() void StorageVirtual::DropExecutionPortal()
{ {
this->DeviceTransferState->releaseDevice(); this->DeviceTransferState->releaseDevice();
this->DeviceUpToDate = false; this->DeviceUpToDate = false;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
void StorageVirtual::ReleaseResources() void StorageVirtual::DropAllPortals()
{ {
this->DeviceTransferState->releaseAll(); this->DeviceTransferState->releaseAll();
this->HostUpToDate = false; this->HostUpToDate = false;
......
...@@ -62,13 +62,13 @@ public: ...@@ -62,13 +62,13 @@ public:
/// ///
/// Only needs to overridden by subclasses such as Zip that have member /// Only needs to overridden by subclasses such as Zip that have member
/// variables that themselves have execution memory /// variables that themselves have execution memory
virtual void ReleaseResourcesExecution(); virtual void ReleaseResourcesExecution() = 0;
/// Releases all resources in both the control and execution environments. /// Releases all resources in both the control and execution environments.
/// ///
/// Only needs to overridden by subclasses such as Zip that have member /// Only needs to overridden by subclasses such as Zip that have member
/// variables that themselves have execution memory /// variables that themselves have execution memory
virtual void ReleaseResources(); virtual void ReleaseResources() = 0;
/// Returns the number of entries in the array. /// Returns the number of entries in the array.
/// ///
...@@ -82,10 +82,7 @@ public: ...@@ -82,10 +82,7 @@ public:
/// ErrorBadValue if the allocation is not feasible (for example, the /// ErrorBadValue if the allocation is not feasible (for example, the
/// array storage is read-only). /// array storage is read-only).
/// ///
void Allocate(vtkm::Id numberOfValues) virtual void Allocate(vtkm::Id numberOfValues) = 0;
{
std::cout << "StorageVirtual::Allocate(" << numberOfValues << ") Not Implemented!" << std::endl;
} //return this->DoAllocate(numberOfValues); }
/// \brief Reduces the size of the array without changing its values. /// \brief Reduces the size of the array without changing its values.
/// ///
...@@ -95,10 +92,7 @@ public: ...@@ -95,10 +92,7 @@ public:
/// \c numberOfValues must be equal or less than the preexisting size /// \c numberOfValues must be equal or less than the preexisting size
/// (returned from GetNumberOfValues). That is, this method can only be used /// (returned from GetNumberOfValues). That is, this method can only be used
/// to shorten the array, not lengthen. /// to shorten the array, not lengthen.
void Shrink(vtkm::Id numberOfValues) virtual void Shrink(vtkm::Id numberOfValues) = 0;
{
std::cout << "StorageVirtual::Shrink(" << numberOfValues << ") Not Implemented!." << std::endl;
} //return this->DoShrink(numberOfValues); }
/// Determines if storage types matches the type passed in. /// Determines if storage types matches the type passed in.
/// ///
...@@ -156,6 +150,16 @@ public: ...@@ -156,6 +150,16 @@ public:
READ_WRITE READ_WRITE
}; };
protected:
/// Drop the reference to the execution portal. The underlying array handle might still be
/// managing data on the execution side, but our references might be out of date, so drop
/// them and refresh them later if necessary.
void DropExecutionPortal();
/// Drop the reference to all portals. The underlying array handle might still be managing data,
/// but our references might be out of date, so drop them and refresh them later if necessary.
void DropAllPortals();
private: private:
//Memory management routines //Memory management routines
// virtual void DoAllocate(vtkm::Id numberOfValues) = 0; // virtual void DoAllocate(vtkm::Id numberOfValues) = 0;
...@@ -198,10 +202,13 @@ public: ...@@ -198,10 +202,13 @@ public:
const vtkm::cont::ArrayHandle<T, S>& GetHandle() const { return this->Handle; } const vtkm::cont::ArrayHandle<T, S>& GetHandle() const { return this->Handle; }
vtkm::Id GetNumberOfValues() const { return this->Handle.GetNumberOfValues(); } vtkm::Id GetNumberOfValues() const override { return this->Handle.GetNumberOfValues(); }
void ReleaseResourcesExecution() override;
void ReleaseResources() override;
void ReleaseResourcesExecution(); void Allocate(vtkm::Id numberOfValues) override;
void ReleaseResources(); void Shrink(vtkm::Id numberOfValues) override;
private: private:
std::unique_ptr<vtkm::cont::internal::detail::StorageVirtual> MakeNewInstance() const std::unique_ptr<vtkm::cont::internal::detail::StorageVirtual> MakeNewInstance() const
......
...@@ -119,7 +119,7 @@ StorageVirtualImpl<T, S>::StorageVirtualImpl(vtkm::cont::ArrayHandle<T, S>&& ah) ...@@ -119,7 +119,7 @@ StorageVirtualImpl<T, S>::StorageVirtualImpl(vtkm::cont::ArrayHandle<T, S>&& ah)
template <typename T, typename S> template <typename T, typename S>
void StorageVirtualImpl<T, S>::ReleaseResourcesExecution() void StorageVirtualImpl<T, S>::ReleaseResourcesExecution()
{ {
vtkm::cont::internal::detail::StorageVirtual::ReleaseResourcesExecution(); this->DropExecutionPortal();
this->Handle.ReleaseResourcesExecution(); this->Handle.ReleaseResourcesExecution();
} }
...@@ -127,10 +127,24 @@ void StorageVirtualImpl<T, S>::ReleaseResourcesExecution() ...@@ -127,10 +127,24 @@ void StorageVirtualImpl<T, S>::ReleaseResourcesExecution()
template <typename T, typename S> template <typename T, typename S>
void StorageVirtualImpl<T, S>::ReleaseResources() void StorageVirtualImpl<T, S>::ReleaseResources()
{ {
vtkm::cont::internal::detail::StorageVirtual::ReleaseResources(); this->DropAllPortals();
this->Handle.ReleaseResources(); this->Handle.ReleaseResources();
} }
template <typename T, typename S>
void StorageVirtualImpl<T, S>::Allocate(vtkm::Id numberOfValues)
{
this->DropAllPortals();
this->Handle.Allocate(numberOfValues);
}
template <typename T, typename S>
void StorageVirtualImpl<T, S>::Shrink(vtkm::Id numberOfValues)
{
this->DropAllPortals();
this->Handle.Shrink(numberOfValues);
}
struct PortalWrapperToDevice struct PortalWrapperToDevice
{ {
template <typename DeviceAdapterTag, typename Handle> template <typename DeviceAdapterTag, typename Handle>
......
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