Merge topic 'consolidate-count-to-offset'

4c6522de2 Precompile ConvertNumComponentsToOffsets
b1343474c Consolidate count-to-offset algorithms

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Li-Ta Lo <ollie@lanl.gov>
Merge-request: !2580
This commit is contained in:
Kenneth Moreland 2021-09-17 15:44:25 +00:00 committed by Kitware Robot
commit 585ac97043
29 changed files with 352 additions and 142 deletions

@ -0,0 +1,28 @@
# Consolidate count-to-offset algorithms
For no particularly good reason, there were two functions that converted
and array of counts to an array of offsets: `ConvertNumComponentsToOffsets`
and `ConvertNumIndicesToOffsets`. These functions were identical, except
one was defined in `ArrayHandleGroupVecVariable.h` and the other was
defined in `CellSetExplicit.h`.
These two functions have been consolidated into one (which is now called
`ConvertNumComponentsToOffsets`). The consolidated function has also been
put in its own header file: `ConvertNumComponentsToOffsets.h`.
Normally, backward compatibility would be established using deprecated
features. However, one of the things being worked on is the removal of
device-specific code (e.g. `vtkm::cont::Algorithm`) from core classes like
`CellSetExplicit` so that less code needs to use the device compiler
(especially downstream code).
`ConvertNumComponentsToOffsets` has also been changed to provide a
pre-compiled version for common arrays. This helps with the dual goals of
compiling less device code and allowing data set builders to not have to
use the device compiler. For cases where you need to compile
`ConvertNumComponentsToOffsets` for a different kind of array, you can use
the internal `ConvertNumComponentsToOffsetsTemplate`.
Part of this change removed unnecessary includes of `Algorithm.h` in
`ArrayHandleGroupVecVariable.h` and `CellSetExplicit.h`. This header had to
be added to some classes that were not including it themselves.

@ -10,14 +10,10 @@
#ifndef vtk_m_cont_ArrayHandleGroupVecVariable_h
#define vtk_m_cont_ArrayHandleGroupVecVariable_h
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayGetValues.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/ArrayPortal.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/Assert.h>
#include <vtkm/VecFromPortal.h>
@ -303,77 +299,6 @@ make_ArrayHandleGroupVecVariable(const ComponentsArrayHandleType& componentsArra
return vtkm::cont::ArrayHandleGroupVecVariable<ComponentsArrayHandleType, OffsetsArrayHandleType>(
componentsArray, offsetsArray);
}
/// \c ConvertNumComponentsToOffsets takes an array of Vec sizes (i.e. the number of components in
/// each Vec) and returns an array of offsets to a packed array of such Vecs. The resulting array
/// can be used with \c ArrayHandleGroupVecVariable.
///
/// \param numComponentsArray the input array that specifies the number of components in each group
/// Vec.
///
/// \param offsetsArray (optional) the output \c ArrayHandle, which must have a value type of \c
/// vtkm::Id. If the output \c ArrayHandle is not given, it is returned.
///
/// \param componentsArraySize (optional) a reference to a \c vtkm::Id and is filled with the expected
/// size of the component values array.
///
/// \param device (optional) specifies the device on which to run the conversion.
///
template <typename NumComponentsArrayType, typename OffsetsStorage>
VTKM_CONT void ConvertNumComponentsToOffsets(
const NumComponentsArrayType& numComponentsArray,
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorage>& offsetsArray,
vtkm::Id& componentsArraySize,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
{
using namespace vtkm::cont;
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
Algorithm::ScanExtended(device, make_ArrayHandleCast<vtkm::Id>(numComponentsArray), offsetsArray);
componentsArraySize = ArrayGetValue(offsetsArray.GetNumberOfValues() - 1, offsetsArray);
}
template <typename NumComponentsArrayType, typename OffsetsStorage>
VTKM_CONT void ConvertNumComponentsToOffsets(
const NumComponentsArrayType& numComponentsArray,
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorage>& offsetsArray,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
{
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
vtkm::cont::Algorithm::ScanExtended(
device, vtkm::cont::make_ArrayHandleCast<vtkm::Id>(numComponentsArray), offsetsArray);
}
template <typename NumComponentsArrayType>
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsets(
const NumComponentsArrayType& numComponentsArray,
vtkm::Id& componentsArraySize,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
{
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray;
vtkm::cont::ConvertNumComponentsToOffsets(
numComponentsArray, offsetsArray, componentsArraySize, device);
return offsetsArray;
}
template <typename NumComponentsArrayType>
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsets(
const NumComponentsArrayType& numComponentsArray,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
{
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
vtkm::Id dummy;
return vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, dummy, device);
}
}
} // namespace vtkm::cont

@ -73,6 +73,7 @@ set(headers
ColorTable.h
ColorTableMap.h
ColorTableSamples.h
ConvertNumComponentsToOffsets.h
CoordinateSystem.h
DataSet.h
DataSetBuilderCurvilinear.h
@ -176,6 +177,7 @@ set(device_sources
CellSetExtrude.cxx
CellSetStructured.cxx
ColorTable.cxx
ConvertNumComponentsToOffsets.cxx
CoordinateSystem.cxx
DataSet.cxx
DataSetBuilderCurvilinear.cxx

@ -51,51 +51,6 @@ struct CellSetExplicitConnectivityChooser
#define VTKM_DEFAULT_OFFSETS_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
#endif
template <typename S1, typename S2>
void ConvertNumIndicesToOffsets(const vtkm::cont::ArrayHandle<vtkm::Id, S1>& numIndices,
vtkm::cont::ArrayHandle<vtkm::Id, S2>& offsets)
{
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
vtkm::cont::Algorithm::ScanExtended(numIndices, offsets);
}
template <typename T, typename S1, typename S2>
void ConvertNumIndicesToOffsets(const vtkm::cont::ArrayHandle<T, S1>& numIndices,
vtkm::cont::ArrayHandle<vtkm::Id, S2>& offsets)
{
const auto castCounts = vtkm::cont::make_ArrayHandleCast<vtkm::Id>(numIndices);
ConvertNumIndicesToOffsets(castCounts, offsets);
}
template <typename T, typename S1, typename S2>
void ConvertNumIndicesToOffsets(const vtkm::cont::ArrayHandle<T, S1>& numIndices,
vtkm::cont::ArrayHandle<vtkm::Id, S2>& offsets,
vtkm::Id& connectivitySize /* outparam */)
{
ConvertNumIndicesToOffsets(numIndices, offsets);
connectivitySize = vtkm::cont::ArrayGetValue(offsets.GetNumberOfValues() - 1, offsets);
}
template <typename T, typename S>
vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumIndicesToOffsets(
const vtkm::cont::ArrayHandle<T, S>& numIndices)
{
vtkm::cont::ArrayHandle<vtkm::Id> offsets;
ConvertNumIndicesToOffsets(numIndices, offsets);
return offsets;
}
template <typename T, typename S>
vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumIndicesToOffsets(
const vtkm::cont::ArrayHandle<T, S>& numIndices,
vtkm::Id& connectivityLength /* outparam */)
{
vtkm::cont::ArrayHandle<vtkm::Id> offsets;
ConvertNumIndicesToOffsets(numIndices, offsets, connectivityLength);
return offsets;
}
template <typename ShapesStorageTag = VTKM_DEFAULT_SHAPES_STORAGE_TAG,
typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG,
typename OffsetsStorageTag = VTKM_DEFAULT_OFFSETS_STORAGE_TAG>

@ -20,6 +20,7 @@
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/cont/internal/ConnectivityExplicitInternals.h>
#include <vtkm/cont/internal/ConvertNumComponentsToOffsetsTemplate.h>
#include <vtkm/internal/ConnectivityStructuredInternals.h>
#include <vtkm/worklet/WorkletMapTopology.h>
@ -92,7 +93,8 @@ public:
vtkm::Id& connectivityLength /* outparam */,
vtkm::cont::DeviceAdapterId)
{
return vtkm::cont::ConvertNumIndicesToOffsets(numIndices, connectivityLength);
return vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate(numIndices,
connectivityLength);
}
template <typename CellSetPermutationType, typename OffsetsStorageType>

@ -0,0 +1,103 @@
//============================================================================
// 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/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/internal/ConvertNumComponentsToOffsetsTemplate.h>
#include <vtkm/List.h>
namespace
{
struct CallNumToOffsets
{
template <typename BaseType>
VTKM_CONT void operator()(BaseType,
const vtkm::cont::UnknownArrayHandle& numComponentsArray,
vtkm::cont::ArrayHandle<vtkm::Id>& offsetsArray,
vtkm::cont::DeviceAdapterId device,
bool& converted)
{
if (!numComponentsArray.IsBaseComponentType<BaseType>())
{
// Not the right type.
return;
}
vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate(
numComponentsArray.ExtractComponent<BaseType>(0, vtkm::CopyFlag::Off), // TODO: Allow copy
offsetsArray,
device);
converted = true;
}
};
} // anonymous namespace
namespace vtkm
{
namespace cont
{
void ConvertNumComponentsToOffsets(const vtkm::cont::UnknownArrayHandle& numComponentsArray,
vtkm::cont::ArrayHandle<vtkm::Id>& offsetsArray,
vtkm::Id& componentsArraySize,
vtkm::cont::DeviceAdapterId device)
{
vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, offsetsArray, device);
componentsArraySize =
vtkm::cont::ArrayGetValue(offsetsArray.GetNumberOfValues() - 1, offsetsArray);
}
void ConvertNumComponentsToOffsets(const vtkm::cont::UnknownArrayHandle& numComponentsArray,
vtkm::cont::ArrayHandle<vtkm::Id>& offsetsArray,
vtkm::cont::DeviceAdapterId device)
{
if (numComponentsArray.GetNumberOfComponentsFlat() > 1)
{
throw vtkm::cont::ErrorBadType(
"ConvertNumComponentsToOffsets only works with arrays of integers, not Vecs.");
}
using SupportedTypes = vtkm::List<vtkm::Int32, vtkm::Int64>;
bool converted = false;
vtkm::ListForEach(
CallNumToOffsets{}, SupportedTypes{}, numComponentsArray, offsetsArray, device, converted);
if (!converted)
{
internal::ThrowCastAndCallException(numComponentsArray, typeid(SupportedTypes));
}
}
vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsets(
const vtkm::cont::UnknownArrayHandle& numComponentsArray,
vtkm::Id& componentsArraySize,
vtkm::cont::DeviceAdapterId device)
{
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray;
vtkm::cont::ConvertNumComponentsToOffsets(
numComponentsArray, offsetsArray, componentsArraySize, device);
return offsetsArray;
}
vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsets(
const vtkm::cont::UnknownArrayHandle& numComponentsArray,
vtkm::cont::DeviceAdapterId device)
{
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray;
vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, offsetsArray, device);
return offsetsArray;
}
} // namespace vtkm::cont
} // namespace vtkm

@ -0,0 +1,70 @@
//============================================================================
// 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.
//============================================================================
#ifndef vtk_m_cont_ConvertNumComponentsToOffsets_h
#define vtk_m_cont_ConvertNumComponentsToOffsets_h
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DeviceAdapterTag.h>
#include <vtkm/cont/UnknownArrayHandle.h>
#include <vtkm/cont/vtkm_cont_export.h>
namespace vtkm
{
namespace cont
{
/// @{
/// `ConvertNumComponentsToOffsets` takes an array of Vec sizes (i.e. the number of components in
/// each `Vec`) and returns an array of offsets to a packed array of such `Vec`s. The resulting
/// array can be used with `ArrayHandleGroupVecVariable`.
///
/// \param numComponentsArray the input array that specifies the number of components in each group
/// Vec.
///
/// \param offsetsArray (optional) the output \c ArrayHandle, which must have a value type of \c
/// vtkm::Id. If the output \c ArrayHandle is not given, it is returned.
///
/// \param componentsArraySize (optional) a reference to a \c vtkm::Id and is filled with the
/// expected size of the component values array.
///
/// \param device (optional) specifies the device on which to run the conversion.
///
/// Note that this function is pre-compiled for some set of `ArrayHandle` types. If you get a
/// warning about an inefficient conversion (or the operation fails outright), you might need to
/// use `vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate`.
///
VTKM_CONT_EXPORT void ConvertNumComponentsToOffsets(
const vtkm::cont::UnknownArrayHandle& numComponentsArray,
vtkm::cont::ArrayHandle<vtkm::Id>& offsetsArray,
vtkm::Id& componentsArraySize,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny{});
VTKM_CONT_EXPORT void ConvertNumComponentsToOffsets(
const vtkm::cont::UnknownArrayHandle& numComponentsArray,
vtkm::cont::ArrayHandle<vtkm::Id>& offsetsArray,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny{});
VTKM_CONT_EXPORT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsets(
const vtkm::cont::UnknownArrayHandle& numComponentsArray,
vtkm::Id& componentsArraySize,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny{});
VTKM_CONT_EXPORT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsets(
const vtkm::cont::UnknownArrayHandle& numComponentsArray,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny{});
/// @}
} // namespace vtkm::cont
} // namespace vtkm
#endif // vtk_m_cont_ConvertNumComponentsToOffsets_h

@ -14,6 +14,7 @@
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/ArrayHandleCompositeVector.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DataSet.h>
@ -84,7 +85,7 @@ public:
VTKM_ASSERT(xVals.GetNumberOfValues() == yVals.GetNumberOfValues());
VTKM_ASSERT(xVals.GetNumberOfValues() == zVals.GetNumberOfValues());
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numIndices);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numIndices);
return DataSetBuilderExplicit::BuildDataSet(
vtkm::cont::make_ArrayHandleCompositeVector(xVals, yVals, zVals),
@ -109,7 +110,7 @@ public:
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
const std::string& coordsNm = "coords")
{
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numIndices);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numIndices);
return DataSetBuilderExplicit::BuildDataSet(coords, shapes, offsets, connectivity, coordsNm);
}
@ -176,7 +177,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
auto shapesArray = vtkm::cont::make_ArrayHandle(shapes, vtkm::CopyFlag::On);
auto connArray = vtkm::cont::make_ArrayHandle(connectivity, vtkm::CopyFlag::On);
auto offsetsArray = vtkm::cont::ConvertNumIndicesToOffsets(
auto offsetsArray = vtkm::cont::ConvertNumComponentsToOffsets(
vtkm::cont::make_ArrayHandle(numIndices, vtkm::CopyFlag::Off));
return DataSetBuilderExplicit::BuildDataSet(
@ -195,7 +196,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
auto shapesArray = vtkm::cont::make_ArrayHandle(shapes, vtkm::CopyFlag::On);
auto connArray = vtkm::cont::make_ArrayHandle(connectivity, vtkm::CopyFlag::On);
auto offsetsArray = vtkm::cont::ConvertNumIndicesToOffsets(
auto offsetsArray = vtkm::cont::ConvertNumComponentsToOffsets(
vtkm::cont::make_ArrayHandle(numIndices, vtkm::CopyFlag::Off));
return DataSetBuilderExplicit::BuildDataSet(

@ -19,6 +19,7 @@ set(headers
CastInvalidValue.h
CellLocatorBase.h
ConnectivityExplicitInternals.h
ConvertNumComponentsToOffsetsTemplate.h
DeviceAdapterAlgorithmGeneral.h
DeviceAdapterMemoryManager.h
DeviceAdapterMemoryManagerShared.h

@ -0,0 +1,97 @@
//============================================================================
// 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.
//============================================================================
#ifndef vtk_m_cont_internal_ConvertNumComponentsToOffsetsTemplate_h
#define vtk_m_cont_internal_ConvertNumComponentsToOffsetsTemplate_h
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayGetValues.h>
namespace vtkm
{
namespace cont
{
namespace internal
{
/// @{
/// \brief Template implementation of `ConvertNumComponentsToOffsets`.
///
/// This form of the function can be used in situations where the precompiled
/// `ConvertNumComponentsToOffsets` does not include code paths for a desired
/// array.
///
template <typename NumComponentsArrayType, typename OffsetsStorage>
VTKM_CONT void ConvertNumComponentsToOffsetsTemplate(
const NumComponentsArrayType& numComponentsArray,
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorage>& offsetsArray,
vtkm::Id& componentsArraySize,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
{
using namespace vtkm::cont;
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
Algorithm::ScanExtended(device, make_ArrayHandleCast<vtkm::Id>(numComponentsArray), offsetsArray);
componentsArraySize =
vtkm::cont::ArrayGetValue(offsetsArray.GetNumberOfValues() - 1, offsetsArray);
}
template <typename NumComponentsArrayType, typename OffsetsStorage>
VTKM_CONT void ConvertNumComponentsToOffsetsTemplate(
const NumComponentsArrayType& numComponentsArray,
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorage>& offsetsArray,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
{
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
vtkm::cont::Algorithm::ScanExtended(
device, vtkm::cont::make_ArrayHandleCast<vtkm::Id>(numComponentsArray), offsetsArray);
}
template <typename NumComponentsArrayType>
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsetsTemplate(
const NumComponentsArrayType& numComponentsArray,
vtkm::Id& componentsArraySize,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
{
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray;
vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate(
numComponentsArray, offsetsArray, componentsArraySize, device);
return offsetsArray;
}
template <typename NumComponentsArrayType>
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsetsTemplate(
const NumComponentsArrayType& numComponentsArray,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
{
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray;
vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate(
numComponentsArray, offsetsArray, device);
return offsetsArray;
}
/// @}
} // namespace vtkm::cont::internal
} // namespace vtkm::cont
} // namespace vtkm
#endif // vtk_m_cont_internal_ConvertNumComponentsToOffsetsTemplate_h

@ -30,6 +30,7 @@
#include <vtkm/cont/ArrayHandleTransform.h>
#include <vtkm/cont/ArrayHandleView.h>
#include <vtkm/cont/ArrayHandleZip.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
// MSVC is giving deprecation warnings in stupid places, so just disable the deprecated tests
// for that compiler
@ -1111,7 +1112,9 @@ private:
{
vtkm::Id sourceArraySize;
vtkm::cont::ArrayHandleCounting<vtkm::IdComponent> numComponentsArray(1, 1, ARRAY_SIZE);
vtkm::cont::ArrayHandle<vtkm::Id> numComponentsArray;
vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleCounting<vtkm::IdComponent>(1, 1, ARRAY_SIZE),
numComponentsArray);
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray =
vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, sourceArraySize);
@ -1166,7 +1169,9 @@ private:
{
vtkm::Id sourceArraySize;
vtkm::cont::ArrayHandleCounting<vtkm::IdComponent> numComponentsArray(1, 1, ARRAY_SIZE);
vtkm::cont::ArrayHandle<vtkm::Id> numComponentsArray;
vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleCounting<vtkm::IdComponent>(1, 1, ARRAY_SIZE),
numComponentsArray);
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray = vtkm::cont::ConvertNumComponentsToOffsets(
numComponentsArray, sourceArraySize, DeviceAdapterTag());

@ -13,6 +13,7 @@
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/testing/Testing.h>
@ -46,7 +47,7 @@ void TryNormalOffsets()
numComponentsPortal.Set(i, i % 5);
}
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numComponents);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numComponents);
TestOffsetsToNumComponents(offsets, numComponents);
}

@ -17,6 +17,7 @@
#include <vtkm/cont/CellSetPermutation.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/testing/Testing.h>
// Make sure deprecated types still work (while applicable)
@ -153,7 +154,7 @@ vtkm::cont::CellSetExplicit<> MakeCellSetExplicit()
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;
vtkm::cont::ArrayCopy(BaseLineConnectivity, connectivity);
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numIndices);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numIndices);
vtkm::cont::CellSetExplicit<> cellset;
cellset.Fill(BaseLineNumberOfPoints, shapes, connectivity, offsets);

@ -14,6 +14,8 @@
#include <vtkm/worklet/CellDeepCopy.h>
#include <vtkm/worklet/RemoveUnusedPoints.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vector>
namespace vtkm
@ -45,7 +47,7 @@ vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::DataSet& inData,
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes;
vtkm::cont::ArrayHandle<vtkm::Id> offsets;
vtkm::Id connectivitySize;
vtkm::cont::ConvertNumIndicesToOffsets(numIndices, offsets, connectivitySize);
vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
numIndices.ReleaseResourcesExecution();
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;

@ -14,6 +14,7 @@
#include <vtkm/filter/internal/ResolveFieldTypeAndExecute.h>
#include <vtkm/filter/internal/ResolveFieldTypeAndMap.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/cont/Field.h>
#include <vtkm/cont/Logging.h>

@ -13,6 +13,7 @@
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/cont/ParticleArrayCopy.h>
#include <vtkm/filter/particleadvection/DataSetIntegrator.h>
@ -189,7 +190,7 @@ public:
auto polyLineShape = vtkm::cont::make_ArrayHandleConstant<vtkm::UInt8>(
vtkm::CELL_SHAPE_POLY_LINE, totalNumCells);
vtkm::cont::ArrayCopy(polyLineShape, cellTypes);
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numPointsPerCellArray);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numPointsPerCellArray);
vtkm::cont::CellSetExplicit<> polyLines;
polyLines.Fill(totalNumPts, cellTypes, connectivity, offsets);

@ -10,6 +10,8 @@
#include <vtkm/io/VTKPolyDataReader.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
namespace
{
@ -139,7 +141,7 @@ void VTKPolyDataReader::Read()
}
else
{
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numIndices);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numIndices);
vtkm::cont::CellSetExplicit<> cellSet;
cellSet.Fill(numPoints, shapes, connectivity, offsets);
this->DataSet.SetCellSet(cellSet);

@ -12,6 +12,8 @@
#include <vtkm/io/internal/VTKDataSetCells.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
namespace vtkm
{
namespace io
@ -74,7 +76,7 @@ void VTKUnstructuredGridReader::Read()
}
else
{
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numIndices);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numIndices);
vtkm::cont::CellSetExplicit<> cellSet;
cellSet.Fill(numPoints, shapes, connectivity, offsets);
this->DataSet.SetCellSet(cellSet);

@ -13,6 +13,7 @@
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleGroupVecVariable.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
@ -80,7 +81,7 @@ struct CellDeepCopy
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorage> offsets;
vtkm::Id connectivitySize;
vtkm::cont::ConvertNumIndicesToOffsets(numIndices, offsets, connectivitySize);
vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
connectivity.Allocate(connectivitySize);
vtkm::worklet::DispatcherMapTopology<PassCellStructure> passDispatcher;

@ -24,6 +24,7 @@
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/ArrayHandleView.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/Timer.h>
@ -690,7 +691,7 @@ public:
vtkm::Id numberOfPoints = scalars.GetNumberOfValues() +
this->EdgePointsInterpolation.GetNumberOfValues() + total.NumberOfInCellPoints;
vtkm::cont::ConvertNumIndicesToOffsets(numberOfIndices, offsets);
vtkm::cont::ConvertNumComponentsToOffsets(numberOfIndices, offsets);
output.Fill(numberOfPoints, shapes, connectivity, offsets);
return output;

@ -29,6 +29,7 @@
#include <vtkm/cont/ArrayHandleTransform.h>
#include <vtkm/cont/ArrayHandleView.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Field.h>
#include <vtkm/cont/Timer.h>
@ -770,7 +771,7 @@ public:
vtkm::cont::make_ArrayHandleGroupVec<4>(faceConnectivity),
coordData);
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(facePointCount);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(facePointCount);
outCellSet.Fill(inCellSet.GetNumberOfPoints(), faceShapes, faceConnectivity, offsets);
}
@ -823,7 +824,7 @@ public:
countPolyDataCellPointsDispatcher.Invoke(inCellSet, polyDataPointCount);
vtkm::cont::ConvertNumIndicesToOffsets(
vtkm::cont::ConvertNumComponentsToOffsets(
polyDataPointCount, polyDataOffsets, polyDataConnectivitySize);
vtkm::worklet::DispatcherMapTopology<PassPolyDataCells> passPolyDataCellsDispatcher(
@ -884,7 +885,7 @@ public:
OffsetsArrayType faceOffsets;
vtkm::Id connectivitySize;
vtkm::cont::ConvertNumIndicesToOffsets(facePointCount, faceOffsets, connectivitySize);
vtkm::cont::ConvertNumComponentsToOffsets(facePointCount, faceOffsets, connectivitySize);
ConnectivityArrayType faceConnectivity;
// Must pre allocate because worklet invocation will not have enough

@ -24,6 +24,7 @@
#include <vtkm/cont/ArrayHandleView.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/CellSetPermutation.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/ErrorFilterExecution.h>
@ -839,7 +840,7 @@ public:
vtkm::Id numberOfPoints = cellSet.GetNumberOfPoints() +
this->EdgePointsInterpolation.GetNumberOfValues() + total.NumberOfInCellPoints;
vtkm::cont::ConvertNumIndicesToOffsets(numberOfIndices, offset);
vtkm::cont::ConvertNumComponentsToOffsets(numberOfIndices, offset);
// Create explicit cell set output
output.Fill(numberOfPoints, shapes, connectivity, offset);
//}

@ -16,6 +16,7 @@
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/Field.h>
@ -382,7 +383,7 @@ public:
// Size of connectivity based on size of returned streamlines
vtkm::Id connectivityLen;
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numIndices, connectivityLen);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numIndices, connectivityLen);
// Connectivity is sequential
vtkm::cont::ArrayHandleCounting<vtkm::Id> connCount(0, 1, connectivityLen);

