Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout changes #237

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
15420f2
minor cleanup of README and gibbon-compiler/gibbon.cabal
ulysses4ever Nov 22, 2023
df7386f
Revert "Fix some iterate TODO's in layout pass"
vidsinghal Dec 10, 2023
71a07bb
Revert "Revert "Fix some iterate TODO's in layout pass""
vidsinghal Dec 10, 2023
4803d91
Revert "Fix some iterate TODO's in layout pass"
vidsinghal Dec 10, 2023
85b9f2a
Revert "remove duplicates"
vidsinghal Dec 10, 2023
e38eee8
Revert "[LayoutOpt]: Add a greedy heuristic to ameliorate solver time…
vidsinghal Dec 10, 2023
5026a72
Revert "add support for global layout optimization for multiple funct…
vidsinghal Dec 10, 2023
8441a8e
Revert "[LayoutOptimization] Test multiple functions. Producer Consum…
vidsinghal Dec 10, 2023
753eed4
Revert "remove old comment in test examples"
vidsinghal Dec 10, 2023
06d69d5
Revert "Add dyn flag to enable layout optimization. Remove dependency…
vidsinghal Dec 10, 2023
5937956
Revert "change failing test to pass"
vidsinghal Dec 10, 2023
21dda55
Revert "edit workflow"
vidsinghal Dec 10, 2023
5f33802
Revert "layout3TagSearch.hs: restore state"
vidsinghal Dec 10, 2023
e0b4495
Revert "forgot to add answer file"
vidsinghal Dec 10, 2023
7d079c8
Revert "Mark layout test failing since need academic liscense to inst…
vidsinghal Dec 10, 2023
e541ab4
Revert "move comments to bottom of file"
vidsinghal Dec 10, 2023
a7103dc
Revert "Main pass to optimize layout when user annotates function"
vidsinghal Dec 10, 2023
1c9b980
Revert "Add pass OptimizeADTLayout"
vidsinghal Dec 10, 2023
2d7234c
Revert "add synthetic bench from marmoset paper to tests"
vidsinghal Dec 10, 2023
c34321d
Revert "Filter blogs unit tests"
vidsinghal Dec 10, 2023
801083c
Revert "blog tag search unit tests"
vidsinghal Dec 10, 2023
bc7bca8
Revert "Additional layout unit tests"
vidsinghal Dec 10, 2023
16aded2
Revert "change failing tests"
vidsinghal Dec 10, 2023
d42428b
Revert "init some layout tests in the test-runner"
vidsinghal Dec 10, 2023
fdea1ec
Revert "AddRAN: missing fields in functionMeta record"
vidsinghal Dec 10, 2023
3280574
Revert "src: HaskellFrontend"
vidsinghal Dec 10, 2023
95a4499
Revert "Passes: Access patterns, update GHC version to 9.4.6 in CI"
vidsinghal Dec 10, 2023
365a109
Revert "fix L1 test"
vidsinghal Dec 10, 2023
be07b89
Revert "fix"
vidsinghal Dec 10, 2023
47b9d3c
Revert "Tests: Fix L1 Typecheck case to fix CI error"
vidsinghal Dec 10, 2023
9fc8680
Revert "Passes: CallGraph"
vidsinghal Dec 10, 2023
60e4a60
Revert "Passes: Support for Definition Use Chains"
vidsinghal Dec 10, 2023
5ff5eed
Revert "Passes: Control Flow Graph"
vidsinghal Dec 10, 2023
6c85f54
Fix-build errors due to merger
vidsinghal Dec 10, 2023
4c5da78
fix failing tests
vidsinghal Dec 10, 2023
c2d1501
WIP
vidsinghal Dec 5, 2023
5365ab0
WIP
vidsinghal Dec 9, 2023
e9a3c19
WIP
vidsinghal Dec 10, 2023
9f848dc
WIP: global opt working
vidsinghal Dec 10, 2023
ec35973
WIP
vidsinghal Dec 10, 2023
0747fe8
WIP
vidsinghal Dec 10, 2023
fa7950a
WIP
vidsinghal Dec 10, 2023
e705da4
WIP
vidsinghal Dec 10, 2023
3fb658e
WIP
vidsinghal Dec 10, 2023
2bbd45a
WIP
vidsinghal Dec 10, 2023
627b354
WIP
vidsinghal Dec 10, 2023
1307d9c
WIP
vidsinghal Dec 10, 2023
5f0360e
Fix infinite loop: inference of recursive and scalar attributes for f…
vidsinghal Dec 11, 2023
2d8b49b
WIP: make sure cost model penalizes placing scalar fields after recur…
vidsinghal Dec 11, 2023
d9de77c
WIP: Greedy mode for global optimization works
vidsinghal Dec 11, 2023
9cc1817
WIP
vidsinghal Dec 11, 2023
b66273b
WIP: decision Tree
vidsinghal Nov 9, 2023
4f5efe7
WIP
vidsinghal Dec 11, 2023
9958c73
WIP: fix logic errors
vidsinghal Dec 11, 2023
81cf339
Add a simple example to test scalar after packed field
vidsinghal Dec 15, 2023
12fbb16
Merge branch 'layout_changes' of github.com:iu-parfunc/gibbon into la…
vidsinghal Dec 15, 2023
6a8b8f5
WIP:fix single field use
vidsinghal Dec 29, 2023
4e729e2
Enable Papi high level stats within the iterate construct
vidsinghal Oct 9, 2023
6f36fdb
edits
vidsinghal Jan 8, 2024
c94f78c
remove dbg calls
vidsinghal Jan 8, 2024
cbc361f
Merge branch 'layout_changes' of github.com:iu-parfunc/gibbon into la…
vidsinghal Jan 8, 2024
cc4eb76
compile time script
vidsinghal Jan 9, 2024
cecb100
Add ghc bench that's in the paper
vidsinghal Jan 9, 2024
daebd24
add benchmarks in paper
vidsinghal Jan 9, 2024
2729734
Merge branch 'layout_changes' of github.com:iu-parfunc/gibbon into la…
vidsinghal Jan 9, 2024
508d2b0
Add user defined ordering back to new cost model
vidsinghal Jan 13, 2024
ef5e75e
ensure packedTy is not assigned a scalarTy
vidsinghal Jan 13, 2024
a164373
list example in design
vidsinghal Jan 16, 2024
d01ccdd
fix examples run in design
vidsinghal Jan 16, 2024
9a5d02e
Ecoop 2024 dockerfile
vidsinghal Jan 20, 2024
aa7b456
Add all benchmarks in one place
vidsinghal Jan 20, 2024
80f6cbf
Merge branch 'layout_changes' of github.com:iu-parfunc/gibbon into la…
vidsinghal Jan 20, 2024
663ab3b
forgot to commit iterate changes
vidsinghal Jan 20, 2024
fd8880c
Add automated script to get all the runtimes numbers in the tables fo…
vidsinghal Jan 20, 2024
fdc9970
add script to generate compile times
vidsinghal Jan 20, 2024
3b66084
cache script
vidsinghal Jan 21, 2024
d465842
Merge branch 'layout_changes' of github.com:iu-parfunc/gibbon into la…
vidsinghal Jan 21, 2024
a1b4724
edit
vidsinghal Jan 21, 2024
7cc0726
cache script
vidsinghal Jan 21, 2024
3940da9
makefile
vidsinghal Jan 21, 2024
d59bf09
remove dbg message
vidsinghal Jan 22, 2024
a6cd95d
remove harcoded papi path
vidsinghal Jan 22, 2024
25fa6ec
add misaligned pre
vidsinghal Jan 25, 2024
9918357
more bench examples
vidsinghal Jan 25, 2024
3da170f
edits
vidsinghal Jan 26, 2024
a82d9bb
edit
vidsinghal Jan 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .ECOOP-2024-artifact/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Ubuntu 22
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
ENV USERNAME=root


