-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
asap7/ethmac_lvt: study placement densities and grt
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
- Loading branch information
Showing
9 changed files
with
2,109 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Returns information about user's GCP entitlements | ||
# | ||
# Usage: cred_helper.py [get|test] | ||
# | ||
# get prints the GCP auth token | ||
# test prints the user's GCP entitlements | ||
# | ||
# Calling script without arguments prints out usage information and then exits with a non-zero code (per spec) | ||
# | ||
|
||
import subprocess | ||
import requests | ||
import json | ||
import re | ||
import sys | ||
|
||
|
||
def get_gcloud_auth_token(test): | ||
""" | ||
Returns the gcloud auth token based on the .user-bazelrc | ||
""" | ||
|
||
with open(".user-bazelrc") as f: | ||
all = f.read() | ||
match = re.search(r"# user: (.*)", all) | ||
if match is None: | ||
sys.exit('Did not find username in .user-bazelrc file as "# user: <username>"') | ||
USER = match.group(1) | ||
|
||
cmd = ["gcloud", "auth", "print-access-token", USER] | ||
if test: | ||
print("Running: " + subprocess.list2cmdline(cmd)) | ||
result = subprocess.run(cmd, capture_output=True, text=True, check=True) | ||
token = result.stdout.strip() | ||
return token | ||
|
||
|
||
def generate_credentials(test): | ||
""" | ||
Generate the credentials in a form that Bazel wants, which is the | ||
Authorization key points to a list | ||
""" | ||
|
||
bearer_token = get_gcloud_auth_token(test) | ||
|
||
# Create the JSON object with the required format | ||
credentials = {"headers": {"Authorization": [f"Bearer {bearer_token}"]}} | ||
return credentials | ||
|
||
|
||
def test_permissions(credentials, bucket_name): | ||
""" | ||
Tests the user's entitlements for this bucket | ||
Note that the call to check the permissions needs the Authorization key to | ||
point to a string and not a list. So, take the first element in the list | ||
and make it the only value | ||
""" | ||
|
||
credentials["headers"]["Authorization"] = credentials["headers"]["Authorization"][0] | ||
url = ( | ||
f"https://storage.googleapis.com/storage/v1/b/{bucket_name}/iam/testPermissions" | ||
) | ||
permissions = {"permissions": ["storage.buckets.get", "storage.objects.create"]} | ||
|
||
response = requests.get(url, params=permissions, headers=credentials["headers"]) | ||
response.raise_for_status() | ||
return response.json() | ||
|
||
|
||
def main(): | ||
if ( | ||
len(sys.argv) <= 1 | ||
or (len(sys.argv) == 2 and sys.argv[1] not in ["get", "test"]) | ||
or len(sys.argv) >= 3 | ||
): | ||
sys.exit("Usage: python cred_helper.py [get|test]") | ||
test = sys.argv[1] == "test" | ||
|
||
credentials = generate_credentials(test) | ||
if not test: | ||
print(json.dumps(credentials, indent=2)) | ||
return | ||
|
||
permissions = test_permissions(credentials, "megaboom-bazel-artifacts") | ||
|
||
print(json.dumps(permissions, indent=2)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
load("@bazel-orfs//:sweep.bzl", "orfs_sweep") | ||
load("@orfs-pip//:requirements.bzl", "requirement") | ||
|
||
# Format densities, rounding to 2 decimal places. | ||
PLACEMENT_DENSITIES = [str(0.60 + x * 0.01 + 0.005)[:4] for x in range(20)] | ||
#PLACEMENT_DENSITIES.remove("0.67") | ||
|
||
orfs_sweep( | ||
name = "ethmac_lvt", | ||
arguments = { | ||
# Faster builds | ||
"SKIP_INCREMENTAL_REPAIR": "1", | ||
"GPL_TIMING_DRIVEN": "0", | ||
# Various | ||
"SDC_FILE": "$(location :constraint.sdc)", | ||
"ABC_AREA": "1", | ||
"CORE_UTILIZATION": "40", | ||
"CORE_ASPECT_RATIO": "1", | ||
"CORE_MARGIN": "2", | ||
"PLACE_DENSITY": "0.60", | ||
"ASAP7_USELVT": "1", | ||
"RECOVER_POWER": "1", | ||
"ADDITIONAL_LIBS": "$(LIB_DIR)/asap7sc7p5t_AO_RVT_FF_nldm_211120.lib.gz \ | ||
$(LIB_DIR)/asap7sc7p5t_INVBUF_RVT_FF_nldm_220122.lib.gz \ | ||
$(LIB_DIR)/asap7sc7p5t_OA_RVT_FF_nldm_211120.lib.gz \ | ||
$(LIB_DIR)/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz \ | ||
$(LIB_DIR)/asap7sc7p5t_SEQ_RVT_FF_nldm_220123.lib", | ||
"ADDITIONAL_GDS": "$(PLATFORM_DIR)/gds/asap7sc7p5t_28_R_220121a.gds", | ||
"ADDITIONAL_LEFS": "$(PLATFORM_DIR)/lef/asap7sc7p5t_28_R_1x_220121a.lef", | ||
}, | ||
other_variants = {"base": {}}, | ||
sources = { | ||
"SDC_FILE": [":constraint.sdc"], | ||
}, | ||
sweep = { | ||
density: { | ||
"arguments": { | ||
"PLACE_DENSITY": density, | ||
}, | ||
"previous_stage": { | ||
"floorplan": "ethmac_lvt_synth", | ||
}, | ||
} | ||
for density in PLACEMENT_DENSITIES | ||
}, | ||
top = "ethmac", | ||
verilog_files = ["//:ethmac_lvt_src"], | ||
) | ||
|
||
[filegroup( | ||
name = "ethmac_lvt_{density}_congestion".format(density = density), | ||
srcs = [":ethmac_lvt_{density}_grt".format(density = density)], | ||
output_group = "congestion.rpt", | ||
) for density in PLACEMENT_DENSITIES] | ||
|
||
filegroup( | ||
name = "congestion", | ||
srcs = [":ethmac_lvt_{density}_congestion".format(density = density) for density in PLACEMENT_DENSITIES], | ||
) | ||
|
||
py_binary( | ||
name = "plot_congestion", | ||
srcs = ["plot_congestion.py"], | ||
main = "plot_congestion.py", | ||
deps = [requirement("matplotlib")], | ||
) | ||
|
||
genrule( | ||
name = "plot_pdf", | ||
srcs = [":congestion"], | ||
outs = ["congestion.pdf"], | ||
cmd = "$(execpath :plot_congestion) $@ $(locations :congestion)", | ||
tools = [":plot_congestion"], | ||
) | ||
|
||
sh_binary( | ||
name = "plot", | ||
srcs = [":open_plots.sh"], | ||
args = ["$(location :plot_pdf)"], | ||
data = [":plot_pdf"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
xdg-open $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import sys | ||
import re | ||
import os | ||
|
||
|
||
output = sys.argv[1] | ||
files = sys.argv[2:] | ||
|
||
# count lines in each file and divide by 3 and create a list of those | ||
# numbers | ||
congestion = [] | ||
for file in files: | ||
with open(file, "r") as f: | ||
lines = f.readlines() | ||
print(file) | ||
density = re.search(r"(\d+\.\d+)", file).group(1) | ||
congestion.append((float(density), len(lines) // 4)) | ||
|
||
# xy plot of density vs DRC errors | ||
x, y = zip(*congestion) | ||
plt.plot(x, y, "o-") | ||
plt.xlabel("Density") | ||
plt.ylabel("DRC Errors") | ||
plt.title("Density vs DRC Errors") | ||
plt.grid() | ||
plt.yscale("log") | ||
plt.savefig(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
matplotlib==3.10.0 | ||
PyYAML==6.0.2 |
Oops, something went wrong.