Commit c3f2c346 authored by Robert Maynard's avatar Robert Maynard
Browse files

Merge branch '3dScheduling' into 'master'

Allow invocation of worklets to use vtkm::Id3

@kmorel, @jsmeredith, @dpugmire

This allow invocation of worklets whose input domain is regular connectivity to be scheduled use the ```DeviceAdapters Schedule(vtkm::Id3)``` method.

This is just the first step in having efficient 3d scheduling. The next step is to upgrade all the ```vtkm::exec::arg``` to support Id3 index's for the load and store methods.

Note:
I would love somebody to suggest a better name for ```GetSchedulingDimensions```

See merge request !53
parents 14424000 36c27400
......@@ -31,6 +31,24 @@
namespace vtkm {
template<vtkm::cont::TopologyType From, vtkm::cont::TopologyType To, vtkm::IdComponent Dimension>
struct SchedulingDimension
{
typedef vtkm::Id ValueType;
};
template<vtkm::cont::TopologyType From, vtkm::cont::TopologyType To>
struct SchedulingDimension<From,To, 2>
{
typedef vtkm::Id2 ValueType;
};
template<vtkm::cont::TopologyType From, vtkm::cont::TopologyType To>
struct SchedulingDimension<From,To, 3>
{
typedef vtkm::Id3 ValueType;
};
template<vtkm::cont::TopologyType From, vtkm::cont::TopologyType To, vtkm::IdComponent Dimension>
struct IndexLookupHelper
{
......@@ -71,6 +89,9 @@ template<vtkm::cont::TopologyType FromTopology, vtkm::cont::TopologyType ToTopoo
class RegularConnectivity
{
public:
typedef typename SchedulingDimension< FromTopology,
ToTopoogy,
Dimension >::ValueType SchedulingDimension;
RegularConnectivity():
rs()
{
......@@ -87,6 +108,8 @@ public:
{
}
VTKM_EXEC_CONT_EXPORT
SchedulingDimension GetSchedulingDimensions() const {return rs.GetSchedulingDimensions();}
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetNumberOfElements() const {return rs.GetNumberOfElements();}
......
......@@ -42,6 +42,9 @@ public:
VTKM_EXEC_CONT_EXPORT
vtkm::Vec<vtkm::Id,1> GetNodeDimensions() const { return nodeDim; }
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetSchedulingDimensions() const {return GetNumberOfCells();}
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetNumberOfNodes() const {return nodeDim[0];}
VTKM_EXEC_CONT_EXPORT
......@@ -103,6 +106,11 @@ public:
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetNumberOfNodes() const {return vtkm::internal::VecProduct<2>()(nodeDims);}
//returns an id2 to signal what kind of scheduling to use
VTKM_EXEC_CONT_EXPORT
vtkm::Id2 GetSchedulingDimensions() const {return cellDims;}
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetNumberOfElements() const {return GetNumberOfCells();}
VTKM_EXEC_CONT_EXPORT
......@@ -189,7 +197,11 @@ public:
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetNumberOfNodes() const {return vtkm::internal::VecProduct<3>()(nodeDims);}
//returns an id3 to signal what kind of scheduling to use
VTKM_EXEC_CONT_EXPORT
vtkm::Id3 GetSchedulingDimensions() const { return cellDims;}
vtkm::Id GetNumberOfElements() const {return GetNumberOfCells();}
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetNumberOfCells() const {return vtkm::internal::VecProduct<3>()(cellDims);}
......
......@@ -45,7 +45,13 @@ public:
}
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfElements()
vtkm::Id GetSchedulingDimensions() const
{
return Shapes.GetNumberOfValues();
}
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfElements() const
{
return Shapes.GetNumberOfValues();
}
......
......@@ -95,8 +95,8 @@ inline
void compute_block_size(dim3 rangeMax, dim3 blockSize3d, dim3& gridSize3d)
{
gridSize3d.x = (rangeMax.x % blockSize3d.x != 0) ? (rangeMax.x / blockSize3d.x + 1) : (rangeMax.x / blockSize3d.x);
gridSize3d.y = (rangeMax.y % blockSize3d.y != 1) ? (rangeMax.y / blockSize3d.y + 1) : (rangeMax.y / blockSize3d.y);
gridSize3d.z = (rangeMax.z % blockSize3d.z != 2) ? (rangeMax.z / blockSize3d.z + 1) : (rangeMax.z / blockSize3d.z);
gridSize3d.y = (rangeMax.y % blockSize3d.y != 0) ? (rangeMax.y / blockSize3d.y + 1) : (rangeMax.y / blockSize3d.y);
gridSize3d.z = (rangeMax.z % blockSize3d.z != 0) ? (rangeMax.z / blockSize3d.z + 1) : (rangeMax.z / blockSize3d.z);
}
class PerfRecord
......
......@@ -20,7 +20,10 @@
#ifndef vtk_m_worklet_Dispatcher_MapTopology_h
#define vtk_m_worklet_Dispatcher_MapTopology_h
#include <vtkm/RegularConnectivity.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/ExplicitConnectivity.h>
#include <vtkm/worklet/WorkletMapTopology.h>
#include <vtkm/worklet/internal/DispatcherBase.h>
......@@ -75,16 +78,53 @@ public:
InputDomainType inputDomain =
invocation.Parameters.template GetParameter<InputDomainIndex>();
// For a DispatcherMapTopology, the inputDomain must be an ArrayHandle (or
// a DynamicArrayHandle that gets cast to one). The size of the domain
// (number of threads/worklet instances) is equal to the size of the
// array.
//we need to now template based on the input domain type. If the input
//domain type is a regular or explicit grid we call GetSchedulingDimensions.
//but in theory your input domain could be a permutation array
this->InvokeBasedOnDomainType(invocation,inputDomain);
}
///\todo: GetNumberOfCells
vtkm::Id numInstances = inputDomain.GetNumberOfElements();
template<typename Invocation, typename InputDomainType>
VTKM_CONT_EXPORT
void InvokeBasedOnDomainType(const Invocation &invocation,
const InputDomainType& domain) const
{
//presume that the input domain isn't a grid, so call GetNumberOfValues()
//this code path is currently not exercised as the InputDomain currently
//is required to be Explicit or Regular Connectivity. In the future if
//we ever allow the InputDomain and the TopologyDomain to differ, this
//invocation will be used
this->BasicInvoke(invocation, domain.GetNumberOfValues());
}
template<typename Invocation,
typename T,
typename U,
typename V>
VTKM_CONT_EXPORT
void InvokeBasedOnDomainType(const Invocation &invocation,
const vtkm::cont::ExplicitConnectivity<T,U,V>& domain) const
{
// For a DispatcherMapTopology, when the inputDomain is some for of
// explicit connectivity we call GetSchedulingDimensions which will return
// a linear value representing the number of cells to schedule
this->BasicInvoke(invocation, domain.GetSchedulingDimensions());
}
template<typename Invocation,
vtkm::cont::TopologyType From,
vtkm::cont::TopologyType To,
vtkm::IdComponent Domain>
VTKM_CONT_EXPORT
void InvokeBasedOnDomainType(const Invocation &invocation,
const vtkm::RegularConnectivity<From,To,Domain>& domain) const
{
///\todo:
this->BasicInvoke(invocation, numInstances);
// For a DispatcherMapTopology, the inputDomain is some for of connectivity
// so the GetSchedulingDimensions can return a vtkm::Id for linear scheduling,
// or a vtkm::Id2 or vtkm::Id3 for 3d block scheduling
this->BasicInvoke(invocation, domain.GetSchedulingDimensions());
}
};
......
......@@ -295,6 +295,15 @@ protected:
this->InvokeTransportParameters(invocation, numInstances);
}
template<typename Invocation>
VTKM_CONT_EXPORT
void BasicInvoke(const Invocation &invocation, vtkm::Id2 dimensions) const
{
vtkm::Id3 dim3d(dimensions[0], dimensions[1], 1);
this->InvokeTransportParameters(invocation, dim3d);
}
template<typename Invocation>
VTKM_CONT_EXPORT
void BasicInvoke(const Invocation &invocation, vtkm::Id3 dimensions) const
......
......@@ -19,9 +19,9 @@
##============================================================================
set(unit_tests
UnitTestCellAverage.cxx
UnitTestPointElevation.cxx
UnitTestWorkletMapField.cxx
# UnitTestCellAverage.cxx
# UnitTestPointElevation.cxx
# UnitTestWorkletMapField.cxx
UnitTestWorkletMapFieldMultiParam.cxx
UnitTestWorkletMapTopologyExplicit.cxx
UnitTestWorkletMapTopologyRegular.cxx
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment