Tiramisu Compiler
tiramisu::generator Class Reference

A class for code generation. More...

#include <core.h>

Static Public Member Functions

static void update_producer_expr_name (tiramisu::computation *comp, std::string name_to_replace, std::string replace_with)
 Traverse a tiramisu expression (current_exp) until an expression with the specified name is found. More...
 

Static Protected Member Functions

static std::map< std::string, isl_ast_expr * > compute_iterators_map (tiramisu::computation *comp, isl_ast_build *build)
 
static std::vector< tiramisu::computation * > get_computation_by_node (tiramisu::function *fct, isl_ast_node *node)
 Get the computation associated with a node. More...
 
static std::vector< tiramisu::computation * > filter_computations_by_domain (std::vector< tiramisu::computation * > comp_vec, isl_union_set *node_domain)
 Traverse the vector of computations comp_vec and return the computations that have a domain that intersects with domain. More...
 
static void get_rhs_accesses (const tiramisu::function *func, const tiramisu::computation *comp, std::vector< isl_map * > &accesses, bool return_buffer_accesses)
 Compute the accesses of the RHS of the computation comp and store them in the accesses vector. More...
 
static isl_constraint * get_constraint_for_access (int access_dimension, const tiramisu::expr &access_expression, isl_map *access_relation, isl_constraint *cst, int coeff, const tiramisu::function *fct)
 Analyze the access_expression and return a set of constraints that correspond to the access pattern of the access_expression. More...
 
static Halide::Internal::Stmt halide_stmt_from_isl_node (const tiramisu::function &fct, isl_ast_node *node, int level, std::vector< std::pair< std::string, std::string >> &tagged_stmts, bool is_a_child_block)
 Generate a Halide statement from an ISL ast node object in the ISL ast tree. More...
 
static Halide::Internal::Stmt make_halide_block (const Halide::Internal::Stmt &first, const Halide::Internal::Stmt &second)
 
static Halide::Internal::Stmt make_buffer_alloc (buffer *b, const std::vector< Halide::Expr > &extents, Halide::Internal::Stmt &stmt)
 
static Halide::Internal::Stmt make_buffer_free (buffer *b)
 
static Halide::Expr halide_expr_from_tiramisu_expr (const tiramisu::function *fct, std::vector< isl_ast_expr * > &index_expr, const tiramisu::expr &tiramisu_expr, tiramisu::computation *comp=nullptr)
 Create a Halide expression from a Tiramisu expression. More...
 
static tiramisu::expr replace_accesses (const tiramisu::function *func, std::vector< isl_ast_expr * > &index_expr, const tiramisu::expr &tiramisu_expr)
 
static std::string get_buffer_name (const tiramisu::computation *)
 
static tiramisu::expr comp_to_buffer (tiramisu::computation *comp, std::vector< isl_ast_expr * > &ie, const tiramisu::expr *expr=nullptr)
 
static isl_ast_node * stmt_code_generator (isl_ast_node *node, isl_ast_build *build, void *user)
 Retrieve the access function of the ISL AST leaf node (which represents a computation). More...
 
static void traverse_expr_and_extract_accesses (const tiramisu::function *fct, const tiramisu::computation *comp, const tiramisu::expr &exp, std::vector< isl_map * > &accesses, bool return_buffer_accesses)
 Traverse a tiramisu expression (exp) and extract the access relations from the access operation passed in exp. More...
 
static void _update_producer_expr_name (tiramisu::expr &current_exp, std::string name_to_replace, std::string replace_with)
 Traverse a tiramisu expression (current_exp) until an expression with the specified name is found. More...
 
static Halide::Expr linearize_access (int dims, const halide_dimension_t *shape, isl_ast_expr *index_expr)
 Linearize a multidimensional access to a Halide buffer. More...
 
static Halide::Expr linearize_access (int dims, const halide_dimension_t *shape, std::vector< tiramisu::expr > index_expr)
 Linearize a multidimensional access to a Halide buffer. More...
 
static Halide::Expr linearize_access (int dims, std::vector< Halide::Expr > &strides, std::vector< tiramisu::expr > index_expr)
 Linearize a multidimensional access to a Halide buffer. More...
 
static Halide::Expr linearize_access (int dims, std::vector< Halide::Expr > &strides, isl_ast_expr *index_expr)
 Linearize a multidimensional access to a Halide buffer. More...
 
