Skip to content

Leverage execution policies inside dbAsIfFlatRegion object traversal - #2365

Open
nikosavola wants to merge 2 commits into
KLayout:parallelizefrom
nikosavola:nikosavola/push-lwnxpwsvyrwm
Open

nikosavola wants to merge 2 commits into
KLayout:parallelizefrom
nikosavola:nikosavola/push-lwnxpwsvyrwm

Conversation

@nikosavola

@nikosavola nikosavola commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Same idea as #2364, but for dbAsIfFlatRegion.

merge_polygons_to buffers the polygons with properties and sorts them by property ID before grouping. That sort now uses std::execution::par where the standard library supports execution policies, and stays a plain std::sort where it doesn't (macOS/libc++, MSVC without TBB, C++11 builds). The guards are __cpp_lib_execution and __has_include(<execution>).

Benchmark

The region_merge_properties case from the db_parallel_benchmarks Google Benchmark suite on the parallelize-rebased branch of my fork runs Region#merged end to end on a flat region of property-tagged boxes, so the timing includes everything around the sort, not just the sort itself.

  • 16384 boxes over 8 property groups
  • Intel Xeon Gold 6248 @ 2.5 GHz, 16 cores, Ubuntu 24.04, GCC 13.3, -O2, TBB 2021.11
  • serial and parallel builds of this branch timed back to back at each CPU count, 5 repetitions with random interleaving per run, medians reported
  • CPUs limited with taskset, which also throttles the TBB pool since it sizes itself from the affinity mask
CPUs serial (ms) par (ms) speedup
1 22.816 22.490 1.01x
2 25.463 22.922 1.11x
4 25.572 22.980 1.11x
8 25.282 22.612 1.12x
16 27.185 24.279 1.12x

At 4096 boxes the picture is the same: 1.00x on one core, 1.12x at 16.

Speedup versus number of CPUs

The sort is a small part of the whole merge, so the operation gains about 10% and flattens out near 1.12x. Nothing changes single-threaded. I also ran the same benchmark on an Apple M5 (aarch64, Ubuntu container) and the numbers follow the same curve, so this is not x86-specific.

@nikosavola
nikosavola changed the base branch from master to parallelize June 22, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant