2014-10-15 19:52:27 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
// 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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2014-10-15 19:52:27 +00:00
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
2015-05-21 12:09:22 +00:00
|
|
|
// Copyright 2014 Los Alamos National Security.
|
2014-10-15 19:52:27 +00:00
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2014-10-15 19:52:27 +00:00
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <vtkm/exec/arg/FetchTagExecObject.h>
|
|
|
|
|
2015-09-23 19:38:49 +00:00
|
|
|
#include <vtkm/exec/arg/testing/ThreadIndicesTesting.h>
|
2014-10-15 19:52:27 +00:00
|
|
|
|
|
|
|
#include <vtkm/exec/ExecutionObjectBase.h>
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
struct TestExecutionObject : public vtkm::exec::ExecutionObjectBase
|
|
|
|
{
|
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,
|
|
|
|
vtkm::exec::arg::ThreadIndicesTesting,
|
|
|
|
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
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
int UnitTestFetchExecObject(int, char* [])
|
2014-10-15 19:52:27 +00:00
|
|
|
{
|
|
|
|
return vtkm::testing::Testing::Run(TestExecObjectFetch);
|
|
|
|
}
|