Skip to content

Commit

Permalink
Merge branch 'layout_changes' of github.com:iu-parfunc/gibbon into la…
Browse files Browse the repository at this point in the history
…yout_changes
  • Loading branch information
vidsinghal committed Jan 21, 2024
2 parents 3b66084 + fdc9970 commit d465842
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ rightMostTreeRec iters tree = if iters <= 0

gibbon_main = let
tree = mkTree 29
newTree = iterate (rightMostTree tree) --(rightMostTreeRec 1 tree)
in () --printPacked newTree
newTree = iterate (rightMostTree tree)
in ()
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ rightMostTreeRec iters tree = if iters <= 0

gibbon_main = let
tree = mkTree 29
newTree = iterate (rightMostTree tree) --(rightMostTreeRec 1 tree)
in () --printPacked newTree
newTree = iterate (rightMostTree tree)
in ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import subprocess
import time
import statistics
import numpy as np
import scipy
import re
import os

iterations = 9

def mean_confidence_interval(data, confidence=0.95):
a = 1.0 * np.array(data)
n = len(a)
m, se = np.mean(a), scipy.stats.sem(a)
h = se * scipy.stats.t.ppf((1 + confidence) / 2., n-1)
return m, m-h, m+h

rootdir = "/home/vidush/workdisk/git/gibbon-main/gibbon-compiler/examples/layout_bench/ECOOP-2024-Bench/"

gibbonFiles = ['eval_r.hs', 'layout3FilterBlogs.hs', 'TreeExpoPre.hs', 'layout1TagSearch.hs', 'layout2ListLen.hs', 'layout8TagSearch.hs', 'layout2TagSearch.hs', 'layout8FilterBlogs.hs', 'TreeExpoIn.hs', 'layout4ContentSearch.hs', 'layout3ContentSearch.hs', 'eval_l.hs', 'TreeAddOnePre.hs', 'layout7TagSearch.hs', 'layout2ContentSearch.hs', 'TreeRightMost_l.hs', 'layout2FilterBlogs.hs', 'manyFuncs.hs', 'layout1PowerList.hs', 'TreeCopyPre.hs', 'TreeAddOneIn.hs', 'layout4TagSearch.hs', 'layout1ListLen.hs', 'TreeCopyPost.hs', 'layout8ContentSearch.hs', 'TreeRightMost_r.hs', 'TreeAddOnePost.hs', 'layout1ContentSearch.hs', 'TreeCopyIn.hs', 'layout7ContentSearch.hs', 'layout3TagSearch.hs', 'layout2PowerList.hs', 'layout5ContentSearch.hs', 'layout4FilterBlogs.hs', 'layout5FilterBlogs.hs', 'layout5TagSearch.hs', 'layout7FilterBlogs.hs', 'layout1FilterBlogs.hs', 'TreeExpoPost.hs']


# Compile all Gibbon binaries.
for subdir, dirs, files in os.walk(rootdir):

for file in files:

if ".hs" in file and file in gibbonFiles:

file_path = subdir + file

file_without_haskell_extension = file_path.replace(".hs", '')

iterTimes = []
for i in range(0, iterations):
start = time.time()
gibbon_cmd = subprocess.run(["gibbon", "--packed", "--no-gc", "--to-exe", file_path])
elapsed = time.time()
iterTimes.append(float(elapsed-start))

m, lb, ub = mean_confidence_interval(iterTimes)
median = statistics.median(iterTimes)
print("Gibbon Time: " + file + " : " + "Median: {}, Mean: {}, lb: {}, ub: {}".format(median, m, lb, ub))
print()




def parse_solver_times(array):

solver_times = []
for line in array:

result = re.findall("iter time: ((\d+).(\d+))", line)
#print(result)
if not result == []:
#print(float(result[0][0]))
solver_times.append(float(result[0][0]))

return sum(solver_times)


marmosetFiles = ['eval_r.hs', 'TreeExpoPre.hs', 'layout2ListLen.hs', 'layout8TagSearch.hs', 'layout8FilterBlogs.hs', 'TreeAddOnePre.hs', 'layout8ContentSearch.hs', 'TreeRightMost_l.hs', 'manyFuncs.hs', 'TreeCopyPre.hs', 'layout1PowerList.hs']


# Compile all Marmoset binaries.
for subdir, dirs, files in os.walk(rootdir):

for file in files:

if ".hs" in file and file in marmosetFiles:

file_path = subdir + file

iterTimes = []
solver_times = []