# install dependencies
RUN apt-get update && \
apt-get -y install --no-install-recommends software-properties-common && \
apt-get -y install --no-install-recommends \
libgc-dev \
python3 python3-dev python3-setuptools python-is-python3 python3-pip \
libgmp-dev \
build-essential \
uthash-dev \
vim \
wget \
curl

RUN wget --no-check-certificate https://mirror.racket-lang.org/installers/7.5/racket-7.5-x86_64-linux.sh
RUN chmod +x racket-7.5-x86_64-linux.sh
RUN ./racket-7.5-x86_64-linux.sh


# update path
USER ${USERNAME}
WORKDIR /${USERNAME}
ENV PATH="/${USERNAME}/.local/bin:/${USERNAME}/.cabal/bin:/${USERNAME}/.ghcup/bin:$PATH"
RUN echo "export PATH=${PATH}" >> /${USERNAME}/.profile

#install ghcup
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=9.4.6 BOOTSTRAP_HASKELL_CABAL_VERSION=3.8.1.0 BOOTSTRAP_HASKELL_INSTALL_STACK=1 BOOTSTRAP_HASKELL_INSTALL_HLS=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=P sh

# update cabal package list
RUN cabal update

ARG RUST=1.71.0

# install rustup, rustc, and cargo
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=${RUST}

