Skip to content

Commit

Permalink
Merge pull request #51 from vatai/48-add-support-for-list-of-transfor…
Browse files Browse the repository at this point in the history
…mations

48 add support for list of transformations
  • Loading branch information
vatai authored Dec 25, 2024
2 parents f254fbf + f207a44 commit b0078d6
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
35 changes: 35 additions & 0 deletions scripts/check_mem.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -e
export PYTHONPATH=.
VALGRIND_ARGS=(
--leak-check=full
--show-leak-kinds=all
--track-origins=yes
# --verbose
# --log-file=valgrind-out.txt
--keep-debuginfo=yes
)
TESTS=(
tests.py.test_ctadashi.TestCtadashi.test_full_fuse
tests.py.test_ctadashi.TestCtadashi.test_full_shift_param
tests.py.test_ctadashi.TestCtadashi.test_full_shift_val
tests.py.test_ctadashi.TestCtadashi.test_full_shift_var
tests.py.test_ctadashi.TestCtadashi.test_fuse
tests.py.test_ctadashi.TestCtadashi.test_interchange_1
tests.py.test_ctadashi.TestCtadashi.test_partial_fuse
tests.py.test_ctadashi.TestCtadashi.test_partial_shift_param
tests.py.test_ctadashi.TestCtadashi.test_partial_shift_val
tests.py.test_ctadashi.TestCtadashi.test_partial_shift_var
tests.py.test_ctadashi.TestCtadashi.test_pluto_fig4
tests.py.test_ctadashi.TestCtadashi.test_tile_1
tests.py.test_ctadashi.TestCtadashi.test_tile_2
)

# for i in $(seq 0 12); do
# # python -m unittest -v "${TESTS[$i]}"
# valgrind ${VALGRIND_ARGS[@]} python -m unittest "${TESTS[$i]}" 2>&1 | tail
# echo test "${TESTS[$i]}"
# done

valgrind ${VALGRIND_ARGS[@]} python -m unittest 2>&1 | tail
# valgrind ${VALGRIND_ARGS[@]} python examples/end2end.py
7 changes: 7 additions & 0 deletions tadashi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,13 @@ def locate(self, location: list[int]):
for c in location:
self.ctadashi.goto_child(self.pool_idx, self.scop_idx, c)

def transform_list(self, trs: list) -> bool:
result = []
for node_idx, tr, args in trs:
node = self.schedule_tree[node_idx]
result.append(node.transform(tr, *args))
return result


class Scops:
"""All SCoPs which belong to a given file.
Expand Down
22 changes: 21 additions & 1 deletion tests/py/test_ctadashi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pathlib import Path
from typing import Optional

import tadashi
from tadashi import Scops, TrEnum
from tadashi.apps import Simple

Expand All @@ -25,7 +26,6 @@ class TransformData:


class TestCtadashi(unittest.TestCase):

@staticmethod
def _read_app_comments(app):
TRANSFORMATION = " TRANSFORMATION: "
Expand Down Expand Up @@ -101,6 +101,26 @@ def test_wrong_number_of_args(self):
node = self._get_band_node()
self.assertRaises(ValueError, node.transform, TrEnum.TILE, 2, 3)

def test_transformation_list(self):
# watch python -m unittest tests.py.test_ctadashi.TestCtadashi.test_transformation_list
app = Simple("examples/depnodep.c")
scop = app.scops[0]
transformations = [
[2, tadashi.TrEnum.SET_PARALLEL, []],
[1, tadashi.TrEnum.SET_LOOP_OPT, [0, 3]],
[1, tadashi.TrEnum.FULL_SHIFT_VAL, [-47]],
[3, tadashi.TrEnum.PARTIAL_SHIFT_VAL, [0, 39]],
[1, tadashi.TrEnum.PARTIAL_SHIFT_VAL, [0, 34]],
[3, tadashi.TrEnum.PARTIAL_SHIFT_VAR, [0, -22, 0]],
[3, tadashi.TrEnum.SET_PARALLEL, []],
]
legals = scop.transform_list(transformations)
mod_app = app.generate_code()
mod_app.compile()
for legal in legals[:-1]:
self.assertTrue(legal)
self.assertFalse(legals[-1])


def setup():
if "-v" in sys.argv:
Expand Down

0 comments on commit b0078d6

Please sign in to comment.