Merge topic 'allow_for_easier_scheduling_range_overloads'

36161b42c Renamed to SchedulingRange to follow VTK-m naming convention
40c0c0fef Allow for easier overloads of scheduling_range

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1952
This commit is contained in:
Robert Maynard 2020-01-29 20:18:51 +00:00 committed by Kitware Robot
commit 124fb23c50
8 changed files with 73 additions and 35 deletions

@ -41,6 +41,8 @@ public:
template <typename Invocation>
VTKM_CONT void DoInvoke(Invocation& invocation) const
{
using namespace vtkm::worklet::internal;
// This is the type for the input domain
using InputDomainType = typename Invocation::InputDomainType;
@ -52,7 +54,7 @@ public:
// an VariantArrayHandle that gets cast to one). The size of the domain
// (number of threads/worklet instances) is equal to the size of the
// array.
auto numInstances = internal::scheduling_range(inputDomain);
auto numInstances = SchedulingRange(inputDomain);
// A MapField is a pretty straightforward dispatch. Once we know the number
// of invocations, the superclass can take care of the rest.

@ -44,6 +44,8 @@ public:
template <typename Invocation>
VTKM_CONT void DoInvoke(Invocation& invocation) const
{
using namespace vtkm::worklet::internal;
// This is the type for the input domain
using InputDomainType = typename Invocation::InputDomainType;
using SchedulingRangeType = typename WorkletType::VisitTopologyType;
@ -59,7 +61,7 @@ public:
// Now that we have the input domain, we can extract the range of the
// scheduling and call BadicInvoke.
this->BasicInvoke(invocation, internal::scheduling_range(inputDomain, SchedulingRangeType{}));
this->BasicInvoke(invocation, SchedulingRange(inputDomain, SchedulingRangeType{}));
}
};
}

@ -45,6 +45,8 @@ public:
template <typename Invocation>
void DoInvoke(Invocation& invocation) const
{
using namespace vtkm::worklet::internal;
// This is the type for the input domain
using InputDomainType = typename Invocation::InputDomainType;
@ -56,7 +58,7 @@ public:
// We can pull the input domain parameter (the data specifying the input
// domain) from the invocation object.
const InputDomainType& inputDomain = invocation.GetInputDomain();
auto inputRange = internal::scheduling_range(inputDomain, vtkm::TopologyElementTagPoint{});
auto inputRange = SchedulingRange(inputDomain, vtkm::TopologyElementTagPoint{});
// This is pretty straightforward dispatch. Once we know the number
// of invocations, the superclass can take care of the rest.

@ -44,6 +44,8 @@ public:
template <typename Invocation>
void DoInvoke(Invocation& invocation) const
{
using namespace vtkm::worklet::internal;
// This is the type for the input domain
using InputDomainType = typename Invocation::InputDomainType;
@ -60,7 +62,7 @@ public:
// Now that we have the input domain, we can extract the range of the
// scheduling and call BasicInvoke.
this->BasicInvoke(invocation, internal::scheduling_range(inputDomain));
this->BasicInvoke(invocation, SchedulingRange(inputDomain));
}
};
}

@ -214,6 +214,8 @@ public:
template <typename Invocation>
VTKM_CONT void DoInvoke(Invocation& invocation) const
{
using namespace vtkm::worklet::internal;
// This is the type for the input domain
using InputDomainType = typename Invocation::InputDomainType;
@ -225,15 +227,15 @@ public:
// an VariantArrayHandle that gets cast to one). The size of the domain
// (number of threads/worklet instances) is equal to the size of the
// array.
vtkm::Id fullSize = internal::scheduling_range(inputDomain);
vtkm::Id fullSize = SchedulingRange(inputDomain);
vtkm::Id blockSize = fullSize / NumberOfBlocks;
if (fullSize % NumberOfBlocks != 0)
blockSize += 1;
using TransformFunctorType =
detail::DispatcherStreamingMapFieldTransformFunctor<typename Invocation::ControlInterface>;
using TransferFunctorType =
detail::DispatcherStreamingMapFieldTransferFunctor<typename Invocation::ControlInterface>;
using TransformFunctorType = vtkm::worklet::detail::DispatcherStreamingMapFieldTransformFunctor<
typename Invocation::ControlInterface>;
using TransferFunctorType = vtkm::worklet::detail::DispatcherStreamingMapFieldTransferFunctor<
typename Invocation::ControlInterface>;
for (vtkm::Id block = 0; block < NumberOfBlocks; block++)
{

@ -176,6 +176,20 @@ private:
template <typename T>
VTKM_CONT Keys<T>::Keys() = default;
template <typename KeyType>
inline auto SchedulingRange(const vtkm::worklet::Keys<KeyType>& inputDomain)
-> decltype(inputDomain.GetInputRange())
{
return inputDomain.GetInputRange();
}
template <typename KeyType>
inline auto SchedulingRange(const vtkm::worklet::Keys<KeyType>* const inputDomain)
-> decltype(inputDomain->GetInputRange())
{
return inputDomain->GetInputRange();
}
}
} // namespace vtkm::worklet

@ -48,47 +48,31 @@ namespace vtkm
{
namespace worklet
{
template <typename T>
class Keys;
namespace internal
{
template <typename Domain>
inline auto scheduling_range(const Domain& inputDomain) -> decltype(inputDomain.GetNumberOfValues())
inline auto SchedulingRange(const Domain& inputDomain) -> decltype(inputDomain.GetNumberOfValues())
{
return inputDomain.GetNumberOfValues();
}
template <typename KeyType>
inline auto scheduling_range(const vtkm::worklet::Keys<KeyType>& inputDomain)
-> decltype(inputDomain.GetInputRange())
{
return inputDomain.GetInputRange();
}
template <typename Domain>
inline auto scheduling_range(const Domain* const inputDomain)
inline auto SchedulingRange(const Domain* const inputDomain)
-> decltype(inputDomain->GetNumberOfValues())
{
return inputDomain->GetNumberOfValues();
}
template <typename KeyType>
inline auto scheduling_range(const vtkm::worklet::Keys<KeyType>* const inputDomain)
-> decltype(inputDomain->GetInputRange())
{
return inputDomain->GetInputRange();
}
template <typename Domain, typename SchedulingRangeType>
inline auto scheduling_range(const Domain& inputDomain, SchedulingRangeType type)
inline auto SchedulingRange(const Domain& inputDomain, SchedulingRangeType type)
-> decltype(inputDomain.GetSchedulingRange(type))
{
return inputDomain.GetSchedulingRange(type);
}
template <typename Domain, typename SchedulingRangeType>
inline auto scheduling_range(const Domain* const inputDomain, SchedulingRangeType type)
inline auto SchedulingRange(const Domain* const inputDomain, SchedulingRangeType type)
-> decltype(inputDomain->GetSchedulingRange(type))
{
return inputDomain->GetSchedulingRange(type);

@ -284,6 +284,18 @@ public:
}
};
template <typename T>
inline vtkm::Id SchedulingRange(const std::vector<T>& inputDomain)
{
return static_cast<vtkm::Id>(inputDomain.size());
}
template <typename T>
inline vtkm::Id SchedulingRange(const std::vector<T>* const inputDomain)
{
return static_cast<vtkm::Id>(inputDomain->size());
}
template <typename WorkletType>
class TestDispatcher : public vtkm::worklet::internal::DispatcherBase<TestDispatcher<WorkletType>,
WorkletType,
@ -295,19 +307,37 @@ class TestDispatcher : public vtkm::worklet::internal::DispatcherBase<TestDispat
using ScatterType = typename Superclass::ScatterType;
public:
VTKM_CONT
TestDispatcher(const WorkletType& worklet = WorkletType(),
const ScatterType& scatter = ScatterType())
: Superclass(worklet, scatter)
template <typename... T>
VTKM_CONT TestDispatcher(T&&... args)
: Superclass(std::forward<T>(args)...)
{
}
VTKM_CONT
template <typename Invocation>
void DoInvoke(Invocation&& invocation) const
void DoInvoke(Invocation& invocation) const
{
std::cout << "In TestDispatcher::DoInvoke()" << std::endl;
this->BasicInvoke(invocation, ARRAY_SIZE);
using namespace vtkm::worklet::internal;
// This is the type for the input domain
using InputDomainType = typename Invocation::InputDomainType;
// We can pull the input domain parameter (the data specifying the input
// domain) from the invocation object.
const InputDomainType& inputDomain = invocation.GetInputDomain();
// For a DispatcherMapField, the inputDomain must be an ArrayHandle (or
// an VariantArrayHandle that gets cast to one). The size of the domain
// (number of threads/worklet instances) is equal to the size of the
// array.
//verify the overloads for SchedulingRange work
auto numInstances = SchedulingRange(inputDomain);
// A MapField is a pretty straightforward dispatch. Once we know the number
// of invocations, the superclass can take care of the rest.
this->BasicInvoke(invocation, numInstances);
}
private: