Skip to content

vatai/tadashi

Repository files navigation

Tadashi

Install

After the requirements are installed, TADASHI can be pip installed from GitHub using:

pip install git+https://github.com/vatai/tadashi.git

Requirements are LLVM, clang, autotools, pkgconfig, libyaml, libntl, libgmp, swig. The exact apt-get packages can be found in this file.

Using Docker is also an option.

Development

cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=ctadashi -DCALL_FROM_SETUP_PY=ON
ninja -C build install

Execute with:

PYTHONPATH=. python examples/end2end.py

Documentation

After the double blind review and the end of the anonymity requirement, detailed API documentation will be uploaded to https://tadashi.readthedocs.io/ (or a similar URL).

Quick start

An end-to-end example is provided below (split into parts with comments and outputs). This example can be run from the repository root with the following command:

python examples/inputs/end2end.py

End-to-end example

After importing Tadashi we obtain the loop nests (SCoPs) from a Simple app.

#!/bin/env python
from pathlib import Path
from random import choice, seed

import tadashi
from tadashi.apps import Simple

seed(1234)

dir_path = Path(__file__).parent
examples_path = dir_path if dir_path.name == "examples" else "examples"
app = Simple(f"{examples_path}/inputs/depnodep.c")
print(app)
<tadashi.apps.Simple object at 0x7f7dfe220dd0>

Select a node and a transformation, and check that the transformation is available on the selected node.

node = app.scops[0].schedule_tree[1]
print(f"{node=}")
tr = choice(node.available_transformations)
print(f"{tr=}")
# output:
node=Node type: NodeType.BAND, [{'params': ['N'], 'vars': ['j', 'i']}], [N] -> L_0[{ S_0[j, i] -> [(j)] }], [0]
tr=TrEnum.FULL_SHIFT_PARAM

Check the available arguments for the given node-transformation pair.

args = choice(node.get_args(tr, -10, 10))
print(f"{args=}")
# output:
args=[0, -7]

Perform the transformation and check legality.

legal = node.transform(tr, *args)
print(f"{legal=}")
# output:
legal=True

Generate new code, compile it and measure the performance.

app.compile()
print(f"{app.measure()=}")
transformed_app = app.generate_code()
transformed_app.compile()
print(f"{transformed_app.measure()=}")
# output:
app.measure()=24.0
transformed_app.measure()=39.0

About

A library for code transformations with guaranteed legality

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •