Skip to content

Commit

Permalink
add new results
Browse files Browse the repository at this point in the history
Signed-off-by: victoryang00 <yangyiwei2000@gmail.com>
  • Loading branch information
victoryang00 committed Mar 23, 2024
1 parent bec7667 commit 0a810fd
Show file tree
Hide file tree
Showing 17 changed files with 1,124 additions and 677 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ endif()
if (LINUX)
add_subdirectory(lib/libcrafter/libcrafter)
add_subdirectory(gateway)
add_executable(MVVM_profile src/profile.cpp ${UNCOMMON_SHARED_SOURCE})
target_link_libraries(MVVM_profile fmt::fmt spdlog::spdlog cxxopts::cxxopts ${BLAS_LIBRARIES} MVVM_export vmlib ${WIN_EXTRA_LIBS})
endif ()

file(GLOB_RECURSE SOURCE_FILES src/wamr*.cpp)
add_library(MVVM_export ${SOURCE_FILES} ${UNCOMMON_SHARED_SOURCE})
add_executable(MVVM_restore src/restore.cpp ${UNCOMMON_SHARED_SOURCE})
add_executable(MVVM_checkpoint src/checkpoint.cpp ${UNCOMMON_SHARED_SOURCE})
add_executable(MVVM_profile src/profile.cpp ${UNCOMMON_SHARED_SOURCE})

target_link_libraries(MVVM_export fmt::fmt spdlog::spdlog ${BLAS_LIBRARIES})
target_link_libraries(MVVM_restore fmt::fmt spdlog::spdlog cxxopts::cxxopts ${BLAS_LIBRARIES} MVVM_export vmlib ${WIN_EXTRA_LIBS})
target_link_libraries(MVVM_checkpoint fmt::fmt spdlog::spdlog cxxopts::cxxopts ${BLAS_LIBRARIES} MVVM_export vmlib ${WIN_EXTRA_LIBS})
target_link_libraries(MVVM_profile fmt::fmt spdlog::spdlog cxxopts::cxxopts ${BLAS_LIBRARIES} MVVM_export vmlib ${WIN_EXTRA_LIBS})
add_definitions(-DCXXOPTS_NO_RTTI=1)
235 changes: 181 additions & 54 deletions artifact/bench_comparison.py

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions artifact/bench_comparison_gapbs_mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,14 @@ def plot(results):


if __name__ == "__main__":
mvvm_results = run_mvvm()
native_results = run_native()
qemu_x86_64_results = run_qemu_x86_64()
# # print the results
qemu_aarch64_results = run_qemu_aarch64()
# mvvm_results = run_mvvm()
# native_results = run_native()
# qemu_x86_64_results = run_qemu_x86_64()
# # # print the results
# qemu_aarch64_results = run_qemu_aarch64()

write_to_csv("comparison_gapbs.csv")
# write_to_csv("comparison_gapbs.csv")

results = read_from_csv("comparison_gapbs.csv")
plot(results)

303 changes: 303 additions & 0 deletions artifact/bench_loop_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
import csv
import common_util
from common_util import (
plot_loop_counter,
plot_loop_counter_snapshot,
calculate_loop_counter_averages,
aot_variant_freq,
calculate_loop_counter_snapshot_averages,
)
from multiprocessing import Pool

cmd = [
"llama",
"bc",
"bfs",
"cc",
"cc_sv",
"pr",
"pr_spmv",
"sssp",
"tc",
"bt",
"cg",
"ep",
"ft",
"lu",
"mg",
"sp",
"redis",
# "hdastar",
]
folder = [
"llama",
"gapbs",
"gapbs",
"gapbs",
"gapbs",
"gapbs",
"gapbs",
"gapbs",
"gapbs",
"nas",
"nas",
"nas",
"nas",
"nas",
"nas",
"nas",
"redis",
# "hdastar",
]
arg = [
["stories110M.bin", "-z", "tokenizer.bin", "-t", "0.0"],
["-g20", "-vn300"],
["-g20", "-vn300"],
["-g20", "-vn300"],
["-g20", "-vn300"],
["-g20", "-vn300"],
["-g20", "-vn300"],
["-g20", "-vn300"],
["-g20", "-n1"],
[],
[],
[],
[],
[],
[],
[],
[],
# ["maze-6404.txt", "8"],
]
envs = [
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"a=b",
# "a=b",
]

pool = Pool(processes=16)


def run_mvvm():
results = [[] for _ in range(len(aot_variant_freq))]
name = []
results1 = []
for _ in range(common_util.trial):
for i in range(len(cmd)):
for j in range(len(common_util.aot_variant_freq)):
aot = cmd[i] + common_util.aot_variant_freq[j]
results1.append(
pool.apply_async(common_util.run, (aot, arg[i], envs[i]))
)
# print the results
results1 = [x.get() for x in results1]
exec_time = ""
for exec, output in results1:
lines = output.split("\n")
for line in lines:
if line.__contains__("Execution time:"):
exec_time = line.split(" ")[-2]
# print(exec, exec_time)

