From b116fe452c42acc72afdebe4aba3ecdb83a2fa25 Mon Sep 17 00:00:00 2001 From: Niko Savola Date: Wed, 3 Jun 2026 10:05:30 +0300 Subject: [PATCH 1/2] Use `std::execution::par` in `dbEdgeProcessor` and `dbPolygonTools` sorts --- src/db/db/dbEdgeProcessor.cc | 11 +++++++++-- src/db/db/dbPolygonTools.cc | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/db/db/dbEdgeProcessor.cc b/src/db/db/dbEdgeProcessor.cc index b50f83cf4..1b5a08391 100644 --- a/src/db/db/dbEdgeProcessor.cc +++ b/src/db/db/dbEdgeProcessor.cc @@ -29,6 +29,13 @@ #include "tlProgress.h" #include "gsi.h" +#if defined(__cpp_lib_execution) +#include +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif + #include #include #include @@ -2237,7 +2244,7 @@ EdgeProcessor::redo_or_process (const std::vectorbegin (), mp_work_edges->end (), edge_ymin_compare ()); + std::sort (PARALLEL_EXEC_POLICY mp_work_edges->begin (), mp_work_edges->end (), edge_ymin_compare ()); y = edge_ymin ((*mp_work_edges) [0]); future = mp_work_edges->begin (); @@ -2422,7 +2429,7 @@ EdgeProcessor::redo_or_process (const std::vectorbegin (), mp_work_edges->end (), edge_ymin_compare ()); + std::sort (PARALLEL_EXEC_POLICY mp_work_edges->begin (), mp_work_edges->end (), edge_ymin_compare ()); y = edge_ymin ((*mp_work_edges) [0]); diff --git a/src/db/db/dbPolygonTools.cc b/src/db/db/dbPolygonTools.cc index a5a63cd6c..228a368bf 100644 --- a/src/db/db/dbPolygonTools.cc +++ b/src/db/db/dbPolygonTools.cc @@ -28,6 +28,13 @@ #include "tlLog.h" #include "tlInt128Support.h" +#if defined(__cpp_lib_execution) +#include +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif + #include #include #include @@ -1838,7 +1845,7 @@ rasterize_impl (const db::polygon &polygon, db::area_map &am) } // sort edges - std::sort (edges.begin (), edges.end (), db::edge_ymin_compare ()); + std::sort (PARALLEL_EXEC_POLICY edges.begin (), edges.end (), db::edge_ymin_compare ()); typename std::vector ::iterator c = edges.begin (); @@ -2761,7 +2768,7 @@ decompose_convex_to_trapezoids (const db::SimplePolygon &sp, bool horizontal, db } } - std::sort (edges.begin (), edges.end (), db::edge_ymin_compare ()); + std::sort (PARALLEL_EXEC_POLICY edges.begin (), edges.end (), db::edge_ymin_compare ()); db::Coord y = db::edge_ymin (edges.front ()); From 7e6119c777fbe083c8ca7b31c79c76de12c5eb3c Mon Sep 17 00:00:00 2001 From: Niko Savola Date: Thu, 4 Jun 2026 10:30:27 +0000 Subject: [PATCH 2/2] Make TBB linking conditional and improve backward compatibility of execution header guards --- src/db/db/db.pro | 4 ++++ src/db/db/dbEdgeProcessor.cc | 17 +++++++++++------ src/db/db/dbPolygonTools.cc | 17 +++++++++++------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/db/db/db.pro b/src/db/db/db.pro index d316c1c60..1c1285342 100644 --- a/src/db/db/db.pro +++ b/src/db/db/db.pro @@ -454,3 +454,7 @@ INCLUDEPATH += $$TL_INC $$GSI_INC DEPENDPATH += $$TL_INC $$GSI_INC LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi +packagesExist(tbb) { + LIBS += -ltbb +} + diff --git a/src/db/db/dbEdgeProcessor.cc b/src/db/db/dbEdgeProcessor.cc index 1b5a08391..a9f73666b 100644 --- a/src/db/db/dbEdgeProcessor.cc +++ b/src/db/db/dbEdgeProcessor.cc @@ -1,3 +1,14 @@ +#if __cplusplus >= 201703L + #if __has_include() + #include + #endif +#endif + +#if defined(__cpp_lib_execution) +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif /* @@ -29,12 +40,6 @@ #include "tlProgress.h" #include "gsi.h" -#if defined(__cpp_lib_execution) -#include -#define PARALLEL_EXEC_POLICY std::execution::par, -#else -#define PARALLEL_EXEC_POLICY -#endif #include #include diff --git a/src/db/db/dbPolygonTools.cc b/src/db/db/dbPolygonTools.cc index 228a368bf..849e0a154 100644 --- a/src/db/db/dbPolygonTools.cc +++ b/src/db/db/dbPolygonTools.cc @@ -1,3 +1,14 @@ +#if __cplusplus >= 201703L + #if __has_include() + #include + #endif +#endif + +#if defined(__cpp_lib_execution) +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif /* @@ -28,12 +39,6 @@ #include "tlLog.h" #include "tlInt128Support.h" -#if defined(__cpp_lib_execution) -#include -#define PARALLEL_EXEC_POLICY std::execution::par, -#else -#define PARALLEL_EXEC_POLICY -#endif #include #include