mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
This mechanism sets up CMake variables that allow a user to select which modules/libraries to create. Dependencies will be tracked down to ensure that all of a module's dependencies are also enabled. The modules are also arranged into groups. Groups allow you to set the enable flag for a group of modules at once. Thus, if you have several modules that are likely to be used together, you can create a group for them. This can be handy in converting user-friendly CMake options (such as `VTKm_ENABLE_RENDERING`) to the modules that enable that by pointing to the appropriate group.
102 lines
2.6 KiB
C++
102 lines
2.6 KiB
C++
//============================================================================
|
|
// 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.
|
|
//============================================================================
|
|
|
|
#include <vtkm/exec/arg/FetchTagArrayDirectInOut.h>
|
|
|
|
#include <vtkm/exec/testing/ThreadIndicesTesting.h>
|
|
|
|
#include <vtkm/testing/Testing.h>
|
|
|
|
namespace
|
|
{
|
|
|
|
static constexpr vtkm::Id ARRAY_SIZE = 10;
|
|
|
|
static vtkm::Id g_NumSets;
|
|
|
|
template <typename T>
|
|
struct TestPortal
|
|
{
|
|
using ValueType = T;
|
|
|
|
vtkm::Id GetNumberOfValues() const { return ARRAY_SIZE; }
|
|
|
|
ValueType Get(vtkm::Id index) const
|
|
{
|
|
VTKM_TEST_ASSERT(index >= 0, "Bad portal index.");
|
|
VTKM_TEST_ASSERT(index < this->GetNumberOfValues(), "Bad portal index.");
|
|
return TestValue(index, ValueType());
|
|
}
|
|
|
|
void Set(vtkm::Id index, const ValueType& value) const
|
|
{
|
|
VTKM_TEST_ASSERT(index >= 0, "Bad portal index.");
|
|
VTKM_TEST_ASSERT(index < this->GetNumberOfValues(), "Bad portal index.");
|
|
VTKM_TEST_ASSERT(test_equal(value, ValueType(2) * TestValue(index, ValueType())),
|
|
"Tried to set invalid value.");
|
|
g_NumSets++;
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
struct FetchArrayDirectInTests
|
|
{
|
|
|
|
void operator()()
|
|
{
|
|
TestPortal<T> execObject;
|
|
|
|
using FetchType = vtkm::exec::arg::Fetch<vtkm::exec::arg::FetchTagArrayDirectInOut,
|
|
vtkm::exec::arg::AspectTagDefault,
|
|
TestPortal<T>>;
|
|
|
|
FetchType fetch;
|
|
|
|
g_NumSets = 0;
|
|
|
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
|
{
|
|
vtkm::exec::arg::ThreadIndicesTesting indices(index);
|
|
|
|
T value = fetch.Load(indices, execObject);
|
|
VTKM_TEST_ASSERT(test_equal(value, TestValue(index, T())), "Got invalid value from Load.");
|
|
|
|
value = T(T(2) * value);
|
|
|
|
fetch.Store(indices, execObject, value);
|
|
}
|
|
|
|
VTKM_TEST_ASSERT(g_NumSets == ARRAY_SIZE,
|
|
"Array portal's set not called correct number of times."
|
|
"Store method must be wrong.");
|
|
}
|
|
};
|
|
|
|
struct TryType
|
|
{
|
|
template <typename T>
|
|
void operator()(T) const
|
|
{
|
|
FetchArrayDirectInTests<T>()();
|
|
}
|
|
};
|
|
|
|
void TestExecObjectFetch()
|
|
{
|
|
vtkm::testing::Testing::TryTypes(TryType(), vtkm::TypeListCommon());
|
|
}
|
|
|
|
} // anonymous namespace
|
|
|
|
int UnitTestFetchArrayDirectInOut(int argc, char* argv[])
|
|
{
|
|
return vtkm::testing::Testing::Run(TestExecObjectFetch, argc, argv);
|
|
}
|