Skip to content

Commit

Permalink
Fix XOR threads, add tile size option (and tests for both)
Browse files Browse the repository at this point in the history
  • Loading branch information
donn committed Oct 26, 2023
1 parent 76d5278 commit 11f53e1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
23 changes: 20 additions & 3 deletions openlane/scripts/klayout/xor.drc
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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
Expand All @@ -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)
Expand Down
22 changes: 17 additions & 5 deletions openlane/steps/klayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,21 @@ 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",
Optional[List[str]],
"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]:
Expand All @@ -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",
Expand All @@ -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,
)

Expand Down

0 comments on commit 11f53e1

Please sign in to comment.