Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python updates #1245

Merged
merged 31 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bc2a0d2
run_vcs pylint cleanup
jordancarlin Dec 12, 2024
71168e5
Cleanup lint warnings in CacheSim.py
jordancarlin Dec 12, 2024
1e8d4c2
Cleanup regresssion-wally whitespace
jordancarlin Dec 12, 2024
57d7236
regression-wally passing pylint. Still needs a larger refactoring
jordancarlin Dec 12, 2024
356c6fa
iterelf passing pylint
jordancarlin Dec 12, 2024
bdfc9da
Lots of f-strings
jordancarlin Dec 12, 2024
6ec059e
Merge branch 'main' of https://github.com/openhwgroup/cvw into python…
jordancarlin Dec 17, 2024
fd96fa4
Fix iterelf shebang
jordancarlin Dec 17, 2024
1369914
Cleanup nightly regression script
jordancarlin Dec 17, 2024
dfe1541
Lots more small python script cleanup
jordancarlin Dec 17, 2024
d0b122a
Python multiple imports per line
jordancarlin Dec 17, 2024
0e3030d
Remove python semicolons
jordancarlin Dec 17, 2024
21e35c9
Lots more python cleanup
jordancarlin Dec 18, 2024
51c3d59
Lots more python updates
jordancarlin Dec 18, 2024
32b62e9
Cleanup quotes
jordancarlin Dec 18, 2024
1a2569e
Begin refactoring regression-wally
jordancarlin Dec 18, 2024
c078051
Update README installation badge
jordancarlin Dec 19, 2024
e7b8261
Merge branch 'main' of https://github.com/openhwgroup/cvw into python…
jordancarlin Dec 19, 2024
bd5223b
More regression-wally refactoring
jordancarlin Dec 19, 2024
a10dbac
Merge branch 'breker' of github.com:jordancarlin/cvw into python_updates
jordancarlin Dec 19, 2024
babc5fc
Merge branch 'main' of https://github.com/openhwgroup/cvw into python…
jordancarlin Dec 19, 2024
9f0aebb
Merge branch 'main' of https://github.com/openhwgroup/cvw into python…
jordancarlin Jan 3, 2025
bbc815d
Merge branch 'main' of https://github.com/openhwgroup/cvw into python…
jordancarlin Jan 23, 2025
d697b92
fix spaces in wsim arguments
jordancarlin Jan 23, 2025
f4d6e20
More regression-wally refactoring
jordancarlin Jan 23, 2025
3f53886
Add ruff.toml configuration file
jordancarlin Jan 23, 2025
a07e828
Add ruff lint check in CI
jordancarlin Jan 23, 2025
3acc437
Merge branch 'main' of https://github.com/openhwgroup/cvw into python…
jordancarlin Jan 27, 2025
1d71889
Fix remaining ruff lint errors
jordancarlin Jan 27, 2025
c659b03
A bit more regression-wally cleanup
jordancarlin Jan 27, 2025
cb5b1d7
Remove slack-notifier.py
jordancarlin Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint

on:
push:
paths:
- '**/*.py'
- 'bin/*'
- 'sim/vcs/run_vcs'
- '.ruff.toml'
- '!addins/*'
- '!tests/wally-riscv-arch-test/riscv-test-suite/rv64i_m/Q/*'
- '!tests/fp/quad/fpdatasetgen.py'
pull_request:
paths:
- '**/*.py'
- 'bin/*'
- 'sim/vcs/run_vcs'
- '.ruff.toml'
- '!addins/*'
- '!tests/wally-riscv-arch-test/riscv-test-suite/rv64i_m/Q/*'
- '!tests/fp/quad/fpdatasetgen.py'

jobs:
lint:
name: Python ${{matrix.version}} lint
strategy:
matrix:
version: [39, 312] # Test on oldest and newest verions used in wally-package-install.sh
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set Python version
run: sed -i '/^target-version/c\target-version = "py${{matrix.version}}"' .ruff.toml
- name: Run ruff
uses: astral-sh/ruff-action@v3
31 changes: 31 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Lint all .py files and extra python scripts without extensions
include = ["*.py", "bin/wsim", "bin/regression-wally", "bin/iterelf", "sim/vcs/run_vcs"]
exclude = ["addins/*", "tests/wally-riscv-arch-test/riscv-test-suite/rv64i_m/Q/*", "tests/fp/quad/fpdatasetgen.py"]

# Target oldest version of Python used (Python 3.9 for Ubuntu 20.04 LTS)
target-version = "py39"

line-length=250

[lint]
select = [
"F", # various basic rules
"E101", # indentation contains mixed spaces and tabs
"E4", # imports
"E7", # various improvements
"E9", # error
"W1", # tabs used instead of spaces
"W292", # no newline at end of file
"UP", # Upgraded version available in newer Python
"EXE", # Executable file shebangs
"Q003", # Avoidable escaped quotes
"Q004", # Unnecessary esacpe character
"RUF", # Ruff specific rules
]