for i in range(0, iterations):
file_handle = open("solver_compile_stats.txt", "w")
start = time.time()
gibbon_cmd_haskell = subprocess.run(["gibbon", "--packed", "--no-gc", "--opt-layout-use-solver", "--opt-layout-global", "--to-exe", file_path], stdout=file_handle, stderr=file_handle)
elapsed = time.time()
file_handle.close()
iterTimes.append(float(elapsed-start))
read_file_handle = open("solver_compile_stats.txt", "r")
lines = read_file_handle.readlines()
read_file_handle.close()
solver_time = parse_solver_times(lines)
#print()
#print(solver_time)
#print()
solver_times.append(solver_time)
#print()

#print(iterTimes)
#print(solver_times)

file_handle.close()
read_file_handle.close()

m, lb, ub = mean_confidence_interval(iterTimes)
median = statistics.median(iterTimes)

mm, lbb, ubb = mean_confidence_interval(solver_times)
mediann = statistics.median(solver_times)
print(file + " (total_solver_time) : " + "Median: {}, Mean: {}, lb: {}, ub: {}".format(median, m, lb, ub))
print(file + " (only_solver_time) : " + "Median: {}, Mean: {}, lb: {}, ub: {}".format(mediann, mm, lbb, ubb))
print()




# Compile all Marmoset binaries.
for subdir, dirs, files in os.walk(rootdir):

for file in files:

if ".hs" in file and file in marmosetFiles:

file_path = subdir + file

iterTimes = []

for i in range(0, iterations):
start = time.time()
gibbon_cmd_haskell = subprocess.run(["gibbon", "--packed", "--no-gc", "--opt-layout-global", "--to-exe", file_path])
elapsed = time.time()
iterTimes.append(float(elapsed-start))

m, lb, ub = mean_confidence_interval(iterTimes)
median = statistics.median(iterTimes)
print(file + " (Greedy Times) : " + "Median: {}, Mean: {}, lb: {}, ub: {}".format(median, m, lb, ub))
print()

Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import subprocess
import time
import statistics
import numpy as np
import scipy
import re
import os
import sys

iterations = 9
inf_buffer_size = 10000000000

def mean_confidence_interval(data, confidence=0.95):
a = 1.0 * np.array(data)
n = len(a)
m, se = np.mean(a), scipy.stats.sem(a)
h = se * scipy.stats.t.ppf((1 + confidence) / 2., n-1)
return m, m-h, m+h

rootdir = "/home/vidush/workdisk/git/gibbon-main/gibbon-compiler/examples/layout_bench/ECOOP-2024-Bench/"


# Was thinking to make compile and run separate but not important right now.
#compileTrue = sys.argv[2]
#executeTrue = sys.argv[3]

executables = []

gibbonFiles = ['eval_r.hs', 'layout3FilterBlogs.hs', 'TreeExpoPre.hs', 'layout1TagSearch.hs', 'layout2ListLen.hs', 'layout8TagSearch.hs', 'layout2TagSearch.hs', 'layout8FilterBlogs.hs', 'TreeExpoIn.hs', 'layout4ContentSearch.hs', 'layout3ContentSearch.hs', 'eval_l.hs', 'TreeAddOnePre.hs', 'layout7TagSearch.hs', 'layout2ContentSearch.hs', 'TreeRightMost_l.hs', 'layout2FilterBlogs.hs', 'manyFuncs.hs', 'layout1PowerList.hs', 'TreeCopyPre.hs', 'TreeAddOneIn.hs', 'layout4TagSearch.hs', 'layout1ListLen.hs', 'TreeCopyPost.hs', 'layout8ContentSearch.hs', 'TreeRightMost_r.hs', 'TreeAddOnePost.hs', 'layout1ContentSearch.hs', 'TreeCopyIn.hs', 'layout7ContentSearch.hs', 'layout3TagSearch.hs', 'layout2PowerList.hs', 'layout5ContentSearch.hs', 'layout4FilterBlogs.hs', 'layout5FilterBlogs.hs', 'layout5TagSearch.hs', 'layout7FilterBlogs.hs', 'layout1FilterBlogs.hs', 'TreeExpoPost.hs']

# Compile all Gibbon binaries.
for subdir, dirs, files in os.walk(rootdir):

print("subdir: " + str(subdir))
print("dirs: " + str(dirs))
print("files: " + str(files))


for file in files:

if ".hs" in file and file in gibbonFiles:

file_path = subdir + file

file_without_haskell_extension = file_path.replace(".hs", '')
print("Compile " + file + "...")
gibbon_cmd = ["gibbon", "--no-gc", "--to-exe", "--packed", file_path]

