Skip to content

Commit

Permalink
Snakemake: Add streamer alu (#317)
Browse files Browse the repository at this point in the history
* Add snax alu config

* Add streamer-alu snakefile

* Makefile

* Move streamer_alu to snakemake ci
  • Loading branch information
JosseVanDelm authored Dec 20, 2024
1 parent 9d7aabc commit 18c12fc
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-run-kernel-snake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
working-directory: kernels/${{ matrix.kernel }}
strategy:
matrix:
kernel: [alloc, simple_copy, transform_copy, gemm, rescale, gemmini]
kernel: [alloc, simple_copy, transform_copy, gemm, rescale, gemmini, streamer_alu]
2 changes: 1 addition & 1 deletion .github/workflows/build-run-kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
working-directory: kernels/${{ matrix.kernel }}
strategy:
matrix:
kernel: [streamer_alu, tiled_add, streamer_matmul]
kernel: [tiled_add, streamer_matmul]
36 changes: 0 additions & 36 deletions kernels/streamer_alu/Makefile

This file was deleted.

79 changes: 79 additions & 0 deletions kernels/streamer_alu/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from util.snake.configs import get_snax_alu_config

config = get_snax_alu_config()
config["snaxoptflags"] = ",".join(
[
"insert-accfg-op{accelerator=snax_alu}",
"convert-linalg-to-kernel",
"dispatch-kernels",
"test-insert-debugs",
"set-memory-space",
"set-memory-layout",
"test-insert-debugs",
"realize-memref-casts",
"reuse-memref-allocs",
"insert-sync-barrier",
"dispatch-regions",
"convert-linalg-to-stream",
"convert-stream-to-snax-stream",
"convert-linalg-to-accfg",
"convert-accfg-to-csr",
"snax-copy-to-dma",
"memref-to-snax",
"snax-to-func",
"test-debug-to-func",
"clear-memory-space",
]
)


module default_rules:
snakefile:
"../../util/snake/default_rules.smk"
config:
config


use rule * from default_rules as default_*


# Rules
rule all:
input:
"streamer_add.x",
"streamer_add_stream.x",
run:
for item in input:
shell("{config[vltsim]} {item}")


from gendata import create_data_files


rule generate_data:
output:
"data.c",
"data.h",
run:
create_data_files()


rule compile_simple_main:
input:
"main.c",
"data.o",
output:
temp("main.o"),
shell:
"{config[cc]} {config[cflags]} -c {input} -o {output}"


rule link_snax_binary:
input:
"{file}.o",
"data.o",
"main.o",
output:
"{file}.x",
shell:
"{config[ld]} {config[ldflags]} {input} -o {output}"
3 changes: 2 additions & 1 deletion kernels/streamer_alu/gendata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from util.gendata import create_data, create_header

if __name__ == "__main__":

def create_data_files():
# Reset random seed for reproducible behavior
low_bound = 0
high_bound = 100
Expand Down
11 changes: 11 additions & 0 deletions util/snake/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ def get_snax_gemmx_config():
+ "/snax-kul-cluster-mixed-narrow-wide-rtl/bin/snitch_cluster.vlt"
)
return config


def get_snax_alu_config():
# use CONDA_PREFIX to access pixi env
snax_utils_path = os.environ["CONDA_PREFIX"] + "/snax-utils"
snitch_sw_path = snax_utils_path + "/snax-alu"
config = {}
config.update(get_default_paths())
config.update(get_default_flags(snitch_sw_path))
config["vltsim"] = snax_utils_path + "/snax-alu-rtl/bin/snitch_cluster.vlt"
return config

0 comments on commit 18c12fc

Please sign in to comment.