From cdcc311dc2663999f205aec841828be2707aed25 Mon Sep 17 00:00:00 2001 From: nadavi Date: Wed, 21 Aug 2019 17:18:54 -0600 Subject: [PATCH 1/2] removed ArrayPortalShrink --- vtkm/cont/internal/ArrayPortalShrink.h | 152 ------------------------- vtkm/cont/internal/CMakeLists.txt | 1 - 2 files changed, 153 deletions(-) delete mode 100644 vtkm/cont/internal/ArrayPortalShrink.h diff --git a/vtkm/cont/internal/ArrayPortalShrink.h b/vtkm/cont/internal/ArrayPortalShrink.h deleted file mode 100644 index 258970229..000000000 --- a/vtkm/cont/internal/ArrayPortalShrink.h +++ /dev/null @@ -1,152 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ -#ifndef vtk_m_cont_internal_ArrayPortalShrink_h -#define vtk_m_cont_internal_ArrayPortalShrink_h - -#include -#include -#include -#include - -#include - -namespace vtkm -{ -namespace cont -{ -namespace internal -{ - -/// This ArrayPortal adapter is a utility that allows you to shrink the -/// (reported) array size without actually modifying the underlying allocation. -/// -template -class ArrayPortalShrink -{ -public: - using DelegatePortalType = PortalT; - - using ValueType = typename DelegatePortalType::ValueType; - - VTKM_CONT ArrayPortalShrink() - : NumberOfValues(0) - { - } - - VTKM_CONT ArrayPortalShrink(const DelegatePortalType& delegatePortal) - : DelegatePortal(delegatePortal) - , NumberOfValues(delegatePortal.GetNumberOfValues()) - { - } - - VTKM_CONT ArrayPortalShrink(const DelegatePortalType& delegatePortal, vtkm::Id numberOfValues) - : DelegatePortal(delegatePortal) - , NumberOfValues(numberOfValues) - { - VTKM_ASSERT(numberOfValues <= delegatePortal.GetNumberOfValues()); - } - - /// Copy constructor for any other ArrayPortalShrink with a delegate type - /// that can be copied to this type. This allows us to do any type casting - /// the delegates can do (like the non-const to const cast). - /// - template - VTKM_CONT ArrayPortalShrink(const ArrayPortalShrink& src) - : DelegatePortal(src.GetDelegatePortal()) - , NumberOfValues(src.GetNumberOfValues()) - { - } - - VTKM_CONT - vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; } - - VTKM_CONT - ValueType Get(vtkm::Id index) const - { - VTKM_ASSERT(index >= 0); - VTKM_ASSERT(index < this->GetNumberOfValues()); - return this->DelegatePortal.Get(index); - } - - VTKM_CONT - void Set(vtkm::Id index, const ValueType& value) const - { - VTKM_ASSERT(index >= 0); - VTKM_ASSERT(index < this->GetNumberOfValues()); - this->DelegatePortal.Set(index, value); - } - - /// Special method in this ArrayPortal that allows you to shrink the - /// (exposed) array. - /// - VTKM_CONT - void Shrink(vtkm::Id numberOfValues) - { - VTKM_ASSERT(numberOfValues < this->GetNumberOfValues()); - this->NumberOfValues = numberOfValues; - } - - /// Get a copy of the delegate portal. Although safe, this is probably only - /// useful internally. (It is exposed as public for the templated copy - /// constructor.) - /// - DelegatePortalType GetDelegatePortal() const { return this->DelegatePortal; } - -private: - DelegatePortalType DelegatePortal; - vtkm::Id NumberOfValues; -}; -} -} -} // namespace vtkm::cont::internal - -namespace vtkm -{ -namespace cont -{ - -template -class ArrayPortalToIterators> -{ - using PortalType = vtkm::cont::internal::ArrayPortalShrink; - using DelegateArrayPortalToIterators = vtkm::cont::ArrayPortalToIterators; - -public: - VTKM_SUPPRESS_EXEC_WARNINGS - VTKM_EXEC_CONT - ArrayPortalToIterators(const PortalType& portal) - : DelegateIterators(portal.GetDelegatePortal()) - , NumberOfValues(portal.GetNumberOfValues()) - { - } - - using IteratorType = typename DelegateArrayPortalToIterators::IteratorType; - - VTKM_SUPPRESS_EXEC_WARNINGS - VTKM_EXEC_CONT - IteratorType GetBegin() const { return this->DelegateIterators.GetBegin(); } - - VTKM_SUPPRESS_EXEC_WARNINGS - VTKM_EXEC_CONT - IteratorType GetEnd() const - { - IteratorType iterator = this->GetBegin(); - std::advance(iterator, this->NumberOfValues); - return iterator; - } - -private: - DelegateArrayPortalToIterators DelegateIterators; - vtkm::Id NumberOfValues; -}; -} -} // namespace vtkm::cont - -#endif //vtk_m_cont_internal_ArrayPortalShrink_h diff --git a/vtkm/cont/internal/CMakeLists.txt b/vtkm/cont/internal/CMakeLists.txt index 10c11dd07..3df2f9fa7 100644 --- a/vtkm/cont/internal/CMakeLists.txt +++ b/vtkm/cont/internal/CMakeLists.txt @@ -16,7 +16,6 @@ set(headers ArrayManagerExecution.h ArrayManagerExecutionShareWithControl.h ArrayPortalFromIterators.h - ArrayPortalShrink.h ArrayTransfer.h AtomicInterfaceControl.h AtomicInterfaceExecution.h From 2d9f7ea95b47a3a1895720a83788eb9126d9a346 Mon Sep 17 00:00:00 2001 From: Nick Davis Date: Wed, 28 Aug 2019 10:26:07 -0600 Subject: [PATCH 2/2] add changelog entry --- docs/changelog/remove-array-portal-shrink.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/changelog/remove-array-portal-shrink.md diff --git a/docs/changelog/remove-array-portal-shrink.md b/docs/changelog/remove-array-portal-shrink.md new file mode 100644 index 000000000..6922d6b4d --- /dev/null +++ b/docs/changelog/remove-array-portal-shrink.md @@ -0,0 +1,10 @@ +# Remove ArrayPortalShrink, behavior subsumed by ArrayHandleView + +ArrayPortalShrink originaly allowed a user to pass in a delegate array portal +and then shrink the reported array size without actually modifying the +underlying allocation. An iterator was also provided that would +correctly iterate over the shrunken size of the stored array. + +Instead of directly shrinking the original array, it is prefered +to create an ArrayHandleView from an ArrayHandle and then specify the +number of values to use in the ArrayHandleView constructor.