2016-12-19 20:55:17 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2016-12-19 20:55:17 +00:00
|
|
|
// 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_internal_ReduceByKeyLookup_h
|
|
|
|
#define vtk_m_exec_internal_ReduceByKeyLookup_h
|
|
|
|
|
2018-05-10 23:53:39 +00:00
|
|
|
#include <vtkm/cont/ExecutionObjectBase.h>
|
2016-12-19 20:55:17 +00:00
|
|
|
|
|
|
|
#include <vtkm/StaticAssert.h>
|
|
|
|
#include <vtkm/Types.h>
|
|
|
|
|
|
|
|
#include <type_traits>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace exec
|
|
|
|
{
|
|
|
|
namespace internal
|
|
|
|
{
|
2016-12-19 20:55:17 +00:00
|
|
|
|
2020-02-04 05:00:22 +00:00
|
|
|
/// A superclass of `ReduceBykeyLookup` that can be used when no key values are provided.
|
|
|
|
///
|
|
|
|
template <typename IdPortalType, typename IdComponentPortalType>
|
|
|
|
struct ReduceByKeyLookupBase
|
|
|
|
{
|
|
|
|
VTKM_STATIC_ASSERT((std::is_same<typename IdPortalType::ValueType, vtkm::Id>::value));
|
|
|
|
VTKM_STATIC_ASSERT(
|
|
|
|
(std::is_same<typename IdComponentPortalType::ValueType, vtkm::IdComponent>::value));
|
|
|
|
|
|
|
|
IdPortalType SortedValuesMap;
|
|
|
|
IdPortalType Offsets;
|
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
2024-01-25 21:10:58 +00:00
|
|
|
ReduceByKeyLookupBase(const IdPortalType& sortedValuesMap, const IdPortalType& offsets)
|
2020-02-04 05:00:22 +00:00
|
|
|
: SortedValuesMap(sortedValuesMap)
|
|
|
|
, Offsets(offsets)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
ReduceByKeyLookupBase() {}
|
|
|
|
};
|
|
|
|
|
2017-01-25 15:41:09 +00:00
|
|
|
/// \brief Execution object holding lookup info for reduce by key.
|
2016-12-19 20:55:17 +00:00
|
|
|
///
|
|
|
|
/// A WorkletReduceByKey needs several arrays to map the current output object
|
|
|
|
/// to the respective key and group of values. This execution object holds that
|
|
|
|
/// state.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename KeyPortalType, typename IdPortalType, typename IdComponentPortalType>
|
2020-02-04 05:00:22 +00:00
|
|
|
struct ReduceByKeyLookup : ReduceByKeyLookupBase<IdPortalType, IdComponentPortalType>
|
2016-12-19 20:55:17 +00:00
|
|
|
{
|
|
|
|
using KeyType = typename KeyPortalType::ValueType;
|
|
|
|
|
|
|
|
KeyPortalType UniqueKeys;
|
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-26 17:53:28 +00:00
|
|
|
ReduceByKeyLookup(const KeyPortalType& uniqueKeys,
|
|
|
|
const IdPortalType& sortedValuesMap,
|
2024-01-25 21:10:58 +00:00
|
|
|
const IdPortalType& offsets)
|
|
|
|
: ReduceByKeyLookupBase<IdPortalType, IdComponentPortalType>(sortedValuesMap, offsets)
|
2020-02-04 05:00:22 +00:00
|
|
|
, UniqueKeys(uniqueKeys)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
2016-12-19 20:55:17 +00:00
|
|
|
|
2018-01-18 20:27:40 +00:00
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2016-12-19 20:55:17 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ReduceByKeyLookup() {}
|
2016-12-19 20:55:17 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::exec::internal
|
|
|
|
|
|
|
|
#endif //vtk_m_exec_internal_ReduceByKeyLookup_h
|