diff --git a/doxygen/doxygen.cfg b/doxygen/doxygen.cfg index 7ac82a81d8e..83e1a19aa5e 100644 --- a/doxygen/doxygen.cfg +++ b/doxygen/doxygen.cfg @@ -133,7 +133,7 @@ ALWAYS_DETAILED_SEC = NO # operators of the base classes will not be shown. # The default value is: NO. -INLINE_INHERITED_MEMB = NO +INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the @@ -341,14 +341,14 @@ IDL_PROPERTY_SUPPORT = YES # all members of a group must be documented explicitly. # The default value is: NO. -DISTRIBUTE_GROUP_DOC = NO +DISTRIBUTE_GROUP_DOC = YES # If one adds a struct or class to a group and this option is enabled, then also # any nested class or struct is added to the same group. By default this option # is disabled and one has to add nested compounds explicitly via \ingroup. # The default value is: NO. -GROUP_NESTED_COMPOUNDS = NO +GROUP_NESTED_COMPOUNDS = YES # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that @@ -378,7 +378,7 @@ INLINE_GROUPED_CLASSES = NO # Man pages) or section (for LaTeX and RTF). # The default value is: NO. -INLINE_SIMPLE_STRUCTS = NO +INLINE_SIMPLE_STRUCTS = YES # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So @@ -422,7 +422,7 @@ EXTRACT_ALL = YES # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = YES # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. @@ -743,7 +743,7 @@ WARN_NO_PARAMDOC = NO # a warning is encountered. # The default value is: NO. -WARN_AS_ERROR = NO +WARN_AS_ERROR = YES # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which @@ -845,8 +845,7 @@ EXCLUDE_PATTERNS = # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = std::* \ - Eigen::* +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include diff --git a/stan/math/memory/stack_alloc.hpp b/stan/math/memory/stack_alloc.hpp index 307ec3fcfa3..4706473c384 100644 --- a/stan/math/memory/stack_alloc.hpp +++ b/stan/math/memory/stack_alloc.hpp @@ -88,7 +88,7 @@ class stack_alloc { * if necessary, and allocates len bytes of memory within that * block. * - * @param size_t $len Number of bytes to allocate. + * @param len Number of bytes to allocate. * @return A pointer to the allocated memory. */ char* move_to_next_block(size_t len) { diff --git a/stan/math/opencl/buffer_types.hpp b/stan/math/opencl/buffer_types.hpp index f96359788b7..975be3adf04 100644 --- a/stan/math/opencl/buffer_types.hpp +++ b/stan/math/opencl/buffer_types.hpp @@ -9,20 +9,26 @@ namespace stan { namespace math { namespace opencl_kernels { - -// An in_buffer signifies a cl::Buffer argument used as input. +/** \ingroup kernel_executor_opencl + * An in_buffer signifies a cl::Buffer argument used as input. + */ struct in_buffer {}; -// An out_buffer signifies a cl::Buffer argument used as output. +/** \ingroup kernel_executor_opencl + * An out_buffer signifies a cl::Buffer argument used as output. + */ struct out_buffer {}; -// An in_out_buffer signifies a cl::Buffer argument used as both input and -// output. +/** \ingroup kernel_executor_opencl + * An in_out_buffer signifies a cl::Buffer argument used as both input and + * output. + */ struct in_out_buffer {}; namespace internal { -/** \ingroup opencl +/** kernel_executor_opencl + * @internal * meta template struct for changing read/write buffer argument types to * cl::Buffer types. * @tparam T A template typename that for cases of non-read/write buffers @@ -49,7 +55,9 @@ struct to_buffer { using type = cl::Buffer; }; -// Alias for making const cl::Buffer argument types +/** kernel_executor_opencl + * Alias for making const cl::Buffer argument types + */ template using to_const_buffer_t = const typename internal::to_buffer::type; } // namespace internal diff --git a/stan/math/opencl/copy.hpp b/stan/math/opencl/copy.hpp index f572121ada6..4d6ad9a6675 100644 --- a/stan/math/opencl/copy.hpp +++ b/stan/math/opencl/copy.hpp @@ -72,7 +72,6 @@ inline matrix_cl to_matrix_cl(Vec&& src) { * @param src source matrix on the OpenCL device * @return Eigen matrix with a copy of the data in the source matrix */ - template > inline Eigen::Matrix from_matrix_cl(const matrix_cl& src) { diff --git a/stan/math/opencl/err/check_diagonal_zeros.hpp b/stan/math/opencl/err/check_diagonal_zeros.hpp index 09645965bc4..dac58c1f655 100644 --- a/stan/math/opencl/err/check_diagonal_zeros.hpp +++ b/stan/math/opencl/err/check_diagonal_zeros.hpp @@ -13,7 +13,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if the matrix_cl has zeros on the diagonal * * @param function Function name (for error messages) diff --git a/stan/math/opencl/err/check_invalid_matrix_view.hpp b/stan/math/opencl/err/check_invalid_matrix_view.hpp index f22e14a7c67..047485b7c78 100644 --- a/stan/math/opencl/err/check_invalid_matrix_view.hpp +++ b/stan/math/opencl/err/check_invalid_matrix_view.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if the matrix_cl has an invalid view. * * @param function Function name (for error messages) diff --git a/stan/math/opencl/err/check_mat_size_one.hpp b/stan/math/opencl/err/check_mat_size_one.hpp index e740e9ea2d7..d7905493c1d 100644 --- a/stan/math/opencl/err/check_mat_size_one.hpp +++ b/stan/math/opencl/err/check_mat_size_one.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if the matrix_cl has a single element. * * @param function Function name (for error messages) @@ -27,7 +27,7 @@ inline void check_mat_size_one(const char* function, const char* name, } } -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if the matrix_cl has a single element. * * @param function Function name (for error messages) diff --git a/stan/math/opencl/err/check_matching_dims.hpp b/stan/math/opencl/err/check_matching_dims.hpp index 27f2415f7e1..ee26f0ddc16 100644 --- a/stan/math/opencl/err/check_matching_dims.hpp +++ b/stan/math/opencl/err/check_matching_dims.hpp @@ -7,7 +7,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if two matrix_cls have the same dimensions. * * @param function Function name (for error messages) diff --git a/stan/math/opencl/err/check_nan.hpp b/stan/math/opencl/err/check_nan.hpp index efa2a4aee8f..61267abbfb0 100644 --- a/stan/math/opencl/err/check_nan.hpp +++ b/stan/math/opencl/err/check_nan.hpp @@ -12,7 +12,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if the matrix_cl has NaN values * * @param function Function name (for error messages) diff --git a/stan/math/opencl/err/check_opencl.hpp b/stan/math/opencl/err/check_opencl.hpp index 96df154372d..83b919ddc1a 100644 --- a/stan/math/opencl/err/check_opencl.hpp +++ b/stan/math/opencl/err/check_opencl.hpp @@ -12,7 +12,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Throws the domain error with specifying the OpenCL error that * occurred. It outputs the OpenCL errors that are specified * in OpenCL 2.0. If no matching error number is found, diff --git a/stan/math/opencl/err/check_square.hpp b/stan/math/opencl/err/check_square.hpp index ebc89c51879..8e1d45c860a 100644 --- a/stan/math/opencl/err/check_square.hpp +++ b/stan/math/opencl/err/check_square.hpp @@ -7,7 +7,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if the matrix_cl is square. * * @param function Function name (for error messages) diff --git a/stan/math/opencl/err/check_symmetric.hpp b/stan/math/opencl/err/check_symmetric.hpp index bfb38a15918..a463a1dbb9c 100644 --- a/stan/math/opencl/err/check_symmetric.hpp +++ b/stan/math/opencl/err/check_symmetric.hpp @@ -13,7 +13,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if the matrix_cl is symmetric * * @param function Function name (for error messages) diff --git a/stan/math/opencl/err/check_triangular.hpp b/stan/math/opencl/err/check_triangular.hpp index bc8ec5f9846..d31bffa4a0c 100644 --- a/stan/math/opencl/err/check_triangular.hpp +++ b/stan/math/opencl/err/check_triangular.hpp @@ -8,7 +8,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if the matrix_cl is either upper triangular or lower * triangular. * diff --git a/stan/math/opencl/err/check_vector.hpp b/stan/math/opencl/err/check_vector.hpp index bda9a7e6663..2093daaa591 100644 --- a/stan/math/opencl/err/check_vector.hpp +++ b/stan/math/opencl/err/check_vector.hpp @@ -12,7 +12,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup error_checks_opencl * Check if the matrix is either a row vector or column vector. * This function checks the runtime size of the matrix to check * whether it is a row or column vector. diff --git a/stan/math/opencl/is_matrix_cl.hpp b/stan/math/opencl/is_matrix_cl.hpp index ea577bde2e8..59f31a0c00e 100644 --- a/stan/math/opencl/is_matrix_cl.hpp +++ b/stan/math/opencl/is_matrix_cl.hpp @@ -8,7 +8,10 @@ namespace stan { namespace math { -// Dummy class to instantiate matrix_cl to enable for specific types. +/** + * Dummy class to instantiate matrix_cl to enable for specific types. + * @ingroup matrix_cl_group + */ template class matrix_cl { public: @@ -19,13 +22,15 @@ class matrix_cl { namespace internal { -/** \ingroup opencl +/** \ingroup type_traits + * @internal * This underlying implementation is used when the type is not an std vector. */ template struct is_matrix_cl_impl : std::false_type {}; -/** \ingroup opencl +/** \ingroup type_traits + * @internal * This specialization implementation has a static member named value when the * template type is an std vector. */ @@ -37,7 +42,7 @@ struct is_matrix_cl_impl> : std::true_type {}; template struct is_matrix_cl : std::false_type {}; -/** \ingroup opencl +/** \ingroup type_traits * Checks if the decayed type of T is a matrix_cl. */ template @@ -45,8 +50,8 @@ struct is_matrix_cl< T, std::enable_if_t>::value>> : std::true_type {}; -STAN_ADD_REQUIRE_UNARY(matrix_cl, is_matrix_cl, opencl); -STAN_ADD_REQUIRE_CONTAINER(matrix_cl, is_matrix_cl, opencl); +STAN_ADD_REQUIRE_UNARY(matrix_cl, is_matrix_cl, matrix_cl_group); +STAN_ADD_REQUIRE_CONTAINER(matrix_cl, is_matrix_cl, matrix_cl_group); } // namespace stan #endif diff --git a/stan/math/opencl/kernel_cl.hpp b/stan/math/opencl/kernel_cl.hpp index 601103a68cf..b9188dc5f0c 100644 --- a/stan/math/opencl/kernel_cl.hpp +++ b/stan/math/opencl/kernel_cl.hpp @@ -21,7 +21,7 @@ namespace stan { namespace math { namespace opencl_kernels { namespace internal { -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Extracts the kernel's arguments, used in the global and local kernel * constructor. * @tparam For this general template the function will return back the @@ -34,7 +34,7 @@ inline const T& get_kernel_args(const T& t) { return t; } -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Extracts the kernel's arguments, used in the global and local kernel * constructor. * @tparam K The type of the \c matrix_cl. @@ -46,7 +46,7 @@ inline const cl::Buffer& get_kernel_args(const stan::math::matrix_cl& m) { return m.buffer(); } -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Helper function for assigning events to a \c matrix_cl. * * @tparam T Whether the assignment is to an \c in_buffer, \c out_buffer, or \c @@ -56,7 +56,7 @@ inline const cl::Buffer& get_kernel_args(const stan::math::matrix_cl& m) { */ template struct assign_event_helper { - /** \ingroup opencl + /** \ingroup kernel_executor_opencl * Assigns the event to the \c matrix_cl. * @param e the event to be assigned. * @param m The \c matrix_cl to be assigned to. @@ -88,7 +88,7 @@ struct assign_event_helper { } }; -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Assigns the event to a \c matrix_cl. * @tparam T The type to be assigned, if not a matrix_cl this function * will do nothing. @@ -98,7 +98,7 @@ struct assign_event_helper { template inline void assign_event(const cl::Event& e, const T&) {} -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Assigns the event to a \c matrix_cl * @tparam T The type to be assigned, if not a matrix_cl will do nothing. * @tparam K The type of the \c matrix_cl. @@ -115,7 +115,7 @@ inline void assign_event(const cl::Event& e, template ...> inline void assign_events(const T&) {} -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Adds the event to any \c matrix_cls in the arguments depending on whether * they are \c in_buffer, \c out_buffer, or \c in_out_buffers. * @tparam Arg Arguments given during kernel creation that specify the kernel @@ -138,7 +138,7 @@ inline void assign_events(const cl::Event& new_event, CallArg& m, assign_events(new_event, args...); } -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Helper function to select OpenCL event vectors from an \c matrix_cl * @tparam T For non \c matrix_cl types, the type of the first argument. * Otherwise this is the in/out/inout buffer type. @@ -146,7 +146,7 @@ inline void assign_events(const cl::Event& new_event, CallArg& m, */ template struct select_event_helper { - /** \ingroup opencl + /** \ingroup kernel_executor_opencl * Get the events from a matrix_cl. For non \c matrix_cl types this will do * nothing. * @param m A type to extract the event from. @@ -180,7 +180,7 @@ struct select_event_helper { } }; -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Select events from kernel arguments. Does nothing for non \c matrix_cl types. * @tparam T The argument type for a non \c matrix_cl, else the in/out/in_out * buffer types. @@ -205,7 +205,7 @@ inline const std::vector select_events( } // namespace internal -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Compile an OpenCL kernel. * * @param name The name for the kernel @@ -238,7 +238,7 @@ inline auto compile_kernel(const char* name, return cl::Kernel(); // never reached because check_opencl_error throws } -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Functor used for compiling kernels. * * @tparam Args Parameter pack of all kernel argument types. @@ -250,7 +250,7 @@ class kernel_functor { std::map opts_; public: - /** \ingroup opencl + /** \ingroup kernel_executor_opencl * functor to access the kernel compiler. * @param name The name for the kernel. * @param sources A std::vector of strings containing the code for the kernel. @@ -270,13 +270,13 @@ class kernel_functor { auto operator()() const { return cl::KernelFunctor(kernel_); } - /** \ingroup opencl + /** \ingroup kernel_executor_opencl * @return The options that the kernel was compiled with. */ inline const std::map& get_opts() const { return opts_; } }; -/** \ingroup opencl +/** \ingroup kernel_executor_opencl * Creates functor for kernels * * @tparam Args Parameter pack of all kernel argument types. @@ -285,7 +285,7 @@ template struct kernel_cl { const kernel_functor&...> make_functor; - /** \ingroup opencl + /** \ingroup kernel_executor_opencl * Creates functor for kernels that only need access to defining * the global work size. * @param name The name for the kernel @@ -295,7 +295,7 @@ struct kernel_cl { kernel_cl(const char* name, const std::vector& sources, const std::map& options = {}) : make_functor(name, sources, options) {} - /** \ingroup opencl + /** \ingroup kernel_executor_opencl * Executes a kernel * @tparam CallArgs The types of the callee arguments. * @tparam Args Parameter pack of all kernel argument types. @@ -316,7 +316,7 @@ struct kernel_cl { return kern_event; } - /** \ingroup opencl + /** \ingroup kernel_executor_opencl * Executes a kernel * @tparam CallArgs The types of the callee arguments. * @tparam Args Parameter pack of all kernel argument types. @@ -338,7 +338,7 @@ struct kernel_cl { return kern_event; } - /** \ingroup opencl + /** \ingroup kernel_executor_opencl * Retrieves an option used for compiling the kernel. * @param option_name which option to retrieve * @return option value diff --git a/stan/math/opencl/kernel_generator/as_operation_cl.hpp b/stan/math/opencl/kernel_generator/as_operation_cl.hpp index a7b1e000f09..897691bb949 100644 --- a/stan/math/opencl/kernel_generator/as_operation_cl.hpp +++ b/stan/math/opencl/kernel_generator/as_operation_cl.hpp @@ -13,6 +13,10 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Converts any valid kernel generator expression into an operation. This is an * overload for operations - a no-op @@ -65,6 +69,7 @@ using as_operation_cl_t = std::conditional_t< decltype(as_operation_cl(std::declval())), std::remove_reference_t()))>>; +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/binary_operation.hpp b/stan/math/opencl/kernel_generator/binary_operation.hpp index 99b55a41334..bfe984fd66e 100644 --- a/stan/math/opencl/kernel_generator/binary_operation.hpp +++ b/stan/math/opencl/kernel_generator/binary_operation.hpp @@ -21,6 +21,10 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Represents a binary operation in kernel generator expressions. * @tparam Derived derived type @@ -262,7 +266,7 @@ inline matrix_cl operator*(const T_a& a, const T_b& b) { #undef COMMA #undef ADD_BINARY_OPERATION #undef ADD_BINARY_OPERATION_WITH_CUSTOM_VIEW - +/** @}*/ } // namespace math } // namespace stan #endif diff --git a/stan/math/opencl/kernel_generator/block.hpp b/stan/math/opencl/kernel_generator/block.hpp index 103ca3f0b95..c6b1dc35080 100644 --- a/stan/math/opencl/kernel_generator/block.hpp +++ b/stan/math/opencl/kernel_generator/block.hpp @@ -18,6 +18,10 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Represents submatrix block in kernel generator expressions. * @tparam Derived derived type @@ -253,7 +257,7 @@ inline auto block(T&& a, int start_row, int start_col, int rows, int cols) { return block_>( std::move(a_operation), start_row, start_col, rows, cols); } - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/broadcast.hpp b/stan/math/opencl/kernel_generator/broadcast.hpp index 0438d054e41..e1e482a3f41 100644 --- a/stan/math/opencl/kernel_generator/broadcast.hpp +++ b/stan/math/opencl/kernel_generator/broadcast.hpp @@ -18,6 +18,10 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Represents a broadcasting operation in kernel generator expressions. * @tparam T type of arguments @@ -59,8 +63,7 @@ class broadcast_ /** * Generates kernel code for this and nested expressions. - * @param[in,out] generated set of already generated operations - * @param ng name generator for this kernel + * @param var_name_arg name generator for this kernel * @param i row index variable name * @param j column index variable name * @return part of kernel with code for this and nested expressions @@ -201,7 +204,7 @@ template (std::forward(a)); } - +/** @}*/ } // namespace math } // namespace stan #endif diff --git a/stan/math/opencl/kernel_generator/calc_if.hpp b/stan/math/opencl/kernel_generator/calc_if.hpp index f5b8444e89e..f2380a93dba 100644 --- a/stan/math/opencl/kernel_generator/calc_if.hpp +++ b/stan/math/opencl/kernel_generator/calc_if.hpp @@ -17,6 +17,10 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Represents a calc_if in kernel generator expressions. * @tparam T type of the argument @@ -110,7 +114,7 @@ struct is_without_output_impl> : std::true_type {}; template using is_without_output = internal::is_without_output_impl>; - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/colwise_reduction.hpp b/stan/math/opencl/kernel_generator/colwise_reduction.hpp index 5b580bd9cd8..8f6f2c7b715 100644 --- a/stan/math/opencl/kernel_generator/colwise_reduction.hpp +++ b/stan/math/opencl/kernel_generator/colwise_reduction.hpp @@ -18,6 +18,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ /** * Represents a column wise reduction in kernel generator expressions. So as to @@ -281,7 +284,7 @@ inline auto colwise_min(T&& a) { return colwise_min_>( std::move(arg_copy)); } - +/** @}*/ } // namespace math } // namespace stan #endif diff --git a/stan/math/opencl/kernel_generator/common_return_scalar.hpp b/stan/math/opencl/kernel_generator/common_return_scalar.hpp index d9334da4f78..70888d5abe1 100644 --- a/stan/math/opencl/kernel_generator/common_return_scalar.hpp +++ b/stan/math/opencl/kernel_generator/common_return_scalar.hpp @@ -2,8 +2,16 @@ #define STAN_MATH_OPENCL_KERNEL_GENERATOR_COMMON_RETURN_SCALAR_HPP #include +namespace stan { +namespace math { +/** + * @ingroup type_traits + * Wrapper for `std::common_type_t` + */ template using common_scalar_t = typename std::common_type_t< typename std::remove_reference_t::Scalar...>; +} // namespace math +} // namespace stan #endif diff --git a/stan/math/opencl/kernel_generator/evaluate_into.hpp b/stan/math/opencl/kernel_generator/evaluate_into.hpp index 6e663bd38c5..7492b81b90e 100644 --- a/stan/math/opencl/kernel_generator/evaluate_into.hpp +++ b/stan/math/opencl/kernel_generator/evaluate_into.hpp @@ -14,6 +14,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ template template void operation_cl::evaluate_into(T_lhs& lhs) const { @@ -22,7 +25,7 @@ void operation_cl::evaluate_into(T_lhs& lhs) const { "operation_cl::evaluate_into: left hand side is not a valid expression!"); results(lhs) = expressions(derived()); } - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/get_kernel_source_for_evaluating_into.hpp b/stan/math/opencl/kernel_generator/get_kernel_source_for_evaluating_into.hpp index 11763fd8166..e46f09a71f9 100644 --- a/stan/math/opencl/kernel_generator/get_kernel_source_for_evaluating_into.hpp +++ b/stan/math/opencl/kernel_generator/get_kernel_source_for_evaluating_into.hpp @@ -12,6 +12,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ template template std::string @@ -23,7 +26,7 @@ operation_cl::get_kernel_source_for_evaluating_into( "side is not a valid expression!"); return results(lhs).get_kernel_source_for_evaluating(expressions(derived())); } - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/is_valid_expression.hpp b/stan/math/opencl/kernel_generator/is_valid_expression.hpp index 09a8d4f343a..d4a5fd06de7 100644 --- a/stan/math/opencl/kernel_generator/is_valid_expression.hpp +++ b/stan/math/opencl/kernel_generator/is_valid_expression.hpp @@ -9,6 +9,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ /** * Non-templated base of \c operation is needed for easy checking if something * is a subclass of \c operation. @@ -54,7 +57,7 @@ using require_all_valid_expressions_and_none_scalar_t template using require_all_valid_expressions_t = require_all_t...>; - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/load.hpp b/stan/math/opencl/kernel_generator/load.hpp index 66f4fa363d6..5e5f0f749af 100644 --- a/stan/math/opencl/kernel_generator/load.hpp +++ b/stan/math/opencl/kernel_generator/load.hpp @@ -17,6 +17,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ /** * Represents an access to a \c matrix_cl in kernel generator expressions * @tparam T \c matrix_cl @@ -229,7 +232,7 @@ class load_ } } }; - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/matrix_cl_conversion.hpp b/stan/math/opencl/kernel_generator/matrix_cl_conversion.hpp index 011907b65e7..20566749867 100644 --- a/stan/math/opencl/kernel_generator/matrix_cl_conversion.hpp +++ b/stan/math/opencl/kernel_generator/matrix_cl_conversion.hpp @@ -8,6 +8,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ template template *> matrix_cl>::matrix_cl(const Expr& expresion) @@ -22,7 +25,7 @@ matrix_cl& matrix_cl>::operator=( results(*this) = expressions(expresion); return *this; } - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp index fe4cad0cf2d..44451a16b93 100644 --- a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp +++ b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp @@ -20,6 +20,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ namespace internal { // Template parameter pack can only be at the end of the template list in @@ -470,7 +473,7 @@ template results_cl results(T_results&&... results) { return results_cl(std::forward(results)...); } - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/name_generator.hpp b/stan/math/opencl/kernel_generator/name_generator.hpp index 845eb75818f..bf4cb3a4072 100644 --- a/stan/math/opencl/kernel_generator/name_generator.hpp +++ b/stan/math/opencl/kernel_generator/name_generator.hpp @@ -7,6 +7,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ /** * Unique name generator for variables used in generated kernels. */ @@ -21,7 +24,7 @@ class name_generator { private: int i_{0}; }; - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/operation_cl.hpp b/stan/math/opencl/kernel_generator/operation_cl.hpp index 00debb1065b..72073e50ad8 100644 --- a/stan/math/opencl/kernel_generator/operation_cl.hpp +++ b/stan/math/opencl/kernel_generator/operation_cl.hpp @@ -23,6 +23,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ /** * Parts of an OpenCL kernel, generated by an expression */ @@ -346,6 +349,7 @@ template const bool operation_cl::require_specific_local_size = std::max({false, std::decay_t::Deriv::require_specific_local_size...}); +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/operation_cl_lhs.hpp b/stan/math/opencl/kernel_generator/operation_cl_lhs.hpp index de9a7eefb07..ca46ecd56a1 100644 --- a/stan/math/opencl/kernel_generator/operation_cl_lhs.hpp +++ b/stan/math/opencl/kernel_generator/operation_cl_lhs.hpp @@ -13,6 +13,9 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ /** * Base for all kernel generator operations that can be used on left hand side * of an expression. @@ -138,7 +141,7 @@ class operation_cl_lhs : public operation_cl { }); } }; - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/rowwise_reduction.hpp b/stan/math/opencl/kernel_generator/rowwise_reduction.hpp index eb87b6d7933..d45020d0c34 100644 --- a/stan/math/opencl/kernel_generator/rowwise_reduction.hpp +++ b/stan/math/opencl/kernel_generator/rowwise_reduction.hpp @@ -16,6 +16,11 @@ namespace stan { namespace math { + +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Represents a rowwise reduction in kernel generator expressions. * @tparam Derived derived type @@ -311,7 +316,7 @@ inline auto rowwise_min(T&& a) { return rowwise_min_>( std::move(arg_copy)); } - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/scalar.hpp b/stan/math/opencl/kernel_generator/scalar.hpp index b9a4937f30d..aae504d1c1e 100644 --- a/stan/math/opencl/kernel_generator/scalar.hpp +++ b/stan/math/opencl/kernel_generator/scalar.hpp @@ -15,6 +15,10 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Represents a scalar in kernel generator expressions. * @tparam T type of the scalar @@ -101,7 +105,7 @@ class scalar_ : public operation_cl, T> { */ inline int top_diagonal() const { return std::numeric_limits::max(); } }; - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/select.hpp b/stan/math/opencl/kernel_generator/select.hpp index 53d5629b589..17b10a9389a 100644 --- a/stan/math/opencl/kernel_generator/select.hpp +++ b/stan/math/opencl/kernel_generator/select.hpp @@ -18,6 +18,10 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Represents a selection operation in kernel generator expressions. This is * element wise ternary operator condition ? then : els, also @@ -131,7 +135,7 @@ select(T_condition&& condition, T_then&& then, T_else&& els) { // NOLINT as_operation_cl(std::forward(then)), as_operation_cl(std::forward(els))}; } - +/** @}*/ } // namespace math } // namespace stan #endif diff --git a/stan/math/opencl/kernel_generator/transpose.hpp b/stan/math/opencl/kernel_generator/transpose.hpp index c9e057702a7..e9194fe1811 100644 --- a/stan/math/opencl/kernel_generator/transpose.hpp +++ b/stan/math/opencl/kernel_generator/transpose.hpp @@ -18,6 +18,10 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Represents a transpose in kernel generator expressions. * @@ -127,7 +131,7 @@ inline auto transpose(Arg&& a) { return transpose_>{ std::move(a_operation)}; } - +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/kernel_generator/type_str.hpp b/stan/math/opencl/kernel_generator/type_str.hpp index 6f26aee8639..8ed41d69a14 100644 --- a/stan/math/opencl/kernel_generator/type_str.hpp +++ b/stan/math/opencl/kernel_generator/type_str.hpp @@ -4,6 +4,8 @@ #include +namespace stan { +namespace math { /** * Determines a string name of a type. Unsupported types fail static assert. * @return name of the type @@ -23,6 +25,8 @@ ADD_TYPE_TO_TYPE_STR(double) ADD_TYPE_TO_TYPE_STR(int) ADD_TYPE_TO_TYPE_STR(bool) #undef ADD_TYPE_TO_TYPE_STR - +/** @}*/ +} // namespace math +} // namespace stan #endif #endif diff --git a/stan/math/opencl/kernel_generator/unary_function_cl.hpp b/stan/math/opencl/kernel_generator/unary_function_cl.hpp index e0dbffae745..b04c12c3978 100644 --- a/stan/math/opencl/kernel_generator/unary_function_cl.hpp +++ b/stan/math/opencl/kernel_generator/unary_function_cl.hpp @@ -21,6 +21,10 @@ namespace stan { namespace math { +/** \addtogroup opencl_kernel_generator + * @{ + */ + /** * Represents a unary function in kernel generator expressions. * @tparam Derived derived type @@ -187,7 +191,7 @@ ADD_UNARY_FUNCTION_WITH_INCLUDE(log1p_exp, #undef ADD_UNARY_FUNCTION_WITH_INCLUDE #undef ADD_UNARY_FUNCTION #undef ADD_UNARY_FUNCTION_PASS_ZERO - +/** @}*/ } // namespace math } // namespace stan #endif diff --git a/stan/math/opencl/kernel_generator/unary_operation_cl.hpp b/stan/math/opencl/kernel_generator/unary_operation_cl.hpp index f1afc1fd6f4..879c19cc2f6 100644 --- a/stan/math/opencl/kernel_generator/unary_operation_cl.hpp +++ b/stan/math/opencl/kernel_generator/unary_operation_cl.hpp @@ -33,7 +33,7 @@ class unary_operation_cl /** * Constructor * @param a argument expression - * @param fun function + * @param op operation */ unary_operation_cl(T&& a, const std::string& op) : base(std::forward(a)), op_(op) {} diff --git a/stan/math/opencl/kernel_generator/wrapper.hpp b/stan/math/opencl/kernel_generator/wrapper.hpp index 19446f4bab4..de119770f98 100644 --- a/stan/math/opencl/kernel_generator/wrapper.hpp +++ b/stan/math/opencl/kernel_generator/wrapper.hpp @@ -4,6 +4,10 @@ namespace stan { namespace math { + +/** \addtogroup opencl_kernel_generator + * @{ + */ namespace internal { /** @@ -22,6 +26,7 @@ wrapper make_wrapper(T&& x) { } } // namespace internal +/** @}*/ } // namespace math } // namespace stan diff --git a/stan/math/opencl/matrix_cl.hpp b/stan/math/opencl/matrix_cl.hpp index 17cce29f604..da6e442b0e1 100644 --- a/stan/math/opencl/matrix_cl.hpp +++ b/stan/math/opencl/matrix_cl.hpp @@ -19,31 +19,36 @@ #include /** \ingroup opencl - * @file stan/math/opencl/matrix_cl.hpp - * @brief The matrix_cl class - allocates memory space on the OpenCL device, - * functions for transferring matrices to and from OpenCL devices + * \defgroup matrix_cl_group Matrix + * The matrix_cl class - allocates memory space on the OpenCL device. Operations + * on `matrix_cl` types are executed lazily via the kernel generator + * and async routines. */ namespace stan { namespace math { -/** \ingroup opencl - * Represents a matrix on the OpenCL device. +/** \addtogroup matrix_cl_group + * @{ + */ + +/** + * Represents an arithmetic matrix on the OpenCL device. * @tparam T an arithmetic type for the type stored in the OpenCL buffer. */ template class matrix_cl> { private: cl::Buffer buffer_cl_; // Holds the allocated memory on the device - int rows_{0}; - int cols_{0}; + int rows_{0}; // Number of rows. + int cols_{0}; // Number of columns. // Holds info on if matrix is a special type matrix_cl_view view_{matrix_cl_view::Entire}; mutable std::vector write_events_; // Tracks write jobs mutable std::vector read_events_; // Tracks reads public: - using Scalar = T; - using type = T; + using Scalar = T; // Underlying type of the matrix + using type = T; // Underlying type of the matrix // Forward declare the methods that work in place on the matrix template inline void zeros(); @@ -65,7 +70,7 @@ class matrix_cl> { void view(const matrix_cl_view& view) { view_ = view; } - /** \ingroup opencl + /** * Clear the write events from the event stacks. */ inline void clear_write_events() const { @@ -73,7 +78,7 @@ class matrix_cl> { return; } - /** \ingroup opencl + /** * Clear the read events from the event stacks. */ inline void clear_read_events() const { @@ -81,7 +86,7 @@ class matrix_cl> { return; } - /** \ingroup opencl + /** * Clear the write events from the event stacks. */ inline void clear_read_write_events() const { @@ -90,7 +95,7 @@ class matrix_cl> { return; } - /** \ingroup opencl + /** * Get the events from the event stacks. * @return The write event stack. */ @@ -98,7 +103,7 @@ class matrix_cl> { return write_events_; } - /** \ingroup opencl + /** * Get the events from the event stacks. * @return The read/write event stack. */ @@ -106,7 +111,7 @@ class matrix_cl> { return read_events_; } - /** \ingroup opencl + /** * Get the events from the event stacks. * @return The read/write event stack. */ @@ -114,7 +119,7 @@ class matrix_cl> { return vec_concat(this->read_events(), this->write_events()); } - /** \ingroup opencl + /** * Add an event to the read event stack. * @param new_event The event to be pushed on the event stack. */ @@ -122,7 +127,7 @@ class matrix_cl> { this->read_events_.push_back(new_event); } - /** \ingroup opencl + /** * Add an event to the write event stack. * @param new_event The event to be pushed on the event stack. */ @@ -130,7 +135,7 @@ class matrix_cl> { this->write_events_.push_back(new_event); } - /** \ingroup opencl + /** * Add an event to the read/write event stack. * @param new_event The event to be pushed on the event stack. */ @@ -139,7 +144,7 @@ class matrix_cl> { this->write_events_.push_back(new_event); } - /** \ingroup opencl + /** * Waits for the write events and clears the read event stack. */ inline void wait_for_write_events() const { @@ -149,7 +154,7 @@ class matrix_cl> { write_events_.clear(); } - /** \ingroup opencl + /** * Waits for the read events and clears the read event stack. */ inline void wait_for_read_events() const { @@ -159,7 +164,7 @@ class matrix_cl> { read_events_.clear(); } - /** \ingroup opencl + /** * Waits for read and write events to finish and clears the read, write, and * read/write event stacks. */ @@ -172,7 +177,7 @@ class matrix_cl> { cl::Buffer& buffer() { return buffer_cl_; } matrix_cl() {} - /** \ingroup opencl + /** * Construct a matrix_cl from an existing cl::Buffer object. The matrix * directly uses given buffer - no copying is done. * @@ -253,7 +258,7 @@ class matrix_cl> { check_opencl_error("matrix constructor", e); } - /** \ingroup opencl + /** * Constructor for the matrix_cl that * only allocates the buffer on the OpenCL device. * Regardless of `partial_view`, whole matrix is stored. @@ -281,7 +286,7 @@ class matrix_cl> { } } - /** \ingroup opencl + /** * Constructor for the matrix_cl that creates a copy of the Eigen matrix or * Eigen expression on the OpenCL device. Regardless of `partial_view`, whole * matrix is stored. If a lvalue matrix is passed to this constructor the @@ -328,7 +333,7 @@ class matrix_cl> { } } - /** \ingroup opencl + /** * Constructor for the matrix_cl that creates a copy of the Eigen Map on the * OpenCL device. Regardless of `partial_view`, whole matrix is stored. The * caller must make sure that the memory referenced by map is not deleted @@ -354,7 +359,7 @@ class matrix_cl> { initialize_buffer(A.data()); } - /** \ingroup opencl + /** * Constructor for the matrix_cl that creates a copy of a scalar on the OpenCL * device. Regardless of `partial_view`, whole matrix is stored. If a lvalue * is passed to this constructor the caller must make sure that it does not go @@ -379,7 +384,7 @@ class matrix_cl> { initialize_buffer::value>(&A); } - /** \ingroup opencl + /** * Construct a matrix_cl of size Nx1 from \c std::vector. If a lvalue is * passed to this constructor the caller must make sure that it does not go * out of scope before copying is complete. @@ -401,7 +406,7 @@ class matrix_cl> { matrix_cl_view partial_view = matrix_cl_view::Entire) : matrix_cl(std::forward(A), A.size(), 1) {} - /** \ingroup opencl + /** * Construct from \c std::vector with given rows and columns. If a lvalue * is passed to this constructor the caller must make sure that it does not * go out of scope before copying is complete. @@ -427,7 +432,7 @@ class matrix_cl> { initialize_buffer_optionally_from_heap(std::forward(A)); } - /** \ingroup opencl + /** * Construct from \c array with given rows and columns. The caller * must make sure that data is not deleted before copying is complete. * @@ -461,7 +466,7 @@ class matrix_cl> { require_all_valid_expressions_and_none_scalar_t* = nullptr> matrix_cl(const Expr& expression); // NOLINT(runtime/explicit) - /** \ingroup opencl + /** * Move assignment operator. */ matrix_cl& operator=(matrix_cl&& a) { @@ -475,7 +480,7 @@ class matrix_cl> { return *this; } - /** \ingroup opencl + /** * Copy assignment operator. */ matrix_cl& operator=(const matrix_cl& a) { @@ -501,7 +506,7 @@ class matrix_cl> { matrix_cl& operator=(const Expr& expression); private: - /** \ingroup opencl + /** * Initializes the OpenCL buffer of this matrix by copying the data from given * buffer. Assumes that size of \c this is already set and matches the * buffer size. If \c in_order is false the caller must make sure that data @@ -536,7 +541,7 @@ class matrix_cl> { return transfer_event; } - /** \ingroup opencl + /** * Initializes the OpenCL buffer of this matrix by copying the data from given * object. Assumes that size of \c this is already set and matches the * buffer size. If the object is rvalue (temporary) it is first moved to heap @@ -573,7 +578,7 @@ class matrix_cl> { } } - /** \ingroup opencl + /** * Initializes the OpenCL buffer of this matrix by copying the data from given * matrix_cl. Assumes that size of \c this is already set and matches the * size of given matrix. @@ -595,7 +600,7 @@ class matrix_cl> { } } - /** \ingroup opencl + /** * Deletes the container. Used as a callback for OpenCL event. * @tparam U type of container * @param e cl_event handle @@ -614,6 +619,8 @@ using matrix_cl_prim = matrix_cl>; template using matrix_cl_fp = matrix_cl>; +/** @}*/ + } // namespace math } // namespace stan diff --git a/stan/math/opencl/matrix_cl_view.hpp b/stan/math/opencl/matrix_cl_view.hpp index 1ee68ae717c..c4cf96a6317 100644 --- a/stan/math/opencl/matrix_cl_view.hpp +++ b/stan/math/opencl/matrix_cl_view.hpp @@ -98,7 +98,7 @@ enum class TriangularMapCL { UpperToLower = 0, LowerToUpper = 1 }; // \cond static const char* view_kernel_helpers = STRINGIFY( // \endcond - /** \ingroup opencl + /** \ingroup opencl_kernels * Determines which parts are nonzero in any of the input views. * @param left_view first view * @param right_view second view @@ -106,7 +106,7 @@ static const char* view_kernel_helpers = STRINGIFY( */ int either(int left_view, int right_view) { return left_view | right_view; } - /** \ingroup opencl + /** \ingroup opencl_kernels * Determines which parts are nonzero in both input views. * @param left_view first view * @param right_view second view @@ -114,7 +114,7 @@ static const char* view_kernel_helpers = STRINGIFY( */ int both(int left_view, int right_view) { return left_view & right_view; } - /** \ingroup opencl + /** \ingroup opencl_kernels * Check whether a view contains certain nonzero part * @param view view to check * @param part part to check for (usually `Lower` or `Upper`) diff --git a/stan/math/opencl/opencl.hpp b/stan/math/opencl/opencl.hpp index 9eccd20525b..7583d4849ad 100644 --- a/stan/math/opencl/opencl.hpp +++ b/stan/math/opencl/opencl.hpp @@ -4,11 +4,74 @@ /** * \defgroup opencl OpenCL + * Stan's OpenCL backend allows for computation to be executed in parallel + * on a GPU or in multithreaded CPUs. It is meant to easily conform with Eigen + * such that you can create and read from a `matrix_cl` by doing + * + *```cpp + * Eigen::MatrixXd A_eig = Eigen::MatrixXd::Random(10, 10); + * matrix_cl A(A_eig); + * matrix_cl B = to_matrix_cl(A_eig); + * matrix_cl C = cholesky_decompose(A * B); + * // Read back to eigen matrix. + * Eigen::MatrixXd C_eig = from_matrix_cl(C); + * + * // Also for vectors and raw pointers of pointers + * std::vector A_vec(10, 0); + * matrix_cl B_var(A_vec, 10, 1); + * + * vari** A_vari= // fill + * matrix_cl B_vari(A_vari, 10, 1); + * + *``` + * + * Execution is performed in async and Kernel operations are compounded and + * compiled Just In Time. This allows for a low amount of overhead when passing + * data to and from the device and executing computations. + * + * For more details see the paper on Arvix. + * https://arxiv.org/pdf/1907.01063.pdf */ /** * \ingroup opencl - * \defgroup opencl_kernels OpenCL Kernels + * \defgroup error_checks_opencl Error Checks + */ + +/** + * \ingroup opencl + * \defgroup kernel_executor_opencl Kernel Executor + * The kernel executor allows OpenCL kernels to be executed in async. GPUs + * have the capability to perform reads, writes, and computation at the same + * time. In order to maximize the throughput to the device the Kernel + * Executor assigns matrices read and write events. Write events are blocking + * in that no further operations can be completed until the write event + * is finished. However, read events can happen in async together. + * Take the following for example + * + *```cpp + * matrix_cl A = from_eigen_cl(A_eig); + * matrix_cl B = from_eigen_cl(B_eig); + * matrix_cl C = A * B; + * matrix_cl D = A + B; + * matrix_cl E = C + D; + *``` + * In the above, When `A` and `B` are created from the Eigen matrices `A_eig` + *and `B_eig`. they are both assigned write events to their write event stack. + * `C` and `D` depend on `A` and `B` while `E` depends on + * `C` and `D`. When executing `C`'s operation, `A` and `B` are assigned + * events to their read event stack while `C` is assigned an event to it's write + *event stack. Once `A` and `B` have finished their write event the kernel to + *compute `C` can begin. The excution to create `D` also waits for the write + *events of `A` and `B`, but does not have to wait for the execution of `C` to + *finish. Executing `E` requires waiting for for the write events of both `C` + *and `D`. + * + */ + +/** + * \ingroup opencl + * \defgroup opencl_kernels Custom OpenCL kernels */ #include #include diff --git a/stan/math/opencl/opencl_context.hpp b/stan/math/opencl/opencl_context.hpp index 07ead7af15b..80a070ed010 100644 --- a/stan/math/opencl/opencl_context.hpp +++ b/stan/math/opencl/opencl_context.hpp @@ -24,8 +24,8 @@ #include /** \ingroup opencl - * @file stan/math/opencl/opencl_context.hpp - * @brief Initialization for OpenCL: + * \defgroup opencl_context_group OpenCL Context + * Initialization for OpenCL Context: * 1. create context * 2. Find OpenCL platforms and devices available * 3. set up command queue @@ -34,7 +34,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup opencl_context_group * The opencl_context_base class represents an OpenCL context * in the standard Meyers singleton design pattern. * @@ -55,7 +55,7 @@ class opencl_context_base { friend class opencl_context; private: - /** \ingroup opencl + /** \ingroup opencl_context_group * Construct the opencl_context by initializing the * OpenCL context, devices, command queues, and kernel * groups. @@ -78,9 +78,9 @@ class opencl_context_base { system_error("OpenCL Initialization", "[Platform]", -1, "CL_INVALID_PLATFORM"); } - platform_ = platforms_[OPENCL_PLATFORM_ID]; - platform_name_ = platform_.getInfo(); - platform_.getDevices(DEVICE_FILTER, &devices_); + platform_.push_back(platforms_[OPENCL_PLATFORM_ID]); + platform_name_ = platform_[0].getInfo(); + platform_[0].getDevices(DEVICE_FILTER, &devices_); if (devices_.size() == 0) { system_error("OpenCL Initialization", "[Device]", -1, "CL_DEVICE_NOT_FOUND"); @@ -89,21 +89,22 @@ class opencl_context_base { system_error("OpenCL Initialization", "[Device]", -1, "CL_INVALID_DEVICE"); } - device_ = devices_[OPENCL_DEVICE_ID]; + device_.push_back(devices_[OPENCL_DEVICE_ID]); // context and queue cl_command_queue_properties device_properties; - device_.getInfo(CL_DEVICE_QUEUE_PROPERTIES, - &device_properties); - device_.getInfo(CL_DEVICE_MAX_WORK_GROUP_SIZE, - &max_thread_block_size_); + device_[0].getInfo( + CL_DEVICE_QUEUE_PROPERTIES, &device_properties); + device_[0].getInfo(CL_DEVICE_MAX_WORK_GROUP_SIZE, + &max_thread_block_size_); - context_ = cl::Context(device_); + context_ = cl::Context(device_[0]); if (device_properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { - command_queue_ = cl::CommandQueue( - context_, device_, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, nullptr); + command_queue_ + = cl::CommandQueue(context_, device_[0], + CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, nullptr); in_order_ = CL_FALSE; } else { - command_queue_ = cl::CommandQueue(context_, device_, 0, nullptr); + command_queue_ = cl::CommandQueue(context_, device_[0], 0, nullptr); in_order_ = CL_TRUE; } int thread_block_size_sqrt @@ -139,10 +140,10 @@ class opencl_context_base { cl::Context context_; // Manages the the device, queue, platform, memory, etc cl::CommandQueue command_queue_; // job queue for device, one per device std::vector platforms_; // Vector of available platforms - cl::Platform platform_; // The platform for compiling kernels + std::vector platform_; // The platform for compiling kernels std::string platform_name_; // The platform such as NVIDIA OpenCL or AMD SDK + std::vector device_; // The selected OpenCL device std::vector devices_; // All available OpenCL devices - cl::Device device_; // The selected OpenCL device std::string device_name_; // The name of OpenCL device size_t max_thread_block_size_; // The maximum size of a block of workers on // the device @@ -191,14 +192,14 @@ class opencl_context_base { void operator=(opencl_context_base const&) = delete; }; -/** \ingroup opencl +/** \ingroup opencl_context_group * The API to access the methods and values in opencl_context_base */ class opencl_context { public: opencl_context() = default; - /** \ingroup opencl + /** \ingroup opencl_context_group * Returns the description of the OpenCL platform and device that is used. * Devices will be an OpenCL and Platforms are a specific OpenCL * implementation such as AMD SDK's or Nvidia's OpenCL implementation. @@ -209,52 +210,65 @@ class opencl_context { msg << "Platform ID: " << OPENCL_DEVICE_ID << "\n"; msg << "Platform Name: " << opencl_context_base::getInstance() - .platform_.getInfo() + .platform_[0] + .getInfo() << "\n"; msg << "Platform Vendor: " << opencl_context_base::getInstance() - .platform_.getInfo() + .platform_[0] + .getInfo() << "\n"; msg << "\tDevice " << OPENCL_DEVICE_ID << ": " << "\n"; msg << "\t\tDevice Name: " - << opencl_context_base::getInstance().device_.getInfo() + << opencl_context_base::getInstance() + .device_[0] + .getInfo() << "\n"; msg << "\t\tDevice Type: " - << opencl_context_base::getInstance().device_.getInfo() + << opencl_context_base::getInstance() + .device_[0] + .getInfo() << "\n"; msg << "\t\tDevice Vendor: " << opencl_context_base::getInstance() - .device_.getInfo() + .device_[0] + .getInfo() << "\n"; msg << "\t\tDevice Max Compute Units: " << opencl_context_base::getInstance() - .device_.getInfo() + .device_[0] + .getInfo() << "\n"; msg << "\t\tDevice Global Memory: " << opencl_context_base::getInstance() - .device_.getInfo() + .device_[0] + .getInfo() << "\n"; msg << "\t\tDevice Max Clock Frequency: " << opencl_context_base::getInstance() - .device_.getInfo() + .device_[0] + .getInfo() << "\n"; msg << "\t\tDevice Max Allocateable Memory: " << opencl_context_base::getInstance() - .device_.getInfo() + .device_[0] + .getInfo() << "\n"; msg << "\t\tDevice Local Memory: " << opencl_context_base::getInstance() - .device_.getInfo() + .device_[0] + .getInfo() << "\n"; msg << "\t\tDevice Available: " << opencl_context_base::getInstance() - .device_.getInfo() + .device_[0] + .getInfo() << "\n"; return msg.str(); } - /** \ingroup opencl + /** \ingroup opencl_context_group * Returns the description of the OpenCL platforms and devices that * are available. Devices will be an OpenCL and Platforms are a specific * OpenCL implementation such as AMD SDK's or Nvidia's OpenCL implementation. @@ -318,7 +332,7 @@ class opencl_context { return msg.str(); } - /** \ingroup opencl + /** \ingroup opencl_context_group * Returns the reference to the OpenCL context. The OpenCL context manages * objects such as the device, memory, command queue, program, and kernel * objects. For stan, there should only be one context, queue, device, and @@ -327,7 +341,7 @@ class opencl_context { inline cl::Context& context() { return opencl_context_base::getInstance().context_; } - /** \ingroup opencl + /** \ingroup opencl_context_group * Returns the reference to the active OpenCL command queue for the device. * One command queue will exist per device where * kernels are placed on the command queue and by default executed in order. @@ -335,13 +349,13 @@ class opencl_context { inline cl::CommandQueue& queue() { return opencl_context_base::getInstance().command_queue_; } - /** \ingroup opencl + /** \ingroup opencl_context_group * Returns a copy of the map of kernel defines */ - inline opencl_context_base::map_base_opts base_opts() { + inline opencl_context_base::map_base_opts& base_opts() { return opencl_context_base::getInstance().base_opts_; } - /** \ingroup opencl + /** \ingroup opencl_context_group * Returns the maximum thread block size defined by * CL_DEVICE_MAX_WORK_GROUP_SIZE for the device in the context. This is the * maximum product of thread block dimensions for a particular device. IE a @@ -352,31 +366,31 @@ class opencl_context { return opencl_context_base::getInstance().max_thread_block_size_; } - /** \ingroup opencl + /** \ingroup opencl_context_group * Returns the thread block size for the Cholesky Decompositions L_11. */ inline opencl_context_base::tuning_struct& tuning_opts() { return opencl_context_base::getInstance().tuning_opts_; } - /** \ingroup opencl + /** \ingroup opencl_context_group * Returns a vector containing the OpenCL device used to create the context */ - inline std::vector device() { - return {opencl_context_base::getInstance().device_}; + inline std::vector& device() { + return opencl_context_base::getInstance().device_; } - /** \ingroup opencl + /** \ingroup opencl_context_group * Returns a vector containing the OpenCL platform used to create the context */ - inline std::vector platform() { - return {opencl_context_base::getInstance().platform_}; + inline std::vector& platform() { + return opencl_context_base::getInstance().platform_; } - /** + /** \ingroup opencl_context_group * Return a bool representing whether the write to the OpenCL device are * blocking */ - inline bool in_order() { + inline bool& in_order() { return opencl_context_base::getInstance().in_order_; } }; diff --git a/stan/math/opencl/rev/copy.hpp b/stan/math/opencl/rev/copy.hpp index 29a595ab256..48c573d51b3 100644 --- a/stan/math/opencl/rev/copy.hpp +++ b/stan/math/opencl/rev/copy.hpp @@ -16,7 +16,7 @@ namespace stan { namespace math { -/** +/** \ingroup opencl * Copies the source Eigen matrix of vars to * the destination matrix that is stored * on the OpenCL device. @@ -41,7 +41,7 @@ inline matrix_cl to_matrix_cl(const Eigen::Matrix& src) try { return dst; } -/** +/** \ingroup opencl * Copies the adjoint of the source matrix of vars that is stored * on the OpenCL device to the destination Eigen * matrix. @@ -64,7 +64,7 @@ inline Eigen::Matrix from_matrix_cl(const matrix_cl& src) try { return dst; } -/** +/** \ingroup opencl * Packs the flat triangular matrix on the OpenCL device and * copies the adjoint values to the std::vector. * @@ -88,7 +88,7 @@ inline std::vector packed_copy(const matrix_cl& src) try { return dst; } -/** +/** \ingroup opencl * Copies the packed triangular matrix from * the source std::vector to an OpenCL buffer and * unpacks it to a flat matrix on the OpenCL device. diff --git a/stan/math/opencl/rev/matrix_cl.hpp b/stan/math/opencl/rev/matrix_cl.hpp index a7235361d59..ea0b3c2eb0a 100644 --- a/stan/math/opencl/rev/matrix_cl.hpp +++ b/stan/math/opencl/rev/matrix_cl.hpp @@ -18,31 +18,60 @@ namespace stan { namespace math { +/** \addtogroup matrix_cl_group + * @{ + */ + +/** + * Represents an var matrix on the OpenCL device. + * @tparam T an arithmetic type for the type stored in the OpenCL buffer. + */ template class matrix_cl> { private: - /** - * cl::Buffer provides functionality for working with the OpenCL buffer. - * An OpenCL buffer allocates the memory in the device that - * is provided by the context. - */ - const int rows_; - const int cols_; - mutable matrix_cl val_; - mutable matrix_cl adj_; + const int rows_{0}; // Number of rows + const int cols_{0}; // Number of columns + matrix_cl val_{0, 0}; // holds autodiff values + matrix_cl adj_{0, 0}; // holds autodiff adjoints matrix_cl_view view_{matrix_cl_view::Entire}; public: - using Scalar = T; - using type = T; + using Scalar = T; // Inner type of matrix + using type = T; // Inner type of matrix + /** + * Return the number of rows + */ inline int rows() const { return rows_; } + /** + * Return the number of cols + */ inline int cols() const { return cols_; } + /** + * Return the size of the matrix + */ inline int size() const { return rows_ * cols_; } - inline matrix_cl& val() const { return val_; } - inline matrix_cl& adj() const { return adj_; } + /** + * Constant accessor value matrix + */ + inline const matrix_cl& val() const { return val_; } + + /** + * Accessor for value matrix + */ + inline matrix_cl& val() { return val_; } + + /** + * Constant accessor for the adjoint matrix + */ + inline const matrix_cl& adj() const { return adj_; } + /** + * Accessor for the adjoint matrix + */ + inline matrix_cl& adj() { return adj_; } + matrix_cl() : rows_(0), cols_(0), val_(0, 0), adj_(0, 0) {} // Forward declare the methods that work in place on the matrix @@ -57,14 +86,27 @@ class matrix_cl> { size_t A_j, size_t this_i, size_t this_j, size_t nrows, size_t ncols); + /** + * Read only accessor of the view + */ inline const matrix_cl_view& view() const { return view_; } + /** + * Modify the view. + * @param view a `matrix_cl_view` that indicates a special type of matrix. + */ inline void view(const matrix_cl_view& view) { view_ = view; val_.view(view); adj_.view(view); } + /** + * Construct a matrix from an Eigen type. + * @tparam Mat Type derived from `Eigen::Base` + * @param A an object derived from `Eigen::EigenBase` + * @param partial_view `matrix_cl_view` for declaring special type. + */ template ...> explicit matrix_cl(Mat&& A, matrix_cl_view partial_view = matrix_cl_view::Entire) @@ -74,6 +116,11 @@ class matrix_cl> { adj_(A.adj().eval(), partial_view), view_(partial_view) {} + /** + * Construct a matrix from an `Eigen::Matrix` + * @param A Eigen matrix with a scalar `var` type. + * @param partial_view `matrix_cl_view` for declaring special type. + */ explicit matrix_cl(const matrix_vi& A, matrix_cl_view partial_view = matrix_cl_view::Entire) : rows_(A.rows()), @@ -82,6 +129,13 @@ class matrix_cl> { adj_(A.adj().eval(), partial_view), view_(partial_view) {} + /** + * Construct a matrix from a pointer of vari pointers + * @param A a pointer pointing to varis + * @param R number of rows for the matrix. + * @param C Number of columns for the matrix. + * @param partial_view `matrix_cl_view` for declaring special type. + */ explicit matrix_cl(vari** A, const int& R, const int& C, matrix_cl_view partial_view = matrix_cl_view::Entire) : rows_(R), @@ -123,6 +177,13 @@ class matrix_cl> { adj_.add_write_event(transfer_event2); } + /** + * Create matrix of vars from a vector. + * @param A a standard vector holding vars + * @param R number of rows for the matrix. + * @param C Number of columns for the matrix. + * @param partial_view `matrix_cl_view` for declaring special type. + */ explicit matrix_cl(const std::vector& A, const int& R, const int& C, matrix_cl_view partial_view = matrix_cl_view::Entire) : rows_(R), @@ -164,6 +225,9 @@ class matrix_cl> { adj_.add_write_event(transfer_event2); } + /** + * Initialize a var matrix with size rows and columns + */ explicit matrix_cl(const int& rows, const int& cols, matrix_cl_view partial_view = matrix_cl_view::Entire) : rows_(rows), @@ -172,13 +236,15 @@ class matrix_cl> { adj_(rows, cols), view_(partial_view) {} - matrix_cl operator=(const matrix_cl& A) { + auto& operator=(const matrix_cl& A) { val_ = A.val(); adj_ = A.adj(); return *this; } }; +/** @}*/ + } // namespace math } // namespace stan diff --git a/stan/math/opencl/rev/sub_block.hpp b/stan/math/opencl/rev/sub_block.hpp index 7194433aee2..1962f8fe313 100644 --- a/stan/math/opencl/rev/sub_block.hpp +++ b/stan/math/opencl/rev/sub_block.hpp @@ -11,7 +11,7 @@ namespace stan { namespace math { -/** +/** \ingroup matrix_cl_group * Write the contents of A into * \c this starting at the top left of \c this * @param A input matrix diff --git a/stan/math/opencl/rev/triangular_transpose.hpp b/stan/math/opencl/rev/triangular_transpose.hpp index f54c4fee0c9..71d2f22f7b1 100644 --- a/stan/math/opencl/rev/triangular_transpose.hpp +++ b/stan/math/opencl/rev/triangular_transpose.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { -/** +/** \ingroup matrix_cl_group * Copies the lower/upper triangle of a matrix to its upper/lower triangle. * * @tparam triangular_map Specifies if the copy is diff --git a/stan/math/opencl/rev/zeros.hpp b/stan/math/opencl/rev/zeros.hpp index 57113c119e8..87c8d7ab2d5 100644 --- a/stan/math/opencl/rev/zeros.hpp +++ b/stan/math/opencl/rev/zeros.hpp @@ -14,7 +14,7 @@ namespace stan { namespace math { -/** +/** \ingroup matrix_cl_group * Stores zeros in the matrix on the OpenCL device. * Supports writing zeroes to the lower and upper triangular or * the whole matrix. @@ -32,7 +32,7 @@ inline void matrix_cl>::zeros() try { check_opencl_error("zeros", e); } -/** +/** \ingroup matrix_cl_group * Stores zeros in the strict's triangular part (excluding the diagonal) * of a matrix on the OpenCL device. * Supports writing zeroes to the lower and upper triangular. diff --git a/stan/math/opencl/scalar_type.hpp b/stan/math/opencl/scalar_type.hpp index 1256284cc1d..d788bcd1dd2 100644 --- a/stan/math/opencl/scalar_type.hpp +++ b/stan/math/opencl/scalar_type.hpp @@ -8,6 +8,9 @@ namespace stan { +/** \ingroup type_traits + * Return the scalar type of an OpenCL matrix. + */ template struct scalar_type> { using type = typename scalar_type::Scalar>::type; diff --git a/stan/math/opencl/sub_block.hpp b/stan/math/opencl/sub_block.hpp index adf3fbad24b..d8634af6bc9 100644 --- a/stan/math/opencl/sub_block.hpp +++ b/stan/math/opencl/sub_block.hpp @@ -16,9 +16,9 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup matrix_cl_group * Write the contents of A into - * this starting at the top left of this + * `this` starting at the top left of `this` * @param A input matrix * @param A_i the offset row in A * @param A_j the offset column in A diff --git a/stan/math/opencl/triangular_transpose.hpp b/stan/math/opencl/triangular_transpose.hpp index 6125b589e2a..051c6f722fe 100644 --- a/stan/math/opencl/triangular_transpose.hpp +++ b/stan/math/opencl/triangular_transpose.hpp @@ -14,7 +14,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup matrix_cl_group * Copies the lower/upper triangle of a matrix to its upper/lower triangle. * * @tparam triangular_map Specifies if the copy is diff --git a/stan/math/opencl/value_type.hpp b/stan/math/opencl/value_type.hpp index bb7716319e9..0392008483e 100644 --- a/stan/math/opencl/value_type.hpp +++ b/stan/math/opencl/value_type.hpp @@ -8,6 +8,9 @@ namespace stan { +/** \ingroup type_traits + * Return the value type of an OpenCL matrix. + */ template struct value_type> { using type = typename std::decay_t::Scalar; diff --git a/stan/math/opencl/zeros.hpp b/stan/math/opencl/zeros.hpp index cb834ca9702..ae1bbfe14e5 100644 --- a/stan/math/opencl/zeros.hpp +++ b/stan/math/opencl/zeros.hpp @@ -14,7 +14,7 @@ namespace stan { namespace math { -/** \ingroup opencl +/** \ingroup matrix_cl_group * Stores zeros in the matrix on the OpenCL device. * Supports writing zeroes to the lower and upper triangular or * the whole matrix. @@ -37,7 +37,7 @@ inline void matrix_cl>::zeros() try { check_opencl_error("zeros", e); } -/** \ingroup opencl +/** \ingroup matrix_cl_group * Stores zeros in the strict's triangular part (excluding the diagonal) * of a matrix on the OpenCL device. * Supports writing zeroes to the lower and upper triangular. diff --git a/stan/math/prim/fun/distance.hpp b/stan/math/prim/fun/distance.hpp index aff17417e5f..626f21fc350 100644 --- a/stan/math/prim/fun/distance.hpp +++ b/stan/math/prim/fun/distance.hpp @@ -37,18 +37,18 @@ inline return_type_t distance(const T1& x1, const T2& x2) { * Eigen::MatrixBase and have one compile time dimension equal to 1) * @tparam T2 type of the second vector (must be derived from \c * Eigen::MatrixBase and have one compile time dimension equal to 1) - * @param v1 First vector. - * @param v2 Second vector. + * @param x1 First vector. + * @param x2 Second vector. * @return Distance between the vectors. * @throw std::domain_error If the vectors are not the same * size. */ template * = nullptr> -inline return_type_t distance(const T1& v1, const T2& v2) { +inline return_type_t distance(const T1& x1, const T2& x2) { using std::sqrt; - check_matching_sizes("distance", "v1", v1, "v2", v2); - return sqrt(squared_distance(v1, v2)); + check_matching_sizes("distance", "x1", x1, "x2", x2); + return sqrt(squared_distance(x1, x2)); } } // namespace math diff --git a/stan/math/prim/fun/sum.hpp b/stan/math/prim/fun/sum.hpp index faf043dfb5a..6728a3f84a8 100644 --- a/stan/math/prim/fun/sum.hpp +++ b/stan/math/prim/fun/sum.hpp @@ -14,24 +14,24 @@ namespace math { * Returns specified input value. * * @tparam T Type of element. - * @param v Specified value. + * @param m Specified value. * @return Same value (the sum of one value). */ template * = nullptr> -inline T sum(T v) { - return v; +inline decltype(auto) sum(T&& m) { + return std::forward(m); } /** * Return the sum of the values in the specified standard vector. * * @tparam T Type of elements summed. - * @param xs Standard vector to sum. + * @param m Standard vector to sum. * @return Sum of elements. */ template -inline T sum(const std::vector& xs) { - return std::accumulate(xs.begin(), xs.end(), T{0}); +inline T sum(const std::vector& m) { + return std::accumulate(m.begin(), m.end(), T{0}); } /** @@ -39,12 +39,12 @@ inline T sum(const std::vector& xs) { * Eigen Matrix, Array or expression. * * @tparam T Type of argument - * @param v argument + * @param m argument * @return Sum of coefficients of argument. */ template * = nullptr> -inline value_type_t sum(const T& v) { - return v.sum(); +inline value_type_t sum(const T& m) { + return m.sum(); } } // namespace math diff --git a/stan/math/prim/functor/reduce_sum.hpp b/stan/math/prim/functor/reduce_sum.hpp index 3acd5ddd2d0..7c80276bf69 100644 --- a/stan/math/prim/functor/reduce_sum.hpp +++ b/stan/math/prim/functor/reduce_sum.hpp @@ -96,7 +96,7 @@ struct reduce_sum_impl, * * @param rhs Another partial sum */ - inline void join(const recursive_reducer& child) { sum_ += child.sum_; } + inline void join(const recursive_reducer& rhs) { sum_ += rhs.sum_; } }; /** diff --git a/stan/math/rev/fun/multiply.hpp b/stan/math/rev/fun/multiply.hpp index fa23568d647..d0e42ebc8b7 100644 --- a/stan/math/rev/fun/multiply.hpp +++ b/stan/math/rev/fun/multiply.hpp @@ -548,30 +548,30 @@ class multiply_mat_vari : public vari { * @tparam Mat1 type of first matrix * @tparam Mat2 type of second matrix * - * @param[in] A Matrix - * @param[in] B Matrix + * @param[in] m1 Matrix + * @param[in] m2 Matrix * @return Product of scalar and matrix. */ template * = nullptr, require_any_eigen_vt* = nullptr, require_not_eigen_row_and_col_t* = nullptr> -inline auto multiply(const Mat1& A, const Mat2& B) { +inline auto multiply(const Mat1& m1, const Mat2& m2) { using Ta = value_type_t; using Tb = value_type_t; constexpr int Ra = Mat1::RowsAtCompileTime; constexpr int Ca = Mat1::ColsAtCompileTime; constexpr int Cb = Mat2::ColsAtCompileTime; - check_multiplicable("multiply", "A", A, "B", B); - check_not_nan("multiply", "m1", A); - check_not_nan("multiply", "m2", B); + check_multiplicable("multiply", "m1", m1, "m2", m2); + check_not_nan("multiply", "m1", m1); + check_not_nan("multiply", "m2", m2); // Memory managed with the arena allocator. multiply_mat_vari* baseVari - = new multiply_mat_vari(A, B); - Eigen::Matrix AB_v(A.rows(), B.cols()); + = new multiply_mat_vari(m1, m2); + Eigen::Matrix AB_v(m1.rows(), m2.cols()); AB_v.vi() - = Eigen::Map(&baseVari->variRefAB_[0], A.rows(), B.cols()); + = Eigen::Map(&baseVari->variRefAB_[0], m1.rows(), m2.cols()); return AB_v; } @@ -580,28 +580,28 @@ inline auto multiply(const Mat1& A, const Mat2& B) { * Return the scalar product of a row vector and * a vector. * - * @tparam RowVec type of row vector A - * @tparam ColVec type of column vector B + * @tparam RowVec type of row vector m1 + * @tparam ColVec type of column vector m2 * - * @param[in] A Row vector - * @param[in] B Column vector + * @param[in] m1 Row vector + * @param[in] m2 Column vector * @return Scalar product of row vector and vector */ template < typename RowVec, typename ColVec, require_any_var_t, value_type_t>* = nullptr, require_eigen_row_and_col_t* = nullptr> -inline var multiply(const RowVec& A, const ColVec& B) { +inline var multiply(const RowVec& m1, const ColVec& m2) { using RowVecScalar = value_type_t; using ColVecScalar = value_type_t; constexpr int Ca = RowVec::ColsAtCompileTime; - check_multiplicable("multiply", "A", A, "B", B); - check_not_nan("multiply", "A", A); - check_not_nan("multiply", "B", B); + check_multiplicable("multiply", "m1", m1, "m2", m2); + check_not_nan("multiply", "m1", m1); + check_not_nan("multiply", "m2", m2); // Memory managed with the arena allocator. multiply_mat_vari* baseVari - = new multiply_mat_vari(A, B); + = new multiply_mat_vari(m1, m2); var AB_v; AB_v.vi_ = baseVari->variRefAB_; return AB_v; diff --git a/test/unit/math/opencl/kernel_generator/type_str_test.cpp b/test/unit/math/opencl/kernel_generator/type_str_test.cpp index e97beb24b94..b6630e7bce5 100644 --- a/test/unit/math/opencl/kernel_generator/type_str_test.cpp +++ b/test/unit/math/opencl/kernel_generator/type_str_test.cpp @@ -4,6 +4,7 @@ #include TEST(KernelGenerator, type_str) { + using stan::math::type_str; EXPECT_EQ(type_str(), "double"); EXPECT_EQ(type_str(), "int"); EXPECT_EQ(type_str(), "bool");