ignore = [
"E701", "E702", # multiple statements on one line
"E722", # do not use bare 'except'
"E74", # ambiguous name
"RUF005", # iterable unpacking in list
]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Installation CI](https://github.com/openhwgroup/cvw/actions/workflows/install.yml/badge.svg?branch=main)
[![Installation CI](https://github.com/openhwgroup/cvw/actions/workflows/install.yml/badge.svg?branch=main)](https://github.com/openhwgroup/cvw/actions/workflows/install.yml)

# core-v-wally

Expand Down
5 changes: 1 addition & 4 deletions benchmarks/coremark/coremark_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@

# Loop through each architecture and run the make commands
for arch in arch_list:
if(str in arch):
xlen_value='32'
else:
xlen_value='64'
xlen_value = "32" if str in arch else "64"
os.system("make clean")
make_all = f"make all XLEN={xlen_value} ARCH={arch}"
os.system(make_all)
Expand Down
14 changes: 5 additions & 9 deletions benchmarks/embench/embench_arch_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,17 @@ def tabulate_arch_sweep(directory):
file = case+"_"+arch+".json"
file_path = os.path.join(directory, file)
lines = []
try:
f = open(file_path, "r")
with open(file_path) as f:
lines = f.readlines()
except:
f.close()
#print(file_path+" does not exist")
for line in lines:
#print("File: "+file+" Line: "+line)
#p = re.compile('".*" : .*,')
p = r'"([^"]*)" : ([^,\n]+)'
match = re.search(p, line)
if match:
prog = match.group(1)
result = match.group(2);
d[arch][prog] = result;
result = match.group(2)
d[arch][prog] = result
#print(match.group(1)+" " + match.group(2))
f.close()
for arch in [""] + archs:
Expand All @@ -53,7 +49,7 @@ def tabulate_arch_sweep(directory):
for prog in d[archs[0]]:
print(prog, end="\t")
for arch in archs:
entry = d[arch].get(prog, "n/a");
entry = d[arch].get(prog, "n/a")
print (entry, end="\t")
print("")
print("New geo mean", end="\t")
Expand Down Expand Up @@ -84,4 +80,4 @@ def run_arch_sweep():

directory = run_arch_sweep()
#directory = "run_20231120_072037-caches"
tabulate_arch_sweep(directory)
tabulate_arch_sweep(directory)
12 changes: 6 additions & 6 deletions benchmarks/graphGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

debug = True

def loadCoremark():
def loadCoremark(coremarkData):
"""loads the coremark data dictionary"""
coremarkPath = "riscv-coremark/work/coremark.sim.log"

keywordlist = ["CoreMark 1.0", "CoreMark Size", "MTIME", "MINSTRET", "Branches Miss Predictions", "BTB Misses"]
for keyword in keywordlist:
bashInst = "cat " + coremarkPath + " | grep \"" + keyword + "\" | cut -d \':\' -f 2 | cut -d \" \" -f 2 | tail -1"
bashInst = "cat " + coremarkPath + ' | grep "' + keyword + "\" | cut -d ':' -f 2 | cut -d \" \" -f 2 | tail -1"
result = subprocess.run(bashInst, stdout=subprocess.PIPE, shell=True)
if (debug): print(result)
coremarkData[keyword] = int(result.stdout)
Expand All @@ -25,8 +25,8 @@ def loadCoremark():

def loadEmbench(embenchPath, embenchData):
"""loads the embench data dictionary"""
f = open(embenchPath)
embenchData = json.load(f)
with open(embenchPath) as f:
embenchData = json.load(f)
if (debug): print(embenchData)
return embenchData

Expand Down Expand Up @@ -93,7 +93,7 @@ def main():
embenchSpeedOpt_SpeedData = {}
embenchSizeOpt_SizeData = {}
embenchSpeedOpt_SizeData = {}
# coremarkData = loadCoremark()
coremarkData = loadCoremark(coremarkData)
embenchSpeedOpt_SpeedData = loadEmbench("embench/wallySpeedOpt_speed.json", embenchSpeedOpt_SpeedData)
embenchSizeOpt_SpeedData = loadEmbench("embench/wallySizeOpt_speed.json", embenchSizeOpt_SpeedData)
embenchSpeedOpt_SizeData = loadEmbench("embench/wallySpeedOpt_size.json", embenchSpeedOpt_SizeData)
Expand All @@ -104,4 +104,4 @@ def main():
if __name__ == '__main__':
sys.exit(main())

# "ls -Art ../addins/embench-iot/logs/*speed* | tail -n 1 " # gets most recent embench speed log
# "ls -Art ../addins/embench-iot/logs/*speed* | tail -n 1 " # gets most recent embench speed log
Loading
Loading