RUN . "$HOME/.cargo/env"

ADD . /gibbon

RUN rm /gibbon/gibbon-rts/build/gibbon_rts.h

ENV PATH="$PATH:/gibbon/dist-newstyle/build/x86_64-linux/ghc-9.0.1/gibbon-0.3/x/gibbon/build/gibbon"

#Python dependencies
RUN pip install cplex
RUN pip install docplex
RUN pip install statistics
RUN pip install numpy as np
RUN pip install scipy
RUN pip install re


#Install PAPI
RUN wget https://github.com/icl-utk-edu/papi/archive/refs/tags/papi-7-1-0-t.tar.gz
RUN mkdir papi
RUN tar -xvzf papi-7-1-0-t.tar.gz -C papi
RUN cd papi
RUN cd papi-papi-7-1-0-t
RUN cd src
RUN ./configure
RUN make -j10
RUN make install




CMD ["bash"]
4 changes: 2 additions & 2 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.4.6
- compiler: ghc-9.6.2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9.6.3 is the latest now :-)

compilerKind: ghc
compilerVersion: 9.4.6
compilerVersion: 9.6.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.5
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ similar to Typed Racket, and a small subset of Haskell.

## Building Gibbon

Gibbon is implemented in Haskell, and is set up to be built with
[Cabal](https://cabal.readthedocs.io/en/3.4/).
### Getting Dependencies

Follow the instructions below to have all dependencies.
Gibbon is implemented in Haskell, and is set up to be built with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README changes come from a different PR merged earlier. Just a heads-up.

[Cabal](https://cabal.readthedocs.io/en/latest/), but it has a number of native dependencies.
Follow the instructions below to get all dependencies or enter the Nix shell
with `nix-shell` to get them via [Nix](https://nix.dev/).

- Ubuntu 22.04:
(Parallelism support temporarily not available with ubuntu 22.04 as Cilk support is not avaiable with newer gcc)
Expand Down Expand Up @@ -77,24 +79,25 @@ Others require a few extra steps:

2. [uthash](https://github.com/troydhanson/uthash): Clone the [repository](https://github.com/troydhanson/uthash) and copy all the `.h` files in `src` to `/usr/local/include`

### Actually Building Gibbon

After you have both Cabal and all the dependencies installed, you can build
Gibbon from source:

$ git clone https://github.com/iu-parfunc/gibbon
$ cd gibbon && source set_env.sh
$ cd gibbon-compiler && cabal v2-build . -w ghc-9.4.6
$ cd gibbon-compiler && cabal v2-build

At this point you can run the Gibbon executable:

$ cabal v2-exec -w ghc-9.4.6 gibbon -- -h
$ cabal v2-run gibbon -- -h

If you'd like to run the testsuite, you can do so with:

$ cd $GIBBONDIR && ./run_all_tests.sh
$ ./run_all_tests.sh


## Building a Developement docker container for Gibbon
### Building a Developement docker container for Gibbon

To build the Dockerfile for dev purposes run the command below from the gibbon directory.

Expand Down
135 changes: 135 additions & 0 deletions gibbon-compiler/PAPI_BINARIES/papi_stats2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import os
import subprocess
import re
import numpy as np
import scipy.stats
import json


rootdir="/local/scratch/a/singhav/gibbon/gibbon-compiler/PAPI_BINARIES/"
papi_dir = "/local/scratch/a/singhav/gibbon/gibbon-compiler/PAPI_BINARIES/papi_hl_output/"

iterations = 9

for subdir, dirs, files in os.walk(rootdir):

# subdirectories where the c++ compilation occurs have dirs == []
#if dirs == []:

# Opening JSON file

papi_tot_ins = 0
papi_tot_cyc = 0
papi_l3 = 0
papi_l2_dcm = 0
papi_l3_accesses = 0
for f in files:
if "." not in f:

#print(subdir)
#print(f)

cmd2 = ["rm", "-rf", papi_dir]
c1 = subprocess.Popen(cmd2, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
c1.wait()


#if "Solver" in f and "Filter" not in f:
# cmd = ["./" + f , "--inf-buffer-size", "10000000000", "--biginf-buffer-size", "1000000000", "--iterate", "9"]
#else:
# cmd = ["./" + f , "--iterate", "9"]

#c = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
#c.wait()
cmd = ["./" + f , "--inf-buffer-size", "10000000000", "--iterate", "9"]

#print(cmd)
#writeFileHandle = open(runtimeFile, "w")

try:
c = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
c.wait()
output, error = c.communicate()
#if error is not None:
# cmd = ["./" + f , "--iterate", "9"]
# c = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
# c.wait()
except:
print("ERROR!")
print(e.message)
#cmd = ["./" + f , "--iterate", "9"]
#c = subprocess.Popen(cmd, stdout=writeFileHandle, stderr=subprocess.PIPE, universal_newlines=True)
#c.wait()

#if error is not None:
# cmd = ["./" + f , "--iterate", "9"]
# c = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
# c.wait()

if not os.path.exists(papi_dir):
cmd = ["./" + f , "--iterate", "9"]
c = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
c.wait()


file_name = os.listdir(papi_dir)[0]
file_path = os.path.join(papi_dir, file_name)
fl = open(file_path)

# returns JSON object as
# a dictionary
data = json.load(fl)

# Iterating through the json
# list

#for key in data:
# print(key)
# print(data[key])
# print()

#print(data['threads'])

stats = data['threads']['0']['regions']
#print(stats)
if len(stats) == iterations:
for i in range(0, iterations):
#print(i)
#print(stats[str(i)])
#print()

iter_stats = stats[str(i)]
#print(iter_stats['PAPI_TOT_INS'])
#print(iter_stats['PAPI_TOT_CYC'])
#print(iter_stats['PAPI_L2_DCM'])
#print()

papi_tot_ins += int(iter_stats['PAPI_TOT_INS'])
papi_tot_cyc += int(iter_stats['PAPI_TOT_CYC'])
#papi_l3 += int(iter_stats['PAPI_L3_TCM'])
#papi_l3_accesses += int(iter_stats['PAPI_L3_DCA'])
papi_l2_dcm += int(iter_stats['PAPI_L2_DCM'])

tot_ins_avg = papi_tot_ins / iterations
papi_tot_cyc = papi_tot_cyc / iterations
#papi_l3_avg = papi_l3 / iterations
#papi_l3_accesses_avg = papi_l3_accesses / iterations
papi_l2_dcm_avg = papi_l2_dcm / iterations

#print(f + " : " + "ins : {}, cyc : {}, l3 misses : {}, l3 accesses : {}, miss rate : {}".format(tot_ins_avg, papi_tot_cyc, papi_l3_avg, papi_l3_accesses_avg, float(papi_l3_avg/papi_l3_accesses_avg)))
print(f + " : " + "ins : {}, cyc : {}, l2 dcm : {}".format(tot_ins_avg, papi_tot_cyc, papi_l2_dcm_avg))

#print(tot_ins_avg)
#print(papi_tot_cyc)
#print(papi_l2_avg)

papi_tot_ins = 0
papi_tot_cyc = 0
papi_l3 = 0
papi_l3_accesses = 0
papi_l2_dcm = 0


# Closing file
fl.close()

4 changes: 2 additions & 2 deletions gibbon-compiler/examples/layout_bench/Basics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ mkContentFromText f =
-- This creates all the base cases for the inline type
mkInlineBaseCase :: Int -> Inline
mkInlineBaseCase option =
if option == 0 then (Str (getRandomString 5)) -- get a random word
if option == 0 then (Str (getRandomString 1)) -- get a random word
else Space

-- Make a list of Inline data Type.
Expand All @@ -482,7 +482,7 @@ mkInlineList' length index words =

mkRandomInlineList :: Int -> (PList Inline)
mkRandomInlineList len = if len <= 0 then Nil
else let word = Str (getRandomString 1)
else let word = Str (getRandomString 5)
rst = mkRandomInlineList (len - 1)
in Cons word rst

Expand Down
79 changes: 79 additions & 0 deletions gibbon-compiler/examples/layout_bench/DecisionTree.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
module Bench where
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it layout_bench and layout_benchmarks? Should it be one directory?

Also, I propose adding more subdirectories inside layout_benchmarks, and putting most files inside them, so that the structure is clearer.


import Basics
import Gibbon.Vector
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you squint, you will notice in this line and many others there is a trailing space. This usually can be handled appropriately by your editor. E.g. VS Code: https://stackoverflow.com/a/53663494/465100

import Gibbon.PList

type String = Vector Char

data PackedBool = B Int

data DecisionTree = Node PackedBool Inline DecisionTree DecisionTree | Leaf Inline



mkRandomDecisionTree :: Int -> DecisionTree
mkRandomDecisionTree depth = if depth <= 0 then Leaf (Str (getRandomString 10))
else
let randBool = mod rand 2
randString = getRandomString 500
inline = Str randString
leftSubtree = mkRandomDecisionTree (depth-1)
rightSubtree = mkRandomDecisionTree (depth-1)
in Node (B randBool) inline leftSubtree rightSubtree



fromInline :: Inline -> String
fromInline inline = case inline of
Str a -> a

fromBool :: PackedBool -> Int
fromBool b = case b of
B bb -> bb

merge_plist :: PList Inline -> PList Inline -> PList Inline
merge_plist lst1 lst2 = case lst1 of
Cons x rst -> Cons x (merge_plist rst lst2)
Nil -> lst2


append_plist :: PList Inline -> Inline -> PList Inline
append_plist lst elem = case lst of
Nil -> (Cons elem) Nil
Cons x rst -> Cons x (append_plist rst elem)

singleton_plist :: Inline -> PList Inline
singleton_plist elem = (Cons elem) Nil


accumulateDecisions :: DecisionTree -> PList Inline
accumulateDecisions tree = case tree of
Node b str left right -> let bb = fromBool b
in if bb == 1
then
let curr = append_plist Nil str
vecLeft = accumulateDecisions left
temp = merge_plist curr vecLeft
vecRight = accumulateDecisions right
in merge_plist temp vecRight
else
let vecLeft = accumulateDecisions left
vecRight = accumulateDecisions right
in merge_plist vecLeft vecRight

Leaf str -> (Cons str) Nil


gibbon_main =
let tree = mkRandomDecisionTree 20
vec = iterate (accumulateDecisions tree)
in ()

--- filter

--- Map

--- Search

--- Length
Loading
Loading