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.
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
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).
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
After importing Tadashi we obtain the loop nests (SCoPs) from a Simple app.
from pathlib import Path
import tadashi
from tadashi.apps import Simple
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 0x7260a57196d0>
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 = tadashi.TrEnum.FULL_SHIFT_VAR
print(f"{tr in node.available_transformations=}")
# output:
node=Node type: NodeType.BAND, [{'params': ['N'], 'vars': ['j', 'i']}], [N] -> L_0[{ S_0[j, i] -> [(j)] }], [0] tr in node.available_transformations=True
Check the available arguments for the given node-transformation pair.
print(f"{tr=}")
lu = node.available_args(tr)
print(f"{len(lu)=}")
print(f"{lu[0]=}")
print(f"{lu[1]=}")
# output:
tr=<TrEnum.FULL_SHIFT_VAR: 'full_shift_var'> len(lu)=2 lu[0]=LowerUpperBound(lower=None, upper=None) lu[1]=LowerUpperBound(lower=0, upper=2)
Perform the transformation and check legality.
args = [1, 13]
print(f"{node.valid_args(tr, *args)=}")
legal = node.transform(tr, *args)
print(f"{legal=}")
# output:
node.valid_args(tr, *args)=True 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