Skip to content

Commit

Permalink
Move evaluation scripts to separate directory
Browse files Browse the repository at this point in the history
  • Loading branch information
polybeandip committed Nov 4, 2024
1 parent 7a66029 commit 31fa876
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

shopt -s globstar

cd "$(dirname "$0")/../.." # move to root
cd "$(dirname "$0")/../../.." # move to root

declare -a files=(frontends/queues/tests/**/*.py)
num_files=${#files[@]}
Expand Down
16 changes: 16 additions & 0 deletions frontends/queues/evaluation/plot_pcap_sim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
import json


def append_path_prefix(file):
path_to_script = os.path.dirname(__file__)
path_to_file = os.path.join(path_to_script, file)
return path_to_file


def parse(file):
out[] =


if __name__ == "__main__":

Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ def draw(data, stat, logic, unit):
else:
ax.set_ylabel(f"{stat} ({unit})", fontsize=20)

file = ""

if logic == Logic.RR:
specialized = ax.scatter(
data["specialized"]["round_robin"].keys(),
Expand Down Expand Up @@ -83,39 +81,36 @@ def draw(data, stat, logic, unit):
ax.set_title("Strict Queues", fontweight="bold", fontsize=20)
file = append_path_prefix(f"{stat}_strict")

plt.legend(
(specialized, binheap),
("Specialized (i.e. Cassandra style)", "Binary Heap"),
fontsize=12,
)
plt.legend((specialized, binheap), ("Specialized", "Binary Heap"), fontsize=12)

plt.savefig(file)

print(f"Generated {file}.png")


# Parse data for round_robin and strict queues
stat = sys.argv[1]
data = {}
if stat == "total_time":
file1 = sys.argv[2]
file2 = sys.argv[3]

cycle_data = parse("cycles", file1)
slack_data = parse("worst_slack", file2)

data = cycle_data.copy()
for impl in data.keys():
for logic in data[impl].keys():
for flow_no in data[impl][logic].keys():
cycles = cycle_data[impl][logic][flow_no]
slack = slack_data[impl][logic][flow_no]
data[impl][logic][flow_no] = (1000 * cycles) / (7 - slack)
else:
file = sys.argv[2]
data = parse(stat, file)

# Draw results
unit = "μs" if stat == "total_time" else None
draw(data, stat, Logic.RR, unit)
draw(data, stat, Logic.STRICT, unit)
if __name__ == "__main__":
# Parse data for round_robin and strict queues
stat = sys.argv[1]
data = {}
if stat == "total_time":
file1 = sys.argv[2]
file2 = sys.argv[3]

cycle_data = parse("cycles", file1)
slack_data = parse("worst_slack", file2)

data = cycle_data.copy()
for impl in data.keys():
for logic in data[impl].keys():
for flow_no in data[impl][logic].keys():
cycles = cycle_data[impl][logic][flow_no]
slack = slack_data[impl][logic][flow_no]
data[impl][logic][flow_no] = (1000 * cycles) / (7 - slack)
else:
file = sys.argv[2]
data = parse(stat, file)

# Draw results
unit = "μs" if stat == "total_time" else None
draw(data, stat, Logic.RR, unit)
draw(data, stat, Logic.STRICT, unit)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ "$#" -gt 1 ]; then
exit 1
fi

cd "$(dirname "$0")/../.." # move to root
cd "$(dirname "$0")/../../.." # move to root

declare -a files=(frontends/queues/tests/**/*.py)
num_files=${#files[@]}
Expand Down
7 changes: 5 additions & 2 deletions frontends/queues/tests/binheap/strict/strict_2flow_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import calyx.builder as cb
import queues.queue_call as qc
import queues.sim_pcap as sp
import queues.binheap.strict as st
import queues.flow_inference as fi

Expand All @@ -15,11 +16,13 @@

prog = cb.Builder()

order = [1, 0]
if sim_pcap:
raise Exception("Not Implemented")
flow_infer = fi.insert_tuple_flow_inference(prog, "flow_inference", NUMFLOWS)
pifo = st.insert_binheap_strict(prog, "pifo", NUMFLOWS, order, flow_infer)
sp.insert_main(prog, pifo, num_cmds, NUMFLOWS)
else:
boundaries = [200, 400]
order = [1, 0]
flow_infer = fi.insert_boundary_flow_inference(
prog, "flow_inference", boundaries
)
Expand Down

0 comments on commit 31fa876

Please sign in to comment.