From c6e5cce8bf5943cfa6b9a56797e19e690862eda0 Mon Sep 17 00:00:00 2001 From: Josse Van Delm Date: Thu, 19 Dec 2024 11:37:55 +0100 Subject: [PATCH 1/3] Add initial snakefile --- kernels/simple_copy/Snakefile | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 kernels/simple_copy/Snakefile diff --git a/kernels/simple_copy/Snakefile b/kernels/simple_copy/Snakefile new file mode 100644 index 00000000..5daa5a1b --- /dev/null +++ b/kernels/simple_copy/Snakefile @@ -0,0 +1,66 @@ +from util.snake.configs import get_snax_mac_config + +config = get_snax_mac_config() +config["snaxoptflags"] = ",".join( + [ + "dispatch-kernels", + "set-memory-space", + "set-memory-layout", + "realize-memref-casts", + "reuse-memref-allocs", + "insert-sync-barrier", + "dispatch-regions", + "linalg-to-library-call", + "snax-copy-to-dma", + "memref-to-snax", + "snax-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: + "simple_copy.x", + shell: + "{config[vltsim]} {input[0]}" + + +rule compile_main: + input: + "main.c", + "data.h", + output: + "main.o", + shell: + "{config[cc]} {config[cflags]} -c {input[0]}" + + +rule link_snax_binary: + input: + "simple_copy.o", + "main.o", + "data.o", + output: + "simple_copy.x", + shell: + "{config[ld]} {config[ldflags]} {input} -o {output}" + + +rule generate_data: + output: + "data.c", + "data.h", + script: + "gendata.py" From e46867634c69ed930dd5b9a1be8af14a37055d37 Mon Sep 17 00:00:00 2001 From: Josse Van Delm Date: Thu, 19 Dec 2024 11:40:36 +0100 Subject: [PATCH 2/3] Move simple_copy to snakemake --- .github/workflows/build-run-kernel-snake.yml | 2 +- .github/workflows/build-run-kernel.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-run-kernel-snake.yml b/.github/workflows/build-run-kernel-snake.yml index 4bfb569c..b0dc2cea 100644 --- a/.github/workflows/build-run-kernel-snake.yml +++ b/.github/workflows/build-run-kernel-snake.yml @@ -20,4 +20,4 @@ jobs: working-directory: kernels/${{ matrix.kernel }} strategy: matrix: - kernel: [alloc, transform_copy] + kernel: [alloc, simple_copy, transform_copy] diff --git a/.github/workflows/build-run-kernel.yml b/.github/workflows/build-run-kernel.yml index e3405da0..a5b569c0 100644 --- a/.github/workflows/build-run-kernel.yml +++ b/.github/workflows/build-run-kernel.yml @@ -20,4 +20,4 @@ jobs: working-directory: kernels/${{ matrix.kernel }} strategy: matrix: - kernel: [simple_copy, streamer_alu, tiled_add, streamer_matmul, gemmini, rescale, gemm] + kernel: [streamer_alu, tiled_add, streamer_matmul, gemmini, rescale, gemm] From 321b5ec8199a2870b83e403d04d0ff0c94ae3cd0 Mon Sep 17 00:00:00 2001 From: Josse Van Delm Date: Thu, 19 Dec 2024 11:47:57 +0100 Subject: [PATCH 3/3] Remove makefile and clean up data generation --- kernels/simple_copy/Makefile | 33 --------------------------------- kernels/simple_copy/Snakefile | 7 +++++-- kernels/simple_copy/gendata.py | 5 ++--- 3 files changed, 7 insertions(+), 38 deletions(-) delete mode 100644 kernels/simple_copy/Makefile diff --git a/kernels/simple_copy/Makefile b/kernels/simple_copy/Makefile deleted file mode 100644 index a0b79264..00000000 --- a/kernels/simple_copy/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# Courtesy of Federico Ficarelli - -.DEFAULT_GOAL := all - -include ../../runtime/snax-mac.rules -include ../../runtime/Makefile.rules - -TESTS = -TESTS += simple_copy.x - -CFLAGS += -std=gnu11 -CFLAGS += -Wall -Wextra - -data.c data.h: - $(PYTHON) gendata.py - -%.x: %.o main.o data.o - $(LD) $(LDFLAGS) $^ -o $@ - -sim_%: % - rm -fr ./logs/ - $(VLTSIM) $< - -RUN = $(addprefix run_, $(TESTS)) -$(RUN): run_%: sim_% - mv logs $(subst sim_,,$<).logs - -all: $(TESTS) - -allrun: $(RUN) - -clean: - rm -fr *.ll12 *.x *.o *.logs/ logs/ data.h data.c diff --git a/kernels/simple_copy/Snakefile b/kernels/simple_copy/Snakefile index 5daa5a1b..bc6814b8 100644 --- a/kernels/simple_copy/Snakefile +++ b/kernels/simple_copy/Snakefile @@ -58,9 +58,12 @@ rule link_snax_binary: "{config[ld]} {config[ldflags]} {input} -o {output}" +from gendata import create_data_files + + rule generate_data: output: "data.c", "data.h", - script: - "gendata.py" + run: + create_data_files() diff --git a/kernels/simple_copy/gendata.py b/kernels/simple_copy/gendata.py index c1affca7..c97ecd6f 100644 --- a/kernels/simple_copy/gendata.py +++ b/kernels/simple_copy/gendata.py @@ -1,10 +1,9 @@ -# simple script to generate inputs and expected outputs for simple_mult - import numpy as np from util.gendata import create_data, create_header -if __name__ == "__main__": + +def create_data_files(): array_size = 10 A = np.linspace(1, array_size, array_size, dtype=np.int32) sizes = {"N": array_size}