2016-12-22 00:26:16 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2016-12-22 00:26:16 +00:00
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
|
|
|
// Copyright 2014 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2016-12-22 00:26:16 +00:00
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_exec_arg_ValueCount_h
|
|
|
|
#define vtk_m_exec_arg_ValueCount_h
|
|
|
|
|
|
|
|
#include <vtkm/exec/arg/ExecutionSignatureTagBase.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/exec/arg/Fetch.h>
|
2016-12-22 00:26:16 +00:00
|
|
|
#include <vtkm/exec/arg/ThreadIndicesReduceByKey.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace exec
|
|
|
|
{
|
|
|
|
namespace arg
|
|
|
|
{
|
2016-12-22 00:26:16 +00:00
|
|
|
|
|
|
|
/// \brief Aspect tag to use for getting the value count.
|
|
|
|
///
|
|
|
|
/// The \c AspectTagValueCount aspect tag causes the \c Fetch class to obtain
|
|
|
|
/// the number of values that map to the key.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
struct AspectTagValueCount
|
|
|
|
{
|
|
|
|
};
|
2016-12-22 00:26:16 +00:00
|
|
|
|
|
|
|
/// \brief The \c ExecutionSignature tag to get the number of values.
|
|
|
|
///
|
|
|
|
/// A \c WorkletReduceByKey operates by collecting all values associated with
|
|
|
|
/// identical keys and then giving the worklet a Vec-like object containing all
|
|
|
|
/// values with a matching key. This \c ExecutionSignature tag provides the
|
|
|
|
/// number of values associated with the key and given in the Vec-like objects.
|
|
|
|
///
|
|
|
|
struct ValueCount : vtkm::exec::arg::ExecutionSignatureTagBase
|
|
|
|
{
|
|
|
|
static const vtkm::IdComponent INDEX = 1;
|
2017-08-16 15:34:21 +00:00
|
|
|
using AspectTag = vtkm::exec::arg::AspectTagValueCount;
|
2016-12-22 00:26:16 +00:00
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename FetchTag, typename ExecObjectType>
|
2017-05-26 17:53:28 +00:00
|
|
|
struct Fetch<FetchTag,
|
|
|
|
vtkm::exec::arg::AspectTagValueCount,
|
|
|
|
vtkm::exec::arg::ThreadIndicesReduceByKey,
|
|
|
|
ExecObjectType>
|
2016-12-22 00:26:16 +00:00
|
|
|
{
|
|
|
|
using ThreadIndicesType = vtkm::exec::arg::ThreadIndicesReduceByKey;
|
|
|
|
|
|
|
|
using ValueType = vtkm::IdComponent;
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
VTKM_EXEC
|
2017-05-18 14:29:41 +00:00
|
|
|
ValueType Load(const ThreadIndicesType& indices, const ExecObjectType&) const
|
2016-12-22 00:26:16 +00:00
|
|
|
{
|
|
|
|
return indices.GetNumberOfValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_EXEC
|
2017-05-18 14:29:41 +00:00
|
|
|
void Store(const ThreadIndicesType&, const ExecObjectType&, const ValueType&) const
|
2016-12-22 00:26:16 +00:00
|
|
|
{
|
|
|
|
// Store is a no-op.
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::exec::arg
|
|
|
|
|
|
|
|
#endif //vtk_m_exec_arg_ValueCount_h
|