• Stars
    star
    157
  • Rank 237,511 (Top 5 %)
  • Language
    C
  • Created over 8 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A compiler for functional programs on serialized data

The Gibbon Compiler

test-gibbon

Gibbon is an experimental compiler that transforms high-level functional programs to operate on serialized data.

Typically, programs that process tree-like data represent trees using pointer-based data structures in memory (one heap object per-leaf and per-node) because such a layout is convenient to manipulate in a high-level programming language. This is also generally distinct from the representation of the data in serialized form on disk, which means that a program must perform some sort or marshaling when working with serialized data. Gibbon unifies the in-memory and serialized formats, transforming recursive functions to operate directly on serialized data.

Additionally, while the pointer-based structure is efficient for random access and shape-changing modifications, it can be inefficient for traversals that process most or all of a tree in bulk. The Gibbon project aims to explore optimizations of recursive tree transforms by changing how trees are stored in memory.

Currently, the Gibbon compiler has multiple front-ends: an s-expression synax 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. After you install Cabal, proceed to installing Gibbon's dependencies:

  • Ubuntu (works on 18.04, fails on 20.041]):
 $ sudo apt-get install libgc-dev libgmp-dev gcc-7 uthash-dev software-properties-common
 $ sudo add-apt-repository ppa:plt/racket && sudo apt update && sudo apt install racket
 $ sudo add-apt-repository ppa:hvr/ghc && sudo apt update && sudo apt install ghc-9.0.1 cabal-install-3.4
  • Add /opt/ghc/bin to path for cabal and ghc to work.
  • Install haskell stack using steps at https://docs.haskellstack.org/en/stable/install_and_upgrade/ (works with stack 2.7.3, the version in 18.04, i.e. stack 1.5.1-1 gives AesonException "Error in $['system-info']: key \"os\" not present")
  • Make gcc-7.5 the default gcc with sudo ln -sf /usr/bin/gcc-7 /usr/bin/gcc

1 Header files cilk/cilk.h and cilk/cilk_api.h are not present in libgcc-7-dev which comes with 20.04

  • OSX:

You can install some of the dependencies using Homebrew:

$ brew install libgc gmp gcc@7 ghc@9

Others require a few extra steps:

  1. Racket: Follow the instructions on it's website

  2. uthash: Clone the repository and copy all the .h files in src to /usr/local/include

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.0.1

At this point you can run the Gibbon executable:

$ cabal v2-exec -w ghc-9.0.1 gibbon -- -h

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

$ cd $GIBBONDIR && ./run_all_tests.sh

Using Gibbon

A valid Gibbon program can be written using Haskell syntax or using Racket-like s-expression syntax. Gibbon doesn't support every Haskell feature supported by GHC, but informally, many simple Haskell-98 programs (sans monads) are valid Gibbon programs. One thing to note is that the main point of entry for a Gibbon program is a function named gibbon_main, as opposed to the usual main. Here's a simple Gibbon program that builds a binary tree and sums up its leaves in parallel using a parallel tuple (par):

module Main where

data Tree = Leaf Int
          | Node Int Tree Tree

mkTree :: Int -> Tree
mkTree i =
  if i <= 0
  then Leaf 1
  else
      let x = (mkTree (i-1))
          y = (mkTree (i-1))
      in Node i x y

sumTree :: Tree -> Int
sumTree foo =
  case foo of
    Leaf i     -> i
    Node i a b ->
      let tup = par (sumTree a) (sumTree b)
          x = fst tup
          y = snd tup
      in x + y

gibbon_main = sumTree (mkTree 10)

The Gibbon compiler is able to run in several modes, which are configured via command line flags. Most important are the flags --packed which means "packed mode" (use serialized data structures), --run which means "compile then run", and --parallel which means "enable parallel execution". You can use these to run the above program as follows:

$ gibbon --run --packed --parallel Bintree.hs

This creates a file Bintree.c which contains the C-code, and a Bintree.exe which is the executable for this program. Running ./Bintree.exe prints 1024, the value of sumTree (mkTree 10). There are many other Gibbon features which can be learned by looking at the programs under ./examples/parallel/, and more flags which can be printed with gibbon --help. To view a complete set of primitives supported by Gibbon, you can look at the Gibbon.Prim module located at gibbon/gibbon-stdlib/Gibbon/Prim.hs.

About this repository

This primarily stores the Gibbon compiler, an implementation of a high-performance functional language.

This repository also contains a collection of sub-projects related to benchmarking tree traversals and performing tree traversals on packed representations. Here is a guide to the subdirectories:

  • gibbon-compiler - the prototype compiler for the Gibbon language of packed tree traversals.

  • gibbon - a Racket #lang for Gibbon.

  • ASTBenchmarks - benchmark of treewalks (compiler passes) on ASTs written with Gibbon. Also includes scripts to fetch input datasets.

  • BintreeBench - a submodule containing the tiniest binary tree microbenchmark, implemented several different languages and compilers.

  • core-harvest - tools to harvest realistic, large ASTs (mainly Racket) from the wild.

  • DEVLOG.md - detailed documentation for those hacking on this repository.

More Repositories

1

lvars

The LVish Haskell library
Haskell
81
star
2

haskell_dsl_tour

Examples of relevant technologies for implementing DSLs in Haskell.
Haskell
14
star
3

HSBencher

General benchmarking framework. Especially good at parameter studies.
Haskell
13
star
4

liteinst

Runtime application probing with lightweight binary instrumentation. Related to PLDI17.
C++
9
star
5

verified-instances

Verified instances for parallel programming.
Haskell
8
star
6

ShadowGuard

Low(er) Overhead Shadow Stack Implementation using Binary Static Analysis
C++
8
star
7

popl18-lh-prover-artifact

Artifact for "Towards Complete Verification via SMT"
Haskell
6
star
8

detflow

Haskell
4
star
9

sc-haskell

A survey on the topic of sequentially consistent Haskell.
Haskell
3
star
10

AutoObsidian

Autotuning and Obsidian
Haskell
3
star
11

superaccumulators

Commutative, associative floating-point operations
Haskell
3
star
12

pbbs

An clone of the latest release of the Problem-Based-Benchmark-Suite + some extra scripts on top
C++
3
star
13

isoref-sketch

Sketching out ideas for isolated references.
Haskell
2
star
14

accelerack

C Bindings for Accelerate, Racket Frontend to Accelerate
Racket
2
star
15

BintreeShootout

A simple microbenchmark for tree traversals
Racket
2
star
16

concurrent_cilk

This is the libcilkrts directory ONLY, extended with the Concurrent Cilk implementation. It is SUBTREE MERGED into the large gcc repo. See here: https://github.com/iu-parfunc/gcc
C++
2
star
17

haskell-hpx

Haskell bindings to the HPX library.
Haskell
2
star
18

detmonad-benchdata

Shell
1
star
19

accelerate-redex

A PLT Redex model for the Accelerate language.
Racket
1
star
20

bindings-hpx

Haskell bindings for the HPX library
Haskell
1
star
21

compile-o-rama

Dockerfile and or Nix expressions for building a whole bunch of compilers. Good starting point for microbenchmarking.
Nix
1
star
22

tslogger

thread-safe logging
Haskell
1
star
23

forkbench

A simple, standalone parfib-like benchmark.
C
1
star
24

array-dsl-benchmarks

A benchmark suite across multiple array DSLs, covering CPUs and GPUss
Haskell
1
star
25

pldi2014-artifact

The artifact-evaluation bundle for "Taming the Parallel Effect Zoo" (PLDI 2014)
HTML
1
star
26

cnf-mutable-tests

Haskell
1
star