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_var_proxy Class Reference

A wrapper or "proxy" class around a yc_var pointer. More...

#include <yask_compiler_api.hpp>

Public Member Functions

 yc_var_proxy (const std::string &name, yc_solution_ptr soln, const std::vector< yc_index_node_ptr > &dims, bool is_scratch=false)
 Contructor taking a vector of index vars.
 
 yc_var_proxy (const std::string &name, yc_solution_ptr soln, const std::initializer_list< yc_index_node_ptr > &dims, bool is_scratch=false)
 Contructor taking an initializer_list of index vars.
 
 yc_var_proxy (const std::string &name, yc_solution_ptr soln)
 Contructor for a simple scalar YASK variable.
 
 yc_var_proxy (yc_var_ptr &var)
 Contructor taking an existing YASK variable.
 
 yc_var_proxy (yc_var_proxy &proxy)
 Contructor taking an existing proxy.
 
virtual ~yc_var_proxy ()
 Provide a virtual destructor.
 
virtual yc_var_ptr get_var ()
 Get the underlying yc_var pointer.
 
virtual yc_var_ptr get_var () const
 Get the underlying yc_var pointer.
 
virtual yc_var_point_node_ptr operator() (const std::vector< yc_number_node_ptr > &index_exprs)
 Create an expression for a point in a YASK variable.
 
virtual yc_var_point_node_ptr operator() (const std::initializer_list< yc_number_node_ptr > &index_exprs)
 Create an expression for a point in a var.
 
virtual yc_var_point_node_ptr operator() (const yc_number_any_arg i1=nullptr, const yc_number_any_arg i2=nullptr, const yc_number_any_arg i3=nullptr, const yc_number_any_arg i4=nullptr, const yc_number_any_arg i5=nullptr, const yc_number_any_arg i6=nullptr)
 Create an expression for a point in a 1-6 dim var.
 
virtual operator yc_number_ptr_arg ()
 Create an expression for a point in a zero-dim (scalar) var using implicit conversion.
 
virtual yc_var_point_node_ptr operator[] (const yc_number_any_arg i1)
 Create an expression for a point in a one-dim (array) var.
 

Detailed Description

A wrapper or "proxy" class around a yc_var pointer.

Using this class provides a syntactic alternative to calling yc_solution::new_var() (or yc_solution::new_scratch_var()) followed by yc_var::new_var_point().

To use this wrapper class, construct an object of type yc_var_proxy by passing a yc_solution pointer to it. Then, expressions for points in the var can be created with a more intuitive syntax.

Example code to create a solution with an equation for a variable named "A":

yc_factory ycfac;
auto my_soln = ycfac.new_solution("my_stencil");
auto t = nfac.new_step_index("t");
auto x = nfac.new_domain_index("x");
auto y = nfac.new_domain_index("y");
yc_var_proxy a("A", my_soln, { t, x, y });
a(t+1, x, y) EQUALS (a(t, x, y) +
a(t, x+1, y) +
a(t, x, y+1)) * (1.0/3.0);
Bootstrap factory to create objects needed to define a stencil solution.
Definition yask_compiler_api.hpp:96
virtual yc_solution_ptr new_solution(const std::string &name) const
Create a stencil solution.
Factory to create AST nodes.
Definition yc_node_api.hpp:609
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.
A wrapper or "proxy" class around a yc_var pointer.
Definition yask_compiler_api.hpp:921
#define EQUALS
Recommended macro to make the "equality" operator readable and self-explanatory.
Definition yc_node_api.hpp:1102

Compare to the example shown in yc_solution::new_var().

Scoping and lifetime: Since the yc_var pointer in a yc_var_proxy object is a shared pointer also owned by the yc_solution object used to construct the yc_var_proxy object, the underlying YASK var will not be destroyed until both the yc_var_proxy object and the yc_solution object are destroyed. A yc_var_proxy object created from an existing yc_var object will have the same properties.

Constructor & Destructor Documentation

◆ yc_var_proxy() [1/5]

yask::yc_var_proxy::yc_var_proxy ( const std::string &  name,
yc_solution_ptr  soln,
const std::vector< yc_index_node_ptr > &  dims,
bool  is_scratch = false 
)
inline

Contructor taking a vector of index vars.

A wrapper around yc_solution::new_var() and yc_solution::new_scratch_var().