c = subprocess.Popen(gibbon_cmd)
c.wait()
output, error = c.communicate()

if error is None:
print("Compiled " + file + " succesfully!")

executables.append(file_without_haskell_extension + ".exe")

print()


marmosetFiles = ['eval_r.hs', 'TreeExpoPre.hs', 'layout2ListLen.hs', 'layout8TagSearch.hs', 'layout8FilterBlogs.hs', 'TreeAddOnePre.hs', 'layout8ContentSearch.hs', 'TreeRightMost_l.hs', 'manyFuncs.hs', 'TreeCopyPre.hs', 'layout1PowerList.hs']


# Compile all Marmoset binaries.
for subdir, dirs, files in os.walk(rootdir):

print("subdir: " + str(subdir))
print("dirs: " + str(dirs))
print("files: " + str(files))


for file in files:

if ".hs" in file and file in marmosetFiles:

file_path = subdir + file

file_without_haskell_extension = file_path.replace(".hs", '')
print(file_without_haskell_extension)

solver_binary_name = file_without_haskell_extension + "Solver"
greedy_binary_name = file_without_haskell_extension + "Greedy"

executables.append(solver_binary_name)
executables.append(greedy_binary_name)

print("Compile " + file + " with solver optimization..." )
solver_cmd = ["gibbon", "--no-gc", "--to-exe", "--packed", "--opt-layout-global", "--opt-layout-use-solver", file_path, "-o", solver_binary_name]

c = subprocess.Popen(solver_cmd)
c.wait()
output, error = c.communicate()

if error is None:
print("Compiled " + file + " succesfully!")

print()

print("Compile " + file + " with greedy optimization..." )
greedy_cmd = ["gibbon", "--no-gc", "--to-exe", "--packed", "--opt-layout-global", file_path, "-o", greedy_binary_name]

c = subprocess.Popen(greedy_cmd)
c.wait()
output, error = c.communicate()

if error is None:
print("Compiled " + file + " succesfully!")


print()

#Run all executables
for file in executables:

#print(file)
runtimeFile = file + ".txt"

cmd = [file , "--inf-buffer-size", str(inf_buffer_size), "--iterate", "9"]

writeFileHandle = open(runtimeFile, "w")

try:
c = subprocess.Popen(cmd, stdout=writeFileHandle, stderr=subprocess.PIPE, universal_newlines=True)
c.wait()
output, error = c.communicate()
if error is not None:
cmd = [file , "--iterate", "9"]
c = subprocess.Popen(cmd, stdout=writeFileHandle, stderr=subprocess.PIPE, universal_newlines=True)
c.wait()
except:
print("Error could not run file!")

writeFileHandle.close()
readFileHandle = open(runtimeFile, "r")
fileLines = readFileHandle.readlines()

iterTimes = []
mean = 0.0
median = 0.0
for lines in fileLines:
search = re.match("itertime: (-?\ *[0-9]+\.?[0-9]*(?:[Ee]\ *-?\ *[0-9]+)?)", lines)
#print(search)
if search is not None:
iterTimes.append(float(search.groups()[0]))
#print(iterTimes)
mean = np.mean(iterTimes)
median = np.median(iterTimes)
a, l, u = mean_confidence_interval(iterTimes)
print(str(file) + "(mean:{0}, median:{1}, lower:{2}, upper:{3})".format(str(mean), str(median), str(l), str(u)))
readFileHandle.close()
8 changes: 1 addition & 7 deletions gibbon-compiler/examples/layout_bench/get_compile_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ def mean_confidence_interval(data, confidence=0.95):
h = se * scipy.stats.t.ppf((1 + confidence) / 2., n-1)
return m, m-h, m+h

#rootdir = "/local/scratch/a/singhav/Applications/src/gibbon/gibbon-compiler/examples/layout_benchmarks/blog_management/marmoset/"

rootdir = "/local/scratch/a/singhav/gibbon/gibbon-compiler/examples/layout_bench/"

ut_hash_include = "/local/scratch/a/singhav/Applications/src/uthash-2.3.0/include"

#Passes = ["ContentSearch", "DeleteTag", "InsertTag", "TagSearch"]
rootdir = "/home/vidush/workdisk/git/gibbon-main/gibbon-compiler/examples/layout_bench/ECOOP-2024-Bench/"

Passes = ["ContentSearch", "TagSearch", "FilterBlogs"]

Expand Down

0 comments on commit d465842

Please sign in to comment.