Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*.o
*.jsmod
fractran
fractran-bench
*.prof
.vscode/
web/node_modules
web/gen
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,33 @@ Here's the implementation with some demo (hard coded) FRACTRAN programs called i

## Building and running the code

You need an installation of GHC. Then run `./build.sh` to compile, or run `./build.sh clean` to remove the build products. Then to run the demo, run `./fractran`.
You need an installation of GHC. Then run `./build.sh` to compile, or run `./build.sh clean` to remove the build products. The script now builds two binaries:

- `./fractran` for the original demo flow
- `./fractran-bench` for deterministic benchmark runs

On systems where only dynamic Haskell package artifacts are installed, `./build.sh` uses `-dynamic` by default so the build succeeds without extra package surgery. To run the original demo, use `./fractran`.

Example benchmark run:

```sh
./fractran-bench --program primegame --engine cycle --take 100
```

Available benchmark programs:

- `primegame`
- `paper`
- `hamming`
- `mult`

Available benchmark engines:

- `naive-fast`
- `reg`
- `frac-opt`
- `cycle`
- `compiled`

To build for the browser, there are more steps. You need to install docker and run `./build.sh --browser` to first populate `web/gen`. Webpack depends on the JS output from Asterius which gets dumped to that directory. Then cd into `web` and run `yarn` which will install the NPM package dependencies. You then should be able to run `yarn run serve`.

Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ if [ "$1" = '--browser' ]; then
else
if [ "$1" = 'clean' ]; then
rm -rf out;
rm -f fractran fractran-bench
exit 0
fi
mkdir -p out
ghc --make -prof -fprof-auto src/main.hs -isrc -odir out -hidir out -o fractran
GHC_FLAGS="-dynamic"
if [ "$1" = '--profile' ]; then
GHC_FLAGS="-prof -fprof-auto"
fi
ghc --make $GHC_FLAGS src/main.hs -isrc -odir out -hidir out -o fractran
ghc --make $GHC_FLAGS src/bench_main.hs -isrc -odir out -hidir out -o fractran-bench
fi
Loading