Parameters
[in]nameName of the new var; must be a valid C++ identifier and unique across vars.
[in]solnShared pointer to solution that will share ownership of the yc_var object.
[in]dimsDimensions of the var. Each dimension is identified by an associated index.
[in]is_scratchWhether to make a scratch var.

◆ yc_var_proxy() [2/5]

yask::yc_var_proxy::yc_var_proxy ( const std::string &  name,
yc_solution_ptr  soln,
const std::initializer_list< yc_index_node_ptr > &  dims,
bool  is_scratch = false 
)
inline

Contructor taking an initializer_list of index vars.

A wrapper around yc_solution::new_var() and yc_solution::new_scratch_var().

Note
Not available in the Python API. Use the vector version.
Parameters
[in]nameName of the new var; must be a valid C++ identifier and unique across vars.
[in]solnPointer to solution that will own the var.
[in]dimsDimensions of the var. Each dimension is identified by an associated index.
[in]is_scratchWhether to make a scratch var.

◆ yc_var_proxy() [3/5]

yask::yc_var_proxy::yc_var_proxy ( const std::string &  name,
yc_solution_ptr  soln 
)
inline

Contructor for a simple scalar YASK variable.

A wrapper around yc_solution::new_var().

Parameters
[in]nameName of the new var; must be a valid C++ identifier and unique across vars.
[in]solnPointer to solution that will own the var.

◆ yc_var_proxy() [4/5]

yask::yc_var_proxy::yc_var_proxy ( yc_var_ptr var)
inline

Contructor taking an existing YASK variable.

Creates a new yc_var_proxy wrapper around an existing var.

◆ yc_var_proxy() [5/5]

yask::yc_var_proxy::yc_var_proxy ( yc_var_proxy proxy)
inline

Contructor taking an existing proxy.

Creates a new yc_var_proxy wrapper around a var from an existing proxy.

Member Function Documentation

◆ operator()() [1/3]

virtual yc_var_point_node_ptr yask::yc_var_proxy::operator() ( const std::vector< yc_number_node_ptr > &  index_exprs)
inlinevirtual

Create an expression for a point in a YASK variable.

A wrapper around yc_var::new_var_point(). The number of arguments must match the dimensionality of the var.

Example w/2D var B: A(t+1, x) EQUALS A(t, x) + B(vec),

◆ operator()() [2/3]

virtual yc_var_point_node_ptr yask::yc_var_proxy::operator() ( const std::initializer_list< yc_number_node_ptr > &  index_exprs)
inlinevirtual

Create an expression for a point in a var.

A wrapper around yc_var::new_var_point(). The number of arguments must match the dimensionality of the var.

Example w/2D var B: A(t+1, x) EQUALS A(t, x) + B({x, 3}).

Note
Not available in Python API. Use vector version.

◆ operator()() [3/3]

virtual yc_var_point_node_ptr yask::yc_var_proxy::operator() ( const yc_number_any_arg  i1 = nullptr,
const yc_number_any_arg  i2 = nullptr,
const yc_number_any_arg  i3 = nullptr,
const yc_number_any_arg  i4 = nullptr,
const yc_number_any_arg  i5 = nullptr,
const yc_number_any_arg  i6 = nullptr 
)
inlinevirtual

Create an expression for a point in a 1-6 dim var.

A wrapper around yc_var::new_var_point(). The number of non-null arguments must match the dimensionality of the var. For more than 6 dims, use the vector or initializer-list version.

Example w/2D var B: A(t+1, x) EQUALS A(t, x) + B(x, 3).

Note
Not available in Python API. Use vector version.

◆ operator yc_number_ptr_arg()

virtual yask::yc_var_proxy::operator yc_number_ptr_arg ( )
inlinevirtual

Create an expression for a point in a zero-dim (scalar) var using implicit conversion.

A wrapper around yc_var::new_var_point().

Example w/0D var B: A(t+1, x) EQUALS A(t, x) + B.

Note
Not available in Python API. Use vector version with empty vector.

◆ operator[]()

virtual yc_var_point_node_ptr yask::yc_var_proxy::operator[] ( const yc_number_any_arg  i1)
inlinevirtual

Create an expression for a point in a one-dim (array) var.

A wrapper around yc_var::new_var_point().

Example w/1D var B: A(t+1, x) EQUALS A(t, x) + B[x].

Note
Not available in Python API. Use vector version with 1-element vector.

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