ここに、Tiramisu を使うには、が書いてあったよ。
引用 Tiramisu provides few classes to enable users to represent their program: ・The tiramisu::computation class: a computation is composed of an expression and an iteration space but is not associated with any memory location. ・The tiramisu::function class: a function is composed of multiple computations and a vector of arguments (functions arguments). ・The tiramisu::buffer: a class to represent memory buffers. In general, in order to use Tiramisu to optimize, all what a user needs to do is the following: ・Represent the program that needs to be optimized Instantiate a tiramisu::function, Instantiate a set of tiramisu::computation objects for each function, ・Provide the list of optimizations (memory mapping and schedule) Provide the mapping of each tiramisu::computation to memory (i.e. where each computation should be stored in memory), Provide the schedule of each tiramisu::computation (a list of loop nest transformations and optimizations such as tiling, parallelization, vectorization, fusion, ...), ・Generate code Generate an AST (Abstract Syntax Tree), Generate target code (an object file),
tutorial_01.cppに対応させると、
int main(int argc, char **argv) { global::set_default_tiramisu_options(); global::set_loop_iterator_type(p_int32); // ・The tiramisu::function class: a function is composed of multiple computations // and a vector of arguments (functions arguments). function function0("function0"); // ・The tiramisu::computation class: a computation is composed of an expression and an iteration space // but is not associated with any memory location. expr e3 = expr(3) + expr(4); computation S0("[N]->{S0[i,j]: 0<=i<10 and 0<=j<10}", e3, true, p_uint8, &function0); // ・Provide the list of optimizations (memory mapping and schedule) S0.tile(var("i"), var("j"), 2, 2, var("i0"), var("j0"), var("i1"), var("j1")); S0.tag_parallel_level(var("i0")); // ・The tiramisu::buffer: a class to represent memory buffers. buffer buf0("buf0", {tiramisu::expr(10), tiramisu::expr(10)}, p_uint8, a_output, &function0); S0.set_access("{S0[i,j]->buf0[i,j]}"); function0.set_arguments({&buf0}); function0.gen_time_space_domain(); // ・Generate code // Generate an AST (Abstract Syntax Tree), function0.gen_isl_ast(); function0.gen_halide_stmt(); // Generate target code (an object file), function0.gen_halide_obj("build/generated_fct_tutorial_01.o"); return 0; }