Merge topic 'copy-unknownarrayhandle'
99e613d37 Avoid conversion warnings in `RecombineVec` copy 4c524de62 Fix inverted `ArrayCopy` arguments fa4da95eb Add changelog for copying UnknownArrayHandle 1faed3712 Remove the use of ResetTypes for ArrayCopy ad7033684 Change ArrayCopy of UnknownArrayHandle to limit types 916a01d7b Add general `ArrayCopy` between `UnknownArrayHandle`s 26ea2ab42 Break circular dependency of ArrayCopy.h and UnknownArrayHandle.h 990cc9ece Test copying UnknownArrayHandle Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Sujin Philip <sujin.philip@kitware.com> Merge-request: !2396
This commit is contained in:
commit
0b277b1ec8
9
docs/changelog/copy-unknownarrayhandle.md
Normal file
9
docs/changelog/copy-unknownarrayhandle.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Precompiled `ArrayCopy` for `UnknownArrayHandle`
|
||||
|
||||
Previously, in order to copy an `UnknownArrayHandle`, you had to specify
|
||||
some subset of types and then specially compile a copy for each potential
|
||||
type. With the new ability to extract a component from an
|
||||
`UnknownArrayHandle`, it is now feasible to precompile copying an
|
||||
`UnknownArrayHandle` to another array. This greatly reduces the overhead of
|
||||
using `ArrayCopy` to copy `UnknownArrayHandle`s while simultaneously
|
||||
increasing the likelihood that the copy will be successful.
|
@ -705,8 +705,7 @@ int main(int argc, char* argv[])
|
||||
auto tempFieldData = inDataSet.GetField(0).GetData();
|
||||
values.resize(static_cast<std::size_t>(tempFieldData.GetNumberOfValues()));
|
||||
auto valuesHandle = vtkm::cont::make_ArrayHandle(values, vtkm::CopyFlag::Off);
|
||||
vtkm::cont::ArrayCopy(
|
||||
tempFieldData.ResetTypes<vtkm::List<ValueType>, VTKM_DEFAULT_STORAGE_LIST>(), valuesHandle);
|
||||
vtkm::cont::ArrayCopy(tempFieldData, valuesHandle);
|
||||
valuesHandle.SyncControlArray(); //Forces values to get updated if copy happened on GPU
|
||||
}
|
||||
// Read ASCII data input
|
||||
|
@ -15,6 +15,7 @@
|
||||
/// Reference: Computational Physics 2nd Edition, Nicholas Giordano & Hisao Nakanishi
|
||||
|
||||
#include <iomanip>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandleRandomUniformReal.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
|
133
vtkm/cont/ArrayCopy.cxx
Normal file
133
vtkm/cont/ArrayCopy.cxx
Normal file
@ -0,0 +1,133 @@
|
||||
//============================================================================
|
||||
// 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/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/DeviceAdapterList.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// Use a worklet because device adapter copies often have an issue with casting the values from the
|
||||
// `ArrayHandleRecomineVec` that comes from `UnknownArrayHandle::CastAndCallWithExtractedArray`.
|
||||
struct CopyWorklet : vtkm::worklet::WorkletMapField
|
||||
{
|
||||
using ControlSignature = void(FieldIn, FieldOut);
|
||||
using ExecutionSignature = void(_1, _2);
|
||||
using InputDomain = _1;
|
||||
|
||||
template <typename InType, typename OutType>
|
||||
VTKM_EXEC void operator()(const InType& in, OutType& out) const
|
||||
{
|
||||
out = in;
|
||||
}
|
||||
};
|
||||
|
||||
struct UnknownCopyOnDevice
|
||||
{
|
||||
bool Called = false;
|
||||
|
||||
template <typename InArrayType, typename OutArrayType>
|
||||
void operator()(vtkm::cont::DeviceAdapterId device,
|
||||
const InArrayType& in,
|
||||
const OutArrayType& out)
|
||||
{
|
||||
if (!this->Called && ((device == vtkm::cont::DeviceAdapterTagAny{}) || (in.IsOnDevice(device))))
|
||||
{
|
||||
vtkm::cont::Invoker invoke(device);
|
||||
invoke(CopyWorklet{}, in, out);
|
||||
this->Called = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct UnknownCopyFunctor2
|
||||
{
|
||||
template <typename OutArrayType, typename InArrayType>
|
||||
void operator()(const OutArrayType& out, const InArrayType& in) const
|
||||
{
|
||||
UnknownCopyOnDevice doCopy;
|
||||
|
||||
// Try to copy on a device that the data are already on.
|
||||
vtkm::ListForEach(doCopy, VTKM_DEFAULT_DEVICE_ADAPTER_LIST{}, in, out);
|
||||
|
||||
// If it was not on any device, call one more time with any adapter to copy wherever.
|
||||
doCopy(vtkm::cont::DeviceAdapterTagAny{}, in, out);
|
||||
}
|
||||
};
|
||||
|
||||
struct UnknownCopyFunctor1
|
||||
{
|
||||
template <typename InArrayType>
|
||||
void operator()(const InArrayType& in, vtkm::cont::UnknownArrayHandle& out) const
|
||||
{
|
||||
out.Allocate(in.GetNumberOfValues());
|
||||
|
||||
this->DoIt(in,
|
||||
out,
|
||||
typename std::is_same<vtkm::FloatDefault,
|
||||
typename InArrayType::ValueType::ComponentType>::type{});
|
||||
}
|
||||
|
||||
template <typename InArrayType>
|
||||
void DoIt(const InArrayType& in, vtkm::cont::UnknownArrayHandle& out, std::false_type) const
|
||||
{
|
||||
// Source is not float.
|
||||
using BaseComponentType = typename InArrayType::ValueType::ComponentType;
|
||||
if (out.IsBaseComponentType<BaseComponentType>())
|
||||
{
|
||||
// Arrays have the same base component type. Copy directly.
|
||||
UnknownCopyFunctor2{}(out.ExtractArrayFromComponents<BaseComponentType>(), in);
|
||||
}
|
||||
else if (out.IsBaseComponentType<vtkm::FloatDefault>())
|
||||
{
|
||||
// Can copy anything to default float.
|
||||
UnknownCopyFunctor2{}(out.ExtractArrayFromComponents<vtkm::FloatDefault>(), in);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Arrays have different base types. To reduce the number of template paths from nxn to 3n,
|
||||
// copy first to a temp array of default float.
|
||||
vtkm::cont::UnknownArrayHandle temp = out.NewInstanceFloatBasic();
|
||||
(*this)(in, temp);
|
||||
vtkm::cont::ArrayCopy(temp, out);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename InArrayType>
|
||||
void DoIt(const InArrayType& in, vtkm::cont::UnknownArrayHandle& out, std::true_type) const
|
||||
{
|
||||
// Source array is FloatDefault. That should be copiable to anything.
|
||||
out.CastAndCallWithExtractedArray(UnknownCopyFunctor2{}, in);
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
void ArrayCopy(const vtkm::cont::UnknownArrayHandle& source,
|
||||
vtkm::cont::UnknownArrayHandle& destination)
|
||||
{
|
||||
if (!destination.IsValid())
|
||||
{
|
||||
destination = source.NewInstanceBasic();
|
||||
}
|
||||
|
||||
source.CastAndCallWithExtractedArray(UnknownCopyFunctor1{}, destination);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
@ -15,6 +15,7 @@
|
||||
#include <vtkm/cont/DeviceAdapterTag.h>
|
||||
#include <vtkm/cont/ErrorExecution.h>
|
||||
#include <vtkm/cont/Logging.h>
|
||||
#include <vtkm/cont/UnknownArrayHandle.h>
|
||||
|
||||
#include <vtkm/cont/internal/ArrayHandleDeprecated.h>
|
||||
|
||||
@ -159,56 +160,28 @@ VTKM_CONT void ArrayCopy(const vtkm::cont::ArrayHandle<InValueType, InStorage>&
|
||||
detail::ArrayCopyImpl(source, destination, std::integral_constant<bool, !IsOldStyle::value>{});
|
||||
}
|
||||
|
||||
// Forward declaration
|
||||
// Cannot include UncertainArrayHandle.h here due to circular dependency.
|
||||
template <typename ValueList, typename StorageList>
|
||||
class UncertainArrayHandle;
|
||||
|
||||
// Forward declaration
|
||||
// Cannot include VariantArrayHandle.h here due to circular dependency.
|
||||
template <typename TypeList>
|
||||
class VariantArrayHandleBase;
|
||||
VTKM_CONT_EXPORT void ArrayCopy(const vtkm::cont::UnknownArrayHandle& source,
|
||||
vtkm::cont::UnknownArrayHandle& destination);
|
||||
|
||||
namespace detail
|
||||
template <typename T, typename S>
|
||||
VTKM_CONT void ArrayCopy(const vtkm::cont::UnknownArrayHandle& source,
|
||||
vtkm::cont::ArrayHandle<T, S>& destination)
|
||||
{
|
||||
|
||||
struct ArrayCopyFunctor
|
||||
{
|
||||
template <typename InValueType, typename InStorage, typename OutValueType, typename OutStorage>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<InValueType, InStorage>& source,
|
||||
vtkm::cont::ArrayHandle<OutValueType, OutStorage>& destination) const
|
||||
using DestType = vtkm::cont::ArrayHandle<T, S>;
|
||||
if (source.IsType<DestType>())
|
||||
{
|
||||
vtkm::cont::ArrayCopy(source, destination);
|
||||
ArrayCopy(source.AsArrayHandle<DestType>(), destination);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::UnknownArrayHandle destWrapper(destination);
|
||||
ArrayCopy(source, destWrapper);
|
||||
// Destination array should not change, but just in case.
|
||||
destWrapper.AsArrayHandle(destination);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// \brief Deep copies data in an `UncertainArrayHandle` to an array of a known type.
|
||||
///
|
||||
/// This form of `ArrayCopy` can be used to copy data from an unknown array type to
|
||||
/// an array of a known type. Note that regardless of the source type, the data will
|
||||
/// be deep copied.
|
||||
///
|
||||
template <typename InValueList, typename InStorageList, typename OutValue, typename OutStorage>
|
||||
VTKM_CONT void ArrayCopy(const vtkm::cont::UncertainArrayHandle<InValueList, InStorageList>& src,
|
||||
vtkm::cont::ArrayHandle<OutValue, OutStorage>& dest)
|
||||
{
|
||||
src.CastAndCall(detail::ArrayCopyFunctor{}, dest);
|
||||
}
|
||||
|
||||
/// \brief Deep copies data in a `VariantArrayHandle` to an array of a known type.
|
||||
///
|
||||
/// This form of `ArrayCopy` can be used to copy data from an unknown array type to
|
||||
/// an array of a known type. Note that regardless of the source type, the data will
|
||||
/// be deep copied.
|
||||
///
|
||||
template <typename InTypeList, typename OutValueType, typename OutStorage>
|
||||
VTKM_CONT void ArrayCopy(const vtkm::cont::VariantArrayHandleBase<InTypeList>& source,
|
||||
vtkm::cont::ArrayHandle<OutValueType, OutStorage>& destination)
|
||||
{
|
||||
source.CastAndCall(detail::ArrayCopyFunctor{}, destination);
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -218,7 +218,8 @@ private:
|
||||
}
|
||||
for (vtkm::IdComponent cIndex = 0; cIndex < numComponents; ++cIndex)
|
||||
{
|
||||
this->Portals[cIndex].Set(this->Index, VTraits::GetComponent(src, cIndex));
|
||||
this->Portals[cIndex].Set(this->Index,
|
||||
static_cast<ComponentType>(VTraits::GetComponent(src, cIndex)));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -226,7 +227,8 @@ private:
|
||||
// Special case when copying from a scalar
|
||||
for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
|
||||
{
|
||||
this->Portals[cIndex].Set(this->Index, VTraits::GetComponent(src, 0));
|
||||
this->Portals[cIndex].Set(this->Index,
|
||||
static_cast<ComponentType>(VTraits::GetComponent(src, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,9 +160,10 @@ set(sources
|
||||
TryExecute.cxx
|
||||
)
|
||||
|
||||
# This list of sources has code that uses devices and so might need to be
|
||||
# compiled with a device-specific compiler (like CUDA).
|
||||
set(device_sources
|
||||
# This list of sources has code that uses devices and so might need to be
|
||||
# compiled with a device-specific compiler (like CUDA).
|
||||
set(device_sources
|
||||
ArrayCopy.cxx
|
||||
ArrayRangeCompute.cxx
|
||||
AssignerPartitionedDataSet.cxx
|
||||
BoundsCompute.cxx
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayGetValues.h>
|
||||
#include <vtkm/cont/ArrayHandleDecorator.h>
|
||||
#include <vtkm/cont/Logging.h>
|
||||
@ -479,9 +479,9 @@ void CellSetExplicit<SST, CST, OST>::DeepCopy(const CellSet* src)
|
||||
const auto ct = vtkm::TopologyElementTagCell{};
|
||||
const auto pt = vtkm::TopologyElementTagPoint{};
|
||||
|
||||
vtkm::cont::ArrayCopy(other->GetShapesArray(ct, pt), shapes);
|
||||
vtkm::cont::ArrayCopy(other->GetConnectivityArray(ct, pt), conn);
|
||||
vtkm::cont::ArrayCopy(other->GetOffsetsArray(ct, pt), offsets);
|
||||
shapes.DeepCopyFrom(other->GetShapesArray(ct, pt));
|
||||
conn.DeepCopyFrom(other->GetConnectivityArray(ct, pt));
|
||||
offsets.DeepCopyFrom(other->GetOffsetsArray(ct, pt));
|
||||
|
||||
this->Fill(other->GetNumberOfPoints(), shapes, conn, offsets);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
#define vtk_m_cont_CellSetExtrude_h
|
||||
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
|
||||
|
@ -128,6 +128,11 @@ VTKM_CONT bool UnknownArrayHandle::IsBaseComponentTypeImpl(
|
||||
return this->Container->BaseComponentType == type;
|
||||
}
|
||||
|
||||
VTKM_CONT bool UnknownArrayHandle::IsValid() const
|
||||
{
|
||||
return static_cast<bool>(this->Container);
|
||||
}
|
||||
|
||||
VTKM_CONT UnknownArrayHandle UnknownArrayHandle::NewInstance() const
|
||||
{
|
||||
UnknownArrayHandle newArray;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <vtkm/cont/ArrayHandleMultiplexer.h>
|
||||
#include <vtkm/cont/ArrayHandleRecombineVec.h>
|
||||
#include <vtkm/cont/ArrayHandleStride.h>
|
||||
#include <vtkm/cont/CastAndCall.h>
|
||||
#include <vtkm/cont/DefaultTypes.h>
|
||||
|
||||
#include <memory>
|
||||
@ -385,6 +386,14 @@ public:
|
||||
|
||||
UnknownArrayHandle& operator=(const vtkm::cont::UnknownArrayHandle&) = default;
|
||||
|
||||
/// \brief Returns whether an array is stored in this `UnknownArrayHandle`.
|
||||
///
|
||||
/// If the `UnknownArrayHandle` is constructed without an `ArrayHandle`, it
|
||||
/// will not have an underlying type, and therefore the operations will be
|
||||
/// invalid. It is still possible to set this `UnknownArrayHandle` to an
|
||||
/// `ArrayHandle`.
|
||||
VTKM_CONT bool IsValid() const;
|
||||
|
||||
/// \brief Create a new array of the same type as this array.
|
||||
///
|
||||
/// This method creates a new array that is the same type as this one and
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define vtk_m_cont_testing_TestingFancyArrayHandles_h
|
||||
|
||||
#include <vtkm/VecTraits.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCast.h>
|
||||
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandleConstant.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/UncertainArrayHandle.h>
|
||||
#include <vtkm/cont/UnknownArrayHandle.h>
|
||||
|
||||
#include <vtkm/TypeTraits.h>
|
||||
|
||||
@ -21,16 +23,20 @@ namespace
|
||||
|
||||
static constexpr vtkm::Id ARRAY_SIZE = 10;
|
||||
|
||||
template <typename RefPortalType, typename TestPortalType>
|
||||
void TestValues(const RefPortalType& refPortal, const TestPortalType& testPortal)
|
||||
template <typename RefArrayType, typename TestArrayType>
|
||||
void TestValues(const RefArrayType& refArray, const TestArrayType& testArray)
|
||||
{
|
||||
const vtkm::Id arraySize = refPortal.GetNumberOfValues();
|
||||
VTKM_TEST_ASSERT(arraySize == testPortal.GetNumberOfValues(), "Wrong array size.");
|
||||
auto result = test_equal_ArrayHandles(refArray, testArray);
|
||||
VTKM_TEST_ASSERT(result, result.GetMergedMessage());
|
||||
}
|
||||
|
||||
for (vtkm::Id index = 0; index < arraySize; ++index)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(refPortal.Get(index), testPortal.Get(index)), "Got bad value.");
|
||||
}
|
||||
template <typename ValueType>
|
||||
vtkm::cont::ArrayHandle<ValueType> MakeInputArray()
|
||||
{
|
||||
vtkm::cont::ArrayHandle<ValueType> input;
|
||||
input.Allocate(ARRAY_SIZE);
|
||||
SetPortal(input.WritePortal());
|
||||
return input;
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
@ -39,42 +45,78 @@ void TryCopy()
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
|
||||
"Trying type: " << vtkm::testing::TypeName<ValueType>::Name());
|
||||
|
||||
{ // implicit -> basic
|
||||
{
|
||||
std::cout << "implicit -> basic" << std::endl;
|
||||
vtkm::cont::ArrayHandleIndex input(ARRAY_SIZE);
|
||||
vtkm::cont::ArrayHandle<ValueType> output;
|
||||
vtkm::cont::ArrayCopy(input, output);
|
||||
TestValues(input.ReadPortal(), output.ReadPortal());
|
||||
TestValues(input, output);
|
||||
}
|
||||
|
||||
{ // basic -> basic
|
||||
vtkm::cont::ArrayHandleIndex source(ARRAY_SIZE);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> input;
|
||||
vtkm::cont::ArrayCopy(source, input);
|
||||
{
|
||||
std::cout << "basic -> basic" << std::endl;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> input = MakeInputArray<vtkm::Id>();
|
||||
vtkm::cont::ArrayHandle<ValueType> output;
|
||||
vtkm::cont::ArrayCopy(input, output);
|
||||
TestValues(input.ReadPortal(), output.ReadPortal());
|
||||
TestValues(input, output);
|
||||
|
||||
output.ReleaseResources();
|
||||
vtkm::cont::ArrayCopy(vtkm::cont::UnknownArrayHandle(input), output);
|
||||
TestValues(input, output);
|
||||
}
|
||||
|
||||
{ // implicit -> implicit (index)
|
||||
{
|
||||
std::cout << "implicit -> implicit (index)" << std::endl;
|
||||
vtkm::cont::ArrayHandleIndex input(ARRAY_SIZE);
|
||||
vtkm::cont::ArrayHandleIndex output;
|
||||
vtkm::cont::ArrayCopy(input, output);
|
||||
TestValues(input.ReadPortal(), output.ReadPortal());
|
||||
TestValues(input, output);
|
||||
}
|
||||
|
||||
{ // implicit -> implicit (constant)
|
||||
{
|
||||
std::cout << "implicit -> implicit (constant)" << std::endl;
|
||||
vtkm::cont::ArrayHandleConstant<int> input(41, ARRAY_SIZE);
|
||||
vtkm::cont::ArrayHandleConstant<int> output;
|
||||
vtkm::cont::ArrayCopy(input, output);
|
||||
TestValues(input.ReadPortal(), output.ReadPortal());
|
||||
TestValues(input, output);
|
||||
}
|
||||
|
||||
{ // implicit -> implicit (base->derived, constant)
|
||||
{
|
||||
std::cout << "implicit -> implicit (base->derived, constant)" << std::endl;
|
||||
vtkm::cont::ArrayHandle<int, vtkm::cont::StorageTagConstant> input =
|
||||
vtkm::cont::make_ArrayHandleConstant<int>(41, ARRAY_SIZE);
|
||||
vtkm::cont::ArrayHandleConstant<int> output;
|
||||
vtkm::cont::ArrayCopy(input, output);
|
||||
TestValues(input.ReadPortal(), output.ReadPortal());
|
||||
TestValues(input, output);
|
||||
}
|
||||
|
||||
using TypeList = vtkm::ListAppend<vtkm::TypeListField, vtkm::List<ValueType, vtkm::UInt8>>;
|
||||
using StorageList = VTKM_DEFAULT_STORAGE_LIST;
|
||||
using UnknownArray = vtkm::cont::UnknownArrayHandle;
|
||||
using UncertainArray = vtkm::cont::UncertainArrayHandle<TypeList, StorageList>;
|
||||
|
||||
{
|
||||
std::cout << "unknown -> unknown" << std::endl;
|
||||
UnknownArray input = MakeInputArray<ValueType>();
|
||||
UnknownArray output;
|
||||
vtkm::cont::ArrayCopy(input, output);
|
||||
TestValues(input, output);
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << "uncertain -> basic (same type)" << std::endl;
|
||||
UncertainArray input = MakeInputArray<ValueType>();
|
||||
vtkm::cont::ArrayHandle<ValueType> output;
|
||||
vtkm::cont::ArrayCopy(input, output);
|
||||
TestValues(input, output);
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << "uncertain -> basic (different type)" << std::endl;
|
||||
UncertainArray input = MakeInputArray<vtkm::UInt8>();
|
||||
vtkm::cont::ArrayHandle<ValueType> output;
|
||||
vtkm::cont::ArrayCopy(input, output);
|
||||
TestValues(input, output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
|
||||
#include <vtkm/cont/ArrayHandleCast.h>
|
||||
|
@ -299,9 +299,7 @@ VTKM_CONT void ContourTreeAugmented::DoPostExecute(
|
||||
currBlock.GetField(this->GetActiveFieldName(), this->GetActiveFieldAssociation());
|
||||
//const vtkm::cont::ArrayHandle<T,StorageType> &fieldData = currField.GetData().Cast<vtkm::cont::ArrayHandle<T,StorageType> >();
|
||||
vtkm::cont::ArrayHandle<T> fieldData;
|
||||
vtkm::cont::ArrayCopy(
|
||||
currField.GetData().template ResetTypes<vtkm::List<T>, VTKM_DEFAULT_STORAGE_LIST>(),
|
||||
fieldData);
|
||||
vtkm::cont::ArrayCopy(currField.GetData(), fieldData);
|
||||
auto currContourTreeMesh = vtkm::worklet::contourtree_distributed::MultiBlockContourTreeHelper::
|
||||
ComputeLocalContourTreeMesh<T>(
|
||||
this->MultiBlockTreeHelper->MultiBlockSpatialDecomposition.LocalBlockOrigins.ReadPortal()
|
||||
|
@ -680,9 +680,7 @@ VTKM_CONT void ContourTreeUniformDistributed::DoPostExecute(
|
||||
auto currField =
|
||||
currBlock.GetField(this->GetActiveFieldName(), this->GetActiveFieldAssociation());
|
||||
vtkm::cont::ArrayHandle<FieldType> fieldData;
|
||||
vtkm::cont::ArrayCopy(
|
||||
currField.GetData().ResetTypes(vtkm::List<FieldType>{}, VTKM_DEFAULT_STORAGE_LIST{}),
|
||||
fieldData);
|
||||
vtkm::cont::ArrayCopy(currField.GetData(), fieldData);
|
||||
|
||||
// ... compute and store the actual mesh
|
||||
localDataBlocks[bi]->ContourTreeMeshes.emplace_back(this->LocalBoundaryTrees[bi].VertexIndex,
|
||||
@ -916,9 +914,7 @@ VTKM_CONT void ContourTreeUniformDistributed::DoPostExecute(
|
||||
auto currField =
|
||||
currBlock.GetField(this->GetActiveFieldName(), this->GetActiveFieldAssociation());
|
||||
vtkm::cont::ArrayHandle<FieldType> fieldData;
|
||||
vtkm::cont::ArrayCopy(
|
||||
currField.GetData().ResetTypes(vtkm::List<FieldType>{}, VTKM_DEFAULT_STORAGE_LIST{}),
|
||||
fieldData);
|
||||
vtkm::cont::ArrayCopy(currField.GetData(), fieldData);
|
||||
auto localToGlobalIdRelabeler = vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler(
|
||||
this->MultiBlockSpatialDecomposition.LocalBlockOrigins.ReadPortal().Get(
|
||||
blockData->BlockIndex),
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define vtk_m_filter_particle_density_ngp_hxx
|
||||
|
||||
#include "ParticleDensityNearestGridPoint.h"
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/CellLocatorUniformGrid.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/filter/PolicyBase.h>
|
||||
|
@ -46,8 +46,7 @@ public:
|
||||
if (fieldData.IsType<FieldHandle>())
|
||||
fieldArray = fieldData.AsArrayHandle<FieldHandle>();
|
||||
else
|
||||
vtkm::cont::ArrayCopy(
|
||||
fieldData.ResetTypes<vtkm::TypeListFieldVec3, VTKM_DEFAULT_STORAGE_LIST>(), fieldArray);
|
||||
vtkm::cont::ArrayCopy(fieldData, fieldArray);
|
||||
|
||||
this->Eval = std::shared_ptr<GridEvalType>(new GridEvalType(ds, fieldArray));
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include <vtkm/io/VTKRectilinearGridReader.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace io
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/worklet/contourtree_augmented/Types.h>
|
||||
|
||||
@ -222,42 +223,36 @@ inline std::istream& operator>>(std::istream& inStream, SupernodeOnSuperarc& nod
|
||||
inline void TreeCompiler::AddHierarchicalTree(const vtkm::cont::DataSet& addedTree)
|
||||
{ // TreeCompiler::AddHierarchicalTree()
|
||||
// Copy relevant tree content to STL arrays
|
||||
vtkm::cont::VariantArrayHandle dataValues_array = addedTree.GetField("DataValues").GetData();
|
||||
vtkm::cont::UnknownArrayHandle dataValues_array = addedTree.GetField("DataValues").GetData();
|
||||
std::vector<vtkm::FloatDefault> dataValues(dataValues_array.GetNumberOfValues());
|
||||
auto dataValues_handle = vtkm::cont::make_ArrayHandle(dataValues, vtkm::CopyFlag::Off);
|
||||
vtkm::cont::ArrayCopy(dataValues_array.ResetTypes(vtkm::TypeListScalarAll{}), dataValues_handle);
|
||||
vtkm::cont::ArrayCopy(dataValues_array, dataValues_handle);
|
||||
dataValues_handle.SyncControlArray();
|
||||
|
||||
auto regularNodeGlobalIds_array = addedTree.GetField("RegularNodeGlobalIds").GetData();
|
||||
std::vector<vtkm::Id> regularNodeGlobalIds(regularNodeGlobalIds_array.GetNumberOfValues());
|
||||
auto regularNodeGlobalIds_handle =
|
||||
vtkm::cont::make_ArrayHandle(regularNodeGlobalIds, vtkm::CopyFlag::Off);
|
||||
vtkm::cont::ArrayCopy(
|
||||
regularNodeGlobalIds_array.ResetTypes<vtkm::TypeListId, VTKM_DEFAULT_STORAGE_LIST>(),
|
||||
regularNodeGlobalIds_handle);
|
||||
vtkm::cont::ArrayCopy(regularNodeGlobalIds_array, regularNodeGlobalIds_handle);
|
||||
regularNodeGlobalIds_handle
|
||||
.SyncControlArray(); //Forces values to get updated if copy happened on GPU
|
||||
|
||||
auto superarcs_array = addedTree.GetField("Superarcs").GetData();
|
||||
std::vector<vtkm::Id> added_tree_superarcs(superarcs_array.GetNumberOfValues());
|
||||
auto superarcs_handle = vtkm::cont::make_ArrayHandle(added_tree_superarcs, vtkm::CopyFlag::Off);
|
||||
vtkm::cont::ArrayCopy(superarcs_array.ResetTypes<vtkm::TypeListId, VTKM_DEFAULT_STORAGE_LIST>(),
|
||||
superarcs_handle);
|
||||
vtkm::cont::ArrayCopy(superarcs_array, superarcs_handle);
|
||||
superarcs_handle.SyncControlArray(); //Forces values to get updated if copy happened on GPU
|
||||
|
||||
auto supernodes_array = addedTree.GetField("Supernodes").GetData();
|
||||
std::vector<vtkm::Id> added_tree_supernodes(supernodes_array.GetNumberOfValues());
|
||||
auto supernodes_handle = vtkm::cont::make_ArrayHandle(added_tree_supernodes, vtkm::CopyFlag::Off);
|
||||
vtkm::cont::ArrayCopy(supernodes_array.ResetTypes<vtkm::TypeListId, VTKM_DEFAULT_STORAGE_LIST>(),
|
||||
supernodes_handle);
|
||||
vtkm::cont::ArrayCopy(supernodes_array, supernodes_handle);
|
||||
supernodes_handle.SyncControlArray(); //Forces values to get updated if copy happened on GPU
|
||||
|
||||
auto superparents_array = addedTree.GetField("Superparents").GetData();
|
||||
std::vector<vtkm::Id> superparents(superparents_array.GetNumberOfValues());
|
||||
auto superparents_handle = vtkm::cont::make_ArrayHandle(superparents, vtkm::CopyFlag::Off);
|
||||
vtkm::cont::ArrayCopy(
|
||||
superparents_array.ResetTypes<vtkm::TypeListId, VTKM_DEFAULT_STORAGE_LIST>(),
|
||||
superparents_handle);
|
||||
vtkm::cont::ArrayCopy(superparents_array, superparents_handle);
|
||||
superparents_handle.SyncControlArray(); //Forces values to get updated if copy happened on GPU
|
||||
|
||||
// loop through all of the supernodes in the hierarchical tree
|
||||
|
@ -838,8 +838,7 @@ void TestParticleAdvectionFile(const std::string& fname,
|
||||
if (fieldData.IsType<FieldHandle>())
|
||||
fieldArray = fieldData.AsArrayHandle<FieldHandle>();
|
||||
else
|
||||
vtkm::cont::ArrayCopy(
|
||||
fieldData.ResetTypes<vtkm::TypeListFieldVec3, VTKM_DEFAULT_STORAGE_LIST>(), fieldArray);
|
||||
vtkm::cont::ArrayCopy(fieldData, fieldArray);
|
||||
|
||||
FieldType velocities(fieldArray);
|
||||
GridEvalType eval(ds.GetCoordinateSystem(), ds.GetCellSet(), velocities);
|
||||
|
@ -8,6 +8,7 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user