diff --git a/benchmarking/CMakeLists.txt b/benchmarking/CMakeLists.txt index 2cf18da0c..aa2946cce 100644 --- a/benchmarking/CMakeLists.txt +++ b/benchmarking/CMakeLists.txt @@ -48,14 +48,6 @@ set(benchmarks BenchmarkTopologyAlgorithms ) -#Taking too long to compile with HIPCC -if(HIP IN_LIST Kokkos_DEVICES) - list(REMOVE_ITEM benchmarks - BenchmarkDeviceAdapter - BenchmarkODEIntegrators - ) -endif() - set(VTKm_BENCHS_RANGE_LOWER_BOUNDARY 4096 CACHE STRING "Smallest sample for input size bench for BenchmarkDeviceAdapter") set(VTKm_BENCHS_RANGE_UPPER_BOUNDARY 134217728 CACHE STRING "Biggest sample for input size bench for BenchmarkDeviceAdapter") mark_as_advanced(VTKm_BENCHS_RANGE_LOWER_BOUNDARY VTKm_BENCHS_RANGE_UPPER_BOUNDARY) @@ -64,10 +56,8 @@ foreach (benchmark ${benchmarks}) add_benchmark(NAME ${benchmark} FILE ${benchmark}.cxx LIBS vtkm_source vtkm_filter vtkm_io) endforeach () -if(NOT HIP IN_LIST Kokkos_DEVICES) - target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_LOWER_BOUNDARY=${VTKm_BENCHS_RANGE_LOWER_BOUNDARY}) - target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_UPPER_BOUNDARY=${VTKm_BENCHS_RANGE_UPPER_BOUNDARY}) -endif() +target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_LOWER_BOUNDARY=${VTKm_BENCHS_RANGE_LOWER_BOUNDARY}) +target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_UPPER_BOUNDARY=${VTKm_BENCHS_RANGE_UPPER_BOUNDARY}) if(TARGET vtkm_rendering) add_benchmark(NAME BenchmarkRayTracing FILE BenchmarkRayTracing.cxx LIBS vtkm_rendering vtkm_source) diff --git a/examples/demo/CMakeLists.txt b/examples/demo/CMakeLists.txt index 71e67a6b2..4a247a340 100644 --- a/examples/demo/CMakeLists.txt +++ b/examples/demo/CMakeLists.txt @@ -16,7 +16,4 @@ find_package(VTKm REQUIRED QUIET) if(TARGET vtkm_rendering) add_executable(Demo Demo.cxx) target_link_libraries(Demo PRIVATE vtkm_filter vtkm_rendering vtkm_source) - vtkm_add_target_information(Demo - DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS - DEVICE_SOURCES Demo.cxx) endif() diff --git a/examples/multi_backend/MultiDeviceGradient.hxx b/examples/multi_backend/MultiDeviceGradient.hxx index db3362f7f..2bbd87b26 100644 --- a/examples/multi_backend/MultiDeviceGradient.hxx +++ b/examples/multi_backend/MultiDeviceGradient.hxx @@ -17,8 +17,6 @@ #include -#include - namespace { diff --git a/vtkm/List.h b/vtkm/List.h index d2ad8179a..c9686f6fb 100644 --- a/vtkm/List.h +++ b/vtkm/List.h @@ -14,6 +14,8 @@ #include +#include + namespace vtkm { diff --git a/vtkm/filter/CMakeLists.txt b/vtkm/filter/CMakeLists.txt index e922fbf55..3349c8327 100644 --- a/vtkm/filter/CMakeLists.txt +++ b/vtkm/filter/CMakeLists.txt @@ -46,6 +46,7 @@ set(deprecated_headers PointAverage.h PointElevation.h PointTransform.h + Probe.h Slice.h SplitSharpEdges.h SurfaceNormals.h @@ -106,7 +107,6 @@ set(extra_headers ParticleAdvection.h Pathline.h PathParticle.h - Probe.h Streamline.h StreamSurface.h ) @@ -121,7 +121,6 @@ set(extra_header_template_sources ParticleAdvection.hxx Pathline.hxx PathParticle.hxx - Probe.hxx Streamline.hxx StreamSurface.hxx ) @@ -199,6 +198,7 @@ add_subdirectory(field_conversion) add_subdirectory(field_transform) add_subdirectory(geometry_refinement) add_subdirectory(mesh_info) +add_subdirectory(resampling) add_subdirectory(vector_analysis) add_subdirectory(zfp) diff --git a/vtkm/filter/NewFilter.h b/vtkm/filter/NewFilter.h index df597cb7f..4651f77f0 100644 --- a/vtkm/filter/NewFilter.h +++ b/vtkm/filter/NewFilter.h @@ -420,9 +420,6 @@ protected: const vtkm::cont::PartitionedDataSet& inData); private: - VTKM_CONT - virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input); - template VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input, vtkm::cont::DataSet& output, @@ -438,6 +435,10 @@ private: } } + VTKM_CONT + virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input); + + vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All; bool RunFilterWithMultipleThreads = false; }; diff --git a/vtkm/filter/Probe.h b/vtkm/filter/Probe.h index 55ef54d80..561576a15 100644 --- a/vtkm/filter/Probe.h +++ b/vtkm/filter/Probe.h @@ -10,53 +10,23 @@ #ifndef vtk_m_filter_Probe_h #define vtk_m_filter_Probe_h -#include -#include +#include +#include namespace vtkm { namespace filter { -class Probe : public vtkm::filter::FilterDataSet +VTKM_DEPRECATED(1.8, "Use vtkm/filter/resampling/Probe.h instead of vtkm/filter/Probe.h.") +inline void Probe_deprecated() {} + +inline void Probe_deprecated_warning() { -public: - VTKM_CONT - void SetGeometry(const vtkm::cont::DataSet& geometry); - - VTKM_CONT - const vtkm::cont::DataSet& GetGeometry() const; - - VTKM_CONT void SetInvalidValue(vtkm::Float64 invalidValue) { this->InvalidValue = invalidValue; } - VTKM_CONT vtkm::Float64 GetInvalidValue() const { return this->InvalidValue; } - - template - VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy); - - //Map a new field onto the resulting dataset after running the filter - //this call is only valid after calling DoExecute. - template - VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase); - - template - VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result, - const vtkm::cont::ArrayHandle& input, - const vtkm::filter::FieldMetadata& fieldMeta, - vtkm::filter::PolicyBase policy); - -private: - vtkm::cont::DataSet Geometry; - vtkm::worklet::Probe Worklet; - vtkm::Float64 InvalidValue = vtkm::Nan64(); -}; + Probe_deprecated(); } -} // vtkm::filter -#ifndef vtk_m_filter_Probe_hxx -#include -#endif +} +} // namespace vtkm::filter -#endif // vtk_m_filter_Probe_h +#endif //vtk_m_filter_Probe_h diff --git a/vtkm/filter/Probe.hxx b/vtkm/filter/Probe.hxx deleted file mode 100644 index 3c2a99b1a..000000000 --- a/vtkm/filter/Probe.hxx +++ /dev/null @@ -1,111 +0,0 @@ -//============================================================================ -// 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_filter_Probe_hxx -#define vtk_m_filter_Probe_hxx - -#include - -#include - -#include - -namespace vtkm -{ -namespace filter -{ - -VTKM_CONT -inline void Probe::SetGeometry(const vtkm::cont::DataSet& geometry) -{ - this->Geometry = vtkm::cont::DataSet(); - this->Geometry.SetCellSet(geometry.GetCellSet()); - this->Geometry.AddCoordinateSystem(geometry.GetCoordinateSystem()); -} - -VTKM_CONT -inline const vtkm::cont::DataSet& Probe::GetGeometry() const -{ - return this->Geometry; -} - -template -VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute( - const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy) -{ - this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this), - input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()), - this->Geometry.GetCoordinateSystem().GetData()); - - auto output = this->Geometry; - auto hpf = this->Worklet.GetHiddenPointsField(); - auto hcf = this->Worklet.GetHiddenCellsField( - vtkm::filter::ApplyPolicyCellSet(output.GetCellSet(), policy, *this)); - - output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf)); - output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf)); - - return output; -} - -template -VTKM_CONT inline bool Probe::MapFieldOntoOutput(vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy) -{ - if (field.IsFieldPoint()) - { - // If the field is a point field, then we need to do a custom interpolation of the points. - // In this case, we need to call the superclass's MapFieldOntoOutput, which will in turn - // call our DoMapField. - return this->FilterDataSet::MapFieldOntoOutput(result, field, policy); - } - else if (field.IsFieldCell()) - { - vtkm::cont::Field outField; - if (vtkm::filter::MapFieldPermutation( - field, this->Worklet.GetCellIds(), outField, this->InvalidValue)) - { - // output field should be associated with points - outField = vtkm::cont::Field( - field.GetName(), vtkm::cont::Field::Association::Points, outField.GetData()); - result.AddField(outField); - return true; - } - return false; - } - else if (field.IsFieldGlobal()) - { - result.AddField(field); - return true; - } - else - { - return false; - } -} - -template -VTKM_CONT inline bool Probe::DoMapField(vtkm::cont::DataSet& result, - const vtkm::cont::ArrayHandle& input, - const vtkm::filter::FieldMetadata& fieldMeta, - vtkm::filter::PolicyBase) -{ - VTKM_ASSERT(fieldMeta.IsPointField()); - auto fieldArray = - this->Worklet.ProcessPointField(input, - vtkm::cont::internal::CastInvalidValue(this->InvalidValue), - typename DerivedPolicy::AllCellSetList()); - result.AddField(fieldMeta.AsField(fieldArray)); - return true; -} -} -} // vtkm::filter -#endif diff --git a/vtkm/filter/resampling/CMakeLists.txt b/vtkm/filter/resampling/CMakeLists.txt new file mode 100644 index 000000000..51f5c0074 --- /dev/null +++ b/vtkm/filter/resampling/CMakeLists.txt @@ -0,0 +1,32 @@ +##============================================================================ +## 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. +##============================================================================ +set(resampling_headers + Probe.h + ) + +set(resampling_sources + Probe.cxx) + +vtkm_library( + NAME vtkm_filter_resampling + HEADERS ${resampling_headers} + DEVICE_SOURCES ${resampling_sources} + USE_VTKM_JOB_POOL +) + +target_link_libraries(vtkm_filter_resampling PUBLIC vtkm_worklet vtkm_filter_core) +target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_resampling) + +add_subdirectory(worklet) + +#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - +if (VTKm_ENABLE_TESTING) + add_subdirectory(testing) +endif () diff --git a/vtkm/filter/resampling/Probe.cxx b/vtkm/filter/resampling/Probe.cxx new file mode 100644 index 000000000..c492d5088 --- /dev/null +++ b/vtkm/filter/resampling/Probe.cxx @@ -0,0 +1,83 @@ +//============================================================================ +// 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 vtkm +{ +namespace filter +{ +namespace resampling +{ +vtkm::cont::DataSet Probe::DoExecute(const vtkm::cont::DataSet& input) +{ + vtkm::worklet::Probe worklet; + worklet.Run(input.GetCellSet(), + input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()), + this->Geometry.GetCoordinateSystem().GetData()); + + auto mapper = [&](auto& outDataSet, const auto& f) { this->DoMapField(outDataSet, f, worklet); }; + auto output = this->CreateResult( + input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystems(), mapper); + output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", worklet.GetHiddenPointsField())); + output.AddField( + vtkm::cont::make_FieldCell("HIDDEN", worklet.GetHiddenCellsField(output.GetCellSet()))); + + return output; +} + + +bool Probe::DoMapField(vtkm::cont::DataSet& result, + const vtkm::cont::Field& field, + const vtkm::worklet::Probe& worklet) +{ + if (field.IsFieldPoint()) + { + auto resolve = [&](const auto& concrete) { + using T = typename std::decay_t::ValueType; + vtkm::cont::ArrayHandle outputArray = worklet.ProcessPointField( + concrete, vtkm::cont::internal::CastInvalidValue(this->InvalidValue)); + result.AddPointField(field.GetName(), outputArray); + }; + field.GetData() + .CastAndCallForTypesWithFloatFallback( + resolve); + return true; + } + else if (field.IsFieldCell()) + { + vtkm::cont::Field outField; + if (vtkm::filter::MapFieldPermutation( + field, worklet.GetCellIds(), outField, this->InvalidValue)) + { + // output field should be associated with points + outField = vtkm::cont::Field( + field.GetName(), vtkm::cont::Field::Association::Points, outField.GetData()); + result.AddField(outField); + return true; + } + return false; + } + else if (field.IsFieldGlobal()) + { + result.AddField(field); + return true; + } + else + { + return false; + } +} +} // namespace resampling +} // namespace filter +} // namespace vtkm diff --git a/vtkm/filter/resampling/Probe.h b/vtkm/filter/resampling/Probe.h new file mode 100644 index 000000000..01291c6fd --- /dev/null +++ b/vtkm/filter/resampling/Probe.h @@ -0,0 +1,65 @@ +//============================================================================ +// 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_filter_Probe_h +#define vtk_m_filter_Probe_h + +#include +#include + +namespace vtkm +{ +namespace worklet +{ +class Probe; +} + +namespace filter +{ +namespace resampling +{ +class VTKM_FILTER_RESAMPLING_EXPORT Probe : public vtkm::filter::NewFilterField +{ +public: + VTKM_CONT + void SetGeometry(const vtkm::cont::DataSet& geometry) + { + this->Geometry = vtkm::cont::DataSet(); + this->Geometry.CopyStructure(geometry); + } + + VTKM_CONT + const vtkm::cont::DataSet& GetGeometry() const { return this->Geometry; } + + VTKM_CONT void SetInvalidValue(vtkm::Float64 invalidValue) { this->InvalidValue = invalidValue; } + VTKM_CONT vtkm::Float64 GetInvalidValue() const { return this->InvalidValue; } + +private: + VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; + + bool DoMapField(vtkm::cont::DataSet& result, + const vtkm::cont::Field& field, + const vtkm::worklet::Probe& worklet); + + vtkm::cont::DataSet Geometry; + + vtkm::Float64 InvalidValue = vtkm::Nan64(); +}; +} // namespace resampling + +class VTKM_DEPRECATED(1.8, "Use vtkm::filter::resampling::Probe.") Probe + : public vtkm::filter::resampling::Probe +{ + using resampling::Probe::Probe; +}; + +} // namespace filter +} // namespace vtkm + +#endif // vtk_m_filter_Probe_h diff --git a/vtkm/filter/resampling/testing/CMakeLists.txt b/vtkm/filter/resampling/testing/CMakeLists.txt new file mode 100644 index 000000000..299260f36 --- /dev/null +++ b/vtkm/filter/resampling/testing/CMakeLists.txt @@ -0,0 +1,24 @@ +##============================================================================ +## 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. +##============================================================================ + +set(unit_tests + UnitTestProbe.cxx + ) + +set(libraries + vtkm_filter_clean_grid + vtkm_filter_resampling + ) + +vtkm_unit_tests( + SOURCES ${unit_tests} + LIBRARIES ${libraries} + USE_VTKM_JOB_POOL +) diff --git a/vtkm/filter/testing/UnitTestProbe.cxx b/vtkm/filter/resampling/testing/UnitTestProbe.cxx similarity index 93% rename from vtkm/filter/testing/UnitTestProbe.cxx rename to vtkm/filter/resampling/testing/UnitTestProbe.cxx index 2928b10ec..4887aa032 100644 --- a/vtkm/filter/testing/UnitTestProbe.cxx +++ b/vtkm/filter/resampling/testing/UnitTestProbe.cxx @@ -7,13 +7,12 @@ // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include - #include #include #include -#include +#include +#include namespace { @@ -46,22 +45,9 @@ vtkm::cont::DataSet MakeGeometryDataSet() vtkm::cont::DataSet ConvertDataSetUniformToExplicit(const vtkm::cont::DataSet& uds) { - vtkm::cont::DataSet eds; - vtkm::cont::CellSetExplicit<> cs; - vtkm::worklet::CellDeepCopy::Run(uds.GetCellSet(), cs); - eds.SetCellSet(cs); - - vtkm::cont::ArrayHandle points; - vtkm::cont::ArrayCopy(uds.GetCoordinateSystem().GetData(), points); - eds.AddCoordinateSystem( - vtkm::cont::CoordinateSystem(uds.GetCoordinateSystem().GetName(), points)); - - for (vtkm::IdComponent i = 0; i < uds.GetNumberOfFields(); ++i) - { - eds.AddField(uds.GetField(i)); - } - - return eds; + vtkm::filter::clean_grid::CleanGrid toUnstructured; + toUnstructured.SetMergePoints(true); + return toUnstructured.Execute(uds); } const std::vector& GetExpectedPointData() @@ -153,7 +139,7 @@ private: auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet()); auto geometry = MakeGeometryDataSet(); - vtkm::filter::Probe probe; + vtkm::filter::resampling::Probe probe; probe.SetGeometry(geometry); probe.SetFieldsToPass({ "pointdata", "celldata" }); auto output = probe.Execute(input); @@ -175,7 +161,7 @@ private: auto input = MakeInputDataSet(); auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet()); - vtkm::filter::Probe probe; + vtkm::filter::resampling::Probe probe; probe.SetGeometry(geometry); probe.SetFieldsToPass({ "pointdata", "celldata" }); auto output = probe.Execute(input); @@ -197,7 +183,7 @@ private: auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet()); auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet()); - vtkm::filter::Probe probe; + vtkm::filter::resampling::Probe probe; probe.SetGeometry(geometry); probe.SetFieldsToPass({ "pointdata", "celldata" }); auto output = probe.Execute(input); diff --git a/vtkm/filter/resampling/worklet/CMakeLists.txt b/vtkm/filter/resampling/worklet/CMakeLists.txt new file mode 100644 index 000000000..3aa9b2d67 --- /dev/null +++ b/vtkm/filter/resampling/worklet/CMakeLists.txt @@ -0,0 +1,15 @@ +##============================================================================ +## 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. +##============================================================================ + +set(headers + Probe.h + ) + +vtkm_declare_headers(${headers}) diff --git a/vtkm/worklet/Probe.h b/vtkm/filter/resampling/worklet/Probe.h similarity index 100% rename from vtkm/worklet/Probe.h rename to vtkm/filter/resampling/worklet/Probe.h diff --git a/vtkm/filter/testing/CMakeLists.txt b/vtkm/filter/testing/CMakeLists.txt index 8c0a5e132..52fb18fc3 100644 --- a/vtkm/filter/testing/CMakeLists.txt +++ b/vtkm/filter/testing/CMakeLists.txt @@ -24,21 +24,10 @@ set(unit_tests UnitTestMapFieldPermutation.cxx UnitTestMultiBlockFilter.cxx UnitTestPartitionedDataSetFilters.cxx - UnitTestProbe.cxx UnitTestStreamlineFilter.cxx UnitTestStreamSurfaceFilter.cxx ) -#Taking too long to compile with HIPCC -if(HIP IN_LIST Kokkos_DEVICES) - list(REMOVE_ITEM unit_tests - UnitTestLagrangianFilter.cxx - UnitTestLagrangianStructuresFilter.cxx - UnitTestStreamlineFilter.cxx - UnitTestStreamSurfaceFilter.cxx - ) -endif() - set(libraries vtkm_filter vtkm_io diff --git a/vtkm/worklet/CMakeLists.txt b/vtkm/worklet/CMakeLists.txt index 61d1b295d..4451eb56d 100644 --- a/vtkm/worklet/CMakeLists.txt +++ b/vtkm/worklet/CMakeLists.txt @@ -32,7 +32,6 @@ set(headers NDimsHistMarginalization.h Normalize.h ParticleAdvection.h - Probe.h ScalarsToColors.h ScatterCounting.h ScatterIdentity.h diff --git a/vtkm/worklet/internal/testing/CMakeLists.txt b/vtkm/worklet/internal/testing/CMakeLists.txt index 0102c9c10..30fec2e66 100644 --- a/vtkm/worklet/internal/testing/CMakeLists.txt +++ b/vtkm/worklet/internal/testing/CMakeLists.txt @@ -8,11 +8,8 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -#Failing on HIP backend(crash) -if(NOT HIP IN_LIST Kokkos_DEVICES) - set(unit_tests - UnitTestDispatcherBase.cxx +set(unit_tests + UnitTestDispatcherBase.cxx ) - vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG) -endif() +vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG) diff --git a/vtkm/worklet/internal/testing/UnitTestDispatcherBase.cxx b/vtkm/worklet/internal/testing/UnitTestDispatcherBase.cxx index d17fcafba..bb1658574 100644 --- a/vtkm/worklet/internal/testing/UnitTestDispatcherBase.cxx +++ b/vtkm/worklet/internal/testing/UnitTestDispatcherBase.cxx @@ -12,6 +12,8 @@ #include +#include + #include namespace @@ -111,45 +113,44 @@ namespace arg { template <> -struct TypeCheck> +struct TypeCheck { static constexpr bool value = true; }; template -struct Transport, Device> +struct Transport { using ExecObjectType = TestExecObjectIn; VTKM_CONT - ExecObjectType operator()(const std::vector& contData, - const std::vector&, + ExecObjectType operator()(const vtkm::cont::internal::Buffer& contData, + const vtkm::cont::internal::Buffer&, vtkm::Id inputRange, vtkm::Id outputRange, - vtkm::cont::Token&) const + vtkm::cont::Token& token) const { VTKM_TEST_ASSERT(inputRange == ARRAY_SIZE, "Got unexpected size in test transport."); VTKM_TEST_ASSERT(outputRange == ARRAY_SIZE, "Got unexpected size in test transport."); - return ExecObjectType(contData.data()); + return reinterpret_cast(contData.ReadPointerDevice(Device{}, token)); } }; template -struct Transport, Device> +struct Transport { using ExecObjectType = TestExecObjectOut; VTKM_CONT - ExecObjectType operator()(const std::vector& contData, - const std::vector&, + ExecObjectType operator()(const vtkm::cont::internal::Buffer& contData, + const vtkm::cont::internal::Buffer&, vtkm::Id inputRange, vtkm::Id outputRange, - vtkm::cont::Token&) const + vtkm::cont::Token& token) const { VTKM_TEST_ASSERT(inputRange == ARRAY_SIZE, "Got unexpected size in test transport."); VTKM_TEST_ASSERT(outputRange == ARRAY_SIZE, "Got unexpected size in test transport."); - auto ptr = const_cast(contData.data()); - return ExecObjectType(ptr); + return reinterpret_cast(contData.WritePointerDevice(Device{}, token)); } }; } @@ -283,15 +284,13 @@ public: }; -template -inline vtkm::Id SchedulingRange(const std::vector& inputDomain) +inline vtkm::Id SchedulingRange(const vtkm::cont::internal::Buffer& inputDomain) { - return static_cast(inputDomain.size()); + return static_cast(inputDomain.GetNumberOfBytes() / sizeof(vtkm::Id)); } -template -inline vtkm::Id SchedulingRange(const std::vector* const inputDomain) +inline vtkm::Id SchedulingRange(const vtkm::cont::internal::Buffer* inputDomain) { - return static_cast(inputDomain->size()); + return static_cast(inputDomain->GetNumberOfBytes() / sizeof(vtkm::Id)); } template @@ -345,28 +344,41 @@ void TestBasicInvoke() { std::cout << "Test basic invoke" << std::endl; std::cout << " Set up data." << std::endl; - std::vector inputArray(ARRAY_SIZE); - std::vector outputArray(ARRAY_SIZE); + vtkm::cont::internal::Buffer inputBuffer; + vtkm::cont::internal::Buffer outputBuffer; TestExecObjectType execObject; execObject.Value = EXPECTED_EXEC_OBJECT_VALUE; - std::size_t i = 0; - for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++) { - inputArray[i] = TestValue(index, vtkm::Id()); - outputArray[i] = static_cast(0xDEADDEAD); + vtkm::cont::Token token; + inputBuffer.SetNumberOfBytes( + static_cast(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token); + outputBuffer.SetNumberOfBytes( + static_cast(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token); + auto inputArray = reinterpret_cast(inputBuffer.WritePointerHost(token)); + auto outputArray = reinterpret_cast(outputBuffer.WritePointerHost(token)); + std::size_t i = 0; + for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++) + { + inputArray[i] = TestValue(index, vtkm::Id()); + outputArray[i] = static_cast(0xDEADDEAD); + } } std::cout << " Create and run dispatcher." << std::endl; TestDispatcher dispatcher; - dispatcher.Invoke(inputArray, execObject, &outputArray); + dispatcher.Invoke(inputBuffer, execObject, &outputBuffer); std::cout << " Check output of invoke." << std::endl; - i = 0; - for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++) { - VTKM_TEST_ASSERT(outputArray[i] == TestValue(index, vtkm::Id()) + 1000, - "Got bad value from testing."); + vtkm::cont::Token token; + auto outputArray = reinterpret_cast(outputBuffer.ReadPointerHost(token)); + std::size_t i = 0; + for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++) + { + VTKM_TEST_ASSERT(outputArray[i] == TestValue(index, vtkm::Id()) + 1000, + "Got bad value from testing."); + } } } @@ -374,23 +386,32 @@ void TestInvokeWithError() { std::cout << "Test invoke with error raised" << std::endl; std::cout << " Set up data." << std::endl; - std::vector inputArray(ARRAY_SIZE); - std::vector outputArray(ARRAY_SIZE); + vtkm::cont::internal::Buffer inputBuffer; + vtkm::cont::internal::Buffer outputBuffer; TestExecObjectType execObject; execObject.Value = EXPECTED_EXEC_OBJECT_VALUE; - std::size_t i = 0; - for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, ++i) { - inputArray[i] = TestValue(index, vtkm::Id()); - outputArray[i] = static_cast(0xDEADDEAD); + vtkm::cont::Token token; + inputBuffer.SetNumberOfBytes( + static_cast(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token); + outputBuffer.SetNumberOfBytes( + static_cast(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token); + auto inputArray = reinterpret_cast(inputBuffer.WritePointerHost(token)); + auto outputArray = reinterpret_cast(outputBuffer.WritePointerHost(token)); + std::size_t i = 0; + for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++) + { + inputArray[i] = TestValue(index, vtkm::Id()); + outputArray[i] = static_cast(0xDEADDEAD); + } } try { std::cout << " Create and run dispatcher that raises error." << std::endl; TestDispatcher dispatcher; - dispatcher.Invoke(&inputArray, execObject, outputArray); + dispatcher.Invoke(&inputBuffer, execObject, outputBuffer); VTKM_TEST_FAIL("Exception not thrown."); } catch (vtkm::cont::ErrorExecution& error) diff --git a/vtkm/worklet/testing/CMakeLists.txt b/vtkm/worklet/testing/CMakeLists.txt index 40fdd504d..013332198 100644 --- a/vtkm/worklet/testing/CMakeLists.txt +++ b/vtkm/worklet/testing/CMakeLists.txt @@ -29,7 +29,6 @@ set(unit_tests UnitTestNormalize.cxx UnitTestNDimsHistMarginalization.cxx UnitTestParticleAdvection.cxx - UnitTestProbe.cxx UnitTestScalarsToColors.cxx UnitTestScatterAndMask.cxx UnitTestScatterCounting.cxx @@ -53,13 +52,6 @@ set(unit_tests UnitTestWaveletCompressor.cxx ) -if(HIP IN_LIST Kokkos_DEVICES) - list(REMOVE_ITEM unit_tests - UnitTestParticleAdvection.cxx # Taking too long to compile with HIPCC - UnitTestScalarsToColors.cxx # Failing: incorrect results - ) -endif() - vtkm_unit_tests( SOURCES ${unit_tests} LIBRARIES vtkm_source vtkm_worklet vtkm_filter vtkm_io diff --git a/vtkm/worklet/testing/UnitTestProbe.cxx b/vtkm/worklet/testing/UnitTestProbe.cxx deleted file mode 100644 index 928ede5c7..000000000 --- a/vtkm/worklet/testing/UnitTestProbe.cxx +++ /dev/null @@ -1,211 +0,0 @@ -//============================================================================ -// 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 -#include - -#include - -namespace -{ - -vtkm::cont::DataSet MakeInputDataSet() -{ - auto input = vtkm::cont::DataSetBuilderUniform::Create( - vtkm::Id2(4, 4), vtkm::make_Vec(0.0f, 0.0f), vtkm::make_Vec(1.0f, 1.0f)); - input.AddPointField("pointdata", vtkm::cont::make_ArrayHandleCounting(0.0f, 0.3f, 16)); - input.AddCellField("celldata", vtkm::cont::make_ArrayHandleCounting(0.0f, 0.7f, 9)); - return input; -} - -vtkm::cont::DataSet MakeGeometryDataSet() -{ - auto geometry = vtkm::cont::DataSetBuilderUniform::Create( - vtkm::Id2(9, 9), vtkm::make_Vec(0.7f, 0.7f), vtkm::make_Vec(0.35f, 0.35f)); - return geometry; -} - -vtkm::cont::DataSet ConvertDataSetUniformToExplicit(const vtkm::cont::DataSet& uds) -{ - vtkm::cont::DataSet eds; - - vtkm::cont::CellSetExplicit<> cs; - vtkm::worklet::CellDeepCopy::Run(uds.GetCellSet(), cs); - eds.SetCellSet(cs); - - vtkm::cont::ArrayHandle points; - vtkm::cont::ArrayCopy(uds.GetCoordinateSystem().GetData(), points); - eds.AddCoordinateSystem( - vtkm::cont::CoordinateSystem(uds.GetCoordinateSystem().GetName(), points)); - - for (vtkm::IdComponent i = 0; i < uds.GetNumberOfFields(); ++i) - { - eds.AddField(uds.GetField(i)); - } - - return eds; -} - -const std::vector& GetExpectedPointData() -{ - static std::vector expected = { - 1.05f, 1.155f, 1.26f, 1.365f, 1.47f, 1.575f, 1.68f, 0.0f, 0.0f, 1.47f, 1.575f, 1.68f, - 1.785f, 1.89f, 1.995f, 2.1f, 0.0f, 0.0f, 1.89f, 1.995f, 2.1f, 2.205f, 2.31f, 2.415f, - 2.52f, 0.0f, 0.0f, 2.31f, 2.415f, 2.52f, 2.625f, 2.73f, 2.835f, 2.94f, 0.0f, 0.0f, - 2.73f, 2.835f, 2.94f, 3.045f, 3.15f, 3.255f, 3.36f, 0.0f, 0.0f, 3.15f, 3.255f, 3.36f, - 3.465f, 3.57f, 3.675f, 3.78f, 0.0f, 0.0f, 3.57f, 3.675f, 3.78f, 3.885f, 3.99f, 4.095f, - 4.2f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f - }; - return expected; -} - -const std::vector& GetExpectedCellData() -{ - static std::vector expected = { - 0.0f, 0.7f, 0.7f, 0.7f, 1.4f, 1.4f, 1.4f, 0.0f, 0.0f, 2.1f, 2.8f, 2.8f, 2.8f, 3.5f, - 3.5f, 3.5f, 0.0f, 0.0f, 2.1f, 2.8f, 2.8f, 2.8f, 3.5f, 3.5f, 3.5f, 0.0f, 0.0f, 2.1f, - 2.8f, 2.8f, 2.8f, 3.5f, 3.5f, 3.5f, 0.0f, 0.0f, 4.2f, 4.9f, 4.9f, 4.9f, 5.6f, 5.6f, - 5.6f, 0.0f, 0.0f, 4.2f, 4.9f, 4.9f, 4.9f, 5.6f, 5.6f, 5.6f, 0.0f, 0.0f, 4.2f, 4.9f, - 4.9f, 4.9f, 5.6f, 5.6f, 5.6f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f - }; - return expected; -} - -const std::vector& GetExpectedHiddenPoints() -{ - static std::vector expected = { 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, - 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, - 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; - return expected; -} - -const std::vector& GetExpectedHiddenCells() -{ - static std::vector expected = { 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, - 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, - 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; - return expected; -} - -template -void TestResultArray(const vtkm::cont::ArrayHandle& result, const std::vector& expected) -{ - vtkm::cont::printSummary_ArrayHandle(result, std::cout); - VTKM_TEST_ASSERT(result.GetNumberOfValues() == static_cast(expected.size()), - "Incorrect field size"); - - auto portal = result.ReadPortal(); - vtkm::Id size = portal.GetNumberOfValues(); - for (vtkm::Id i = 0; i < size; ++i) - { - VTKM_TEST_ASSERT(test_equal(portal.Get(i), expected[static_cast(i)]), - "Incorrect field value"); - } -} - -class TestProbe -{ -private: - using FieldArrayType = vtkm::cont::ArrayHandleCounting; - - static void ExplicitToUnifrom() - { - std::cout << "Testing Probe Explicit to Uniform:\n"; - - auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet()); - auto geometry = MakeGeometryDataSet(); - - vtkm::worklet::Probe probe; - probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem()); - - auto pf = probe.ProcessPointField( - input.GetField("pointdata").GetData().AsArrayHandle(), 0.0f); - auto cf = probe.ProcessCellField( - input.GetField("celldata").GetData().AsArrayHandle(), 0.0f); - auto hp = probe.GetHiddenPointsField(); - auto hc = probe.GetHiddenCellsField(geometry.GetCellSet()); - - TestResultArray(pf, GetExpectedPointData()); - TestResultArray(cf, GetExpectedCellData()); - TestResultArray(hp, GetExpectedHiddenPoints()); - TestResultArray(hc, GetExpectedHiddenCells()); - } - - static void UniformToExplict() - { - std::cout << "Testing Probe Uniform to Explicit:\n"; - - auto input = MakeInputDataSet(); - auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet()); - - vtkm::worklet::Probe probe; - probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem()); - - auto pf = probe.ProcessPointField( - input.GetField("pointdata").GetData().AsArrayHandle(), 0.0f); - auto cf = probe.ProcessCellField( - input.GetField("celldata").GetData().AsArrayHandle(), 0.0f); - - auto hp = probe.GetHiddenPointsField(); - auto hc = probe.GetHiddenCellsField(geometry.GetCellSet()); - - TestResultArray(pf, GetExpectedPointData()); - TestResultArray(cf, GetExpectedCellData()); - TestResultArray(hp, GetExpectedHiddenPoints()); - TestResultArray(hc, GetExpectedHiddenCells()); - } - - static void ExplicitToExplict() - { - std::cout << "Testing Probe Explicit to Explicit:\n"; - - auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet()); - auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet()); - - vtkm::worklet::Probe probe; - probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem()); - - auto pf = probe.ProcessPointField( - input.GetField("pointdata").GetData().AsArrayHandle(), 0.0f); - auto cf = probe.ProcessCellField( - input.GetField("celldata").GetData().AsArrayHandle(), 0.0f); - - auto hp = probe.GetHiddenPointsField(); - auto hc = probe.GetHiddenCellsField(geometry.GetCellSet()); - - TestResultArray(pf, GetExpectedPointData()); - TestResultArray(cf, GetExpectedCellData()); - TestResultArray(hp, GetExpectedHiddenPoints()); - TestResultArray(hc, GetExpectedHiddenCells()); - } - -public: - static void Run() - { - ExplicitToUnifrom(); - UniformToExplict(); - ExplicitToExplict(); - } -}; - -} // anonymous namespace - -int UnitTestProbe(int argc, char* argv[]) -{ - return vtkm::cont::testing::Testing::Run(TestProbe::Run, argc, argv); -}