mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merge branch 'msvc-array-handle-fail' into 'master'
MSVC ArrayHandle fail Fix the fact that UnitTestArrayHandle is failing on the Windows dashboards. Also fix some of the MSVC warnings. See merge request !101
This commit is contained in:
commit
53d669772f
@ -145,7 +145,8 @@ public:
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
ArrayPortalToIterators(const PortalType &portal)
|
||||
: Iterator(portal.GetIteratorBegin(), portal.GetNumberOfValues()),
|
||||
: Iterator(portal.GetIteratorBegin(),
|
||||
static_cast<size_t>(portal.GetNumberOfValues())),
|
||||
NumberOfValues(portal.GetNumberOfValues())
|
||||
{ }
|
||||
|
||||
@ -157,7 +158,9 @@ public:
|
||||
VTKM_CONT_EXPORT
|
||||
IteratorType GetEnd() const {
|
||||
IteratorType iterator = this->Iterator;
|
||||
std::advance(iterator, this->NumberOfValues);
|
||||
typedef typename std::iterator_traits<IteratorType>::difference_type
|
||||
difference_type;
|
||||
std::advance(iterator, static_cast<difference_type>(this->NumberOfValues));
|
||||
return iterator;
|
||||
}
|
||||
|
||||
|
@ -197,9 +197,11 @@ private:
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(vtkm::Id index) const
|
||||
{
|
||||
typedef typename OutputPortalType::ValueType ValueType;
|
||||
this->OutputPortal.Set(
|
||||
index + this->OutputOffset,
|
||||
this->InputPortal.Get(index + this->InputOffset));
|
||||
static_cast<ValueType>(
|
||||
this->InputPortal.Get(index + this->InputOffset)));
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
@ -63,41 +64,35 @@ struct TestingArrayHandles
|
||||
};
|
||||
|
||||
template<typename T, typename ExecutionPortalType>
|
||||
struct AssignTestValue
|
||||
struct AssignTestValue : public vtkm::exec::FunctorBase
|
||||
{
|
||||
ExecutionPortalType Portal;
|
||||
VTKM_CONT_EXPORT
|
||||
AssignTestValue(ExecutionPortalType p): Portal(p) {}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(vtkm::Id index,
|
||||
const vtkm::exec::internal::ErrorMessageBuffer &) const
|
||||
void operator()(vtkm::Id index) const
|
||||
{
|
||||
this->Portal.Set(index, TestValue(index, T()) );
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT void SetErrorMessageBuffer(
|
||||
const vtkm::exec::internal::ErrorMessageBuffer &) { }
|
||||
};
|
||||
|
||||
template<typename T, typename ExecutionPortalType>
|
||||
struct InplaceFunctor
|
||||
struct InplaceFunctor : public vtkm::exec::FunctorBase
|
||||
{
|
||||
ExecutionPortalType Portal;
|
||||
VTKM_CONT_EXPORT
|
||||
InplaceFunctor(ExecutionPortalType p): Portal(p) {}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(vtkm::Id index,
|
||||
const vtkm::exec::internal::ErrorMessageBuffer &) const
|
||||
void operator()(vtkm::Id index) const
|
||||
{
|
||||
this->Portal.Set(index, this->Portal.Get(index)+ T(1));
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT void SetErrorMessageBuffer(
|
||||
const vtkm::exec::internal::ErrorMessageBuffer &) { }
|
||||
};
|
||||
|
||||
private:
|
||||
static const vtkm::Id ARRAY_SIZE = 100000;
|
||||
static const vtkm::Id ARRAY_SIZE = 100;
|
||||
|
||||
typedef vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag> Algorithm;
|
||||
|
||||
@ -134,16 +129,14 @@ private:
|
||||
template<typename T>
|
||||
VTKM_CONT_EXPORT void operator()(T) const
|
||||
{
|
||||
T array[ARRAY_SIZE];
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||
std::vector<T> buffer(ARRAY_SIZE);
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||
{
|
||||
array[index] = TestValue(index, T());
|
||||
buffer[static_cast<std::size_t>(index)] = TestValue(index, T());
|
||||
}
|
||||
|
||||
vtkm::cont::internal::Storage<T,vtkm::cont::StorageTagBasic>
|
||||
arrayStorage(array, ARRAY_SIZE);
|
||||
|
||||
vtkm::cont::ArrayHandle<T> arrayHandle(arrayStorage);
|
||||
vtkm::cont::ArrayHandle<T> arrayHandle =
|
||||
vtkm::cont::make_ArrayHandle(buffer);
|
||||
|
||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE,
|
||||
"ArrayHandle has wrong number of entries.");
|
||||
@ -239,13 +232,13 @@ private:
|
||||
|
||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE*2,
|
||||
"Array not allocated correctly.");
|
||||
CheckArray(arrayHandle);
|
||||
array_handle_testing::CheckArray(arrayHandle);
|
||||
|
||||
std::cout << "Try shrinking the array." << std::endl;
|
||||
arrayHandle.Shrink(ARRAY_SIZE);
|
||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE,
|
||||
"Array size did not shrink correctly.");
|
||||
CheckArray(arrayHandle);
|
||||
array_handle_testing::CheckArray(arrayHandle);
|
||||
|
||||
std::cout << "Try reallocating array." << std::endl;
|
||||
arrayHandle.Allocate(ARRAY_SIZE*2);
|
||||
@ -283,8 +276,7 @@ private:
|
||||
{
|
||||
vtkm::testing::Testing::TryAllTypes(VerifyEmptyArrays());
|
||||
vtkm::testing::Testing::TryAllTypes(VerifyUserAllocatedHandle());
|
||||
// TestingArrayHandles<DeviceAdapterTag>::VerifyVTKMAllocatedHandle<T>()();
|
||||
|
||||
vtkm::testing::Testing::TryAllTypes(VerifyVTKMAllocatedHandle());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,7 @@ void TestCellAverageRegular3D()
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<3> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<3> *>(scs.get());
|
||||
VTKM_TEST_ASSERT(cs, "Structured cell set not found");
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Structured cell set not found");
|
||||
|
||||
vtkm::cont::Field result("avgvals",
|
||||
1,
|
||||
@ -72,7 +72,7 @@ void TestCellAverageRegular2D()
|
||||
boost::shared_ptr<vtkm::cont::CellSet> ecs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetExplicit<> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetExplicit<> *>(ecs.get());
|
||||
VTKM_TEST_ASSERT(cs, "Explicit cell set not found");
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Explicit cell set not found");
|
||||
|
||||
vtkm::cont::Field result("avgvals",
|
||||
1,
|
||||
@ -106,7 +106,7 @@ void TestCellAverageExplicit()
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<2> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<2> *>(scs.get());
|
||||
VTKM_TEST_ASSERT(cs, "Structured cell set not found");
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Structured cell set not found");
|
||||
|
||||
vtkm::cont::Field result("avgvals",
|
||||
1,
|
||||
|
@ -165,7 +165,7 @@ TestMaxNodeOrCell()
|
||||
vtkm::cont::CellSetExplicit<> *cse =
|
||||
dynamic_cast<vtkm::cont::CellSetExplicit<>*>(cs.get());
|
||||
|
||||
VTKM_TEST_ASSERT(cse, "Expected an explicit cell set");
|
||||
VTKM_TEST_ASSERT(cse != NULL, "Expected an explicit cell set");
|
||||
|
||||
//Todo:
|
||||
//the scheduling should just be passed a CellSet, and not the
|
||||
@ -216,7 +216,7 @@ TestAvgNodeToCell()
|
||||
vtkm::cont::CellSetExplicit<> *cse =
|
||||
dynamic_cast<vtkm::cont::CellSetExplicit<>*>(cs.get());
|
||||
|
||||
VTKM_TEST_ASSERT(cse, "Expected an explicit cell set");
|
||||
VTKM_TEST_ASSERT(cse != NULL, "Expected an explicit cell set");
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_explicit::AvgNodeToCellValue > dispatcher;
|
||||
dispatcher.Invoke(ds.GetField("nodevar").GetData(),
|
||||
|
@ -149,7 +149,7 @@ TestMaxNodeOrCell()
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<2> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<2> *>(scs.get());
|
||||
VTKM_TEST_ASSERT(cs, "Structured cell set not found");
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Structured cell set not found");
|
||||
|
||||
//Run a worklet to populate a cell centered field.
|
||||
//Here, we're filling it with test values.
|
||||
@ -198,7 +198,7 @@ TestAvgNodeToCell()
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<2> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<2> *>(scs.get());
|
||||
VTKM_TEST_ASSERT(cs, "Structured cell set not found");
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Structured cell set not found");
|
||||
|
||||
//Run a worklet to populate a cell centered field.
|
||||
//Here, we're filling it with test values.
|
||||
|
Loading…
Reference in New Issue
Block a user