YASK
Yet Another Stencil Kit: a software framework for creating HPC stencil code. Copyright 2014-2023 Intel Corporation.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
yask::yc_node_factory Class Reference

Factory to create AST nodes. More...

#include <yc_node_api.hpp>

Public Member Functions

virtual yc_index_node_ptr new_step_index (const std::string &name) const
 Create a step-index node.
 
virtual yc_index_node_ptr new_domain_index (const std::string &name) const
 Create a domain-index node.
 
virtual yc_index_node_ptr new_misc_index (const std::string &name) const
 Create a new miscellaneous index.
 
virtual yc_equation_node_ptr new_equation_node (yc_var_point_node_ptr lhs, yc_number_node_ptr rhs, yc_bool_node_ptr sub_domain_cond=nullptr) const
 Create an equation node.
 
virtual yc_number_node_ptr new_number_node (yc_number_any_arg arg) const
 Create a numerical-value expression node.
 
virtual yc_number_node_ptr new_const_number_node (double val) const
 Create a constant numerical-value node.
 
virtual yc_number_node_ptr new_const_number_node (idx_t val) const
 Create a constant numerical value node.
 
virtual yc_number_node_ptr new_negate_node (yc_number_node_ptr rhs) const
 Create a numerical negation operator node.
 
virtual yc_number_node_ptr new_add_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create an addition node.
 
virtual yc_number_node_ptr new_multiply_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a multiplication node.
 
virtual yc_number_node_ptr new_subtract_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a subtraction node.
 
virtual yc_number_node_ptr new_divide_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a division node.
 
virtual yc_number_node_ptr new_mod_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a modulo node.
 
virtual yc_index_node_ptr new_first_domain_index (yc_index_node_ptr idx) const
 Create a symbol for the first index value in a given dimension.
 
virtual yc_index_node_ptr new_last_domain_index (yc_index_node_ptr idx) const
 Create a symbol for the last index value in a given dimension.
 
virtual yc_bool_node_ptr new_not_node (yc_bool_node_ptr rhs) const
 Create a binary inverse operator node.
 
virtual yc_bool_node_ptr new_and_node (yc_bool_node_ptr lhs, yc_bool_node_ptr rhs) const
 Create a boolean 'and' node.
 
virtual yc_bool_node_ptr new_or_node (yc_bool_node_ptr lhs, yc_bool_node_ptr rhs) const
 Create a boolean 'or' node.
 
virtual yc_bool_node_ptr new_equals_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a numerical-comparison 'equals' node.
 
virtual yc_bool_node_ptr new_not_equals_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a numerical-comparison 'not-equals' node.
 
virtual yc_bool_node_ptr new_less_than_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a numerical-comparison 'less-than' node.
 
virtual yc_bool_node_ptr new_greater_than_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a numerical-comparison 'greater-than' node.
 
virtual yc_bool_node_ptr new_not_less_than_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a numerical-comparison 'greater-than or equals' node.
 
virtual yc_bool_node_ptr new_not_greater_than_node (yc_number_node_ptr lhs, yc_number_node_ptr rhs) const
 Create a numerical-comparison 'less-than or equals' node.
 

Detailed Description

Factory to create AST nodes.

Note
Var-point reference nodes are created from a yc_var object instead of from a yc_node_factory.

Member Function Documentation

◆ new_step_index()

virtual yc_index_node_ptr yask::yc_node_factory::new_step_index ( const std::string &  name) const
virtual

Create a step-index node.

Create a variable to be used to index vars in the solution-step dimension. The name usually describes time, e.g. "t".

Returns
Pointer to new yc_index_node object.
Parameters
[in]nameStep dimension name.

◆ new_domain_index()

virtual yc_index_node_ptr yask::yc_node_factory::new_domain_index ( const std::string &  name) const
virtual

Create a domain-index node.

Create a variable to be used to index vars in the solution-domain dimension. The name usually describes spatial dimensions, e.g. "x" or "y", but it can be any dimension that is specified at run-time, such as an index into a number of parallel problems being solved simultaneously.

Note
This should not include the step dimension, which is specified via new_step_index().
Returns
Pointer to new yc_index_node object.
Parameters
[in]nameDomain index name.

◆ new_misc_index()

virtual yc_index_node_ptr yask::yc_node_factory::new_misc_index ( const std::string &  name) const
virtual

Create a new miscellaneous index.

Create an variable to be used to index vars in the some dimension that is not the step dimension or a domain dimension. The value of these indices are normally compile-time constants, e.g., a fixed index into an array.

Returns
Pointer to new yc_index_node object.
Parameters
[in]nameIndex name.

◆ new_equation_node()

virtual yc_equation_node_ptr yask::yc_node_factory::new_equation_node ( yc_var_point_node_ptr  lhs,
yc_number_node_ptr  rhs,
yc_bool_node_ptr  sub_domain_cond = nullptr 
) const
virtual

Create an equation node.

