From a290de5bcc8e6afb663e59f992f871bcaac2578d Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Mon, 5 Oct 2020 17:50:47 -0400 Subject: [PATCH] BenchmarkFilters: adds unstructured Dataset for some filters - It also remove termination on bench error - It disables passing fields in Countour to skip an error. Signed-off-by: Vicente Adolfo Bolea Sanchez --- benchmarking/BenchmarkFilters.cxx | 35 +++++++++++++++++++++---------- vtkm/filter/Triangulate.hxx | 13 ++++++------ 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/benchmarking/BenchmarkFilters.cxx b/benchmarking/BenchmarkFilters.cxx index fc9ff1e59..76411a93d 100644 --- a/benchmarking/BenchmarkFilters.cxx +++ b/benchmarking/BenchmarkFilters.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -38,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -91,12 +93,15 @@ vtkm::cont::InitializeResult Config; // The input dataset we'll use on the filters: static vtkm::cont::DataSet InputDataSet; +static vtkm::cont::DataSet UnstructuredInputDataSet; // The point scalars to use: static std::string PointScalarsName; // The cell scalars to use: static std::string CellScalarsName; // The point vectors to use: static std::string PointVectorsName; +// Whether the input is a file or is generated +bool FileAsInput = false; bool InputIsStructured() { @@ -398,7 +403,9 @@ void BenchContourGenerator(::benchmark::internal::Benchmark* bm) helper(3); helper(12); } -VTKM_BENCHMARK_APPLY(BenchContour, BenchContourGenerator); + +// :TODO: Disabled until SIGSEGV in Countour when passings field is resolved +//VTKM_BENCHMARK_APPLY(BenchContour, BenchContourGenerator); void BenchExternalFaces(::benchmark::State& state) { @@ -427,10 +434,9 @@ void BenchTetrahedralize(::benchmark::State& state) const vtkm::cont::DeviceAdapterId device = Config.Device; // This filter only supports structured datasets: - if (!InputIsStructured()) + if (FileAsInput && !InputIsStructured()) { state.SkipWithError("Tetrahedralize Filter requires structured data."); - return; } vtkm::filter::Tetrahedralize filter; @@ -455,10 +461,9 @@ void BenchVertexClustering(::benchmark::State& state) const vtkm::Id numDivs = static_cast(state.range(0)); // This filter only supports unstructured datasets: - if (InputIsStructured()) + if (FileAsInput && InputIsStructured()) { - state.SkipWithError("VertexClustering Filter requires unstructured data."); - return; + state.SkipWithError("VertexClustering Filter requires unstructured data (use --tetra)."); } vtkm::filter::VertexClustering filter; @@ -468,8 +473,9 @@ void BenchVertexClustering(::benchmark::State& state) for (auto _ : state) { (void)_; + timer.Start(); - auto result = filter.Execute(InputDataSet); + auto result = filter.Execute(UnstructuredInputDataSet); ::benchmark::DoNotOptimize(result); timer.Stop(); @@ -529,13 +535,12 @@ struct PrepareForInput void BenchReverseConnectivityGen(::benchmark::State& state) { - if (InputIsStructured()) + if (FileAsInput && InputIsStructured()) { - state.SkipWithError("ReverseConnectivityGen requires unstructured data."); - return; + state.SkipWithError("ReverseConnectivityGen requires unstructured data (--use tetra)."); } - auto cellset = InputDataSet.GetCellSet(); + auto cellset = UnstructuredInputDataSet.GetCellSet(); PrepareForInput functor; for (auto _ : state) { @@ -978,6 +983,7 @@ void InitDataSet(int& argc, char** argv) std::cerr << "[InitDataSet] Loading file: " << filename << "\n"; vtkm::io::VTKDataSetReader reader(filename); InputDataSet = reader.ReadDataSet(); + FileAsInput = true; } else { @@ -987,8 +993,15 @@ void InitDataSet(int& argc, char** argv) source.SetExtent({ 0 }, { waveletDim - 1 }); InputDataSet = source.Execute(); + + vtkm::cont::DataSet input = vtkm::cont::testing::MakeTestDataSet().Make2DUniformDataSet2(); + vtkm::filter::Triangulate triangulateFilter; + triangulateFilter.SetFieldsToPass( + vtkm::filter::FieldSelection(vtkm::filter::FieldSelection::MODE_ALL)); + UnstructuredInputDataSet = triangulateFilter.Execute(input); } + if (tetra) { std::cerr << "[InitDataSet] Tetrahedralizing dataset...\n"; diff --git a/vtkm/filter/Triangulate.hxx b/vtkm/filter/Triangulate.hxx index bd1ae667d..ec7745091 100644 --- a/vtkm/filter/Triangulate.hxx +++ b/vtkm/filter/Triangulate.hxx @@ -17,13 +17,14 @@ namespace { -class DeduceCellSet +class DeduceCellSetTriangulate { vtkm::worklet::Triangulate& Worklet; vtkm::cont::CellSetSingleType<>& OutCellSet; public: - DeduceCellSet(vtkm::worklet::Triangulate& worklet, vtkm::cont::CellSetSingleType<>& outCellSet) + DeduceCellSetTriangulate(vtkm::worklet::Triangulate& worklet, + vtkm::cont::CellSetSingleType<>& outCellSet) : Worklet(worklet) , OutCellSet(outCellSet) { @@ -35,17 +36,17 @@ public: } }; template <> -void DeduceCellSet::operator()(const vtkm::cont::CellSetExplicit<>& cellset) const +void DeduceCellSetTriangulate::operator()(const vtkm::cont::CellSetExplicit<>& cellset) const { this->OutCellSet = Worklet.Run(cellset); } template <> -void DeduceCellSet::operator()(const vtkm::cont::CellSetStructured<2>& cellset) const +void DeduceCellSetTriangulate::operator()(const vtkm::cont::CellSetStructured<2>& cellset) const { this->OutCellSet = Worklet.Run(cellset); } template <> -void DeduceCellSet::operator()(const vtkm::cont::CellSetStructured<3>& cellset) const +void DeduceCellSetTriangulate::operator()(const vtkm::cont::CellSetStructured<3>& cellset) const { this->OutCellSet = Worklet.Run(cellset); } @@ -72,7 +73,7 @@ inline VTKM_CONT vtkm::cont::DataSet Triangulate::DoExecute( const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(); vtkm::cont::CellSetSingleType<> outCellSet; - DeduceCellSet triangulate(this->Worklet, outCellSet); + DeduceCellSetTriangulate triangulate(this->Worklet, outCellSet); vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), triangulate);