2014-10-15 21:47:39 +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 21:47:39 +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/WorkIndex.h>
|
|
|
|
|
|
|
|
#include <vtkm/exec/arg/FetchTagArrayDirectIn.h>
|
|
|
|
|
2022-02-16 12:50:39 +00:00
|
|
|
#include <vtkm/exec/testing/ThreadIndicesTesting.h>
|
2014-10-15 21:47:39 +00:00
|
|
|
|
|
|
|
#include <vtkm/testing/Testing.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace
|
|
|
|
{
|
2014-10-15 21:47:39 +00:00
|
|
|
|
2015-09-23 19:38:49 +00:00
|
|
|
void TestWorkIndexFetch()
|
2014-10-15 21:47:39 +00:00
|
|
|
{
|
2015-09-23 19:38:49 +00:00
|
|
|
std::cout << "Trying WorkIndex fetch." << std::endl;
|
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using FetchType =
|
|
|
|
vtkm::exec::arg::Fetch<vtkm::exec::arg::FetchTagArrayDirectIn, // Not used but probably common.
|
|
|
|
vtkm::exec::arg::AspectTagWorkIndex,
|
|
|
|
vtkm::internal::NullType>;
|
2014-10-15 21:47:39 +00:00
|
|
|
|
|
|
|
FetchType fetch;
|
|
|
|
|
|
|
|
for (vtkm::Id index = 0; index < 10; index++)
|
|
|
|
{
|
2015-09-23 19:38:49 +00:00
|
|
|
vtkm::exec::arg::ThreadIndicesTesting indices(index);
|
2015-10-07 18:14:00 +00:00
|
|
|
|
2015-09-22 04:35:13 +00:00
|
|
|
vtkm::Id value = fetch.Load(indices, vtkm::internal::NullType());
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(value == index, "Fetch did not give correct work index.");
|
2014-10-15 21:47:39 +00:00
|
|
|
|
|
|
|
value++;
|
|
|
|
|
|
|
|
// This should be a no-op.
|
2015-09-22 04:35:13 +00:00
|
|
|
fetch.Store(indices, vtkm::internal::NullType(), value);
|
2014-10-15 21:47:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2019-01-01 22:19:02 +00:00
|
|
|
int UnitTestFetchWorkIndex(int argc, char* argv[])
|
2014-10-15 21:47:39 +00:00
|
|
|
{
|
2019-01-01 22:19:02 +00:00
|
|
|
return vtkm::testing::Testing::Run(TestWorkIndexFetch, argc, argv);
|
2014-10-15 21:47:39 +00:00
|
|
|
}
|