Skip to content

Commit

Permalink
Snakemake: Add simple_copy kernel (#312)
Browse files Browse the repository at this point in the history
* Add initial snakefile

* Move simple_copy to snakemake

* Remove makefile and clean up data generation
  • Loading branch information
JosseVanDelm authored Dec 20, 2024
1 parent c523293 commit d8c421e
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 38 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, transform_copy]
kernel: [alloc, simple_copy, transform_copy]
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: [simple_copy, streamer_alu, tiled_add, streamer_matmul, gemmini, rescale, gemm]
kernel: [streamer_alu, tiled_add, streamer_matmul, gemmini, rescale, gemm]
33 changes: 0 additions & 33 deletions kernels/simple_copy/Makefile

This file was deleted.

69 changes: 69 additions & 0 deletions kernels/simple_copy/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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}"


from gendata import create_data_files


rule generate_data:
output:
"data.c",
"data.h",
run:
create_data_files()
5 changes: 2 additions & 3 deletions kernels/simple_copy/gendata.py
Original file line number Diff line number Diff line change
@@ -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}
Expand Down

0 comments on commit d8c421e

Please sign in to comment.