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.
65 lines
2.0 KiB
C++
65 lines
2.0 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.
|
|
//============================================================================
|
|
#ifndef vtk_m_exec_arg_ThreadIndicesReduceByKey_h
|
|
#define vtk_m_exec_arg_ThreadIndicesReduceByKey_h
|
|
|
|
#include <vtkm/exec/arg/ThreadIndicesBasic.h>
|
|
|
|
#include <vtkm/exec/internal/ReduceByKeyLookup.h>
|
|
|
|
namespace vtkm
|
|
{
|
|
namespace exec
|
|
{
|
|
namespace arg
|
|
{
|
|
|
|
/// \brief Container for thread indices in a reduce by key invocation.
|
|
///
|
|
/// This specialization of \c ThreadIndices adds extra indices that deal with a
|
|
/// reduce by key. In particular, it save the indices used to map from a unique
|
|
/// key index to the group of input values that has that key associated with
|
|
/// it.
|
|
///
|
|
class ThreadIndicesReduceByKey : public vtkm::exec::arg::ThreadIndicesBasic
|
|
{
|
|
using Superclass = vtkm::exec::arg::ThreadIndicesBasic;
|
|
|
|
public:
|
|
template <typename P1, typename P2>
|
|
VTKM_EXEC ThreadIndicesReduceByKey(
|
|
vtkm::Id threadIndex,
|
|
vtkm::Id inIndex,
|
|
vtkm::IdComponent visitIndex,
|
|
vtkm::Id outIndex,
|
|
const vtkm::exec::internal::ReduceByKeyLookupBase<P1, P2>& keyLookup)
|
|
: Superclass(threadIndex, inIndex, visitIndex, outIndex)
|
|
, ValueOffset(keyLookup.Offsets.Get(inIndex))
|
|
, NumberOfValues(static_cast<vtkm::IdComponent>(keyLookup.Offsets.Get(inIndex + 1) -
|
|
keyLookup.Offsets.Get(inIndex)))
|
|
{
|
|
}
|
|
|
|
VTKM_EXEC
|
|
vtkm::Id GetValueOffset() const { return this->ValueOffset; }
|
|
|
|
VTKM_EXEC
|
|
vtkm::IdComponent GetNumberOfValues() const { return this->NumberOfValues; }
|
|
|
|
private:
|
|
vtkm::Id ValueOffset;
|
|
vtkm::IdComponent NumberOfValues;
|
|
};
|
|
}
|
|
}
|
|
} // namespace vtkm::exec::arg
|
|
|
|
#endif //vtk_m_exec_arg_ThreadIndicesReduceByKey_h
|