Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ruff
python -m pip install "ruff==0.15.22"
- name: Check formating with ruff
run: |
ruff format --check
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ruff
python -m pip install "ruff==0.15.22"
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ruff pytest pytest-cov coverage
python -m pip install "ruff==0.15.22" pytest pytest-cov coverage
if [ -f requirements.txt ]; then python -m pip install --user -r requirements.txt; fi

- name: Install TiraLibCPP
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pyyaml = "^6.0.1"
[tool.poetry.group.dev.dependencies]
pytest-cov = "^4.1.0"
coverage = "^7.2.7"
ruff = "^0.9"
ruff = "0.15.22"

[build-system]
requires = ["poetry-core"]
Expand Down
58 changes: 56 additions & 2 deletions tests/tiramisu/test_schedule.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from types import SimpleNamespace

import pytest

import tests.utils as test_utils
from tests.utils import benchmark_program_test_sample
from tiralib.config import BaseConfig
from tiralib.tiramisu import tiramisu_actions
from tiralib.tiramisu.schedule import Schedule
from tiralib.tiramisu.tiramisu_actions.parallelization import Parallelization
from tiralib.config import BaseConfig
from tests.utils import benchmark_program_test_sample


def test_execute():
Expand Down Expand Up @@ -105,6 +107,58 @@ def test_is_legal():
assert legality is True


def test_illegal_server_result_keeps_last_valid_tree():
BaseConfig.init()
test_program = benchmark_program_test_sample()

class FakeServer:
def run(self, *args, **kwargs):
return SimpleNamespace(
legality=False,
isl_ast="",
additional_info="",
)

test_program.server = FakeServer()
schedule = Schedule(test_program)
original_tree = schedule.tree
schedule.add_optimizations([Parallelization(params=[("comp02", 0)])])

assert schedule.is_legal() is False
assert schedule.tree is original_tree


def test_legal_server_result_updates_tree_for_follow_up_actions():
BaseConfig.init()
test_program = benchmark_program_test_sample()

class FakeServer:
def run(self, *args, **kwargs):
return SimpleNamespace(
legality=True,
isl_ast=(
"0|iterator|i|0|i <= 3|\n"
"1|iterator|j|0|j <= 7|\n"
"2|computation|comp02\n"
),
additional_info="",
)

test_program.server = FakeServer()
schedule = Schedule(test_program)
schedule.add_optimizations([Parallelization(params=[("comp02", 0)])])

assert schedule.is_legal() is True
unrolling = tiramisu_actions.Unrolling(
params=[("comp02", -1), 4],
comps=["comp02"],
)
schedule.add_optimizations([unrolling])

assert unrolling.iterator_id == ("comp02", 1)
assert str(unrolling) == "U(L1,4,comps=['comp02'])"


def test_copy():
BaseConfig.init()
original = Schedule(benchmark_program_test_sample())
Expand Down
17 changes: 16 additions & 1 deletion tests/tiramisu/test_tiramisu_tree.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tests.utils as test_utils
from tiralib.tiramisu.tiramisu_tree import TiramisuTree
from tiralib.config import BaseConfig
from tiralib.tiramisu.tiramisu_tree import TiramisuTree


def test_from_annotations():
Expand Down Expand Up @@ -58,6 +58,21 @@ def test_get_candidate_computations():
]


def test_repeated_isl_ast_computations_are_unique():
t_tree = TiramisuTree.from_isl_ast_string_list(
[
"0|iterator|i|0|i <= 3|",
"1|computation|comp00",
"0|iterator|i|0|i <= 3|",
"1|computation|comp00",
]
)

assert t_tree.computations == ["comp00"]
assert t_tree.computations_absolute_order == {"comp00": 1}
assert t_tree.get_iterator_subtree_computations(("comp00", 0)) == ["comp00"]


def test_get_root_of_node():
t_tree = test_utils.tree_test_sample()

Expand Down
17 changes: 11 additions & 6 deletions tiralib/tiramisu/compiling_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ def compile_legality(cls, schedule: Schedule, with_ast: bool = False):
legality_result = legality_result.strip()
if legality_result not in ["0", "1"]:
raise Exception(f"Error in legality check: {legality_result}")
if legality_result == "0":
return False, None
ast = TiramisuTree.from_isl_ast_string_list(
isl_ast_string_list=result_lines[1:]
)
return legality_result == "1", ast
return True, ast

else:
result = result.strip()
Expand Down Expand Up @@ -100,11 +102,14 @@ def get_legality_code(cls, schedule: Schedule, with_ast: bool = False):

if with_ast:
legality_check_lines += """
auto fct = tiramisu::global::get_implicit_function();

fct->gen_time_space_domain();
fct->gen_isl_ast();
fct->print_isl_ast_representation();
if (is_legal)
{
auto fct = tiramisu::global::get_implicit_function();

fct->gen_time_space_domain();
fct->gen_isl_ast();
fct->print_isl_ast_representation();
}
"""

cpp_code = schedule.tiramisu_program.cpp_code.replace(
Expand Down
Loading
Loading