2014-10-15 19:52:27 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2014-10-15 19:52:27 +00:00
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <vtkm/exec/arg/FetchTagExecObject.h>
|
|
|
|
|
2022-02-16 12:50:39 +00:00
|
|
|
#include <vtkm/exec/testing/ThreadIndicesTesting.h>
|
2014-10-15 19:52:27 +00:00
|
|
|
|
|
|
|
#include <vtkm/testing/Testing.h>
|
|
|
|
|
|
|
|
#define EXPECTED_NUMBER 67
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace
|
|
|
|
{
|
2014-10-15 19:52:27 +00:00
|
|
|
|
2018-09-08 17:07:06 +00:00
|
|
|
struct TestExecutionObject
|
2014-10-15 19:52:27 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
TestExecutionObject()
|
|
|
|
: Number(static_cast<vtkm::Int32>(0xDEADDEAD))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TestExecutionObject(vtkm::Int32 number)
|
|
|
|
: Number(number)
|
|
|
|
{
|
|
|
|
}
|
2014-10-15 19:52:27 +00:00
|
|
|
vtkm::Int32 Number;
|
|
|
|
};
|
|
|
|
|
2015-09-23 19:38:49 +00:00
|
|
|
void TryInvocation()
|
2014-10-15 19:52:27 +00:00
|
|
|
{
|
2015-09-23 19:38:49 +00:00
|
|
|
TestExecutionObject execObjectStore(EXPECTED_NUMBER);
|
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using FetchType = vtkm::exec::arg::Fetch<vtkm::exec::arg::FetchTagExecObject,
|
|
|
|
vtkm::exec::arg::AspectTagDefault,
|
|
|
|
TestExecutionObject>;
|
2014-10-15 19:52:27 +00:00
|
|
|
|
|
|
|
FetchType fetch;
|
|
|
|
|
2015-09-23 19:38:49 +00:00
|
|
|
vtkm::exec::arg::ThreadIndicesTesting indices(0);
|
2015-10-07 18:14:00 +00:00
|
|
|
|
2015-09-23 19:38:49 +00:00
|
|
|
TestExecutionObject execObject = fetch.Load(indices, execObjectStore);
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(execObject.Number == EXPECTED_NUMBER, "Did not load object correctly.");
|
2014-10-15 19:52:27 +00:00
|
|
|
|
|
|
|
execObject.Number = -1;
|
|
|
|
|
|
|
|
// This should be a no-op.
|
2015-09-23 19:38:49 +00:00
|
|
|
fetch.Store(indices, execObjectStore, execObject);
|
2014-10-15 19:52:27 +00:00
|
|
|
|
|
|
|
// Data in Invocation should not have changed.
|
2015-09-23 19:38:49 +00:00
|
|
|
VTKM_TEST_ASSERT(execObjectStore.Number == EXPECTED_NUMBER,
|
2014-10-15 19:52:27 +00:00
|
|
|
"Fetch changed read-only execution object.");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestExecObjectFetch()
|
|
|
|
{
|
2015-09-23 19:38:49 +00:00
|
|
|
TryInvocation();
|
2014-10-15 19:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2019-01-01 22:19:02 +00:00
|
|
|
int UnitTestFetchExecObject(int argc, char* argv[])
|
2014-10-15 19:52:27 +00:00
|
|
|
{
|
2019-01-01 22:19:02 +00:00
|
|
|
return vtkm::testing::Testing::Run(TestExecObjectFetch, argc, argv);
|
2014-10-15 19:52:27 +00:00
|
|
|
}
|