mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
d77c5812c3
The `vtkm::worklet::Keys` object held a `SortedValuesMap` array, an `Offsets` array, a `Counts` array, and (optionally) a `UniqueKeys` array. Of these, the `Counts` array is redundant because the counts are trivially computed by subtracting adjacent entries in the offsets array. This pattern shows up a lot in VTK-m, and most places we have moved to removing the counts and just using the offsets. This change removes the `Count` array from the `Keys` object. Where the count is needed internally, adjacent offsets are subtracted. The deprecated `GetCounts` method is implemented by copying values into a new array.
42 lines
1.7 KiB
C++
42 lines
1.7 KiB
C++
//============================================================================
|
|
// 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.
|
|
//============================================================================
|
|
|
|
#define vtk_m_worklet_Keys_cxx
|
|
#include <vtkm/worklet/Keys.h>
|
|
#include <vtkm/worklet/Keys.hxx>
|
|
|
|
#define VTK_M_KEYS_EXPORT(T) \
|
|
template class VTKM_WORKLET_EXPORT vtkm::worklet::Keys<T>; \
|
|
template VTKM_WORKLET_EXPORT VTKM_CONT void vtkm::worklet::Keys<T>::BuildArrays( \
|
|
const vtkm::cont::ArrayHandle<T>& keys, \
|
|
vtkm::worklet::KeysSortType sort, \
|
|
vtkm::cont::DeviceAdapterId device)
|
|
|
|
VTK_M_KEYS_EXPORT(vtkm::Id);
|
|
VTK_M_KEYS_EXPORT(vtkm::Id2);
|
|
VTK_M_KEYS_EXPORT(vtkm::Id3);
|
|
#ifdef VTKM_USE_64BIT_IDS
|
|
VTK_M_KEYS_EXPORT(vtkm::IdComponent);
|
|
#endif
|
|
|
|
#undef VTK_M_KEYS_EXPORT
|
|
|
|
// Putting this deprecated implementation here because I am too lazy to create
|
|
// a separate source file just for a deprecated method.
|
|
#include <vtkm/cont/ArrayCopyDevice.h>
|
|
#include <vtkm/cont/ArrayHandleOffsetsToNumComponents.h>
|
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> vtkm::worklet::internal::KeysBase::GetCounts() const
|
|
{
|
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> counts;
|
|
vtkm::cont::ArrayCopyDevice(
|
|
vtkm::cont::make_ArrayHandleOffsetsToNumComponents(this->GetOffsets()), counts);
|
|
return counts;
|
|
}
|