From 08ac892e4e491dfb553984bea7787724d4347c81 Mon Sep 17 00:00:00 2001 From: Niko Savola Date: Wed, 3 Jun 2026 14:55:49 +0300 Subject: [PATCH 1/2] Leverage execution policies in `dbShapes` and PLC decomposition --- src/db/db/dbPLCConvexDecomposition.cc | 12 ++++++++++-- src/db/db/dbShapes.cc | 10 +++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/db/db/dbPLCConvexDecomposition.cc b/src/db/db/dbPLCConvexDecomposition.cc index 95633fb3a..9e1b50914 100644 --- a/src/db/db/dbPLCConvexDecomposition.cc +++ b/src/db/db/dbPLCConvexDecomposition.cc @@ -30,6 +30,14 @@ #include #include #include +#include + +#if defined(__cpp_lib_execution) +#include +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif // #define DEBUG_DUMP_ESSENTIAL_EDGES @@ -269,7 +277,7 @@ ConvexDecomposition::hertel_mehlhorn_decomposition (Triangulation &tris, const C if (! new_points.empty ()) { - std::sort (new_points.begin (), new_points.end (), less_compare_func ()); + std::sort (PARALLEL_EXEC_POLICY new_points.begin (), new_points.end (), less_compare_func ()); new_points.erase (std::unique (new_points.begin (), new_points.end (), equal_compare_func ()), new_points.end ()); // Insert the new points and make connections @@ -332,7 +340,7 @@ ConvexDecomposition::hertel_mehlhorn_decomposition (Triangulation &tris, const C } } - std::sort (sorted_edges.begin (), sorted_edges.end (), SortAngleAndEdgesByEdgeLength ()); + std::sort (PARALLEL_EXEC_POLICY sorted_edges.begin (), sorted_edges.end (), SortAngleAndEdgesByEdgeLength ()); for (auto i = sorted_edges.end (); i != sorted_edges.begin (); ) { --i; diff --git a/src/db/db/dbShapes.cc b/src/db/db/dbShapes.cc index 8176df950..dbfca4a90 100644 --- a/src/db/db/dbShapes.cc +++ b/src/db/db/dbShapes.cc @@ -30,6 +30,14 @@ #include "dbLayout.h" #include +#include + +#if defined(__cpp_lib_execution) +#include +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif namespace db { @@ -111,7 +119,7 @@ layer_op::erase (Shapes *shapes) std::vector done; done.resize (m_shapes.size (), false); - std::sort (m_shapes.begin (), m_shapes.end ()); + std::sort (PARALLEL_EXEC_POLICY m_shapes.begin (), m_shapes.end ()); typename std::vector::const_iterator s_begin = m_shapes.begin (); typename std::vector::const_iterator s_end = m_shapes.end (); From 6f167d2dd1731c84aeeaebc9001119741b5867db Mon Sep 17 00:00:00 2001 From: Niko Savola Date: Fri, 25 Sep 2026 10:42:32 +0300 Subject: [PATCH 2/2] Include execution before checking its feature macro --- src/db/db/dbPLCConvexDecomposition.cc | 7 ++++++- src/db/db/dbShapes.cc | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/db/db/dbPLCConvexDecomposition.cc b/src/db/db/dbPLCConvexDecomposition.cc index 9e1b50914..ca7f611dc 100644 --- a/src/db/db/dbPLCConvexDecomposition.cc +++ b/src/db/db/dbPLCConvexDecomposition.cc @@ -32,8 +32,13 @@ #include #include +#if __cplusplus >= 201703L + #if __has_include() + #include + #endif +#endif + #if defined(__cpp_lib_execution) -#include #define PARALLEL_EXEC_POLICY std::execution::par, #else #define PARALLEL_EXEC_POLICY diff --git a/src/db/db/dbShapes.cc b/src/db/db/dbShapes.cc index dbfca4a90..deb9fe916 100644 --- a/src/db/db/dbShapes.cc +++ b/src/db/db/dbShapes.cc @@ -32,8 +32,13 @@ #include #include +#if __cplusplus >= 201703L + #if __has_include() + #include + #endif +#endif + #if defined(__cpp_lib_execution) -#include #define PARALLEL_EXEC_POLICY std::execution::par, #else #define PARALLEL_EXEC_POLICY