for a in common_util.aot_variant_freq:
if exec.__contains__(a):
if a == "-ckpt-loop-counter-1.aot":
results[0].append(exec_time)
elif a == "-ckpt-loop-counter-4.aot":
results[1].append(exec_time)
elif a == "-ckpt-loop-counter-8.aot":
results[2].append(exec_time)
elif a == "-ckpt-loop-counter-16.aot":
results[3].append(exec_time)
elif a == "-ckpt-loop-counter-20.aot":
results[4].append(exec_time)
elif a == "-ckpt-loop-counter-30.aot":
results[5].append(exec_time)
elif a == "-ckpt-loop-pgo.aot":
results[6].append(exec_time)
elif a == "-pure.aot":
results[8].append(exec_time)
elif (
a == ".aot"
and not exec.__contains__("-ckpt-loop-counter-1.aot")
and not exec.__contains__("-ckpt-loop-counter-4.aot")
and not exec.__contains__("-ckpt-loop-counter-8.aot")
and not exec.__contains__("-ckpt-loop-counter-16.aot")
and not exec.__contains__("-ckpt-loop-counter-20.aot")
and not exec.__contains__("-ckpt-loop-counter-30.aot")
and not exec.__contains__("-ckpt-loop-pgo.aot")
and not exec.__contains__("-pure.aot")
):
results[7].append(exec_time)
name.append(exec)
final_results = list(zip(name, *results))
print(results)
return final_results


def run_mvvm_profile():
results1 = []
# for _ in range(common_util.trial):
for i in range(len(cmd)):
# for j in range(len(common_util.aot_variant_freq)):
aot = cmd[i] + "-ckpt-loop-pgo.aot"
results1.append(
pool.apply_async(common_util.run_profile, (aot, arg[i], envs[i]))
)
results1 = [x.get() for x in results1]


def run_mvvm_snapshot():
results = [[] for _ in range(len(aot_variant_freq))]
name = []
results1 = []
for _ in range(common_util.trial):
for i in range(len(cmd)):
for j in range(len(common_util.aot_variant_freq)):
aot = cmd[i] + common_util.aot_variant_freq[j]
results1.append(
pool.apply_async(common_util.run_checkpoint, (aot, arg[i], envs[i]))
)
# print the results
results1 = [x.get() for x in results1]
exec_time = ""
for exec, output in results1:
lines = output.split("\n")
for line in lines:
if line.__contains__("Snapshot Overhead:"):
exec_time = line.split(" ")[-2]
# print(exec, exec_time)

for a in common_util.aot_variant_freq:
if exec.__contains__(a):
if a == "-ckpt-loop-counter-1.aot":
results[0].append(exec_time)
elif a == "-ckpt-loop-counter-4.aot":
results[1].append(exec_time)
elif a == "-ckpt-loop-counter-8.aot":
results[2].append(exec_time)
elif a == "-ckpt-loop-counter-16.aot":
results[3].append(exec_time)
elif a == "-ckpt-loop-counter-20.aot":
results[4].append(exec_time)
elif a == "-ckpt-loop-counter-30.aot":
results[5].append(exec_time)
elif a == "-ckpt-loop-pgo.aot":
results[6].append(exec_time)
elif a == "-pure.aot":
results[8].append(exec_time)
elif (
a == ".aot"
and not exec.__contains__("-ckpt-loop-counter-1.aot")
and not exec.__contains__("-ckpt-loop-counter-4.aot")
and not exec.__contains__("-ckpt-loop-counter-8.aot")
and not exec.__contains__("-ckpt-loop-counter-16.aot")
and not exec.__contains__("-ckpt-loop-counter-20.aot")
and not exec.__contains__("-ckpt-loop-counter-30.aot")
and not exec.__contains__("-ckpt-loop-pgo.aot")
and not exec.__contains__("-pure.aot")
):
results[7].append(exec_time)
name.append(exec)
final_results = list(zip(name, *results))
print(results)
return final_results


def write_to_csv(filename):
# 'data' is a list of tuples, e.g., [(checkpoint_result_0, checkpoint_result_1, restore_result_2), ...]
with open(filename, "a+", newline="") as csvfile:
writer = csv.writer(csvfile)
# Optionally write headers
writer.writerow(["name", *aot_variant_freq])

# Write the data
for idx, row in enumerate(mvvm_results):
writer.writerow(
[
row[0],
row[1],
row[2],
row[3],
row[4],
row[5],
row[6],
row[7],
row[8],
row[9],
]
)


def read_from_csv(filename):
with open(filename, "r") as csvfile:
reader = csv.reader(csvfile)
next(reader)
results = []
for row in reader:
results.append(
(
row[0],
float(row[1]),
float(row[2]),
float(row[3]),
float(row[4]),
float(row[5]),
float(row[6]),
float(row[7]),
float(row[8]),
float(row[9]),
)
)
return results


def read_from_csv_snapshot(filename):
with open(filename, "r") as csvfile:
reader = csv.reader(csvfile)
next(reader)
results = []
for row in reader:
results.append(
(
row[0],
float(row[1]),
float(row[2]),
float(row[3]),
float(row[4]),
float(row[5]),
float(row[6]),
)
)
return results


if __name__ == "__main__":
# run_mvvm_profile()
# mvvm_results = run_mvvm()
# write_to_csv("policy_loop_counter2.csv")
mvvm_results = read_from_csv("policy_loop_counter2.csv")
plot_loop_counter(mvvm_results, "policy_loop_counter.pdf")
print(calculate_loop_counter_averages(mvvm_results))
# mvvm_results = run_mvvm_snapshot()
# write_to_csv("policy_loop_snapshot.csv")
mvvm_results = read_from_csv_snapshot("policy_loop_snapshot.csv")
# mvvm_results = read_from_csv("policy_loop_snapshot.csv")
plot_loop_counter_snapshot(mvvm_results, "policy_loop_counter_snapshot.pdf")
print(calculate_loop_counter_snapshot_averages(mvvm_results))
Loading

0 comments on commit 0a810fd

Please sign in to comment.