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

Add jq stage to fud2 #2333

Merged
merged 5 commits into from
Nov 5, 2024
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
11 changes: 11 additions & 0 deletions fud2/scripts/jq.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "rtl_sim" as sim;

export const jq_state = state("jq", ["jq"]);

defop dat_to_jq(json: sim::dat) >> out: jq_state {
let expr = config_or("jq.expr", ".");
let jq = config_or("jq.exe", "jq");
let flags = config_or("jq.flags", "");

shell(`${jq} '${expr}' ${flags} ${json} > ${out}`);
}
6 changes: 5 additions & 1 deletion fud2/tests/snapshots/tests__list_ops.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: fud2/tests/tests.rs
snapshot_kind: text
---
[
(
Expand Down Expand Up @@ -48,6 +47,11 @@ snapshot_kind: text
"dahlia",
"calyx",
),
(
"dat_to_jq",
"dat",
"jq",
),
(
"debug",
"cider",
Expand Down
2 changes: 1 addition & 1 deletion fud2/tests/snapshots/tests__list_states.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: fud2/tests/tests.rs
snapshot_kind: text
---
[
"calyx",
Expand All @@ -12,6 +11,7 @@ snapshot_kind: text
"firrtl",
"firrtl-with-primitives",
"flamegraph",
"jq",
"mrxl",
"primitive-uses-json",
"sim",
Expand Down
19 changes: 19 additions & 0 deletions fud2/tests/snapshots/tests__test@plan_dat_to_jq.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
source: fud2/tests/tests.rs
description: "emit plan: dat_to_jq"
---
build-tool = fud2
rule get-rsrc
command = $build-tool get-rsrc $out

jq.expr = .
jq.exe = jq
jq.flags =
rule dat_to_jq_rule_1
command = ${jq.exe} '${jq.expr}' ${jq.flags} $i0 > $o0
build _dat_to_jq_rule_1.fake $o0: dat_to_jq_rule_1 $i0
i0 = /input.ext
o0 = /output.ext


default /output.ext
1 change: 1 addition & 0 deletions fud2/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl InstaTest for Plan {
.merge(("xilinx.vitis", "/test/xilinx/vitis"))
.merge(("xilinx.xrt", "/test/xilinx/xrt"))
.merge(("dahlia", "/test/bin/dahlia"))
.merge(("jq.expr", "."))
.merge(("c0", "v1"));
let run = Run::with_config(driver, self, config);
let mut buf = vec![];
Expand Down
67 changes: 41 additions & 26 deletions interp/tests/runt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ expect_dir = "unit"
name = "multi-comp"
paths = ["multi-comp/*.futil"]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s cider.flags="--dump-registers" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""
timeout = 10

Expand All @@ -37,10 +38,11 @@ name = "complex"
paths = ["complex/*.futil"]

cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s cider.flags="--dump-registers" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""
timeout = 10
expect_dir = "complex"
Expand All @@ -49,11 +51,12 @@ expect_dir = "complex"
name = "primitives"
paths = ["primitives/*.futil"]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s calyx.args="--log off" \
-s cider.flags="--dump-registers" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""
timeout = 10
expect_dir = "primitives"
Expand All @@ -71,10 +74,11 @@ expect_dir = "par-to-seq"
name = "control"
paths = ["control/*.futil", "control/iteration/*.futil"]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s cider.flags="--dump-registers" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""
timeout = 10
expect_dir = "control"
Expand All @@ -83,15 +87,18 @@ expect_dir = "control"
name = "invoke"
paths = ["control/invoke/*.futil"]
cmd = """
fud2 {} --from calyx --to dat --through cider -s sim.data={}.data -s calyx.args="--log off" | jq --sort-keys
fud2 {} --from calyx --to jq --through cider -s sim.data={}.data -s calyx.args="--log off" -s jq.flags="--sort-keys"
"""
timeout = 10

[[tests]]
name = "invoke compiled"
paths = ["control/invoke/*.futil"]
cmd = """
fud2 {} --from calyx --to dat --through cider -s cider.calyx-passes=" -p compile-invoke" -s sim.data={}.data -s calyx.args="--log off" | jq --sort-keys
fud2 {} --from calyx --to jq --through cider \
-s cider.calyx-passes=" -p compile-invoke" \
-s sim.data={}.data -s calyx.args="--log off" \
-s jq.flags="--sort-keys"
"""

[[tests]]
Expand All @@ -116,11 +123,12 @@ expect_dir = "tests/lowered/"
name = "correctness dynamic"
paths = ["../../tests/correctness/*.futil"]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s sim.data={}.data \
-s calyx.args="--log off" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""

[[tests]]
Expand All @@ -134,13 +142,14 @@ cmd = """
name = "correctness lowered"
paths = ["../../tests/correctness/*.futil"]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s sim.data={}.data \
-s calyx.args="--log off" \
-s cider.calyx-passes="-p all" \
-s cider.flags="--no-verify" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""
timeout = 60

Expand All @@ -149,23 +158,25 @@ timeout = 60
name = "correctness ref cells"
paths = ["../../tests/correctness/ref-cells/*.futil"]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s sim.data={}.data \
-s calyx.args="--log off" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""

[[tests]]
name = "correctness ref cells compiled"
paths = ["../../tests/correctness/ref-cells/*.futil"]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s sim.data={}.data \
-s calyx.args="--log off" \
-s cider.calyx-passes=" -p compile-invoke" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""

[[tests]]
Expand All @@ -176,45 +187,49 @@ paths = [
"../../tests/correctness/numeric-types/fixed-point/*.futil",
]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s sim.data={}.data \
-s calyx.args="--log off" \
-s cider.converter-flags="-r --legacy-quotes" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""

[[tests]]
name = "[frontend] tcam testing"
paths = ["../../tests/correctness/tcam/*.futil"]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s calyx.args="--log off" \
-s sim.data={}.data \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""

[[tests]]
name = "benchmark misc"
paths = ["benchmarks/*.futil"]
cmd = """
fud2 --from calyx --to dat \
fud2 --from calyx --to jq \
--through cider \
-s sim.data={}.data \
-s calyx.args="--log off" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""

[[tests]]
name = "benchmark polybench"
paths = ["benchmarks/polybench/*.fuse"]
cmd = """
fud2 --from dahlia --to dat \
fud2 --from dahlia --to jq \
--through cider \
-s sim.data={}.data \
-s calyx.args="--log off" \
{} | jq --sort-keys
-s jq.flags="--sort-keys" \
{}
"""
timeout = 180

Expand Down
Loading