Indicates var point on LHS is equivalent to expression on RHS. This is NOT a test for equality. When an equation is created, it is automatically added to the list of equations for the yc_solution that contains the var that is on the LHS.

An optional domain condition may be provided to define the sub-domain to which this equation applies. Domain conditions are always evaluated with respect to the overall problem domain, i.e., independent of any specific MPI domain decomposition that might occur at run-time. If a domain condition is not provided, the equation applies to the entire problem domain. A domain condition can be added to an equation after its creation via yc_equation_node.set_cond(). See yc_equation_node.set_cond() for more information and an example.

A step condition is similar to a domain condition, but enables or disables the entire equation based on the current step (usually time) and/or other values. A step condition can only be added to an equation after its creation via yc_equation_node.set_step_cond(). See yc_equation_node.set_step_cond() for more information and an example.

Returns
Pointer to new yc_equation_node object.
Parameters
[in]lhsVar-point before EQUALS operator.
[in]rhsExpression after EQUALS operator.
[in]sub_domain_condOptional expression defining sub-domain where lhs EQUALS rhs is valid.

◆ new_number_node()

virtual yc_number_node_ptr yask::yc_node_factory::new_number_node ( yc_number_any_arg  arg) const
inlinevirtual

Create a numerical-value expression node.

A generic method to create a pointer to a numerical expression from any type supported by yc_number_any_arg constructors.

Note
Not available in Python API. Use a more explicit method.
Parameters
[in]argArgument to convert to a numerical expression.

◆ new_const_number_node() [1/2]

virtual yc_number_node_ptr yask::yc_node_factory::new_const_number_node ( double  val) const
virtual

Create a constant numerical-value node.

Use to add a constant to an expression. The overloaded arithmetic operators allow double arguments, so in most cases, it is not necessary to call this directly.

Returns
Pointer to new yc_const_number_node object.
Parameters
[in]valValue to store in node.

◆ new_const_number_node() [2/2]

virtual yc_number_node_ptr yask::yc_node_factory::new_const_number_node ( idx_t  val) const
virtual

Create a constant numerical value node.

Integer version of new_const_number_node(double). It may be necessary to cast other integer types to idx_t to avoid ambiguous overloading of this function.

Returns
Pointer to new yc_const_number_node object.
Parameters
[in]valValue to store in node.

◆ new_negate_node()

virtual yc_number_node_ptr yask::yc_node_factory::new_negate_node ( yc_number_node_ptr  rhs) const
virtual

Create a numerical negation operator node.

This is the explicit form, which is usually not needed because new negation nodes can also be created via the overloaded unary - operator.

Returns
Pointer to new yc_negate_node object.
Parameters
[in]rhsExpression after - sign.

◆ new_add_node()

virtual yc_number_node_ptr yask::yc_node_factory::new_add_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create an addition node.

This is the explicit form, which is usually not needed because new addition nodes can also be created via the overloaded + operator.

Returns
Pointer to new yc_add_node object. Returns rhs if lhs is a null node pointer and vice-versa.
Parameters
[in]lhsExpression before + sign.
[in]rhsExpression after + sign.

◆ new_multiply_node()

virtual yc_number_node_ptr yask::yc_node_factory::new_multiply_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a multiplication node.

This is the explicit form, which is usually not needed because new multiplication nodes can also be created via the overloaded * operator.

Returns
Pointer to new yc_multiply_node object. Returns rhs if lhs is a null node pointer and vice-versa.
Parameters
[in]lhsExpression before * sign.
[in]rhsExpression after * sign.

◆ new_subtract_node()

virtual yc_number_node_ptr yask::yc_node_factory::new_subtract_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a subtraction node.

This is binary subtraction. Use new_negate_node() for unary -.

This is the explicit form, which is usually not needed because new subtraction nodes can also be created via the overloaded - operator.

Returns
Pointer to new yc_subtract_node object. Returns - rhs if lhs is a null node pointer and lhs if rhs is null.
Parameters
[in]lhsExpression before - sign.
[in]rhsExpression after - sign.

◆ new_divide_node()

virtual yc_number_node_ptr yask::yc_node_factory::new_divide_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a division node.

This is the explicit form, which is usually not needed because new division nodes can also be created via the overloaded / operator.

Returns
Pointer to new yc_divide_node object. Returns 1.0 / rhs if lhs is a null node pointer and lhs if rhs is null.
Parameters
[in]lhsExpression before / sign.
[in]rhsExpression after / sign.

◆ new_mod_node()

virtual yc_number_node_ptr yask::yc_node_factory::new_mod_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a modulo node.

This is the explicit form, which is usually not needed because new modulo nodes can also be created via the overloaded % operator. The modulo operator converts both operands to integers before performing the operation.

Returns
Pointer to new yc_mod_node object.
Parameters
[in]lhsExpression before % sign.
[in]rhsExpression after % sign.

◆ new_first_domain_index()