static tiramisu::expr linearize_access (int dims, std::vector< tiramisu::expr > &strides, std::vector< tiramisu::expr > index_expr)
 Linearize a multidimensional access to a Halide buffer. More...
 
static tiramisu::expr linearize_access (int dims, std::vector< tiramisu::expr > &strides, isl_ast_expr *index_expr)
 Linearize a multidimensional access to a Halide buffer. More...
 

Detailed Description

A class for code generation.

Definition at line 4288 of file core.h.

Member Function Documentation

static void tiramisu::generator::_update_producer_expr_name ( tiramisu::expr current_exp,
std::string  name_to_replace,
std::string  replace_with 
)
staticprotected

Traverse a tiramisu expression (current_exp) until an expression with the specified name is found.

Replace that name with a new name. Replaces all occurrences.

static tiramisu::expr tiramisu::generator::comp_to_buffer ( tiramisu::computation comp,
std::vector< isl_ast_expr * > &  ie,
const tiramisu::expr expr = nullptr 
)
staticprotected
static std::map<std::string, isl_ast_expr *> tiramisu::generator::compute_iterators_map ( tiramisu::computation comp,
isl_ast_build *  build 
)
staticprotected
static std::vector<tiramisu::computation *> tiramisu::generator::filter_computations_by_domain ( std::vector< tiramisu::computation * >  comp_vec,
isl_union_set *  node_domain 
)
staticprotected

Traverse the vector of computations comp_vec and return the computations that have a domain that intersects with domain.

static std::string tiramisu::generator::get_buffer_name ( const tiramisu::computation )
staticprotected
static std::vector<tiramisu::computation *> tiramisu::generator::get_computation_by_node ( tiramisu::function fct,
isl_ast_node *  node 
)
staticprotected

Get the computation associated with a node.

static isl_constraint* tiramisu::generator::get_constraint_for_access ( int  access_dimension,
const tiramisu::expr access_expression,
isl_map *  access_relation,
isl_constraint *  cst,
int  coeff,
const tiramisu::function fct 
)
staticprotected

Analyze the access_expression and return a set of constraints that correspond to the access pattern of the access_expression.

access_dimension: The dimension of the access. For example, the access C0(i0, i1, i2) have three access dimensions: i0, i1 and i2. access_expression: The expression of the access. This expression is parsed recursively (by calling get_constraint_for_access) and is gradually used to update the constraint. access_relation: The access relation that represents the access. cst: The constraint that defines the access and that is being constructed. Different calls to get_constraint_for_access modify this constraint gradually until the final constraint is created. Only the final constraint is added to the access_relation. coeff: The coefficient in which all the dimension coefficients of the constraint are going to be multiplied. This coefficient is used to implement o_minus, o_mul and o_sub.

static void tiramisu::generator::get_rhs_accesses ( const tiramisu::function func,
const tiramisu::computation comp,
std::vector< isl_map * > &  accesses,
bool  return_buffer_accesses 
)
staticprotected

Compute the accesses of the RHS of the computation comp and store them in the accesses vector.

If return_buffer_accesses is set to true, this function returns access functions to buffers. Otherwise it returns access functions to computations.

static Halide::Expr tiramisu::generator::halide_expr_from_tiramisu_expr ( const tiramisu::function fct,
std::vector< isl_ast_expr * > &  index_expr,
const tiramisu::expr tiramisu_expr,
tiramisu::computation comp = nullptr 
)
staticprotected

Create a Halide expression from a Tiramisu expression.

static Halide::Internal::Stmt tiramisu::generator::halide_stmt_from_isl_node ( const tiramisu::function fct,
isl_ast_node *  node,
int  level,
std::vector< std::pair< std::string, std::string >> &  tagged_stmts,
bool  is_a_child_block 
)
staticprotected

Generate a Halide statement from an ISL ast node object in the ISL ast tree.

Level represents the level of the node in the schedule. 0 means root. It taks as input:

  • a function fct for which we are generating code,
  • a node,
  • level represents the current loop level being traversed (0 means the outer level.
  • is_a_child_block indicates whether the block that is ging to be generated is a child block for an other block. In such a case, allocate and let statements should not be generate. Allocate and let statements should only be generated in non-child blocks so that their scope reaches the whole block.
static Halide::Expr tiramisu::generator::linearize_access ( int  dims,
const halide_dimension_t *  shape,
isl_ast_expr *  index_expr 
)
staticprotected

Linearize a multidimensional access to a Halide buffer.

Supposing that we have buf[N1][N2][N3], transform buf[i][j][k] into buf[k + j*N3 + i*N3*N2]. Note that the first arg in index_expr is the buffer name. The other args are the indices for each dimension of the buffer.

static Halide::Expr tiramisu::generator::linearize_access ( int  dims,
const halide_dimension_t *  shape,
std::vector< tiramisu::expr index_expr 
)
staticprotected

Linearize a multidimensional access to a Halide buffer.

Supposing that we have buf[N1][N2][N3], transform buf[i][j][k] into buf[k + j*N3 + i*N3*N2]. Note that the first arg in index_expr is the buffer name. The other args are the indices for each dimension of the buffer.

static Halide::Expr tiramisu::generator::linearize_access ( int  dims,
std::vector< Halide::Expr > &  strides,
std::vector< tiramisu::expr index_expr 
)
staticprotected

Linearize a multidimensional access to a Halide buffer.

Supposing that we have buf[N1][N2][N3], transform buf[i][j][k] into buf[k + j*N3 + i*N3*N2]. Note that the first arg in index_expr is the buffer name. The other args are the indices for each dimension of the buffer.

static Halide::Expr tiramisu::generator::linearize_access ( int  dims,
std::vector< Halide::Expr > &  strides,
isl_ast_expr *  index_expr 
)
staticprotected

Linearize a multidimensional access to a Halide buffer.

Supposing that we have buf[N1][N2][N3], transform buf[i][j][k] into buf[k + j*N3 + i*N3*N2]. Note that the first arg in index_expr is the buffer name. The other args are the indices for each dimension of the buffer.

static tiramisu::expr tiramisu::generator::linearize_access ( int  dims,
std::vector< tiramisu::expr > &  strides,
std::vector< tiramisu::expr index_expr 
)
staticprotected

Linearize a multidimensional access to a Halide buffer.

Supposing that we have buf[N1][N2][N3], transform buf[i][j][k] into buf[k + j*N3 + i*N3*N2]. Note that the first arg in index_expr is the buffer name. The other args are the indices for each dimension of the buffer.

static tiramisu::expr tiramisu::generator::linearize_access ( int  dims,
std::vector< tiramisu::expr > &  strides,
isl_ast_expr *  index_expr 
)
staticprotected

Linearize a multidimensional access to a Halide buffer.

Supposing that we have buf[N1][N2][N3], transform buf[i][j][k] into buf[k + j*N3 + i*N3*N2]. Note that the first arg in index_expr is the buffer name. The other args are the indices for each dimension of the buffer.

static Halide::Internal::Stmt tiramisu::generator::make_buffer_alloc ( buffer b,
const std::vector< Halide::Expr > &  extents,
Halide::Internal::Stmt &  stmt 
)
staticprotected
static Halide::Internal::Stmt tiramisu::generator::make_buffer_free ( buffer b)
staticprotected
static Halide::Internal::Stmt tiramisu::generator::make_halide_block ( const Halide::Internal::Stmt &  first,
const Halide::Internal::Stmt &  second 
)
staticprotected
static tiramisu::expr tiramisu::generator::replace_accesses ( const tiramisu::function func,
std::vector< isl_ast_expr * > &  index_expr,
const tiramisu::expr tiramisu_expr 
)
staticprotected
static isl_ast_node* tiramisu::generator::stmt_code_generator ( isl_ast_node *  node,
isl_ast_build *  build,
void *  user 
)
staticprotected

Retrieve the access function of the ISL AST leaf node (which represents a computation).

Store the access in computation->access.

static void tiramisu::generator::traverse_expr_and_extract_accesses ( const tiramisu::function fct,
const tiramisu::computation comp,
const tiramisu::expr exp,
std::vector< isl_map * > &  accesses,
bool  return_buffer_accesses 
)
staticprotected

Traverse a tiramisu expression (exp) and extract the access relations from the access operation passed in exp.

The access relations are added to the vector accesses. The access relation is from the domain of the computation comp to the domain of the computation accessed by the access operation. If return_buffer_accesses = true, an access to a buffer is created instead of an access to computations.

static void tiramisu::generator::update_producer_expr_name ( tiramisu::computation comp,
std::string  name_to_replace,
std::string  replace_with 
)
static

Traverse a tiramisu expression (current_exp) until an expression with the specified name is found.

Replace that name with a new name. Replaces all occurrences.


The documentation for this class was generated from the following file: