Commit 78c7909c authored by Kenneth Moreland's avatar Kenneth Moreland

Enable automatic transformation of Unknown/UncertainArrayHandle

parent 06579aac
......@@ -116,8 +116,20 @@ VTKM_CONT vtkm::cont::UncertainArrayHandle<NewValueTypeList, NewStorageTypeList>
{
return vtkm::cont::UncertainArrayHandle<NewValueTypeList, NewStorageTypeList>(*this);
}
namespace internal
{
template <typename ValueTypeList, typename StorageTypeList>
struct DynamicTransformTraits<vtkm::cont::UncertainArrayHandle<ValueTypeList, StorageTypeList>>
{
using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
};
} // namespace internal
}
}
} // namespace vtkm::cont
//=============================================================================
// Specializations of serialization related classes
......
......@@ -604,6 +604,18 @@ void CastAndCall(const UnknownArrayHandle& handle, Functor&& f, Args&&... args)
handle.CastAndCallForTypes<VTKM_DEFAULT_TYPE_LIST, VTKM_DEFAULT_STORAGE_LIST>(
std::forward<Functor>(f), std::forward<Args>(args)...);
}
namespace internal
{
template <>
struct DynamicTransformTraits<vtkm::cont::UnknownArrayHandle>
{
using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
};
} // namespace internal
}
} // namespace vtkm::cont
......
......@@ -10,7 +10,8 @@
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/VariantArrayHandle.h>
#include <vtkm/cont/UncertainArrayHandle.h>
#include <vtkm/cont/UnknownArrayHandle.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
......@@ -122,25 +123,26 @@ struct DoVariantTestWorklet
vtkm::cont::ArrayHandle<T> inoutHandle;
std::cout << "Create and run dispatcher with variant arrays." << std::endl;
std::cout << "Create and run dispatcher with unknown arrays." << std::endl;
vtkm::worklet::DispatcherMapField<WorkletType> dispatcher;
vtkm::cont::VariantArrayHandle inputVariant(inputHandle);
vtkm::cont::UnknownArrayHandle inputVariant(inputHandle);
{ //Verify we can pass by value
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
vtkm::cont::VariantArrayHandle outputVariant(outputHandle);
vtkm::cont::VariantArrayHandle inoutVariant(inoutHandle);
dispatcher.Invoke(inputVariant.ResetTypes(vtkm::List<T>{}),
outputVariant.ResetTypes(vtkm::List<T>{}),
inoutVariant.ResetTypes(vtkm::List<T>{}));
vtkm::cont::UnknownArrayHandle outputVariant(outputHandle);
vtkm::cont::UnknownArrayHandle inoutVariant(inoutHandle);
dispatcher.Invoke(
inputVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>(),
outputVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>(),
inoutVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>());
CheckPortal(outputHandle.ReadPortal());
CheckPortal(inoutHandle.ReadPortal());
}
{ //Verify we can pass by pointer
vtkm::cont::VariantArrayHandle outputVariant(outputHandle);
vtkm::cont::VariantArrayHandle inoutVariant(inoutHandle);
vtkm::cont::UnknownArrayHandle outputVariant(outputHandle);
vtkm::cont::UnknownArrayHandle inoutVariant(inoutHandle);
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
dispatcher.Invoke(&inputVariant, outputHandle, inoutHandle);
......
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