diff --git a/openlane/scripts/klayout/xor.drc b/openlane/scripts/klayout/xor.drc index 30c33072d..36b957a0f 100755 --- a/openlane/scripts/klayout/xor.drc +++ b/openlane/scripts/klayout/xor.drc @@ -23,8 +23,11 @@ if !defined?(RBA) opts.on("-t", "--top TOP_CELL", "Top cell name (required)") do |top_cell| options[:top_cell] = top_cell end - opts.on("-T", "--threads THREAD_COUNT", "Thread count") do |threads| - options[:threads] = (threads or "1").to_i + opts.on("-t", "--tile-size TILE_SIZE", "Tile size (in µm)") do |tile_size| + options[:tile_size] = tile_size.to_i + end + opts.on("-n", "--threads THREAD_COUNT", "Lower bound on the thread count used by this process (+ managing threads)") do |threads| + options[:threads] = threads.to_i end end optparse.parse! @@ -43,6 +46,7 @@ if !defined?(RBA) "-rd", "jobs=#{options[:threads]}", "-rd", "rdb_out=#{File.absolute_path(options[:rdb_out])}", "-rd", "ignore=#{options[:ignore]}", + "-rd", "tilesize=#{options[:tile_size]}", ] puts "Running: '#{args.join(" ")}'…" exec *args @@ -52,10 +56,23 @@ end verbose # Run XOR -$jobs = $jobs.to_i or 1 +if $jobs == "" + $jobs = "1" +end +$jobs = $jobs.to_i + info "Using #{$jobs} threads…" threads($jobs) +# Tiling +if $tilesize == "" + $tilesize = "500" +end +$tilesize = $tilesize.to_i + +info "Using a tile size of (#{$tilesize} µm)²…" +tiles($tilesize.um, $tilesize.um) + # Set up inputs puts $a, $b a = source($a, $top_cell) diff --git a/openlane/steps/klayout.py b/openlane/steps/klayout.py index 7133fba75..df2ad76fc 100644 --- a/openlane/steps/klayout.py +++ b/openlane/steps/klayout.py @@ -257,9 +257,8 @@ class XOR(KLayoutStep): config_vars = KLayoutStep.config_vars + [ Variable( "KLAYOUT_XOR_THREADS", - int, - "Specifies number of threads used in the KLayout XOR check.", - default=1, + Optional[int], + "Specifies number of threads used in the KLayout XOR check. If unset, this will be equal to your machine's thread count.", ), Variable( "KLAYOUT_XOR_IGNORE_LAYERS", @@ -267,6 +266,12 @@ class XOR(KLayoutStep): "KLayout layers to ignore during XOR operations.", pdk=True, ), + Variable( + "KLAYOUT_XOR_TILE_SIZE", + Optional[int], + "A tile size for the XOR process in µm.", + pdk=True, + ), ] def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]: @@ -285,6 +290,12 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]: kwargs, env = self.extract_env(kwargs) + tile_size_options = [] + if tile_size := self.config["KLAYOUT_XOR_TILE_SIZE"]: + tile_size_options += ["--tile-size", str(tile_size)] + + thread_count = self.config["KLAYOUT_XOR_THREADS"] or os.cpu_count() or 1 + self.run_subprocess( [ "ruby", @@ -298,12 +309,13 @@ def run(self, state_in: State, **kwargs) -> Tuple[ViewsUpdate, MetricsUpdate]: "--top", self.config["DESIGN_NAME"], "--threads", - self.config["KLAYOUT_XOR_THREADS"], + thread_count, "--ignore", ignored, layout_a, layout_b, - ], + ] + + tile_size_options, env=env, ) diff --git a/test/steps/all b/test/steps/all index 781cc7e11..aa2085a53 160000 --- a/test/steps/all +++ b/test/steps/all @@ -1 +1 @@ -Subproject commit 781cc7e119a0e0e723ca206d96ebfc1b5f8fa860 +Subproject commit aa2085a53ea152f4b4a3bc5da8684e1653cc1cbd