Working streaming dispatcher

This commit is contained in:
Christopher Sewell 2016-08-03 18:48:31 -06:00
parent ced9fd32db
commit 504e6f55df
6 changed files with 73 additions and 25 deletions

@ -129,10 +129,6 @@ struct GetTypeInParentheses<void(T)>
} // namespace detail
//VTKM_CONT_EXPORT \
//virtual ~classname() { } \
// \
// Implementation for VTKM_ARRAY_HANDLE_SUBCLASS macros
#define VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, fullclasstype, superclass, typename__) \
typedef typename__ vtkm::cont::detail::GetTypeInParentheses<void fullclasstype>::type Thisclass;\
@ -150,6 +146,9 @@ struct GetTypeInParentheses<void(T)>
classname(const vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, typename__ Superclass::StorageTag> &src) : Superclass(src) { } \
\
VTKM_CONT_EXPORT \
virtual ~classname() { } \
\
VTKM_CONT_EXPORT \
Thisclass &operator=(const Thisclass &src) \
{ \
this->Superclass::operator=(src); \
@ -407,7 +406,7 @@ public:
/// array storage is read-only).
///
VTKM_CONT_EXPORT
void Allocate(vtkm::Id numberOfValues) const
void Allocate(vtkm::Id numberOfValues)
{
this->ReleaseResourcesExecutionInternal();
this->Internals->ControlArray.Allocate(numberOfValues);
@ -464,7 +463,7 @@ public:
/// Releases all resources in both the control and execution environments.
///
VTKM_CONT_EXPORT void ReleaseResources() const
VTKM_CONT_EXPORT void ReleaseResources()
{
this->ReleaseResourcesExecutionInternal();
@ -685,7 +684,7 @@ public:
}
VTKM_CONT_EXPORT
void ReleaseResourcesExecutionInternal() const
void ReleaseResourcesExecutionInternal()
{
if (this->Internals->ExecutionArrayValid)
{

@ -149,7 +149,7 @@ public:
}
VTKM_CONT_EXPORT
void AllocateFullArray(vtkm::Id numberOfValues) const {
void AllocateFullArray(vtkm::Id numberOfValues) {
VTKM_ASSERT(this->Valid);
this->InputArray.Allocate(numberOfValues);
}
@ -201,12 +201,6 @@ public:
typename ArrayHandleInputType::ValueType,
StorageTagStreaming<ArrayHandleInputType> >));
~ArrayHandleStreaming() {
typedef typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter> DeviceAlgorithms;
DeviceAlgorithms::Synchronize();
this->SyncControlArray();
}
private:
typedef vtkm::cont::internal::Storage<ValueType,StorageTag> StorageType;
@ -217,13 +211,14 @@ public:
const vtkm::Id curBlockSize)
: Superclass(StorageType(inputArray, blockIndex, blockSize, curBlockSize))
{
std::cout << "Stream constructor" << std::endl;
this->GetPortalConstControl().SetBlockIndex(blockIndex);
this->GetPortalConstControl().SetBlockSize(blockSize);
this->GetPortalConstControl().SetCurBlockSize(curBlockSize);
}
VTKM_CONT_EXPORT
void AllocateFullArray(vtkm::Id numberOfValues) const {
void AllocateFullArray(vtkm::Id numberOfValues) {
this->ReleaseResourcesExecutionInternal();
this->Internals->ControlArray.AllocateFullArray(numberOfValues);
this->Internals->ControlArrayValid = true;

@ -156,8 +156,8 @@ public:
VTKM_CONT_EXPORT
PortalType PrepareForOutput(vtkm::Id numberOfValues)
{
if (this->GetNumberOfValues() == 0)
{
//if (this->GetNumberOfValues() == 0)
//{
std::cout << "Preparing for output" << std::endl;
if (numberOfValues > this->GetNumberOfValues())
{
@ -172,9 +172,10 @@ std::cout << "Preparing for output" << std::endl;
}
catch (std::bad_alloc error)
{
std::cout << "Caught error" << std::endl;
throw vtkm::cont::ErrorControlBadAllocation(error.what());
}
}
//}
return PortalType(this->Array.data(),
this->Array.data() + static_cast<difference_type>(this->Array.size()));
}
@ -261,6 +262,7 @@ private:
VTKM_CONT_EXPORT
void CopyToExecution()
{
std::cout << "Copy to execution" << std::endl;
try
{
this->Array.assign(

@ -29,7 +29,6 @@ namespace worklet {
namespace detail {
template<typename ControlInterface, typename Device>
struct DispatcherStreamingMapFieldTransformFunctor
{
@ -107,6 +106,7 @@ struct DispatcherStreamingMapFieldTransformFunctor
};
template<typename ControlInterface, typename Device>
struct DispatcherStreamingMapFieldTransferFunctor
{
@ -168,6 +168,8 @@ struct DispatcherStreamingMapFieldTransferFunctor
operator()(const ParameterType &invokeData,
vtkm::internal::IndexTag<Index>) const
{
std::cout << "Calling transfer" << std::endl;
invokeData.SyncControlArray();
return TransformImpl<ParameterType,
vtkm::cont::internal::ArrayHandleCheck<ParameterType>::type::value>()(invokeData);
}
@ -214,6 +216,21 @@ public:
NumberOfBlocks = numberOfBlocks;
}
template<typename Invocation, typename DeviceAdapter>
VTKM_CONT_EXPORT
void ABasicInvoke(const Invocation &invocation,
vtkm::Id numInstances,
DeviceAdapter device) const
{
this->BasicInvoke(
/*invocation.ChangeParameters(
invocation.Parameters.StaticTransformCont(
TransformFunctorType(block, blockSize, numberOfInstances, fullSize))),*/
invocation,
numInstances,
Device());
}
template<typename Invocation>
VTKM_CONT_EXPORT
void DoInvoke(const Invocation &invocation) const
@ -250,14 +267,43 @@ public:
invocation.Parameters.StaticTransformCont(
TransformFunctorType(block, blockSize, numberOfInstances, fullSize))));
*/
this->BasicInvoke(
typedef typename Invocation::ParameterInterface ParameterInterfaceType;
typedef typename ParameterInterfaceType::StaticTransformType<TransformFunctorType>::type ReportedType;
ReportedType newParams = invocation.Parameters.StaticTransformCont(
TransformFunctorType(block, blockSize, numberOfInstances, fullSize));
typedef typename Invocation::ChangeParametersType<ReportedType>::type ChangedType;
ChangedType changedParams = invocation.ChangeParameters(newParams);
std::cout << "Before invoke" << std::endl;
this->BasicInvoke(changedParams, numberOfInstances, Device());
std::cout << "After invoke" << std::endl;
//Invocation::ChangeParametersType<>::type invocation.ChangeParameters(
// invocation.Parameters.StaticTransformCont(
// TransformFunctorType(block, blockSize, numberOfInstances, fullSize)));
/* this->BasicInvoke(
invocation.ChangeParameters(
invocation.Parameters.StaticTransformCont(
TransformFunctorType(block, blockSize, numberOfInstances, fullSize))),
numberOfInstances,
Device());
*/
invocation.Parameters.StaticTransformCont(TransferFunctorType());
typedef typename ChangedType::ParameterInterface ParameterInterfaceType2;
const ParameterInterfaceType2 &parameters2 = changedParams.Parameters;
typedef typename ParameterInterfaceType2::template StaticTransformType<
TransferFunctorType>::type ExecObjectParameters2;
ExecObjectParameters2 execObjectParameters =
parameters2.StaticTransformCont(TransferFunctorType());
//changedParams.StaticTransformCont(TransferFunctorType());
//invocation.Parameters.StaticTransformCont(TransferFunctorType());
}
}

@ -468,11 +468,13 @@ protected:
vtkm::Id3 dimensions,
DeviceAdapter device) const
{
std::cout << "A0" << std::endl;
this->InvokeTransportParameters(
invocation,
dimensions,
this->Worklet.GetScatter().GetOutputRange(dimensions),
device);
std::cout << "A1" << std::endl;
}
WorkletType Worklet;
@ -498,17 +500,18 @@ private:
// control environment) in a FunctionInterface. Specifically, we use a
// static transform of the FunctionInterface to call the transport on each
// argument and return the corresponding execution environment object.
std::cout << "C0" << std::endl;
typedef typename Invocation::ParameterInterface ParameterInterfaceType;
const ParameterInterfaceType &parameters = invocation.Parameters;
std::cout << "C1" << std::endl;
typedef detail::DispatcherBaseTransportFunctor<
typename Invocation::ControlInterface, DeviceAdapter> TransportFunctorType;
typedef typename ParameterInterfaceType::template StaticTransformType<
TransportFunctorType>::type ExecObjectParameters;
std::cout << "C2" << std::endl;
ExecObjectParameters execObjectParameters =
parameters.StaticTransformCont(TransportFunctorType(outputRange));
std::cout << "C3" << std::endl;
// Get the arrays used for scattering input to output.
typename WorkletType::ScatterType::OutputToInputMapType outputToInputMap =
this->Worklet.GetScatter().GetOutputToInputMap(inputRange);
@ -517,6 +520,7 @@ private:
// Replace the parameters in the invocation with the execution object and
// pass to next step of Invoke. Also add the scatter information.
std::cout << "B0" << std::endl;
this->InvokeSchedule(
invocation
.ChangeParameters(execObjectParameters)
@ -524,6 +528,7 @@ private:
.ChangeVisitArray(visitArray.PrepareForInput(device)),
outputRange,
device);
std::cout << "B1" << std::endl;
}
template<typename Invocation, typename RangeType, typename DeviceAdapter>

@ -20,6 +20,7 @@
#include <vtkm/cont/ArrayHandleStreaming.h>
#include <vtkm/worklet/DispatcherStreamingMapField.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/cont/testing/Testing.h>
@ -48,7 +49,7 @@ void TestStreamingSine()
{
std::cout << "Testing Streaming Sine" << std::endl;
const int N = 25; const int NBlocks = 1;
const int N = 14; const int NBlocks = 4;
vtkm::cont::ArrayHandle<vtkm::Float32> input, output;
std::vector<float> data(N), test(N);
for (unsigned int i=0; i<N; i++)