update scripts

This commit is contained in:
Richard Yan
2025-01-30 18:03:21 -08:00
parent 7a88736430
commit ce3fa99465
6 changed files with 135 additions and 28 deletions

View File

@@ -3,6 +3,7 @@
import sys import sys
import signal import signal
import re import re
import time
PRINT_BUF = 0x20000 / 4 PRINT_BUF = 0x20000 / 4
@@ -54,9 +55,9 @@ def translator(line):
return "" return ""
def timestamp_parser(line): def timestamp_parser(line):
parts = line.strip().split() match = re.match(r"^\s*(\d+):", line)
if parts: if match:
return parts[0][:-1] return match.group(1)
else: else:
return "" return ""
@@ -65,13 +66,16 @@ sim_ended = False
def signal_handler(sig, frame): def signal_handler(sig, frame):
if sim_started: if sim_started:
print("\033[u") print("\033[B")
sys.exit(0) sys.exit(0)
def main(): def main():
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
current_timestamp = "" curr_timestamp = -1
prev_timestamp = -1
curr_clock = time.time()
prev_clock = time.time()
re_start_num = re.compile(r"^\s*[0-9]+:") re_start_num = re.compile(r"^\s*[0-9]+:")
print("\033[2J\033[H") print("\033[2J\033[H")
@@ -81,28 +85,36 @@ def main():
perf_counters = False perf_counters = False
hang_detector = 0 hang_detector = 0
if (len(sys.argv) > 1) and (sys.argv[1] == "started"):
sim_started = True
for line in sys.stdin: for line in sys.stdin:
line = line.rstrip('\n') line = line.rstrip('\n')
ts_countdown -= 1
if "Chronologic VCS simulator" in line: if "Chronologic VCS simulator" in line:
sim_started = True sim_started = True
sim_nontrace = re.match(re_start_num, line) is None sim_nontrace = re.match(re_start_num, line) is None
if "has no more active warps" in line:
sim_ended = True
if "====================CORE" in line: if "====================CORE" in line:
perf_counters = True perf_counters = True
if hang_detector >= 8: if hang_detector >= 8:
print("\n\033[3mpossible hang detected\033[0m\n") print("\n\033[3mpossible hang detected\033[0m\n")
if (not sim_started) or sim_ended: if "has no more active warps" in line:
if "has no more active warps" not in line: sim_ended = True
print(line)
if (not sim_started):
print(line)
continue continue
elif sim_started and (not sim_ended):
if sim_ended:
if "has no more active warps" not in line:
sim_ended = False
else:
continue
if sim_started and (not sim_ended):
if sim_nontrace: if sim_nontrace:
if not perf_counters: if not perf_counters:
print(line) print(line)
@@ -114,19 +126,24 @@ def main():
hang_detector = 0 hang_detector = 0
if ts_countdown == 0: if ts_countdown == 0:
timestamp = timestamp_parser(line) match = re.match(r"^\s*(\d+):", line)
if match:
if timestamp: prev_clock = curr_clock
current_timestamp = timestamp prev_timestamp = curr_timestamp
curr_clock = time.time()
curr_timestamp = match.group(1)
speed_in_hz = (int(curr_timestamp) - int(prev_timestamp)) / (curr_clock - prev_clock) if curr_clock - prev_clock > 0 else 0
# Save cursor position # Save cursor position
print("\033[s", end='') print("\033[s", end='')
# Move cursor to top-left corner, clear line, bold, timestamp, unbold # Move cursor to top-left corner, clear line, bold, timestamp, unbold
print("\033[H\033[2K\033[1", current_timestamp, "\033[0m", end='') print("\033[H\033[2K\033[1m[TIME]", curr_timestamp, "[SPEED]", int(speed_in_hz), "\033[0m", end='')
# Restore cursor position # Restore cursor position
print("\033[u", end='') print("\033[u", end='', flush=True)
ts_countdown = 100
ts_countdown = 200
else: else:
ts_countdown = 1 ts_countdown = 10
ts_countdown -= 1 ts_countdown -= 1
translated_line = translator(line) translated_line = translator(line)

View File

