-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Snakemake: Add support for transform-copy (#311)
* Move transform_copy flow to snakemake * Add snakefile for transform-copy * Remove old makefile * Fix typo * Add all to running the snakemake experiments
- Loading branch information
1 parent
db2ea35
commit c523293
Showing
5 changed files
with
79 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
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", | ||
"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_* | ||
|
||
|
||
from gendata import create_files | ||
|
||
|
||
# Rules | ||
rule all: | ||
input: | ||
"transform_copy.x", | ||
"transform_from_none.x", | ||
"transform_from_strided.x", | ||
run: | ||
shell("{config[vltsim]} {input[0]} {input[0]}") | ||
shell("{config[vltsim]} {input[1]} {input[1]}") | ||
shell("{config[vltsim]} {input[2]} {input[2]}") | ||
|
||
|
||
rule generate_data: | ||
output: | ||
"{folder}/data.c", | ||
"{folder}/data.h", | ||
run: | ||
create_files(f"{wildcards.folder}/data") | ||
|
||
|
||
rule compile_snax_binary: | ||
input: | ||
"{file}.o", | ||
"main_{file}.o", | ||
"{file}/data.o", | ||
output: | ||
"{file}.x", | ||
shell: | ||
"{config[ld]} {config[ldflags]} {input} -o {output}" | ||
|
||
|
||
rule compile_main: | ||
input: | ||
"{file}/data.h", | ||
"main.c", | ||
output: | ||
temp("main_{file}.o"), | ||
shell: | ||
"{config[cc]} {config[cflags]} -I./{wildcards.file} -c {input[1]} -o {output}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
# simple script to generate inputs and expected outputs for simple_mult | ||
from math import sqrt | ||
|
||
import numpy as np | ||
|
||
from util.gendata import create_data, create_header | ||
|
||
if __name__ == "__main__": | ||
|
||
def create_files(filename: str): | ||
array_size = 64 | ||
A = np.linspace(1, array_size, array_size, dtype=np.int32) | ||
B = np.reshape(A, [2, 4, 2, 4]) | ||
B = np.swapaxes(B, 1, 2) | ||
B = B.flatten() | ||
sizes = {"N": array_size, "N_sqrt": sqrt(array_size)} | ||
variables = {"A": A, "B": B} | ||
create_header("transform_copy/data.h", sizes, variables) | ||
create_data("transform_copy/data.c", variables) | ||
create_header("transform_from_none/data.h", sizes, variables) | ||
create_data("transform_from_none/data.c", variables) | ||
create_header("transform_from_strided/data.h", sizes, variables) | ||
create_data("transform_from_strided/data.c", variables) | ||
create_header(f"{filename}.h", sizes, variables) | ||
create_data(f"{filename}.c", variables) |