From 399acf83da5eda166dfcbc614d8f0beb7057ae3e Mon Sep 17 00:00:00 2001 From: Julian Stahl Date: Thu, 8 Sep 2022 18:21:52 +0200 Subject: [PATCH] Fix benchmarks again? --- .../benchmark/Isosurfacing_3/CMakeLists.txt | 4 ++ .../benchmark/Isosurfacing_3/benchmark.cpp | 45 ++++++++++++------- .../Isosurfacing_3/benchmark_util.py | 4 +- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Isosurfacing_3/benchmark/Isosurfacing_3/CMakeLists.txt b/Isosurfacing_3/benchmark/Isosurfacing_3/CMakeLists.txt index fa14f3abee3..722c6770a76 100644 --- a/Isosurfacing_3/benchmark/Isosurfacing_3/CMakeLists.txt +++ b/Isosurfacing_3/benchmark/Isosurfacing_3/CMakeLists.txt @@ -12,4 +12,8 @@ find_package(TBB) include(CGAL_TBB_support) if(TARGET CGAL::TBB_support) target_link_libraries(benchmark PUBLIC CGAL::TBB_support) + target_compile_definitions(benchmark PUBLIC ${SCENARIO}) + target_compile_definitions(benchmark PUBLIC ${KERNEL}) + target_compile_definitions(benchmark PUBLIC ${ALGO}) + target_compile_definitions(benchmark PUBLIC ${TAG}) endif() diff --git a/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark.cpp b/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark.cpp index 4223d8e5d2b..79d7e2f8c74 100644 --- a/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark.cpp +++ b/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark.cpp @@ -38,15 +38,20 @@ struct Implicit_sphere { typedef CGAL::Isosurfacing::Implicit_domain, SphereGradient> Domain; typedef typename GeomTraits::Vector_3 Vector; - Domain domain(const std::size_t N) const { + Implicit_sphere(const std::size_t N) : res(2.0 / N, 2.0 / N, 2.0 / N) {} - const Vector res(2.0 / N, 2.0 / N, 2.0 / N); - return Domain({-1, -1, -1, 1, 1, 1}, res, SphereValue(), SphereGradient()); + Domain domain() const { + return Domain({-1, -1, -1, 1, 1, 1}, res, val, grad); } typename GeomTraits::FT iso() const { return 0.8; } + +private: + SphereValue val; + SphereGradient grad; + Vector res; }; template @@ -57,14 +62,11 @@ struct Grid_sphere { typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Point_3 Point; - Domain domain(const std::size_t N) const { - + Grid_sphere(const std::size_t N) : grid(N, N, N, {-1, -1, -1, 1, 1, 1}) { const FT resolution = 2.0 / N; SphereValue val; SphereGradient grad; - Grid grid(N, N, N, {-1, -1, -1, 1, 1, 1}); - for (std::size_t x = 0; x < grid.xdim(); x++) { const FT xp = x * resolution - 1.0; @@ -79,12 +81,18 @@ struct Grid_sphere { } } } + } + + Domain domain() const { return Domain(grid); } typename GeomTraits::FT iso() const { return 0.8; } + +private: + Grid grid; }; template @@ -93,8 +101,7 @@ struct Skull_image { typedef CGAL::Isosurfacing::Cartesian_grid_domain Domain; typedef CGAL::Cartesian_grid_3 Grid; - Domain domain(const std::size_t N) const { - + Skull_image(const std::size_t N) : grid(2, 2, 2, {-1, -1, -1, 1, 1, 1}) { const std::string fname = "../data/skull_2.9.inr"; CGAL::Image_3 image; if (!image.read(fname)) { @@ -102,13 +109,19 @@ struct Skull_image { return EXIT_FAILURE; } - const Grid grid(image); + grid = Grid(image); + } + + Domain domain() const { return Domain(grid); } typename GeomTraits::FT iso() const { return 2.9; } + +private: + Grid grid; }; int main(int argc, char* argv[]) { @@ -143,13 +156,13 @@ int main(int argc, char* argv[]) { #if defined SCENARIO_GRID_SPHERE std::cout << "SCENARIO_GRID_SPHERE" << std::endl; - auto scenario = Grid_sphere(); + auto scenario = Grid_sphere(N); #elif defined SCENARIO_IMPLICIT_SPHERE std::cout << "SCENARIO_IMPLICIT_SPHERE" << std::endl; - auto scenario = Implicit_sphere(); + auto scenario = Implicit_sphere(N); #elif defined SCENARIO_SKULL_IMAGE std::cout << "SCENARIO_SKULL_IMAGE" << std::endl; - auto scenario = Skull_image(); + auto scenario = Skull_image(N); #else std::cout << "no scenario selected!" << std::endl; auto scenario = Implicit_sphere(); @@ -173,14 +186,14 @@ int main(int argc, char* argv[]) { #if defined ALGO_MARCHING_CUBES std::cout << "ALGO_MARCHING_CUBES" << std::endl; - CGAL::Isosurfacing::make_triangle_mesh_using_marching_cubes(scenario.domain(N), scenario.iso(), points, + CGAL::Isosurfacing::make_triangle_mesh_using_marching_cubes(scenario.domain(), scenario.iso(), points, polygons); #elif defined ALGO_DUAL_CONTOURING std::cout << "ALGO_DUAL_CONTOURING" << std::endl; - CGAL::Isosurfacing::make_quad_mesh_using_dual_contouring(scenario.domain(N), scenario.iso(), points, polygons); + CGAL::Isosurfacing::make_quad_mesh_using_dual_contouring(scenario.domain(), scenario.iso(), points, polygons); #else std::cout << "no algorithm selected!" << std::endl; - CGAL::Isosurfacing::make_triangle_mesh_using_marching_cubes(scenario.domain(N), scenario.iso(), points, + CGAL::Isosurfacing::make_triangle_mesh_using_marching_cubes(scenario.domain(), scenario.iso(), points, polygons); #endif diff --git a/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark_util.py b/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark_util.py index 991635fc28c..1e0dc66e218 100644 --- a/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark_util.py +++ b/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark_util.py @@ -23,8 +23,8 @@ def run(cmd, output=True): def build(scenario, kernel, algorithm, tag): run(["cmake", "-E", "make_directory", "build"]) - run(["cmake", "-B", "build", "-DCMAKE_BUILD_TYPE=Release", "-DCGAL_DIR=../../../"]) - run(["make", "-C", "build", "CXX_FLAGS='-D" + scenario + " -D" + kernel + " -D" + algorithm + " -D" + tag + "'"]) + run(["cmake", "-B", "build", "-DCMAKE_BUILD_TYPE=Release", "-DSCENARIO=" + scenario, "-DKERNEL=" + kernel, "-DALGO=" + algorithm, "-DTAG=" + tag, "-DCGAL_DIR=../../../"]) + run(["make", "-C", "build"]) def execute(n, threads, times=1): time = 0