Commit c83b585b authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Fix ExecObject tag in WorkletBase

The ExecObject tag for the ControlSignature was not declared right so
would cause a compile error if it was ever used. Clearly this was not
being tested properly, so the dispatcher base unit test now passes an
ExecObject parameter.
parent 4afb6fe5
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <vtkm/exec/arg/FetchTagExecObject.h> #include <vtkm/exec/arg/FetchTagExecObject.h>
#include <vtkm/exec/arg/WorkIndex.h> #include <vtkm/exec/arg/WorkIndex.h>
#include <vtkm/cont/arg/ControlSignatureTagBase.h>
#include <vtkm/cont/arg/TransportTagExecObject.h> #include <vtkm/cont/arg/TransportTagExecObject.h>
#include <vtkm/cont/arg/TypeCheckTagExecObject.h> #include <vtkm/cont/arg/TypeCheckTagExecObject.h>
...@@ -59,7 +60,7 @@ public: ...@@ -59,7 +60,7 @@ public:
typedef vtkm::exec::arg::WorkIndex WorkIndex; typedef vtkm::exec::arg::WorkIndex WorkIndex;
/// \c ControlSignature tag for execution object inputs. /// \c ControlSignature tag for execution object inputs.
struct ExecObject { struct ExecObject : vtkm::cont::arg::ControlSignatureTagBase {
typedef vtkm::cont::arg::TypeCheckTagExecObject TypeCheckTag; typedef vtkm::cont::arg::TypeCheckTagExecObject TypeCheckTag;
typedef vtkm::cont::arg::TransportTagExecObject TransportTag; typedef vtkm::cont::arg::TransportTagExecObject TransportTag;
typedef vtkm::exec::arg::FetchTagExecObject FetchTag; typedef vtkm::exec::arg::FetchTagExecObject FetchTag;
......
...@@ -127,6 +127,13 @@ struct Fetch<TestFetchTagOutput, vtkm::exec::arg::AspectTagDefault, Invocation, ...@@ -127,6 +127,13 @@ struct Fetch<TestFetchTagOutput, vtkm::exec::arg::AspectTagDefault, Invocation,
namespace { namespace {
struct TestExecObjectType : vtkm::exec::ExecutionObjectBase
{
vtkm::Id Value;
};
static const vtkm::Id EXPECTED_EXEC_OBJECT_VALUE = 123;
class TestWorkletBase : public vtkm::worklet::internal::WorkletBase class TestWorkletBase : public vtkm::worklet::internal::WorkletBase
{ {
public: public:
...@@ -145,14 +152,18 @@ public: ...@@ -145,14 +152,18 @@ public:
class TestWorklet : public TestWorkletBase class TestWorklet : public TestWorkletBase
{ {
public: public:
typedef void ControlSignature(TestIn, TestOut); typedef void ControlSignature(TestIn, ExecObject, TestOut);
typedef _2 ExecutionSignature(_1, WorkIndex); typedef _3 ExecutionSignature(_1, _2, WorkIndex);
VTKM_EXEC_EXPORT VTKM_EXEC_EXPORT
vtkm::Id operator()(vtkm::Id value, vtkm::Id index) const vtkm::Id operator()(vtkm::Id value,
TestExecObjectType execObject,
vtkm::Id index) const
{ {
VTKM_TEST_ASSERT(value == TestValue(index, vtkm::Id()), VTKM_TEST_ASSERT(value == TestValue(index, vtkm::Id()),
"Got bad value in worklet."); "Got bad value in worklet.");
VTKM_TEST_ASSERT(execObject.Value == EXPECTED_EXEC_OBJECT_VALUE,
"Got bad exec object in worklet.");
return TestValue(index, vtkm::Id()) + 1000; return TestValue(index, vtkm::Id()) + 1000;
} }
}; };
...@@ -162,11 +173,11 @@ public: ...@@ -162,11 +173,11 @@ public:
class TestErrorWorklet : public TestWorkletBase class TestErrorWorklet : public TestWorkletBase
{ {
public: public:
typedef void ControlSignature(TestIn, TestOut); typedef void ControlSignature(TestIn, ExecObject, TestOut);
typedef void ExecutionSignature(_1, _2); typedef void ExecutionSignature(_1, _2, _3);
VTKM_EXEC_EXPORT VTKM_EXEC_EXPORT
void operator()(vtkm::Id, vtkm::Id) const void operator()(vtkm::Id, TestExecObjectType, vtkm::Id) const
{ {
this->RaiseError(ERROR_MESSAGE); this->RaiseError(ERROR_MESSAGE);
} }
...@@ -185,7 +196,7 @@ class TestDispatcher : ...@@ -185,7 +196,7 @@ class TestDispatcher :
WorkletType, WorkletType,
TestWorkletBase, TestWorkletBase,
Device> Superclass; Device> Superclass;
typedef vtkm::internal::FunctionInterface<void(vtkm::Id *, vtkm::Id *)> typedef vtkm::internal::FunctionInterface<void(vtkm::Id *, TestExecObjectType, vtkm::Id *)>
ParameterInterface; ParameterInterface;
typedef vtkm::internal::Invocation< typedef vtkm::internal::Invocation<
ParameterInterface, ParameterInterface,
...@@ -214,6 +225,8 @@ void TestBasicInvoke() ...@@ -214,6 +225,8 @@ void TestBasicInvoke()
std::cout << " Set up data." << std::endl; std::cout << " Set up data." << std::endl;
vtkm::Id inputArray[ARRAY_SIZE]; vtkm::Id inputArray[ARRAY_SIZE];
vtkm::Id outputArray[ARRAY_SIZE]; vtkm::Id outputArray[ARRAY_SIZE];
TestExecObjectType execObject;
execObject.Value = EXPECTED_EXEC_OBJECT_VALUE;
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++) for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{ {
...@@ -223,7 +236,7 @@ void TestBasicInvoke() ...@@ -223,7 +236,7 @@ void TestBasicInvoke()
std::cout << " Create and run dispatcher." << std::endl; std::cout << " Create and run dispatcher." << std::endl;
TestDispatcher<TestWorklet> dispatcher; TestDispatcher<TestWorklet> dispatcher;
dispatcher.Invoke(inputArray, outputArray); dispatcher.Invoke(inputArray, execObject, outputArray);
std::cout << " Check output of invoke." << std::endl; std::cout << " Check output of invoke." << std::endl;
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++) for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
...@@ -239,6 +252,8 @@ void TestInvokeWithError() ...@@ -239,6 +252,8 @@ void TestInvokeWithError()
std::cout << " Set up data." << std::endl; std::cout << " Set up data." << std::endl;
vtkm::Id inputArray[ARRAY_SIZE]; vtkm::Id inputArray[ARRAY_SIZE];
vtkm::Id outputArray[ARRAY_SIZE]; vtkm::Id outputArray[ARRAY_SIZE];
TestExecObjectType execObject;
execObject.Value = EXPECTED_EXEC_OBJECT_VALUE;
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++) for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{ {
...@@ -250,7 +265,7 @@ void TestInvokeWithError() ...@@ -250,7 +265,7 @@ void TestInvokeWithError()
{ {
std::cout << " Create and run dispatcher that raises error." << std::endl; std::cout << " Create and run dispatcher that raises error." << std::endl;
TestDispatcher<TestErrorWorklet> dispatcher; TestDispatcher<TestErrorWorklet> dispatcher;
dispatcher.Invoke(inputArray, outputArray); dispatcher.Invoke(inputArray, execObject, outputArray);
VTKM_TEST_FAIL("Exception not thrown."); VTKM_TEST_FAIL("Exception not thrown.");
} }
catch (vtkm::cont::ErrorExecution error) catch (vtkm::cont::ErrorExecution error)
...@@ -266,12 +281,13 @@ void TestInvokeWithBadType() ...@@ -266,12 +281,13 @@ void TestInvokeWithBadType()
std::cout << "Test invoke with bad type" << std::endl; std::cout << "Test invoke with bad type" << std::endl;
vtkm::Id array[ARRAY_SIZE]; vtkm::Id array[ARRAY_SIZE];
TestExecObjectType execObject;
TestDispatcher<TestWorklet> dispatcher; TestDispatcher<TestWorklet> dispatcher;
try try
{ {
std::cout << " First argument bad." << std::endl; std::cout << " First argument bad." << std::endl;
dispatcher.Invoke(NULL, array); dispatcher.Invoke(NULL, execObject, array);
} }
catch (vtkm::cont::ErrorControlBadType error) catch (vtkm::cont::ErrorControlBadType error)
{ {
...@@ -284,7 +300,7 @@ void TestInvokeWithBadType() ...@@ -284,7 +300,7 @@ void TestInvokeWithBadType()
try try
{ {
std::cout << " Second argument bad." << std::endl; std::cout << " Second argument bad." << std::endl;
dispatcher.Invoke(array, NULL); dispatcher.Invoke(array, NULL, array);
} }
catch (vtkm::cont::ErrorControlBadType error) catch (vtkm::cont::ErrorControlBadType error)
{ {
...@@ -293,6 +309,19 @@ void TestInvokeWithBadType() ...@@ -293,6 +309,19 @@ void TestInvokeWithBadType()
VTKM_TEST_ASSERT(error.GetMessage().find(" 2 ") != std::string::npos, VTKM_TEST_ASSERT(error.GetMessage().find(" 2 ") != std::string::npos,
"Parameter index not named in error message."); "Parameter index not named in error message.");
} }
try
{
std::cout << " Third argument bad." << std::endl;
dispatcher.Invoke(array, execObject, NULL);
}
catch (vtkm::cont::ErrorControlBadType error)
{
std::cout << " Got expected exception." << std::endl;
std::cout << " " << error.GetMessage() << std::endl;
VTKM_TEST_ASSERT(error.GetMessage().find(" 3 ") != std::string::npos,
"Parameter index not named in error message.");
}
} }
void TestDispatcherBase() void TestDispatcherBase()
......
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