Commit 0e847f2c authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot

Merge topic 'remove_cellset_need_of_default_device'

46843ff4 CellSetExplicit has no dependency on default vtk-m device
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland's avatarKenneth Moreland <kmorel@sandia.gov>
Merge-request: !1636
parents 9cf1dc18 46843ff4
......@@ -255,7 +255,7 @@ VTKM_CONT void
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, ItemTupleLength>& ids) const
{
this->Data->PointToCell.BuildIndexOffsets(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
this->Data->PointToCell.BuildIndexOffsets(vtkm::cont::DeviceAdapterTagAny{});
vtkm::IdComponent numIndices = this->GetNumberOfPointsInCell(index);
vtkm::Id start = this->Data->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
for (vtkm::IdComponent i = 0; i < numIndices && i < ItemTupleLength; i++)
......@@ -272,7 +272,7 @@ VTKM_CONT void
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle<vtkm::Id>& ids) const
{
this->Data->PointToCell.BuildIndexOffsets(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
this->Data->PointToCell.BuildIndexOffsets(vtkm::cont::DeviceAdapterTagAny{});
vtkm::IdComponent numIndices = this->GetNumberOfPointsInCell(index);
ids.Allocate(numIndices);
vtkm::Id start = this->Data->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
......
......@@ -24,6 +24,7 @@
#include <vtkm/cont/TryExecute.h>
#include <vtkm/cont/internal/TransferInfo.h>
#include <vtkm/cont/internal/VirtualObjectTransfer.h>
#include <vtkm/cont/internal/VirtualObjectTransferShareWithControl.h>
namespace vtkm
......
......@@ -21,11 +21,11 @@
#define vtk_m_cont_internal_ConnectivityExplicitInternals_h
#include <vtkm/CellShape.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/internal/DeviceAdapterError.h>
#include <vtkm/cont/internal/ReverseConnectivityBuilder.h>
#include <vtkm/exec/ExecutionWholeArray.h>
......@@ -37,10 +37,10 @@ namespace cont
namespace internal
{
template <typename NumIndicesArrayType, typename IndexOffsetArrayType, typename DeviceAdapterTag>
template <typename NumIndicesArrayType, typename IndexOffsetArrayType>
void buildIndexOffsets(const NumIndicesArrayType& numIndices,
IndexOffsetArrayType& offsets,
DeviceAdapterTag,
vtkm::cont::DeviceAdapterId device,
std::true_type)
{
//We first need to make sure that NumIndices and IndexOffsetArrayType
......@@ -50,14 +50,13 @@ void buildIndexOffsets(const NumIndicesArrayType& numIndices,
// Although technically we are making changes to this object, the changes
// are logically consistent with the previous state, so we consider it
// valid under const.
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>;
Algorithm::ScanExclusive(CastedNumIndicesType(numIndices), offsets);
vtkm::cont::Algorithm::ScanExclusive(device, CastedNumIndicesType(numIndices), offsets);
}
template <typename NumIndicesArrayType, typename IndexOffsetArrayType, typename DeviceAdapterTag>
template <typename NumIndicesArrayType, typename IndexOffsetArrayType>
void buildIndexOffsets(const NumIndicesArrayType&,
IndexOffsetArrayType&,
DeviceAdapterTag,
vtkm::cont::DeviceAdapterId,
std::false_type)
{
//this is a no-op as the storage for the offsets is an implicit handle
......@@ -67,13 +66,13 @@ void buildIndexOffsets(const NumIndicesArrayType&,
//cause a compile time failure.
}
template <typename ArrayHandleIndices, typename ArrayHandleOffsets, typename DeviceAdapterTag>
template <typename ArrayHandleIndices, typename ArrayHandleOffsets>
void buildIndexOffsets(const ArrayHandleIndices& numIndices,
ArrayHandleOffsets offsets,
DeviceAdapterTag tag)
vtkm::cont::DeviceAdapterId deviceId)
{
using IsWriteable = vtkm::cont::internal::IsWriteableArrayHandle<ArrayHandleOffsets>;
buildIndexOffsets(numIndices, offsets, tag, typename IsWriteable::type());
buildIndexOffsets(numIndices, offsets, deviceId, typename IsWriteable::type());
}
template <typename ShapeStorageTag = VTKM_DEFAULT_STORAGE_TAG,
......@@ -119,25 +118,24 @@ struct ConnectivityExplicitInternals
this->IndexOffsets.ReleaseResourcesExecution();
}
template <typename Device>
VTKM_CONT void BuildIndexOffsets(Device) const
{
VTKM_ASSERT(this->ElementsValid);
if (!this->IndexOffsetsValid)
VTKM_CONT void BuildIndexOffsets(vtkm::cont::DeviceAdapterId deviceId) const
{
if (deviceId == vtkm::cont::DeviceAdapterTagUndefined())
{
buildIndexOffsets(this->NumIndices, this->IndexOffsets, Device());
this->IndexOffsetsValid = true;
throw vtkm::cont::ErrorBadValue("Cannot build indices using DeviceAdapterTagUndefined");
}
if (deviceId == vtkm::cont::DeviceAdapterTagError())
{
throw vtkm::cont::ErrorBadValue("Cannot build indices using DeviceAdapterTagError");
}
}
VTKM_CONT
void BuildIndexOffsets(vtkm::cont::DeviceAdapterTagError) const
{
VTKM_ASSERT(this->ElementsValid);
if (!this->IndexOffsetsValid)
{
throw vtkm::cont::ErrorBadType(
"Cannot build indices using the error device. Must be created previously.");
buildIndexOffsets(this->NumIndices, this->IndexOffsets, deviceId);
this->IndexOffsetsValid = true;
}
}
......
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