|
Graph Framework
|
Class representing a 1D accumulated array. More...
#include <piecewise.hpp>
Public Member Functions | |
| atomic_accumulate_1D_node (shared_leaf< T, SAFE_MATH > var, shared_leaf< T, SAFE_MATH > index, shared_leaf< T, SAFE_MATH > x) | |
| Construct a 1D index. | |
| virtual backend::buffer< T > | evaluate () |
| Evaluate the results of accumulate. | |
| virtual shared_leaf< T, SAFE_MATH > | df (shared_leaf< T, SAFE_MATH > x) |
| Transform node to derivative. | |
| virtual shared_leaf< T, SAFE_MATH > | compile (std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage) |
| Compile the node. | |
| virtual bool | is_match (shared_leaf< T, SAFE_MATH > x) |
| Query if the nodes match. | |
| virtual bool | is_arg_match (shared_leaf< T, SAFE_MATH > x) |
| Query if the nodes arguments match. | |
| virtual void | to_latex () const |
| Convert the node to latex. | |
| virtual shared_leaf< T, SAFE_MATH > | to_vizgraph (std::stringstream &stream, jit::register_map ®isters) |
| Convert the node to vizgraph. | |
| virtual shared_leaf< T, SAFE_MATH > | get_power_exponent () const |
| Get the exponent of a power. | |
Public Member Functions inherited from graph::triple_node< T, SAFE_MATH > | |
| triple_node (shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > m, shared_leaf< T, SAFE_MATH > r, const std::string s) | |
| Reduces and assigns the left and right branches. | |
| virtual void | compile_preamble (std::ostringstream &stream, jit::register_map ®isters, jit::visiter_map &visited, jit::register_usage &usage, jit::texture1d_list &textures1d, jit::texture2d_list &textures2d, jit::preamble_map &pre_funcs, int &avail_const_mem) |
| Compile preamble. | |
| shared_leaf< T, SAFE_MATH > | get_middle () const |
| Get the middle branch. | |
| virtual bool | is_all_variables () const |
| Test if node acts like a variable. | |
Public Member Functions inherited from graph::branch_node< T, SAFE_MATH > | |
| branch_node (shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r, const std::string s) | |
| Assigns the left and right branches. | |
| branch_node (shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r, const std::string s, const size_t count, const bool pseudo) | |
| Assigns the left and right branches. | |
| shared_leaf< T, SAFE_MATH > | get_left () const |
| Get the left branch. | |
| shared_leaf< T, SAFE_MATH > | get_right () const |
| Get the right branch. | |
Public Member Functions inherited from graph::leaf_node< T, SAFE_MATH > | |
| leaf_node (const std::string s, const size_t count, const bool pseudo) | |
| Construct a basic node. | |
| virtual | ~leaf_node () |
| Destructor. | |
| virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > | reduce () |
| Reduction method. | |
| virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > | df (std::shared_ptr< leaf_node< T, SAFE_MATH > > x) |
| Transform node to derivative. | |
| virtual bool | is_match (std::shared_ptr< leaf_node< T, SAFE_MATH > > x) |
| Query if the nodes match. | |
| bool | is_power_base_match (std::shared_ptr< leaf_node< T, SAFE_MATH > > x) |
| Check if the base of the powers match. | |
| virtual void | set (const T d) |
| Set the value of variable data. | |
| virtual void | set (const size_t index, const T d) |
| Set the value of variable data. | |
| virtual void | set (const std::vector< T > &d) |
| Set the value of variable data. | |
| virtual void | set (const backend::buffer< T > &d) |
| Set the value of variable data. | |
| virtual bool | is_constant () const |
| Test if node is a constant. | |
| virtual bool | has_constant_zero () const |
| Test the constant node has a zero. | |
| bool | is_normal () |
| Test if the result is normal. | |
| virtual bool | is_power_like () const |
| Test if the node acts like a power of variable. | |
| virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > | get_power_base () |
| Get the base of a power. | |
| size_t | get_hash () const |
| Get the hash for the node. | |
| size_t | get_complexity () const |
| Get the number of nodes in the subgraph. | |
| virtual bool | has_pseudo () const |
| Query if the node contains pseudo variables. | |
| virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > | remove_pseudo () |
| Remove pseudo variable nodes. | |
| virtual void | endline (std::ostringstream &stream, const jit::register_usage &usage, const char end=';') const |
| End a line in the kernel source. | |
Additional Inherited Members | |
Public Types inherited from graph::leaf_node< T, SAFE_MATH > | |
| typedef T | base |
| Type def to retrieve the backend type. | |
Static Public Attributes inherited from graph::leaf_node< T, SAFE_MATH > | |
| static thread_local caches_t | caches |
| A per thread instance of the cache structure. | |
Protected Attributes inherited from graph::triple_node< T, SAFE_MATH > | |
| shared_leaf< T, SAFE_MATH > | middle |
| Middle branch of the tree. | |
Protected Attributes inherited from graph::branch_node< T, SAFE_MATH > | |
| shared_leaf< T, SAFE_MATH > | left |
| Left branch of the tree. | |
| shared_leaf< T, SAFE_MATH > | right |
| Right branch of the tree. | |
Protected Attributes inherited from graph::leaf_node< T, SAFE_MATH > | |
| const size_t | hash |
| Hash for node. | |
| const size_t | complexity |
| Graph complexity. | |
| std::unordered_map< size_t, std::shared_ptr< leaf_node< T, SAFE_MATH > > > | df_cache |
| Cache derivative terms. | |
| const bool | contains_pseudo |
| Node contains pseudo variables. | |
Class representing a 1D accumulated array.
This class is used to implement summation into an array. This uses atomic add to avoid race conditions when multiple threads try to accumulate.
Indicies are selected by
x_norm' = (x - xmin)/dx (1)
| T | Base type of the calculation. |
| SAFE_MATH | Use Safe Math operations. |
|
inline |
Construct a 1D index.
| [in] | var | Array node to accumulate to. |
| [in] | index | Index into the array. |
| [in] | x | Argument to add the existing array value. |
|
inlinevirtual |
Compile the node.
This node first evaluates the value of the argument then chooses the correct index of the variable.
x' = (x - xmin)/dx (1)
y[i] = atomic_add(y[i], x) (2)
| [in,out] | stream | String buffer stream. |
| [in,out] | registers | List of defined registers. |
| [in] | thread_mem | List of defined thread memory registers. |
| [in] | usage | List of register usage count. |
Implements graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Transform node to derivative.
This node is effectively.
y_i + x (1)
So its effective derivative is
∂y_i/∂z + ∂x/dz
| [in] | x | The variable to take the derivative to. |
|
inlinevirtual |
Evaluate the results of accumulate.
Evaluate functions are only used by the reduction. So this node does not evaluate the argument. Instead this only returns the data as if it were a constant.
Implements graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Get the exponent of a power.
Reimplemented from graph::branch_node< T, SAFE_MATH >.
|
inlinevirtual |
Query if the nodes arguments match.
The argument of this node can be deferred so we need to check if the arguments are null.
| [in] | x | Other graph to check if it is a match. |
|
inlinevirtual |
Query if the nodes match.
Assumes both arguments are either set or not set.
| [in] | x | Other graph to check if it is a match. |
|
inlinevirtual |
Convert the node to latex.
Reimplemented from graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Convert the node to vizgraph.
| [in,out] | stream | String buffer stream. |
| [in,out] | registers | List of defined registers. |
Implements graph::leaf_node< T, SAFE_MATH >.