Subject: CGAL users discussion list
List archive
[cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares
Chronological Thread
- From: Valentin Pi <>
- To:
- Subject: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares
- Date: Tue, 9 Jan 2024 00:09:18 +0100
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-data: A9a23:4Eu2nK8Q/PqTHkAnG7gXDrUD1nuTJUtcMsCJ2f8bNWPcYEJGY0x3y WFKXmCGPfeDY2Lzedkgatjj90kFuJTXyoVnS1E/qnpEQiMRo6IpJ/zJdxaqZ3v6wu7rFR88s Z1GMrEsCOhuExcwcz/0auCJQUFUjP3OHPymYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArlV ena+qUzA3f7nWYoWo4ow/jb8k835ayi4GhwUmEWPJingneOzxH5M7pEfcldH1OgKqFIE+izQ fr0zb3R1gs1KD9wYj8Nuu+TnnwiGtY+DyDW4pZlc/TKbix5m8AH+v1T2Mzwxqtgo27hc9hZk L2hvHErIOsjFvWkdO81C3G0H8ziVEHvFXCuzXWX6KSuI0P6n3TEzeVcJhAzIZcko8lcJnNw7 ftFLw4scUXW7w626OrTpuhEg8M+MI/kOZNZvHx8pd3bJax/G9aZGfqMvIIehWdYasNmRZ4yY +IHYD5iagzBSxJKKhEbBfrSmc/x2iSiKmQC9wz9SawfwnDY6Qhg96LWc/3bY+2mQJ4WwEaBu TeTl4j+KlRAXDCF8hKO/Xuow+POhijmQ5k6D6y97vcsgVuJx2VVBgd+aLegify+l1L4VNdPb UoZ5kLCsJQPyaBidfGlNzXQnZJOlkd0twN4QrBiujKegLHZ+RiYDWUiRztMIo5u/swvSDBgk hfDk9r1DHY9+PeYWFCMxIey9DmSACkyKXNdRCkmSQBe3cLvjrtuhT3yT/FiMpWPsPvLJR/Kz QunlhMO34cosZZT1oGQ30z2vDa3l52YEi83/lr2W0ym3CNYZamkRYqi2VfG39l9LaKybFqIj F4bkeew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/hlWBcl1drqOZHmsfUfP9C/XPQVOEMK3XnCo9a9uNlRXDedA vd8vm9H5E9W7y3sZKSGZQ1jIFTAMCcq1Ajig1EFPxeEnXXvgp0bvtcLVPBY0Qg0bpaNH6Xyas V9C10S/DhIsKbdJcG9VvOMB43OJzz9CxEdiaEjI4o69VrZ6aWFTNuDC9A66y02iQqkBsFlIPh LGpxbA2b1wO8rQe84/SPfW+mBcTa5j9F4yCuzDj28sWSkJ8xmOAptHtqntlh75BaNJ9pfVAhx Rg/7PXf1YyR0KgCizYhw5d8s5b8=
Hello everyone,
I hope this issue fits this list. In our current project we need
to compute a lot of small Minkowski sums, and I wanted to ask if
someone could please give me some help in speeding that process
up. The following CGAL program computing the Minkowski sum of two
small polygons demonstrates the problem.
main.cpp:
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_convex_decomposition_2.h>
#include <CGAL/Polygon_triangulation_decomposition_2.h>
#include <CGAL/minkowski_sum_2.h>
#include <chrono>
#include <iostream>
#include <vector>
typedef CGAL::Exact_predicates_exact_constructions_kernel
Kernel;
typedef CGAL::Point_2<Kernel> Point;
typedef CGAL::Polygon_2<Kernel> Polygon;
typedef CGAL::Polygon_with_holes_2<Kernel>
Polygon_with_holes;
int main(int argc, char** argv) {
using std::vector;
using std::chrono::high_resolution_clock;
vector square_1_points({Point(0, 0), Point(4, 0), Point(4,
4)});
vector square_2_points({Point(2, 1), Point(3, 1), Point(3,
2)});
Polygon square_1(square_1_points.begin(),
square_1_points.end());
Polygon square_2(square_2_points.begin(),
square_2_points.end());
auto t1 = high_resolution_clock::now();
Polygon_with_holes result =
CGAL::minkowski_sum_2(square_1, square_2,
CGAL::Hertel_Mehlhorn_convex_decomposition_2<Kernel>());
auto t2 = high_resolution_clock::now();
std::cout <<
std::chrono::duration_cast<std::chrono::microseconds>(t2 -
t1).count() << "µs" << std::endl;
return EXIT_SUCCESS;
}
CMakeLists.txt:
cmake_minimum_required(VERSION 3.19.1)
# SotMS: "Slowness of the Minkowski Sum"
project(sotms)
find_package(CGAL 5.6 REQUIRED COMPONENTS Core)
add_compile_options(-O2)
set(CMAKE_BUILD_TYPE Release)
add_executable(sotms src/main.cpp)
target_link_libraries(sotms CGAL::CGAL_Core)
Compilation and execution (move the main.cpp in a folder named src
and the CMakeLists.txt in a folder above before):
$ cd src
$ cmake ..
$ make -j
$ ./sotms
I have observed the following:
1. The execution times for CGAL::minkowski_sum_2
for the above program lie around 200µs. This gives room for about
5000 Minkowski sums per second, which is not a lot, given the
complexity of the above problem.
2. In the main project we usually have runtimes of about 1500µs.
In some executions of our main project program the runtime jumps
to several seconds up to minutes, but I cannot reproduce that well
yet.
3. Repeating the above code (by introducing a for loop wrapping
around the lines 23-27) yields runtimes of about 20µs, but I think
this is due to optimizations, but 20µs is still too much.
4. Disabling optimizations (-O0)
gives runtimes of about 1000µs for the first Minkowski sum, which
then upon repetition of the computation breaks down to about 200µs
again for some reason.
I have already tried changing the kernel to an inexact kernel,
which still gives poor performance and does not suit our use case,
since it often crashes. I am on an Arch Linux (x64) laptop, CGAL
is compiled with GMP and MPFR, everything is up to date. The CGAL
version in the Arch repository is 5.6
Best
Valentin
- [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Valentin Pi, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Efi Fogel, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Valentin Pi, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Efi Fogel, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Valentin Pi, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Efi Fogel, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Valentin Pi, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Efi Fogel, 01/10/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Valentin Pi, 01/10/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Andrew Cunningham, 01/12/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Andreas Fabri, 01/17/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Valentin Pi, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Efi Fogel, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Valentin Pi, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Efi Fogel, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Valentin Pi, 01/09/2024
- Re: [cgal-discuss] Slow Performance when Computing the Minkowski Sum of two Simple Squares, Efi Fogel, 01/09/2024
Archive powered by MHonArc 2.6.19+.