Merge pull request #1276 from jordancarlin/ruff
Some checks failed
Lint / Python 312 lint (push) Has been cancelled
Lint / Python 39 lint (push) Has been cancelled

A bit more python cleanup
This commit is contained in:
David Harris 2025-02-16 04:11:43 -08:00 committed by GitHub
commit c380227447
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 89 additions and 74 deletions

View file

@ -9,14 +9,13 @@ 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
"F", # various basic rules (pyflakes)
"E", # errors (pycodestyle)
"W", # warnings (pycodestyle)
"I", # Import related rules (isort)
"UP", # Upgraded version available in newer Python
"B", # bugbear rules
"A", # shadow builtins
"EXE", # Executable file shebangs
"Q003", # Avoidable escaped quotes
"Q004", # Unnecessary esacpe character
@ -24,8 +23,13 @@ select = [
]
ignore = [
"E501", # line too long
"E701", "E702", # multiple statements on one line
"E722", # do not use bare 'except'
"E74", # ambiguous name
"E741", # ambiguous variable name
"W291", # trailing whitespace
"W293", # blank line contains whitespace
"B007", # loop control variable not used
"B9", # overly opinionated rules
"RUF005", # iterable unpacking in list
]

View file

@ -29,9 +29,10 @@
###########################################################################################
import csv
import os
import re
import csv
# list of architectures to run.
arch_list = [
"rv32i_zicsr",
@ -47,7 +48,6 @@ arch_list = [
"rv64gc",
"rv64gc_zba_zbb_zbs"
]
str="32"
# Define regular expressions to match the desired fields
mt_regex = r"Elapsed MTIME: (\d+).*?Elapsed MINSTRET: (\d+).*?COREMARK/MHz Score: [\d,]+ / [\d,]+ = (\d+\.\d+).*?CPI: \d+ / \d+ = (\d+\.\d+).*?Load Stalls (\d+).*?Store Stalls (\d+).*?D-Cache Accesses (\d+).*?D-Cache Misses (\d+).*?I-Cache Accesses (\d+).*?I-Cache Misses (\d+).*?Branches (\d+).*?Branches Miss Predictions (\d+).*?BTB Misses (\d+).*?Jump and JR (\d+).*?RAS Wrong (\d+).*?Returns (\d+).*?BP Class Wrong (\d+)"
@ -65,7 +65,7 @@ with open(resultfile, mode='w', newline='') as csvfile:
# Loop through each architecture and run the make commands
for arch in arch_list:
xlen_value = "32" if str in arch else "64"
xlen_value = "32" if "32" in arch else "64"
os.system("make clean")
make_all = f"make all XLEN={xlen_value} ARCH={arch}"
os.system(make_all)

View file

@ -5,10 +5,10 @@
# Run embench on a variety of architectures and collate results
import os
from datetime import datetime
import re
import collections
import os
import re
from datetime import datetime
archs = ["rv32i_zicsr", "rv32im_zicsr", "rv32imc_zicsr", "rv32imc_zba_zbb_zbc_zbs_zicsr", "rv32imafdc_zba_zbb_zbc_zbs_zicsr"]
@ -64,9 +64,9 @@ def run_arch_sweep():
current_date = datetime.now()
# Format date as a string in the format YYYYMMDD
date_string = current_date.strftime('%Y%m%d_%H%M%S')
dir = "run_"+date_string
target_dir = "run_"+date_string
# Create a directory with the date string as its name
os.mkdir(dir)
os.mkdir(target_dir)
# make a directory with the current date as its name
@ -75,8 +75,8 @@ def run_arch_sweep():
os.system("make clean")
os.system("make run ARCH="+arch)
for res in ["SizeOpt_size", "SizeOpt_speed", "SpeedOpt_size", "SpeedOpt_speed"]:
os.system("mv -f wally"+res+".json "+dir+"/wally"+res+"_"+arch+".json")
return dir
os.system("mv -f wally"+res+".json "+target_dir+"/wally"+res+"_"+arch+".json")
return target_dir
directory = run_arch_sweep()
#directory = "run_20231120_072037-caches"

View file

@ -2,9 +2,10 @@
# Daniel Torres 2022
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
import json
import subprocess
import sys
import json
import plotly.graph_objects as go
from plotly.subplots import make_subplots

View file

@ -41,11 +41,12 @@
# Add -d or --dist to report the distribution of loads, stores, and atomic ops.
# These distributions may not add up to 100; this is because of flushes or invalidations.
import math
import argparse
import math
import os
import sys
class CacheLine:
def __init__(self):
self.tag = 0

View file

@ -6,10 +6,12 @@
import argparse
import multiprocessing
import os
import sys
import multiprocessing
from multiprocessing import Pool, TimeoutError as MPTimeoutError
from multiprocessing import Pool
from multiprocessing import TimeoutError as MPTimeoutError
TIMEOUT_DUR = 60 # 1` minute
class bcolors:

View file

@ -66,17 +66,18 @@ Conclusion:
In summary, this Python script facilitates the automation of nightly regression builds, providing comprehensive reporting and email notification capabilities to ensure effective communication and monitoring of regression test results.
"""
import os
import shutil
from datetime import datetime
import time
import re
import markdown
import subprocess
import argparse
import logging
import os
import re
import shutil
import subprocess
import time
from datetime import datetime
from pathlib import Path
import markdown
class FolderManager:
"""A class for managing folders and repository cloning."""

View file

@ -26,13 +26,13 @@
## and limitations under the License.
################################################################################################
import argparse
import math
import os
import sys
import matplotlib.pyplot as plt
import math
import numpy as np
import argparse
import matplotlib.pyplot as plt
import numpy as np
RefDataBP = [('twobitCModel6', 'twobitCModel', 64, 128, 10.0060297551637), ('twobitCModel8', 'twobitCModel', 256, 512, 8.4320392215602), ('twobitCModel10', 'twobitCModel', 1024, 2048, 7.29493318805151),
('twobitCModel12', 'twobitCModel', 4096, 8192, 6.84739616147794), ('twobitCModel14', 'twobitCModel', 16384, 32768, 5.68432926870082), ('twobitCModel16', 'twobitCModel', 65536, 131072, 5.68432926870082),
@ -262,7 +262,7 @@ def ReportAsText(benchmarkDict):
if(not args.summary):
for benchmark in benchmarkDict:
print(benchmark)
for (name, type, entries, size, val) in benchmarkDict[benchmark]:
for (name, prefixName, entries, size, val) in benchmarkDict[benchmark]:
sys.stdout.write(f'{name} {entries if not args.size else size} {val if not args.invert else 100 - val:0.2f}\n')
def Inversion(lst):

View file

@ -12,13 +12,14 @@
# output.
#
##################################
import sys
import shutil
import os
import argparse
import multiprocessing
import os
import shutil
import sys
from collections import namedtuple
from multiprocessing import Pool, TimeoutError as MPTimeoutError
from multiprocessing import Pool
from multiprocessing import TimeoutError as MPTimeoutError
# Globals
WALLY = os.environ.get('WALLY')
@ -255,13 +256,13 @@ testfloatdivconfigs = [
"f_div_2_1_rv32gc", "f_div_2_1_rv64gc", "f_div_2_2_rv32gc",
"f_div_2_2_rv64gc", "f_div_2_4_rv32gc", "f_div_2_4_rv64gc",
"f_div_4_1_rv32gc", "f_div_4_1_rv64gc", "f_div_4_2_rv32gc",
"f_div_4_2_rv64gc", "f_div_4_4_rv32gc", "f_div_4_4_rv64gc"
"f_div_4_2_rv64gc", "f_div_4_4_rv32gc", "f_div_4_4_rv64gc",
]
# list of tests not supported by ImperasDV yet that should be waived during lockstep testing
lockstepwaivers = [
"WALLY-q-01.S_ref.elf", # Q extension is not supported by ImperasDV
"WALLY-cbom-01.S_ref.elf" #, # cbom extension is not supported by ImperasDV because there is no cache model in ImperasDV
"WALLY-cbom-01.S_ref.elf", #, # cbom extension is not supported by ImperasDV because there is no cache model in ImperasDV
]
##################################
@ -333,10 +334,7 @@ def addTestsByDir(testDir, config, sim, coverStr, configs, lockstepMode=0, breke
if file.endswith(fileEnd) and file.startswith(fileStart):
fullfile = os.path.join(dirpath, file)
fields = fullfile.rsplit('/', 3)
if fields[2] == "ref":
shortelf = f"{fields[1]}_{fields[3]}"
else:
shortelf = f"{fields[2]}_{fields[3]}"
shortelf = f"{fields[1]}_{fields[3]}" if fields[2] == "ref" else f"{fields[2]}_{fields[3]}"
if shortelf in lockstepwaivers: # skip tests that itch bugs in ImperasDV
print(f"{bcolors.WARNING}Skipping waived test {shortelf}{bcolors.ENDC}")
continue
@ -465,10 +463,9 @@ def selectTests(args, sims, coverStr):
if (args.testfloat or args.nightly): # for nightly, run testfloat along with others
testfloatconfigs = ["fdqh_rv64gc", "fdq_rv64gc", "fdh_rv64gc", "fd_rv64gc", "fh_rv64gc", "f_rv64gc", "fdqh_rv32gc", "f_rv32gc"]
for config in testfloatconfigs + testfloatdivconfigs:
tests = ["div", "sqrt", "cvtint", "cvtfp"]
if config in testfloatconfigs:
tests = ["div", "sqrt", "add", "sub", "mul", "cvtint", "cvtfp", "fma", "cmp"]
else:
tests = ["div", "sqrt", "cvtint", "cvtfp"]
tests.extend(["add", "sub", "mul", "fma", "cmp"])
if "f_" in config:
tests.remove("cvtfp")
for test in tests:

View file

@ -1,5 +1,5 @@
import shutil
import os
import shutil
# if WALLY is defined, then get it
WALLY_HOME = os.getenv("WALLY")

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import sys
import re
import sys
def usage():
print("Usage: ./renumber.py <input xdc file> <output xdc file>")

View file

@ -28,8 +28,8 @@
## either express or implied. See the License for the specific language governing permissions
## and limitations under the License.
################################################################################################
import os
import argparse
import os
import subprocess
# NOTE: make sure testbench.sv has the ICache and DCache loggers enabled!

View file

@ -1,18 +1,19 @@
#!/usr/bin/env python3
# Madeleine Masser-Frye (mmmasserfrye@hmc.edu) 06/2022
from collections import namedtuple
import re
import argparse
import csv
import os
import re
import subprocess
from matplotlib.cbook import flatten
import matplotlib.pyplot as plt
from collections import namedtuple
import matplotlib.lines as lines
import matplotlib.pyplot as plt
import numpy as np
from adjustText import adjust_text
from ppa.ppaAnalyze import noOutliers
from matplotlib import ticker
import argparse
import os
from matplotlib.cbook import flatten
from ppa.ppaAnalyze import noOutliers
def synthsintocsv():
@ -25,7 +26,7 @@ def synthsintocsv():
allSynths = output.decode("utf-8").split('\n')[:-1]
specReg = re.compile('[a-zA-Z0-9]+')
metricReg = re.compile('-?\d+\.\d+[e]?[-+]?\d*')
metricReg = re.compile(r'-?\d+\.\d+[e]?[-+]?\d*')
with open("Summary.csv", "w") as file:
writer = csv.writer(file)

View file

@ -5,18 +5,19 @@
# James Stine james.stine@okstate.edu 15 October 2023
#
import scipy.optimize as opt
import subprocess
import csv
import re
from matplotlib.cbook import flatten
import matplotlib.pyplot as plt
import matplotlib.lines as lines
import matplotlib as mpl
import numpy as np
from collections import namedtuple
import sklearn.metrics as skm # depricated, will need to replace with scikit-learn
import os
import re
import subprocess
from collections import namedtuple
import matplotlib as mpl
import matplotlib.lines as lines
import matplotlib.pyplot as plt
import numpy as np
import scipy.optimize as opt
import sklearn.metrics as skm # depricated, will need to replace with scikit-learn
from matplotlib.cbook import flatten
def synthsfromcsv(filename):
@ -48,7 +49,7 @@ def synthsintocsv():
allSynths = output.decode("utf-8").split("\n")[:-1]
specReg = re.compile("[a-zA-Z0-9]+")
metricReg = re.compile("-?\d+\.\d+[e]?[-+]?\d*")
metricReg = re.compile(r"-?\d+\.\d+[e]?[-+]?\d*")
with open("ppaData.csv", "w") as file:
writer = csv.writer(file)

View file

@ -5,11 +5,13 @@
# James Stine james.stine@okstate.edu 15 October 2023
#
import subprocess
import re
import subprocess
from multiprocessing import Pool
from ppaAnalyze import synthsfromcsv
def runCommand(module, width, tech, freq):
command = f"make synth DESIGN={module} WIDTH={width} TECH={tech} DRIVE=INV FREQ={freq} MAXOPT=1 MAXCORES=1"
subprocess.call(command, shell=True)

View file

@ -1,9 +1,10 @@
#!/usr/bin/env python3
# Madeleine Masser-Frye mmasserfrye@hmc.edu 1/2023
import argparse
import subprocess
from multiprocessing import Pool
import argparse
def runSynth(config, mod, tech, freq, maxopt, usesram):
global pool

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys
import fileinput
import sys
address = 0

View file

@ -6,6 +6,7 @@
# extract all arch test vectors
import os
wally = os.popen('echo $WALLY').read().strip()
def ext_bits(my_string):

View file

@ -6,6 +6,7 @@
# date created: 3-29-2023
import os
wally = os.popen('echo $WALLY').read().strip()
# print(wally)

View file

@ -1,2 +1,3 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

View file

@ -1,7 +1,7 @@
import logging
import os
import re
import shutil
import logging
import riscof.utils as utils
from riscof.pluginTemplate import pluginTemplate

View file

@ -1,6 +1,6 @@
import logging
import os
import re
import logging
import riscof.utils as utils
from riscof.pluginTemplate import pluginTemplate