1#ifndef STAN_MATH_OPENCL_KERNEL_GENERATOR_CALC_IF_HPP
2#define STAN_MATH_OPENCL_KERNEL_GENERATOR_CALC_IF_HPP
28template <
bool Do_Calculate,
typename T>
31 typename std::remove_reference_t<T>::Scalar, T> {
33 using Scalar =
typename std::remove_reference_t<T>::Scalar;
44 const std::string& col_index_name,
45 const bool view_handled,
46 const std::string& var_name_arg)
const {
67 template <
typename T_result>
69 std::unordered_map<const void*, const char*>& generated,
70 std::unordered_map<const void*, const char*>& generated_all,
72 const std::string& col_index_name,
const T_result& result)
const {
74 return this->
template get_arg<0>().get_whole_kernel_parts(
75 generated, generated_all, ng, row_index_name, col_index_name, result);
92 std::unordered_map<const void*, const char*>& generated,
93 std::unordered_map<const void*, const char*>& generated_all,
94 cl::Kernel& kernel,
int& arg_num)
const {
96 this->
template get_arg<0>().set_args(generated, generated_all, kernel,
106 return this->
template get_arg<0>().thread_rows();
114 return this->
template get_arg<0>().thread_cols();
118template <
bool Do_Calculate,
typename T,
120 std::enable_if_t<Do_Calculate>* =
nullptr>
126template <
bool Do_Calculate,
typename T,
127 std::enable_if_t<!Do_Calculate>* =
nullptr>
calc_if_(T &&a)
Constructor.
int thread_rows() const
Number of rows threads need to be launched for.
kernel_parts generate(const std::string &row_index_name, const std::string &col_index_name, const bool view_handled, const std::string &var_name_arg) const
kernel_parts get_whole_kernel_parts(std::unordered_map< const void *, const char * > &generated, std::unordered_map< const void *, const char * > &generated_all, name_generator &ng, const std::string &row_index_name, const std::string &col_index_name, const T_result &result) const
Generates kernel code for assigning this expression into result expression.
typename std::remove_reference_t< T >::Scalar Scalar
void set_args(std::unordered_map< const void *, const char * > &generated, std::unordered_map< const void *, const char * > &generated_all, cl::Kernel &kernel, int &arg_num) const
Sets kernel arguments for nested expressions.
int thread_cols() const
Number of columns threads need to be launched for.
Represents a calc_if in kernel generator expressions.
Unique name generator for variables used in generated kernels.
Base for all kernel generator operations.
Represents a scalar in kernel generator expressions.
calc_if_< true, as_operation_cl_t< T > > calc_if(T &&a)
require_all_t< is_kernel_expression< Types >... > require_all_kernel_expressions_t
Enables a template if all given types are are a valid kernel generator expressions.
T_operation && as_operation_cl(T_operation &&a)
Converts any valid kernel generator expression into an operation.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Parts of an OpenCL kernel, generated by an expression.