Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vatai committed Sep 21, 2024
1 parent 7a9ac8a commit da36e72
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
28 changes: 28 additions & 0 deletions examples/end2end.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import tadashi
from tadashi.apps import Simple
app = Simple("examples/depnodep.c")
scops = tadashi.Scops(app)

node = scops[0].schedule_tree[1]
print(f"{node=}")
tr = tadashi.TrEnum.FULL_SHIFT_VAR
print(f"{tr in node.available_transformations=}")
# output:

print(f"{tr=}")
lu = node.available_args(tr)
print(f"{len(lu)=}")
print(f"{lu[0]=}")
print(f"{lu[1]=}")
# output:

args = [13, 1]
print(f"{node.valid_args(tr, *args)=}")
legal = node.transform(tr, *args)
print(f"{legal=}")
# output:

scops.generate_code()
app.compile()
print(f"{app.measure()=}")
# output:
10 changes: 5 additions & 5 deletions readme.org
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ environment variable to point to the repository root.

After importing Tadashi we obtain the loop nests (SCoPs) from a [[./tadashi/apps.py][Simple]]
app.
#+begin_src python :session s1 :results output :exports both
#+begin_src python :session s1 :results output :exports both :tangle examples/end2end.py
import tadashi
from tadashi.apps import Simple
app = Simple("examples/depnodep.c")
Expand All @@ -27,7 +27,7 @@ app.

Select a node and a transformation, and check that the transformation
is available on the selected node.
#+begin_src python :exports both :session s1 :results output :exports both
#+begin_src python :exports both :session s1 :results output :exports both :tangle examples/end2end.py
node = scops[0].schedule_tree[1]
print(f"{node=}")
tr = tadashi.TrEnum.FULL_SHIFT_VAR
Expand All @@ -40,7 +40,7 @@ is available on the selected node.
: tr in node.available_transformations=True

Check the available arguments for the given node-transformation pair.
#+begin_src python :exports both :session s1 :results output :exports both
#+begin_src python :exports both :session s1 :results output :exports both :tangle examples/end2end.py
print(f"{tr=}")
lu = node.available_args(tr)
print(f"{len(lu)=}")
Expand All @@ -57,7 +57,7 @@ Check the available arguments for the given node-transformation pair.


Perform the transformation and check legality.
#+begin_src python :exports both :session s1 :results output :exports both
#+begin_src python :exports both :session s1 :results output :exports both :tangle examples/end2end.py
args = [13, 1]
print(f"{node.valid_args(tr, *args)=}")
legal = node.transform(tr, *args)
Expand All @@ -70,7 +70,7 @@ Perform the transformation and check legality.
: legal=True

Generate new code, compile it and measure the performance.
#+begin_src python :exports both :session s1 :results output :exports both
#+begin_src python :exports both :session s1 :results output :exports both :tangle examples/end2end.py
scops.generate_code()
app.compile()
print(f"{app.measure()=}")
Expand Down
9 changes: 5 additions & 4 deletions tadashi/tadashilib.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,11 @@ def generate_code(self, input_path="", output_path=""):
output_path_bytes = str(output_path).encode()
if not output_path:
output_path_bytes = self.source_path_bytes
input_path_bytes = str(input_path).encode()
if not input_path:
# rewrite the original source_path file with the generated code
input_path_bytes = self.get_input_path_bytes_and_backup_source()
input_path_bytes = str(self.app.alt_source_path).encode()
# input_path_bytes = str(input_path).encode()
# if not input_path:
# # rewrite the original source_path file with the generated code
# input_path_bytes = self.get_input_path_bytes_and_backup_source()
self.ctadashi.generate_code(input_path_bytes, output_path_bytes)

def __len__(self):
Expand Down

0 comments on commit da36e72

Please sign in to comment.