Remove invalid PortalType

Several ArrayHandles (actuall Storage implementations) had a fake portal
type that only defined invalid value types and no Get/Set methods. The
idea was to quickly identify when using a read-only array for writing.
However, this was more trouble than it was worth as the compiler just
gives  an incomprehensible error and it is hard to track down the actual
value.

Now actually define some type even if it is never used.
This commit is contained in:
Kenneth Moreland 2019-07-17 18:39:00 -06:00
parent 8d3310fe55
commit 6d37ce9453
4 changed files with 42 additions and 35 deletions

@ -16,6 +16,8 @@
#include <vtkm/cont/ExecutionAndControlObjectBase.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
#include <vtkm/internal/ArrayPortalHelpers.h>
#include <vtkm/cont/serial/internal/DeviceAdapterRuntimeDetectorSerial.h>
namespace vtkm
@ -148,7 +150,8 @@ public:
VTKM_EXEC_CONT
void Set(vtkm::Id index, const ValueType& value) const
{
return this->Portal.Set(index, this->InverseFunctor(value));
using call_supported_t = typename vtkm::internal::PortalSupportsSets<PortalType>::type;
this->Set(call_supported_t(), index, value);
}
VTKM_SUPPRESS_EXEC_WARNINGS
@ -157,6 +160,14 @@ public:
private:
InverseFunctorType InverseFunctor;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
inline void Set(std::true_type, vtkm::Id index, const ValueType& value) const
{
this->Portal.Set(index, this->InverseFunctor(value));
}
VTKM_EXEC_CONT inline void Set(std::false_type, vtkm::Id, const ValueType&) const {}
};
}
}
@ -274,19 +285,16 @@ class Storage<typename StorageTagTransform<ArrayHandleType, FunctorType>::ValueT
public:
using ValueType = typename StorageTagTransform<ArrayHandleType, FunctorType>::ValueType;
// This is meant to be invalid. Because Transform arrays are read only, you
// should only be able to use the const version.
struct PortalType
{
using ValueType = void*;
using IteratorType = void*;
};
using PortalConstType =
vtkm::exec::internal::ArrayPortalTransform<ValueType,
typename ArrayHandleType::PortalConstControl,
typename FunctorManager::FunctorType>;
// Note that this array is read only, so you really should only be getting the const
// version of the portal. If you actually try to write to this portal, you will
// get an error.
using PortalType = PortalConstType;
VTKM_CONT
Storage()
: Valid(false)

@ -12,6 +12,8 @@
#include <vtkm/internal/IndicesExtrude.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/cont/tbb/DeviceAdapterTBB.h>
@ -97,17 +99,14 @@ class VTKM_ALWAYS_EXPORT Storage<T, internal::StorageTagExtrudePlane>
public:
using ValueType = T;
// This is meant to be invalid. Because point arrays are read only, you
// should only be able to use the const version.
struct PortalType
{
using ValueType = void*;
using IteratorType = void*;
};
using PortalConstType =
vtkm::exec::ArrayPortalExtrudePlane<typename HandleType::PortalConstControl>;
// Note that this array is read only, so you really should only be getting the const
// version of the portal. If you actually try to write to this portal, you will
// get an error.
using PortalType = PortalConstType;
Storage()
: Array()
, NumberOfPlanes(0)
@ -120,7 +119,11 @@ public:
{
}
PortalType GetPortal() { return PortalType{}; }
PortalType GetPortal()
{
throw vtkm::cont::ErrorBadType(
"Extrude ArrayHandles are read only. Cannot get writable portal.");
}
PortalConstType GetPortalConst() const
{
@ -382,16 +385,13 @@ class Storage<T, internal::StorageTagExtrude>
public:
using ValueType = T;
// This is meant to be invalid. Because point arrays are read only, you
// should only be able to use the const version.
struct PortalType
{
using ValueType = void*;
using IteratorType = void*;
};
using PortalConstType = exec::ArrayPortalExtrude<TPortalType>;
// Note that this array is read only, so you really should only be getting the const
// version of the portal. If you actually try to write to this portal, you will
// get an error.
using PortalType = PortalConstType;
Storage()
: Array()
, NumberOfPlanes(0)
@ -415,7 +415,11 @@ public:
VTKM_ASSERT(this->Array.GetNumberOfValues() >= 0);
}
PortalType GetPortal() { return PortalType{}; }
PortalType GetPortal()
{
throw vtkm::cont::ErrorBadType(
"Extrude ArrayHandles are read only. Cannot get writable portal.");
}
PortalConstType GetPortalConst() const
{

@ -53,13 +53,9 @@ public:
using ValueType = typename ArrayPortalType::ValueType;
using PortalConstType = ArrayPortalType;
// This is meant to be invalid. Because implicit arrays are read only, you
// should only be able to use the const version.
struct PortalType
{
using ValueType = void*;
using IteratorType = void*;
};
// Note that this portal is likely to be read-only, so you will probably get an error
// if you try to write to it.
using PortalType = ArrayPortalType;
VTKM_CONT
Storage(const PortalConstType& portal = PortalConstType())

@ -56,7 +56,6 @@ struct TemplatedTests
using ValueType = typename StorageType::ValueType;
using PortalType = typename StorageType::PortalType;
using IteratorType = typename PortalType::IteratorType;
void BasicAllocation()
{