virtual yc_index_node_ptr yask::yc_node_factory::new_first_domain_index ( yc_index_node_ptr  idx) const
virtual

Create a symbol for the first index value in a given dimension.

Create an expression that indicates the first value in the overall problem domain in dim dimension. The dim argument is created via new_domain_index().

See yc_equation_node.set_cond() for more information and an example.

Returns
Pointer to new yc_index_node object.
Parameters
[in]idxDomain index.

◆ new_last_domain_index()

virtual yc_index_node_ptr yask::yc_node_factory::new_last_domain_index ( yc_index_node_ptr  idx) const
virtual

Create a symbol for the last index value in a given dimension.

Create an expression that indicates the last value in the overall problem domain in dim dimension. The dim argument is created via new_domain_index().

See yc_equation_node.set_cond() for more information and an example.

Returns
Pointer to new yc_index_node object.
Parameters
[in]idxDomain index.

◆ new_not_node()

virtual yc_bool_node_ptr yask::yc_node_factory::new_not_node ( yc_bool_node_ptr  rhs) const
virtual

Create a binary inverse operator node.

This is the explicit form, which is usually not needed because new "not" nodes can also be created via the overloaded ! operator or the yc_not function in Python.

Returns
Pointer to new yc_not_node object.
Parameters
[in]rhsExpression after ! sign.

◆ new_and_node()

virtual yc_bool_node_ptr yask::yc_node_factory::new_and_node ( yc_bool_node_ptr  lhs,
yc_bool_node_ptr  rhs 
) const
virtual

Create a boolean 'and' node.

This is the explicit form, which is usually not needed because new "and" nodes can also be created via the overloaded && operator or the yc_and function in Python.

Returns
Pointer to new yc_and_node object.
Parameters
[in]lhsExpression before && sign.
[in]rhsExpression after && sign.

◆ new_or_node()

virtual yc_bool_node_ptr yask::yc_node_factory::new_or_node ( yc_bool_node_ptr  lhs,
yc_bool_node_ptr  rhs 
) const
virtual

Create a boolean 'or' node.

This is the explicit form, which is usually not needed because new "or" nodes can also be created via the overloaded || operator or the yc_or function in Python.

Returns
Pointer to new yc_or_node object.
Parameters
[in]lhsExpression before || sign.
[in]rhsExpression after || sign.

◆ new_equals_node()

virtual yc_bool_node_ptr yask::yc_node_factory::new_equals_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a numerical-comparison 'equals' node.

This is the explicit form, which is usually not needed because new "equals" nodes can also be created via the overloaded == operator.

Returns
Pointer to new yc_equals_node object.
Parameters
[in]lhsExpression before == sign.
[in]rhsExpression after == sign.

◆ new_not_equals_node()

virtual yc_bool_node_ptr yask::yc_node_factory::new_not_equals_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a numerical-comparison 'not-equals' node.

This is the explicit form, which is usually not needed because new "not-equals" nodes can also be created via the overloaded != operator.

Returns
Pointer to new yc_not_equals_node object.
Parameters
[in]lhsExpression before != sign.
[in]rhsExpression after != sign.

◆ new_less_than_node()

virtual yc_bool_node_ptr yask::yc_node_factory::new_less_than_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a numerical-comparison 'less-than' node.

This is the explicit form, which is usually not needed because new "less-than" nodes can also be created via the overloaded < operator.

Returns
Pointer to new yc_less_than_node object.
Parameters
[in]lhsExpression before < sign.
[in]rhsExpression after < sign.

◆ new_greater_than_node()

virtual yc_bool_node_ptr yask::yc_node_factory::new_greater_than_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a numerical-comparison 'greater-than' node.

This is the explicit form, which is usually not needed because new "greater-than" nodes can also be created via the overloaded > operator.

Returns
Pointer to new yc_greater_than_node object.
Parameters
[in]lhsExpression before > sign.
[in]rhsExpression after > sign.

◆ new_not_less_than_node()

virtual yc_bool_node_ptr yask::yc_node_factory::new_not_less_than_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a numerical-comparison 'greater-than or equals' node.

This is the explicit form, which is usually not needed because new "greater-than or equals" nodes can also be created via the overloaded >= operator.

Returns
Pointer to new yc_not_less_than_node object.
Parameters
[in]lhsExpression before >= sign.
[in]rhsExpression after >= sign.

◆ new_not_greater_than_node()

virtual yc_bool_node_ptr yask::yc_node_factory::new_not_greater_than_node ( yc_number_node_ptr  lhs,
yc_number_node_ptr  rhs 
) const
virtual

Create a numerical-comparison 'less-than or equals' node.

This is the explicit form, which is usually not needed because new "less-than or equals" nodes can also be created via the overloaded <= operator.

Returns
Pointer to new yc_not_greater_than_node object.
Parameters
[in]lhsExpression before <= sign.
[in]rhsExpression after <= sign.

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