Commit 950b12b1 authored by Sujin Philip's avatar Sujin Philip
Browse files

Add ArrayHandleVirtualCoordinates

parent a4d0b57b
This diff is collapsed.
......@@ -39,6 +39,7 @@ set(headers
ArrayHandleSwizzle.h
ArrayHandleTransform.h
ArrayHandleUniformPointCoordinates.h
ArrayHandleVirtualCoordinates.h
ArrayHandleZip.h
ArrayPortal.h
ArrayPortalToIterators.h
......
......@@ -20,6 +20,7 @@
set(unit_tests
UnitTestCudaArrayHandleFancy.cu
UnitTestCudaArrayHandleVirtualCoordinates.cu
UnitTestCudaCellLocatorTwoLevelUniformGrid.cu
UnitTestCudaComputeRange.cu
UnitTestCudaDataSetExplicit.cu
......
//============================================================================
// 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.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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/cont/cuda/DeviceAdapterCuda.h>
#include <vtkm/cont/testing/TestingArrayHandleVirtualCoordinates.h>
int UnitTestCudaArrayHandleVirtualCoordinates(int, char* [])
{
return vtkm::cont::testing::TestingArrayHandleVirtualCoordinates<
vtkm::cont::DeviceAdapterTagCuda>::Run();
}
......@@ -21,6 +21,7 @@
set(unit_tests
UnitTestSerialArrayHandle.cxx
UnitTestSerialArrayHandleFancy.cxx
UnitTestSerialArrayHandleVirtualCoordinates.cxx
UnitTestSerialCellLocatorTwoLevelUniformGrid.cxx
UnitTestSerialComputeRange.cxx
UnitTestSerialDataSetExplicit.cxx
......
//============================================================================
// 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.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/cont/testing/TestingArrayHandleVirtualCoordinates.h>
int UnitTestSerialArrayHandleVirtualCoordinates(int, char* [])
{
return vtkm::cont::testing::TestingArrayHandleVirtualCoordinates<
vtkm::cont::DeviceAdapterTagSerial>::Run();
}
......@@ -21,6 +21,7 @@
set(unit_tests
UnitTestTBBArrayHandle.cxx
UnitTestTBBArrayHandleFancy.cxx
UnitTestTBBArrayHandleVirtualCoordinates.cxx
UnitTestTBBCellLocatorTwoLevelUniformGrid.cxx
UnitTestTBBComputeRange.cxx
UnitTestTBBDataSetExplicit.cxx
......
//============================================================================
// 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.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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/cont/tbb/DeviceAdapterTBB.h>
#include <vtkm/cont/testing/TestingArrayHandleVirtualCoordinates.h>
int UnitTestTBBArrayHandleVirtualCoordinates(int, char* [])
{
return vtkm::cont::testing::TestingArrayHandleVirtualCoordinates<
vtkm::cont::DeviceAdapterTagTBB>::Run();
}
......@@ -23,6 +23,7 @@ set(headers
MakeTestDataSet.h
Testing.h
TestingArrayHandles.h
TestingArrayHandleVirtualCoordinates.h
TestingCellLocatorTwoLevelUniformGrid.h
TestingComputeRange.h
TestingDeviceAdapter.h
......
//============================================================================
// 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.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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.
//============================================================================
#ifndef vtk_m_cont_testing_TestingArrayHandleVirtualCoordinates_h
#define vtk_m_cont_testing_TestingArrayHandleVirtualCoordinates_h
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
namespace vtkm
{
namespace cont
{
namespace testing
{
namespace
{
struct CopyWorklet : public vtkm::worklet::WorkletMapField
{
typedef void ControlSignature(FieldIn<FieldCommon> in, FieldOut<FieldCommon> out);
typedef _2 ExecutionSignature(_1);
template <typename T>
VTKM_EXEC T operator()(const T& in) const
{
return in;
}
};
} // anonymous namespace
template <typename DeviceAdapter>
class TestingArrayHandleVirtualCoordinates
{
private:
using ArrayHandleRectilinearCoords =
vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>>;
template <typename T, typename InStorageTag, typename OutStorageTag>
static void TestVirtualAccess(const vtkm::cont::ArrayHandle<T, InStorageTag>& in,
vtkm::cont::ArrayHandle<T, OutStorageTag>& out)
{
vtkm::worklet::DispatcherMapField<CopyWorklet, DeviceAdapter>().Invoke(
vtkm::cont::ArrayHandleVirtualCoordinates(in),
vtkm::cont::ArrayHandleVirtualCoordinates(out));
VTKM_TEST_ASSERT(test_equal_portals(in.GetPortalConstControl(), out.GetPortalConstControl()),
"Input and output portals don't match");
}
static void TestAll()
{
using PointType = vtkm::Vec<vtkm::FloatDefault, 3>;
static const vtkm::Id length = 64;
vtkm::cont::ArrayHandle<PointType> out;
std::cout << "Testing basic ArrayHandle as input\n";
vtkm::cont::ArrayHandle<PointType> a1;
a1.Allocate(length);
for (vtkm::Id i = 0; i < length; ++i)
{
a1.GetPortalControl().Set(i, TestValue(i, PointType()));
}
TestVirtualAccess(a1, out);
std::cout << "Testing ArrayHandleUniformPointCoordinates as input\n";
TestVirtualAccess(vtkm::cont::ArrayHandleUniformPointCoordinates(vtkm::Id3(4, 4, 4)), out);
std::cout << "Testing ArrayHandleCartesianProduct as input\n";
vtkm::cont::ArrayHandle<vtkm::FloatDefault> c1, c2, c3;
c1.Allocate(length);
c2.Allocate(length);
c3.Allocate(length);
for (vtkm::Id i = 0; i < length; ++i)
{
auto p = a1.GetPortalConstControl().Get(i);
c1.GetPortalControl().Set(i, p[0]);
c2.GetPortalControl().Set(i, p[1]);
c3.GetPortalControl().Set(i, p[2]);
}
TestVirtualAccess(vtkm::cont::make_ArrayHandleCartesianProduct(c1, c2, c3), out);
}
public:
static int Run() { return vtkm::cont::testing::Testing::Run(TestAll); }
};
}
}
} // vtkm::cont::testing
#endif // vtk_m_cont_testing_TestingArrayHandleVirtualCoordinates_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment