diff --git a/docs/changelog/consolidate-count-to-offset.md b/docs/changelog/consolidate-count-to-offset.md new file mode 100644 index 000000000..76c8d20ce --- /dev/null +++ b/docs/changelog/consolidate-count-to-offset.md @@ -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. diff --git a/vtkm/cont/ArrayHandleGroupVecVariable.h b/vtkm/cont/ArrayHandleGroupVecVariable.h index d8b178fb7..1056378e5 100644 --- a/vtkm/cont/ArrayHandleGroupVecVariable.h +++ b/vtkm/cont/ArrayHandleGroupVecVariable.h @@ -10,14 +10,10 @@ #ifndef vtk_m_cont_ArrayHandleGroupVecVariable_h #define vtk_m_cont_ArrayHandleGroupVecVariable_h -#include -#include #include #include #include #include -#include -#include #include #include @@ -303,77 +299,6 @@ make_ArrayHandleGroupVecVariable(const ComponentsArrayHandleType& componentsArra return vtkm::cont::ArrayHandleGroupVecVariable( 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 -VTKM_CONT void ConvertNumComponentsToOffsets( - const NumComponentsArrayType& numComponentsArray, - vtkm::cont::ArrayHandle& 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(numComponentsArray), offsetsArray); - - componentsArraySize = ArrayGetValue(offsetsArray.GetNumberOfValues() - 1, offsetsArray); -} - -template -VTKM_CONT void ConvertNumComponentsToOffsets( - const NumComponentsArrayType& numComponentsArray, - vtkm::cont::ArrayHandle& 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(numComponentsArray), offsetsArray); -} - -template -VTKM_CONT vtkm::cont::ArrayHandle ConvertNumComponentsToOffsets( - const NumComponentsArrayType& numComponentsArray, - vtkm::Id& componentsArraySize, - vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny()) -{ - VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType); - - vtkm::cont::ArrayHandle offsetsArray; - vtkm::cont::ConvertNumComponentsToOffsets( - numComponentsArray, offsetsArray, componentsArraySize, device); - return offsetsArray; -} - -template -VTKM_CONT vtkm::cont::ArrayHandle 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 diff --git a/vtkm/cont/CMakeLists.txt b/vtkm/cont/CMakeLists.txt index b13a013ed..6c0aa1768 100644 --- a/vtkm/cont/CMakeLists.txt +++ b/vtkm/cont/CMakeLists.txt @@ -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 diff --git a/vtkm/cont/CellSetExplicit.h b/vtkm/cont/CellSetExplicit.h index 06f64f59b..166dbeee7 100644 --- a/vtkm/cont/CellSetExplicit.h +++ b/vtkm/cont/CellSetExplicit.h @@ -51,51 +51,6 @@ struct CellSetExplicitConnectivityChooser #define VTKM_DEFAULT_OFFSETS_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG #endif -template -void ConvertNumIndicesToOffsets(const vtkm::cont::ArrayHandle& numIndices, - vtkm::cont::ArrayHandle& offsets) -{ - VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf); - - vtkm::cont::Algorithm::ScanExtended(numIndices, offsets); -} - -template -void ConvertNumIndicesToOffsets(const vtkm::cont::ArrayHandle& numIndices, - vtkm::cont::ArrayHandle& offsets) -{ - const auto castCounts = vtkm::cont::make_ArrayHandleCast(numIndices); - ConvertNumIndicesToOffsets(castCounts, offsets); -} - -template -void ConvertNumIndicesToOffsets(const vtkm::cont::ArrayHandle& numIndices, - vtkm::cont::ArrayHandle& offsets, - vtkm::Id& connectivitySize /* outparam */) -{ - ConvertNumIndicesToOffsets(numIndices, offsets); - connectivitySize = vtkm::cont::ArrayGetValue(offsets.GetNumberOfValues() - 1, offsets); -} - -template -vtkm::cont::ArrayHandle ConvertNumIndicesToOffsets( - const vtkm::cont::ArrayHandle& numIndices) -{ - vtkm::cont::ArrayHandle offsets; - ConvertNumIndicesToOffsets(numIndices, offsets); - return offsets; -} - -template -vtkm::cont::ArrayHandle ConvertNumIndicesToOffsets( - const vtkm::cont::ArrayHandle& numIndices, - vtkm::Id& connectivityLength /* outparam */) -{ - vtkm::cont::ArrayHandle offsets; - ConvertNumIndicesToOffsets(numIndices, offsets, connectivityLength); - return offsets; -} - template diff --git a/vtkm/cont/CellSetPermutation.h b/vtkm/cont/CellSetPermutation.h index ddc3a3678..66f06f9e5 100644 --- a/vtkm/cont/CellSetPermutation.h +++ b/vtkm/cont/CellSetPermutation.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -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 diff --git a/vtkm/cont/ConvertNumComponentsToOffsets.cxx b/vtkm/cont/ConvertNumComponentsToOffsets.cxx new file mode 100644 index 000000000..8bf942190 --- /dev/null +++ b/vtkm/cont/ConvertNumComponentsToOffsets.cxx @@ -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 +#include + +#include + +#include + +namespace +{ + +struct CallNumToOffsets +{ + template + VTKM_CONT void operator()(BaseType, + const vtkm::cont::UnknownArrayHandle& numComponentsArray, + vtkm::cont::ArrayHandle& offsetsArray, + vtkm::cont::DeviceAdapterId device, + bool& converted) + { + if (!numComponentsArray.IsBaseComponentType()) + { + // Not the right type. + return; + } + + vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate( + numComponentsArray.ExtractComponent(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& 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& 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; + bool converted = false; + vtkm::ListForEach( + CallNumToOffsets{}, SupportedTypes{}, numComponentsArray, offsetsArray, device, converted); + if (!converted) + { + internal::ThrowCastAndCallException(numComponentsArray, typeid(SupportedTypes)); + } +} + +vtkm::cont::ArrayHandle ConvertNumComponentsToOffsets( + const vtkm::cont::UnknownArrayHandle& numComponentsArray, + vtkm::Id& componentsArraySize, + vtkm::cont::DeviceAdapterId device) +{ + vtkm::cont::ArrayHandle offsetsArray; + vtkm::cont::ConvertNumComponentsToOffsets( + numComponentsArray, offsetsArray, componentsArraySize, device); + return offsetsArray; +} + +vtkm::cont::ArrayHandle ConvertNumComponentsToOffsets( + const vtkm::cont::UnknownArrayHandle& numComponentsArray, + vtkm::cont::DeviceAdapterId device) +{ + vtkm::cont::ArrayHandle offsetsArray; + vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, offsetsArray, device); + return offsetsArray; +} + +} // namespace vtkm::cont +} // namespace vtkm diff --git a/vtkm/cont/ConvertNumComponentsToOffsets.h b/vtkm/cont/ConvertNumComponentsToOffsets.h new file mode 100644 index 000000000..07286927e --- /dev/null +++ b/vtkm/cont/ConvertNumComponentsToOffsets.h @@ -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 +#include +#include + +#include + +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& offsetsArray, + vtkm::Id& componentsArraySize, + vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny{}); + +VTKM_CONT_EXPORT void ConvertNumComponentsToOffsets( + const vtkm::cont::UnknownArrayHandle& numComponentsArray, + vtkm::cont::ArrayHandle& offsetsArray, + vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny{}); + +VTKM_CONT_EXPORT vtkm::cont::ArrayHandle ConvertNumComponentsToOffsets( + const vtkm::cont::UnknownArrayHandle& numComponentsArray, + vtkm::Id& componentsArraySize, + vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny{}); + +VTKM_CONT_EXPORT vtkm::cont::ArrayHandle ConvertNumComponentsToOffsets( + const vtkm::cont::UnknownArrayHandle& numComponentsArray, + vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny{}); + +/// @} + +} // namespace vtkm::cont +} // namespace vtkm + +#endif // vtk_m_cont_ConvertNumComponentsToOffsets_h diff --git a/vtkm/cont/DataSetBuilderExplicit.h b/vtkm/cont/DataSetBuilderExplicit.h index bf3c697a1..8450afba9 100644 --- a/vtkm/cont/DataSetBuilderExplicit.h +++ b/vtkm/cont/DataSetBuilderExplicit.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -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& 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( diff --git a/vtkm/cont/internal/CMakeLists.txt b/vtkm/cont/internal/CMakeLists.txt index c342848e7..72ccae355 100644 --- a/vtkm/cont/internal/CMakeLists.txt +++ b/vtkm/cont/internal/CMakeLists.txt @@ -19,6 +19,7 @@ set(headers CastInvalidValue.h CellLocatorBase.h ConnectivityExplicitInternals.h + ConvertNumComponentsToOffsetsTemplate.h DeviceAdapterAlgorithmGeneral.h DeviceAdapterMemoryManager.h DeviceAdapterMemoryManagerShared.h diff --git a/vtkm/cont/internal/ConvertNumComponentsToOffsetsTemplate.h b/vtkm/cont/internal/ConvertNumComponentsToOffsetsTemplate.h new file mode 100644 index 000000000..8bb95efee --- /dev/null +++ b/vtkm/cont/internal/ConvertNumComponentsToOffsetsTemplate.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 +#include + +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 +VTKM_CONT void ConvertNumComponentsToOffsetsTemplate( + const NumComponentsArrayType& numComponentsArray, + vtkm::cont::ArrayHandle& 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(numComponentsArray), offsetsArray); + + componentsArraySize = + vtkm::cont::ArrayGetValue(offsetsArray.GetNumberOfValues() - 1, offsetsArray); +} + +template +VTKM_CONT void ConvertNumComponentsToOffsetsTemplate( + const NumComponentsArrayType& numComponentsArray, + vtkm::cont::ArrayHandle& 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(numComponentsArray), offsetsArray); +} + +template +VTKM_CONT vtkm::cont::ArrayHandle ConvertNumComponentsToOffsetsTemplate( + const NumComponentsArrayType& numComponentsArray, + vtkm::Id& componentsArraySize, + vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny()) +{ + VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType); + + vtkm::cont::ArrayHandle offsetsArray; + vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate( + numComponentsArray, offsetsArray, componentsArraySize, device); + return offsetsArray; +} + +template +VTKM_CONT vtkm::cont::ArrayHandle ConvertNumComponentsToOffsetsTemplate( + const NumComponentsArrayType& numComponentsArray, + vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny()) +{ + VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType); + + vtkm::cont::ArrayHandle 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 diff --git a/vtkm/cont/testing/TestingFancyArrayHandles.h b/vtkm/cont/testing/TestingFancyArrayHandles.h index 3ce80ea73..51a454b1f 100644 --- a/vtkm/cont/testing/TestingFancyArrayHandles.h +++ b/vtkm/cont/testing/TestingFancyArrayHandles.h @@ -30,6 +30,7 @@ #include #include #include +#include // 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 numComponentsArray(1, 1, ARRAY_SIZE); + vtkm::cont::ArrayHandle numComponentsArray; + vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleCounting(1, 1, ARRAY_SIZE), + numComponentsArray); vtkm::cont::ArrayHandle offsetsArray = vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, sourceArraySize); @@ -1166,7 +1169,9 @@ private: { vtkm::Id sourceArraySize; - vtkm::cont::ArrayHandleCounting numComponentsArray(1, 1, ARRAY_SIZE); + vtkm::cont::ArrayHandle numComponentsArray; + vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleCounting(1, 1, ARRAY_SIZE), + numComponentsArray); vtkm::cont::ArrayHandle offsetsArray = vtkm::cont::ConvertNumComponentsToOffsets( numComponentsArray, sourceArraySize, DeviceAdapterTag()); diff --git a/vtkm/cont/testing/UnitTestArrayHandleOffsetsToNumComponents.cxx b/vtkm/cont/testing/UnitTestArrayHandleOffsetsToNumComponents.cxx index 4464cdaa1..a317f39ee 100644 --- a/vtkm/cont/testing/UnitTestArrayHandleOffsetsToNumComponents.cxx +++ b/vtkm/cont/testing/UnitTestArrayHandleOffsetsToNumComponents.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/vtkm/cont/testing/UnitTestCellSet.cxx b/vtkm/cont/testing/UnitTestCellSet.cxx index 56f9f425b..af018657f 100644 --- a/vtkm/cont/testing/UnitTestCellSet.cxx +++ b/vtkm/cont/testing/UnitTestCellSet.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #include // Make sure deprecated types still work (while applicable) @@ -153,7 +154,7 @@ vtkm::cont::CellSetExplicit<> MakeCellSetExplicit() vtkm::cont::ArrayHandle 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); diff --git a/vtkm/filter/CleanGrid.hxx b/vtkm/filter/CleanGrid.hxx index 321e3fc94..931b45a62 100644 --- a/vtkm/filter/CleanGrid.hxx +++ b/vtkm/filter/CleanGrid.hxx @@ -14,6 +14,8 @@ #include #include +#include + #include namespace vtkm @@ -45,7 +47,7 @@ vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::DataSet& inData, vtkm::cont::ArrayHandle shapes; vtkm::cont::ArrayHandle offsets; vtkm::Id connectivitySize; - vtkm::cont::ConvertNumIndicesToOffsets(numIndices, offsets, connectivitySize); + vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize); numIndices.ReleaseResourcesExecution(); vtkm::cont::ArrayHandle connectivity; diff --git a/vtkm/filter/Filter.hxx b/vtkm/filter/Filter.hxx index 78f3ba69f..fe5229f78 100644 --- a/vtkm/filter/Filter.hxx +++ b/vtkm/filter/Filter.hxx @@ -14,6 +14,7 @@ #include #include +#include #include #include #include diff --git a/vtkm/filter/particleadvection/AdvectorBaseAlgorithm.h b/vtkm/filter/particleadvection/AdvectorBaseAlgorithm.h index e33ef19e4..8695b62b9 100644 --- a/vtkm/filter/particleadvection/AdvectorBaseAlgorithm.h +++ b/vtkm/filter/particleadvection/AdvectorBaseAlgorithm.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -189,7 +190,7 @@ public: auto polyLineShape = vtkm::cont::make_ArrayHandleConstant( 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); diff --git a/vtkm/io/VTKPolyDataReader.cxx b/vtkm/io/VTKPolyDataReader.cxx index e134d6160..1dfb9f4d8 100644 --- a/vtkm/io/VTKPolyDataReader.cxx +++ b/vtkm/io/VTKPolyDataReader.cxx @@ -10,6 +10,8 @@ #include +#include + 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); diff --git a/vtkm/io/VTKUnstructuredGridReader.cxx b/vtkm/io/VTKUnstructuredGridReader.cxx index 8a5a0b136..c28ee3221 100644 --- a/vtkm/io/VTKUnstructuredGridReader.cxx +++ b/vtkm/io/VTKUnstructuredGridReader.cxx @@ -12,6 +12,8 @@ #include +#include + 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); diff --git a/vtkm/worklet/CellDeepCopy.h b/vtkm/worklet/CellDeepCopy.h index 29198c799..c6c078ded 100644 --- a/vtkm/worklet/CellDeepCopy.h +++ b/vtkm/worklet/CellDeepCopy.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -80,7 +81,7 @@ struct CellDeepCopy vtkm::cont::ArrayHandle offsets; vtkm::Id connectivitySize; - vtkm::cont::ConvertNumIndicesToOffsets(numIndices, offsets, connectivitySize); + vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize); connectivity.Allocate(connectivitySize); vtkm::worklet::DispatcherMapTopology passDispatcher; diff --git a/vtkm/worklet/Clip.h b/vtkm/worklet/Clip.h index c9fa8aaf0..ab86f8af4 100644 --- a/vtkm/worklet/Clip.h +++ b/vtkm/worklet/Clip.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/vtkm/worklet/ExternalFaces.h b/vtkm/worklet/ExternalFaces.h index 110f7b98a..3b52b9325 100644 --- a/vtkm/worklet/ExternalFaces.h +++ b/vtkm/worklet/ExternalFaces.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -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 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 diff --git a/vtkm/worklet/MIR.h b/vtkm/worklet/MIR.h index d311be828..8781840b1 100644 --- a/vtkm/worklet/MIR.h +++ b/vtkm/worklet/MIR.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -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); //} diff --git a/vtkm/worklet/StreamLineUniformGrid.h b/vtkm/worklet/StreamLineUniformGrid.h index a78caea16..51b5ed5fe 100644 --- a/vtkm/worklet/StreamLineUniformGrid.h +++ b/vtkm/worklet/StreamLineUniformGrid.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -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 connCount(0, 1, connectivityLen); diff --git a/vtkm/worklet/TriangleWinding.h b/vtkm/worklet/TriangleWinding.h index 67b20b23f..1505fcef0 100644 --- a/vtkm/worklet/TriangleWinding.h +++ b/vtkm/worklet/TriangleWinding.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -232,7 +233,7 @@ public: { // Multiple cell types: vtkm::cont::ArrayHandle offsets; vtkm::Id connSize; - vtkm::cont::ConvertNumIndicesToOffsets(numIndices, offsets, connSize); + vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connSize); numIndices.ReleaseResourcesExecution(); vtkm::cont::ArrayHandle conn; diff --git a/vtkm/worklet/connectivities/CellSetDualGraph.h b/vtkm/worklet/connectivities/CellSetDualGraph.h index 36f443ae0..c5063b35e 100644 --- a/vtkm/worklet/connectivities/CellSetDualGraph.h +++ b/vtkm/worklet/connectivities/CellSetDualGraph.h @@ -10,6 +10,7 @@ #ifndef vtk_m_worklet_connectivity_CellSetDualGraph_h #define vtk_m_worklet_connectivity_CellSetDualGraph_h +#include #include #include #include diff --git a/vtkm/worklet/contourtree_augmented/meshtypes/ContourTreeMesh.h b/vtkm/worklet/contourtree_augmented/meshtypes/ContourTreeMesh.h index ed70b9889..75776f992 100644 --- a/vtkm/worklet/contourtree_augmented/meshtypes/ContourTreeMesh.h +++ b/vtkm/worklet/contourtree_augmented/meshtypes/ContourTreeMesh.h @@ -75,6 +75,7 @@ #include #include #include +#include #include #include #include diff --git a/vtkm/worklet/cosmotools/CosmoTools.h b/vtkm/worklet/cosmotools/CosmoTools.h index faa7da3a0..297fe7b99 100644 --- a/vtkm/worklet/cosmotools/CosmoTools.h +++ b/vtkm/worklet/cosmotools/CosmoTools.h @@ -70,6 +70,7 @@ #include #include +#include #include #include #include diff --git a/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h b/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h index fc77b18d7..43365e84a 100644 --- a/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h +++ b/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -230,7 +231,7 @@ public: vtkm::cont::make_ArrayHandleConstant(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); } }; diff --git a/vtkm/worklet/testing/UnitTestCellSetDualGraph.cxx b/vtkm/worklet/testing/UnitTestCellSetDualGraph.cxx index 6cd9f6903..bf0560bab 100644 --- a/vtkm/worklet/testing/UnitTestCellSetDualGraph.cxx +++ b/vtkm/worklet/testing/UnitTestCellSetDualGraph.cxx @@ -8,6 +8,7 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ #include +#include #include #include