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

Define two binaries for compiler and deprecate futil in favor of calyx #1454

Merged
merged 7 commits into from
May 9, 2023
Merged
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: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"-b",
"${input:backend}",
],
"program": "${workspaceFolder}/target/debug/futil",
"program": "${workspaceFolder}/target/debug/calyx",
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"sourceLanguages": [
Expand Down
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ features = ["matrix_graph"]
name = "calyx"
version = "0.1.3"
build = false
default-run = "calyx"
edition.workspace = true
description.workspace = true
authors.workspace = true
Expand All @@ -58,9 +59,13 @@ categories.workspace = true
readme.workspace = true

[[bin]]
name = "futil"
name = "calyx"
path = "src/main.rs"

[[bin]]
name = "futil"
path = "src/futil.rs"

[dependencies]
atty.workspace = true
itertools.workspace = true
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,19 @@ RUN cargo build --all

# Install fud
WORKDIR /home/calyx/fud
RUN FLIT_ROOT_INSTALL=1 flit install --symlink
RUN FLIT_ROOT_INSTALL=1 flit install --symlink --deps production
RUN mkdir -p /root/.config
ENV PATH=$PATH:/root/.local/bin
ENV PYTHONPATH=/root/.local/lib/python3.9/site-packages:$PYTHONPATH

# Setup fud
RUN fud config --create global.futil_directory /home/calyx && \
fud config stages.dahlia.exec '/home/dahlia/fuse' && \
fud config stages.futil.exec '/home/calyx/target/debug/futil' && \
fud config stages.futil.exec '/home/calyx/target/debug/calyx' && \
fud config stages.interpreter.exec '/home/calyx/target/debug/interp' && \
fud register ntt -p '/home/calyx/frontends/ntt-pipeline/fud/ntt.py' && \
fud register mrxl -p '/home/calyx/frontends/mrxl/fud/mrxl.py'
fud register mrxl -p '/home/calyx/frontends/mrxl/fud/mrxl.py' && \
fud c --delete stages.verilog.top_module

# Install calyx-py
WORKDIR /home/calyx/calyx-py
Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@

Calyx is an intermediate language and infrastructure for building compilers that generate custom hardware accelerators.

See the [Calyx website][site], [language documentation][docs] and the
[documentation for the source code][source-docs]
for more information. Calyx's design is based on [our paper][paper].
See the [Calyx website][site], [language documentation][docs] and the [documentation for the source code][source-docs] for more information.
Calyx's design is based on [our paper][paper].

## Installation

### Quick
If you want to try out the compiler, install it using `cargo`:
```
cargo install futil
cargo install calyx
```

This will install the `futil` binary which includes the calyx frontend,
optimization passes, and several backends.
This will install the `calyx` binary can optimize and compile Calyx programs to Verilog or [CIRCT][].

### Recommended

Expand All @@ -31,16 +29,22 @@ Follow the [getting started][docs] instructions.
## Organization

This repository contains the source code for the following:
1. [`calyx`][] (`calyx/`): The intermediate representation used for hardware
accelerator generation.
2. [`futil`][] (`src/`): The compiler infrastructure for compiling Calyx programs.
If `calyx` is like LLVM, then `futil` is Clang.
3. Calyx debugger (`interp/`): An interpreter and debugger for Calyx.
4. `fud`, The Calyx driver: Utility tool that wraps various hardware toolchains.
* [`calyx-utils`][]: Utilities for the Calyx compiler
* [`calyx-frontend`][]: Parser and frontend AST for the Calyx language.
* [`calyx-ir`][]: The Calyx intermediate language.
* [`calyx-opt`][]: Optimizations for the Calyx intermediate language.
* [`calyx`][]: The Calyx compiler driver.

You can also use the Calyx compiler as a library and implement your own optimizations. To do this, following the [source documentation][source-docs].

[site]: https://calyxir.org
[docs]: https://docs.calyxir.org
[source-docs]: https://docs.calyxir.org/source/calyx
[paper]: https://rachitnigam.com/files/pubs/calyx.pdf

[`calyx-utils`]: https://crates.io/crates/calyx-utils
[`calyx-frontend`]: https://crates.io/crates/calyx-frontend
[`calyx-ir`]: https://crates.io/crates/calyx-ir
[`calyx-opt`]: https://crates.io/crates/calyx-opt
[`calyx`]: https://crates.io/crates/calyx
[`futil`]: https://crates.io/crates/futil
[circt]: https://docs.calyxir.org/fud/circt.html
2 changes: 1 addition & 1 deletion docs/fud/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fud config stages.futil.exec
Keys can be updated using `fud config key value`.
For example, the following command updates the path to the Calyx compiler.
```bash
fud config stages.futil.exec ./target/debug/futil
fud config stages.futil.exec ./target/debug/calyx
```

## Adding Backends
Expand Down
18 changes: 16 additions & 2 deletions docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ generated by Calyx.

## Compiler Installation

Install [Rust][rust] (it should automatically install `cargo`).
Calyx is written in Rust. First, install [Rust][rust] (it should automatically install `cargo`).

### Install Crate

If you want just to play with the compiler, install the [`calyx` crate][calyx-crate]:
```
cargo install calyx
```
This will install the `calyx` binary which can optimize and compile Calyx programs. You will still need the [`primitives/core.futil`][core-lib] and [its accompanying Verilog file](https://github.com/cucapra/calyx/blob/master/primitives/core.sv) library to compile most programs.

### Installing from Source

Follow these instructions if you want to modify the compiler.


Clone the repository:
```
Expand All @@ -23,7 +36,7 @@ cargo build
You can invoke the compiler in one of two ways:
```
cargo run -- --help # Rebuilds the compiler if the sources changed
./target/debug/futil --help # Default debug build of the compiler
./target/debug/calyx --help # Default debug build of the compiler
```

## Running Core Tests
Expand Down Expand Up @@ -138,3 +151,4 @@ Congratulations! You've simulated your first hardware design with Calyx.
[fud-icarus]: ./fud/index.md#icarus-verilog
[fud-verilator]: ./fud/index.md#verilator
[icarus-install-source]: https://iverilog.fandom.com/wiki/Installation_Guide#Installation_From_Source
[calyx-crate]: https://crates.io/crates/calyx
10 changes: 7 additions & 3 deletions fud/fud/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"externals": {},
"stages": {
"futil": {
"exec": "./target/debug/futil",
"exec": "./target/debug/calyx",
"file_extensions": [".futil"],
"flags": None,
},
Expand Down Expand Up @@ -147,8 +147,12 @@ def __delitem__(self, keys):
data = self.data
lastkey = keys[-1]
for k in keys[:-1]: # when assigning drill down to *second* last key
data = data[k]
del data[lastkey]
if k in data:
data = data[k]
if lastkey in data:
del data[lastkey]
else:
log.warn(f"`{'.'.join(keys)}' not found. Ignoring delete command.")

def __contains__(self, keys):
data = self.data
Expand Down
6 changes: 3 additions & 3 deletions interp/runt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ timeout = 3
name = "par to seq"
paths = ["tests/control/par_reg.futil", "tests/control/par_mem.futil"]
cmd = """
../target/debug/futil {} -p par-to-seq -l ../ | ../target/debug/interp | jq .memories --sort-keys
../target/debug/calyx {} -p par-to-seq -l ../ | ../target/debug/interp | jq .memories --sort-keys
"""
timeout = 3

Expand Down Expand Up @@ -77,7 +77,7 @@ paths = [
# "tests/control/iteration/*.futil"
]
cmd = """
../target/debug/futil {} -d pre-opt -d post-opt -p simplify-with-control -l ../ | ../target/debug/interp | jq .memories --sort-keys
../target/debug/calyx {} -d pre-opt -d post-opt -p simplify-with-control -l ../ | ../target/debug/interp | jq .memories --sort-keys
"""
expect_dir = "tests/lowered/"
timeout = 3
Expand All @@ -86,7 +86,7 @@ timeout = 3
name = "fully structural static"
paths = ["tests/control/static*.futil"]
cmd = """
../target/debug/futil {} -d pre-opt -d post-opt -l ../ | ../target/debug/interp | jq .memories --sort-keys
../target/debug/calyx {} -d pre-opt -d post-opt -l ../ | ../target/debug/interp | jq .memories --sort-keys
"""
expect_dir = "tests/lowered/"
timeout = 3
Expand Down
32 changes: 16 additions & 16 deletions runt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ paths = [
# gets the pass flags a comment on the first line of the test file
cmd = """
flags="$(head -n 1 {} | cut -c 3-) -m file"
./target/debug/futil {} $flags
./target/debug/calyx {} $flags
"""

[[tests]]
name = "[core] parsing"
# Round-tripping from the compiler should not change anything.
paths = [ "./tests/parsing/*.expect" ]
cmd = """
./target/debug/futil {} -m file -p none
./target/debug/calyx {} -m file -p none
"""

[[tests]]
name = "[core] import"
# Round-tripping from the compiler should not change anything.
paths = [ "./tests/import/a.futil" ]
cmd = """
./target/debug/futil {} -p none \
./target/debug/calyx {} -p none \
| sed 's/extern \".*\\(calyx\\/.*\\)\"/extern \"<ROOT>\\/\\1\"/'
"""

Expand All @@ -40,14 +40,14 @@ paths = [
"tests/errors/parser/*.futil"
]
cmd = """
./target/debug/futil {} -p well-formed -p papercut -p synthesis-papercut
./target/debug/calyx {} -p well-formed -p papercut -p synthesis-papercut
"""

[[tests]]
name = "[core] futil examples"
paths = ["examples/futil/*.futil"]
cmd = """
./target/debug/futil {} -m file -d tdst
./target/debug/calyx {} -m file -d tdst
"""

##### Backend Tests #####
Expand All @@ -56,7 +56,7 @@ name = "[core] backends"
paths = [ "tests/backend/**/*.futil" ]
cmd = """
flags=$(head -n 1 {} | cut -c 3-)
./target/debug/futil {} $flags
./target/debug/calyx {} $flags
"""

##### Frontend Tests #####
Expand All @@ -65,7 +65,7 @@ name = "[frontend] dahlia"
paths = [ "tests/frontend/dahlia/*.fuse" ]
cmd = """
fud e {} --to futil -q \
-s futil.exec './target/debug/futil' \
-s futil.exec './target/debug/calyx' \
| tail -n+2
"""

Expand Down Expand Up @@ -116,7 +116,7 @@ fud exec --to jq \
--through verilog \
--through dat \
-s verilog.data {}.data \
-s futil.exec './target/debug/futil' \
-s futil.exec './target/debug/calyx' \
-s futil.flags ' -d tdst' \
-s verilog.cycle_limit 500 \
-s jq.expr ".memories" \
Expand All @@ -134,7 +134,7 @@ cmd = """
fud exec --to jq \
--through verilog \
--through dat \
-s futil.exec './target/debug/futil' \
-s futil.exec './target/debug/calyx' \
-s verilog.cycle_limit 500 \
-s verilog.data {}.data \
-s jq.expr ".memories" \
Expand All @@ -155,7 +155,7 @@ fud exec --to jq \
--through verilog \
--through dat \
-s verilog.data {}.data \
-s futil.exec './target/debug/futil' \
-s futil.exec './target/debug/calyx' \
-s futil.flags ' -d tdst --nested' \
-s verilog.cycle_limit 500 \
-s jq.expr ".memories" \
Expand All @@ -173,7 +173,7 @@ cmd = """
fud exec --to jq \
--through verilog \
--through dat \
-s futil.exec './target/debug/futil' \
-s futil.exec './target/debug/calyx' \
-s futil.flags ' --nested' \
-s verilog.cycle_limit 500 \
-s verilog.data {}.data \
Expand All @@ -193,7 +193,7 @@ cmd = """
fud exec --to jq \
--through verilog \
--through dat \
-s futil.exec './target/debug/futil' \
-s futil.exec './target/debug/calyx' \
-s futil.flags ' -x tdst:force -p all -d group2invoke' \
-s verilog.cycle_limit 500 \
-s verilog.data {}.data \
Expand All @@ -212,7 +212,7 @@ cmd = """
fud exec --to jq \
--through verilog \
--through dat \
-s futil.exec './target/debug/futil' \
-s futil.exec './target/debug/calyx' \
-s futil.flags '-p all -d tdst -d group2invoke' \
-s verilog.cycle_limit 500 \
-s verilog.data {}.data \
Expand Down Expand Up @@ -258,7 +258,7 @@ fud e --from systolic --to jq \
--through verilog \
--through vcd_json \
-s verilog.data {}.data \
-s futil.exec './target/debug/futil' \
-s futil.exec './target/debug/calyx' \
-s jq.file {}.jq \
{} -q
"""
Expand Down Expand Up @@ -307,7 +307,7 @@ paths = [
"tests/errors/runtime/*.futil"
]
cmd = """
fud exec -s futil.exec './target/debug/futil' \
fud exec -s futil.exec './target/debug/calyx' \
-s verilog.cycle_limit 500 \
--through verilog \
{} --to dat -q 2>&1 | \
Expand Down Expand Up @@ -368,7 +368,7 @@ paths = [
"tests/xilinx/compile/vectorized-add.futil",
]
cmd = """
target/debug/futil {} -b xilinx
target/debug/calyx {} -b xilinx
"""


Expand Down
Loading