@ -32,6 +32,7 @@
#include <vtkm/cont/ArrayRangeCompute.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/Invoker.h>
@ -232,7 +233,7 @@ public:
{ // Multiple cell types:
vtkm::cont::ArrayHandle<vtkm::Id> offsets;
vtkm::Id connSize;
vtkm::cont::ConvertNumIndicesToOffsets(numIndices, offsets, connSize);
vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connSize);
numIndices.ReleaseResourcesExecution();
vtkm::cont::ArrayHandle<vtkm::Id> conn;

@ -10,6 +10,7 @@
#ifndef vtk_m_worklet_connectivity_CellSetDualGraph_h
#define vtk_m_worklet_connectivity_CellSetDualGraph_h
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/exec/CellEdge.h>
#include <vtkm/worklet/DispatcherMapField.h>

@ -75,6 +75,7 @@
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ArrayRangeCompute.h>
#include <vtkm/cont/ArrayRangeComputeTemplate.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/EnvironmentTracker.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/io/ErrorIO.h>

@ -70,6 +70,7 @@
#include <vtkm/worklet/cosmotools/EqualsMinimumPotential.h>
#include <vtkm/worklet/cosmotools/SetCandidateParticles.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayHandleCompositeVector.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleCounting.h>

@ -18,6 +18,7 @@
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/ExecutionObjectBase.h>
#include <vtkm/Particle.h>
@ -230,7 +231,7 @@ public:
vtkm::cont::make_ArrayHandleConstant<vtkm::UInt8>(vtkm::CELL_SHAPE_POLY_LINE, numSeeds);
vtkm::cont::ArrayCopy(polyLineShape, cellTypes);
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numPoints);
auto offsets = vtkm::cont::ConvertNumComponentsToOffsets(numPoints);
polyLines.Fill(positions.GetNumberOfValues(), cellTypes, connectivity, offsets);
}
};

@ -8,6 +8,7 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/ArrayHandleGroupVecVariable.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/Contour.h>