@@ -156,7 +156,9 @@ def main():
print(translated_line, end='') print(translated_line, end='')
sys.stdout.flush() sys.stdout.flush()
print("") print("\033[s", end='')
print("\033[" + str(lineno) + "H\033[2K\033[1m" + run_label, "DONE", "\033[0m", end='')
print("\033[u", end='', flush=True)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@@ -47,7 +47,6 @@ suffix="-debug"
dims=(256 512 1024) dims=(256 512 1024)
for dim in "${dims[@]}"; do for dim in "${dims[@]}"; do
echo "$element"
start_run VirgoFP16Config sgemm_tcore/kernel.radiance.gemm.tcore.volta.dim${dim}.elf "volta${dim} " "${suffix}" start_run VirgoFP16Config sgemm_tcore/kernel.radiance.gemm.tcore.volta.dim${dim}.elf "volta${dim} " "${suffix}"
start_run VirgoFP16Config sgemm_tcore/kernel.radiance.gemm.tcore.ampere.dim${dim}.elf "ampere${dim}" "${suffix}" start_run VirgoFP16Config sgemm_tcore/kernel.radiance.gemm.tcore.ampere.dim${dim}.elf "ampere${dim}" "${suffix}"
start_run VirgoHopperConfig sgemm_tcore/kernel.radiance.gemm.tcore.hopper.dim${dim}.elf "hopper${dim}" "${suffix}" start_run VirgoHopperConfig sgemm_tcore/kernel.radiance.gemm.tcore.hopper.dim${dim}.elf "hopper${dim}" "${suffix}"

43
sims/vcs/scripts/runtime_all.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
set -e
echoerr() { echo "$@" 1>&2; }
CURRENT_DIR="${PWD##*/}"
if [[ "$CURRENT_DIR" != "vcs" ]]; then
echoerr "Error: This script must be run from chipyard/sims/vcs."
exit 1
fi
source ./scripts/env.sh > /dev/null
rm -f /tmp/markers.log
runtime() {
log_path="output/chipyard.harness.TestHarness.$1/kernel.radiance.gemm.$2.log"
check_exists "${log_path}"
if [ -z "$(tail -n10 ${log_path} | rg 'finish called')" ]; then
echo "$3,0"
return
fi
rg "(e0d0a013|be90a013)" ${log_path} > /tmp/markers.log
echo -n "$3,"
python3 ./scripts/runtime_fast.py /tmp/markers.log
rm -f /tmp/markers.log
}
check_exists() {
if ! [ -f "$1" ]; then
echoerr "Error: looked for file $1 that does not exist."
exit 1
fi
}
echo ",cycles"
dims=(256 512 1024)
for dim in "${dims[@]}"; do
runtime VirgoFP16Config tcore.volta.dim${dim} "volta${dim}"
runtime VirgoFP16Config tcore.ampere.dim${dim} "ampere${dim}"
runtime VirgoHopperConfig tcore.hopper.dim${dim} "hopper${dim}"
runtime VirgoHopperConfig virgo.hopper.dim${dim} "virgo${dim}"
done

View File

@@ -0,0 +1,48 @@
import re
import argparse
def parse_log(file_path):
# Compile regular expressions for the required substrings and format
pc_line_pattern = re.compile(r"^\s+(\d+):.*?PC=0x([\da-f]+).*?instr=(0xbe90a013|0xe0d0a013).*?$")
commit_line_pattern = re.compile(r"^\s+(\d+):.*commit:.*$")
# PC=0x800007a0, instr=0xbe90a013
# Initialize dictionaries to track first and last occurrences
beg_const = "0xbe90a013"
end_const = "0xe0d0a013"
occurrences = {
beg_const: {"first": None, "last": None},
end_const: {"first": None, "last": None}
}
# pc = {
# "0xbe90a013": None,
# "0xe0d0a013": None
# }
with open(file_path, 'r') as log_file:
for line in log_file:
match = pc_line_pattern.search(line)
if match:
timestamp = int(match.group(1))
pc_value = match.group(2)
data_value = match.group(3)
if occurrences[data_value]["first"] is None:
occurrences[data_value]["first"] = timestamp
occurrences[data_value]["last"] = timestamp
return occurrences
if __name__ == "__main__":
# Set up command-line argument parsing
parser = argparse.ArgumentParser(description="Parse log file for specific substrings and their timestamps.")
parser.add_argument("file_path", help="Path to the log file to parse")
# Parse command-line arguments
args = parser.parse_args()
# Parse the log file and print the result
result = parse_log(args.file_path)
# print(result)
print(f"{int((result['0xe0d0a013']['last'] - result['0xbe90a013']['first']) * 0.4)}")

View File

@@ -9,8 +9,6 @@ fsdbs=(
) )
for fsdb_file in "${fsdbs[@]}"; do for fsdb_file in "${fsdbs[@]}"; do
#n=${files_and_n_values[$fsdb_file]}
n=256
echo "parsing sharedmem reads for file $fsdb_file" echo "parsing sharedmem reads for file $fsdb_file"
@@ -24,11 +22,11 @@ for fsdb_file in "${fsdbs[@]}"; do
# Clean up temp file # Clean up temp file
rm -f /tmp/smem_activity.log rm -f /tmp/smem_activity.log
echo "reads: $reads" echo "number of 4-byte reads: $reads"
# Calculate final value # Calculate final value
result=$(echo "scale=6; $reads / ($n * $n / 64)" | bc) result=$(echo "scale=3; $reads * 4 / 1048576" | bc)
echo -e "multiple of input data size: $result\n" echo -e "total read data in MiB: $result\n"
done done