updating basic transport example to use new execution object creation
updating the transport execution object test to use the factory to create an execution object based on the templated device and chaged the trasport tag to call the prepareForExectuion(Device) method to create the execution object.
This commit is contained in:
parent
7e5a55881b
commit
8fb4fc6760
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include <vtkm/cont/ExecutionObjectFactoryBase.h>
|
#include <vtkm/cont/ExecutionObjectFactoryBase.h>
|
||||||
|
|
||||||
|
#include <vtkm/exec/ExecutionObjectBase.h>
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
namespace cont
|
namespace cont
|
||||||
@ -53,13 +55,13 @@ struct Transport<vtkm::cont::arg::TransportTagExecObject, ContObjectType, Device
|
|||||||
(std::is_base_of<vtkm::cont::ExecutionObjectFactoryBase, ContObjectType>::value),
|
(std::is_base_of<vtkm::cont::ExecutionObjectFactoryBase, ContObjectType>::value),
|
||||||
"All execution objects are expected to inherit from vtkm::exec::ExecutionObjectBase");
|
"All execution objects are expected to inherit from vtkm::exec::ExecutionObjectBase");
|
||||||
|
|
||||||
using ExecObjectType = ContObjectType;
|
// using ExecObjectType = typename ContObjectType::template ExecObjectType<Device>;
|
||||||
|
using ExecObjectType = typename ContObjectType::template ExecObjectType<Device>;
|
||||||
template <typename InputDomainType>
|
template <typename InputDomainType>
|
||||||
VTKM_CONT ExecObjectType
|
VTKM_CONT ExecObjectType
|
||||||
operator()(const ContObjectType& object, const InputDomainType&, vtkm::Id, vtkm::Id) const
|
operator()(const ContObjectType& object, const InputDomainType&, vtkm::Id, vtkm::Id) const
|
||||||
{
|
{
|
||||||
return object;
|
return object.PrepareForExecution(Device());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,12 @@
|
|||||||
|
|
||||||
#include <vtkm/cont/arg/TransportTagExecObject.h>
|
#include <vtkm/cont/arg/TransportTagExecObject.h>
|
||||||
|
|
||||||
#include <vtkm/cont/ExecutionObjectFactoryBase.h>
|
|
||||||
#include <vtkm/exec/FunctorBase.h>
|
#include <vtkm/exec/FunctorBase.h>
|
||||||
|
|
||||||
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/ExecutionObjectFactoryBase.h>
|
||||||
|
|
||||||
#include <vtkm/cont/testing/Testing.h>
|
#include <vtkm/cont/testing/Testing.h>
|
||||||
|
|
||||||
#define EXPECTED_NUMBER 42
|
#define EXPECTED_NUMBER 42
|
||||||
@ -32,14 +33,31 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
struct TestExecutionObject : public vtkm::cont::ExecutionObjectFactoryBase
|
template <typename Device>
|
||||||
|
struct ExecutionObject
|
||||||
{
|
{
|
||||||
vtkm::Int32 Number;
|
vtkm::Int32 Number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TestExecutionObject : public vtkm::cont::ExecutionObjectFactoryBase
|
||||||
|
{
|
||||||
|
vtkm::Int32 Number;
|
||||||
|
|
||||||
|
template <typename Device>
|
||||||
|
using ExecObjectType = ExecutionObject<Device>;
|
||||||
|
|
||||||
|
template <typename Device>
|
||||||
|
VTKM_CONT ExecObjectType<Device> PrepareForExecution(Device) const
|
||||||
|
{
|
||||||
|
ExecObjectType<Device> object;
|
||||||
|
object.Number = this->Number;
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template <typename Device>
|
||||||
struct TestKernel : public vtkm::exec::FunctorBase
|
struct TestKernel : public vtkm::exec::FunctorBase
|
||||||
{
|
{
|
||||||
TestExecutionObject Object;
|
ExecutionObject<Device> Object;
|
||||||
|
|
||||||
VTKM_EXEC
|
VTKM_EXEC
|
||||||
void operator()(vtkm::Id) const
|
void operator()(vtkm::Id) const
|
||||||
@ -60,7 +78,7 @@ void TryExecObjectTransport(Device)
|
|||||||
vtkm::cont::arg::Transport<vtkm::cont::arg::TransportTagExecObject, TestExecutionObject, Device>
|
vtkm::cont::arg::Transport<vtkm::cont::arg::TransportTagExecObject, TestExecutionObject, Device>
|
||||||
transport;
|
transport;
|
||||||
|
|
||||||
TestKernel kernel;
|
TestKernel<Device> kernel;
|
||||||
kernel.Object = transport(contObject, nullptr, 1, 1);
|
kernel.Object = transport(contObject, nullptr, 1, 1);
|
||||||
|
|
||||||
vtkm::cont::DeviceAdapterAlgorithm<Device>::Schedule(kernel, 1);
|
vtkm::cont::DeviceAdapterAlgorithm<Device>::Schedule(kernel, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user