diff --git a/src/analysis_and_optimization/Memory_patterns.ml b/src/analysis_and_optimization/Memory_patterns.ml index 00b134416..f7a037ab6 100644 --- a/src/analysis_and_optimization/Memory_patterns.ml +++ b/src/analysis_and_optimization/Memory_patterns.ml @@ -2,6 +2,30 @@ open Core open Core.Poly open Middle +type demotion = int * Mem_pattern.t * string [@@deriving compare] + +let demotion_reasons = ref [] + +let get_warnings () = + let mem_name pattern = + match pattern with Mem_pattern.SoA -> "SoA" | AoS -> "AoS" in + !demotion_reasons + |> List.dedup_and_sort ~compare:compare_demotion + |> List.map ~f:(fun (linenum, pattern, msg) -> + Printf.sprintf "Optimization hazard warning (Line %i): %s warning: %s" + linenum (mem_name pattern) msg) + +let user_warning_op (mem_pattern : Mem_pattern.t) (linenum : int) (msg : string) + (names : string) = + if not (String.is_empty names || String.is_empty msg) then + demotion_reasons := + (linenum, mem_pattern, msg ^ " " ^ names) :: !demotion_reasons + +let concat_set_str (set : string Set.Poly.t) = + Set.fold + ~f:(fun acc elem -> if acc = "" then acc ^ elem else acc ^ ", " ^ elem) + ~init:"" set + (** Return a Var expression of the name for each type containing an eigen matrix @@ -98,7 +122,7 @@ let query_stan_math_mem_pattern_support (name : string) Frontend.SignatureMismatch.check_compatible_arguments_mod_conv x args |> Result.is_ok) namematches in - let is_soa = function _, _, _, Mem_pattern.SoA -> true | _ -> false in + let is_soa (_, _, _, p) = p = Mem_pattern.SoA in List.exists ~f:is_soa filteredmatches (*Validate whether a function can support SoA matrices*) @@ -116,13 +140,13 @@ let is_fun_soa_supported name exprs = will be returned if the matrix or vector is accessed by single cell indexing. *) -let rec query_initial_demotable_expr (in_loop : bool) ~(acc : string Set.Poly.t) - Expr.{pattern; _} : string Set.Poly.t = +let rec query_initial_demotable_expr (in_loop : bool) (stmt_linenum : int) + ~(acc : string Set.Poly.t) Expr.{pattern; _} : string Set.Poly.t = let query_expr (accum : string Set.Poly.t) = - query_initial_demotable_expr in_loop ~acc:accum in + query_initial_demotable_expr in_loop stmt_linenum ~acc:accum in match pattern with | FunApp (kind, (exprs : Expr.Typed.t list)) -> - query_initial_demotable_funs in_loop acc kind exprs + query_initial_demotable_funs in_loop stmt_linenum acc kind exprs | Indexed ((Expr.{meta= {type_; _}; _} as expr), indexed) -> let index_set = Set.Poly.union_list @@ -132,8 +156,12 @@ let rec query_initial_demotable_expr (in_loop : bool) ~(acc : string Set.Poly.t) (query_expr acc)) indexed) in let index_demotes = - if is_uni_eigen_loop_indexing in_loop type_ indexed then - Set.union (query_var_eigen_names expr) index_set + if is_uni_eigen_loop_indexing in_loop type_ indexed then ( + let single_index_set = query_var_eigen_names expr in + let failure_str = concat_set_str (Set.inter acc single_index_set) in + let msg = "Accessed by element in a for loop:" in + user_warning_op SoA stmt_linenum msg failure_str; + Set.union single_index_set index_set) else Set.union (query_expr acc expr) index_set in Set.union acc index_demotes | Var (_ : string) | Lit ((_ : Expr.Pattern.litType), (_ : string)) -> acc @@ -141,9 +169,16 @@ let rec query_initial_demotable_expr (in_loop : bool) ~(acc : string Set.Poly.t) | TupleProjection (expr, _) -> query_expr acc expr | TernaryIf (predicate, texpr, fexpr) -> let predicate_demotes = query_expr acc predicate in - Set.union - (Set.union predicate_demotes (query_var_eigen_names texpr)) - (query_var_eigen_names fexpr) + let full_set = + Set.union + (Set.union predicate_demotes (query_var_eigen_names texpr)) + (query_var_eigen_names fexpr) in + if Set.is_empty full_set then full_set + else + let failure_str = concat_set_str (Set.inter acc full_set) in + let msg = "Used in a ternary operator which is not allowed:" in + user_warning_op SoA stmt_linenum msg failure_str; + full_set | EAnd (lhs, rhs) | EOr (lhs, rhs) -> (*We need to get the demotes from both sides*) let full_lhs_rhs = Set.union (query_expr acc lhs) (query_expr acc rhs) in @@ -166,9 +201,11 @@ let rec query_initial_demotable_expr (in_loop : bool) ~(acc : string Set.Poly.t) to the UDF. exprs The expression list passed to the functions. *) -and query_initial_demotable_funs (in_loop : bool) (acc : string Set.Poly.t) - (kind : 'a Fun_kind.t) (exprs : Expr.Typed.t list) : string Set.Poly.t = - let query_expr accum = query_initial_demotable_expr in_loop ~acc:accum in +and query_initial_demotable_funs (in_loop : bool) (stmt_linenum : int) + (acc : string Set.Poly.t) (kind : 'a Fun_kind.t) (exprs : Expr.Typed.t list) + : string Set.Poly.t = + let query_expr accum = + query_initial_demotable_expr in_loop stmt_linenum ~acc:accum in let top_level_eigen_names = Set.Poly.union_list (List.map ~f:query_var_eigen_names exprs) in let demoted_eigen_names = List.fold ~init:acc ~f:query_expr exprs in @@ -181,11 +218,26 @@ and query_initial_demotable_funs (in_loop : bool) (acc : string Set.Poly.t) | name -> ( match is_fun_soa_supported name exprs with | true -> Set.union acc demoted_eigen_names - | false -> Set.union acc demoted_and_top_level_names)) + | false -> + let fail_names = + concat_set_str (Set.inter acc top_level_eigen_names) in + user_warning_op SoA stmt_linenum + ("Function " ^ name ^ " is not supported:") + fail_names; + Set.union acc demoted_and_top_level_names)) | CompilerInternal (Internal_fun.FnMakeArray | FnMakeRowVec | FnMakeTuple) -> + let fail_names = + concat_set_str (Set.inter acc demoted_and_top_level_names) in + user_warning_op SoA stmt_linenum + "Used in {} make array or make row vector compiler functions:" + fail_names; Set.union acc demoted_and_top_level_names | CompilerInternal (_ : 'a Internal_fun.t) -> acc | UserDefined ((_ : string), (_ : bool Fun_kind.suffix)) -> + let fail_names = + concat_set_str (Set.inter acc demoted_and_top_level_names) in + user_warning_op SoA stmt_linenum "Used in user defined function:" + fail_names; Set.union acc demoted_and_top_level_names (** @@ -283,9 +335,10 @@ let contains_at_least_one_ad_matrix_or_all_data [query_initial_demotable_expr] for an explanation of the logic. *) let rec query_initial_demotable_stmt (in_loop : bool) (acc : string Set.Poly.t) - (Stmt.{pattern; _} : Stmt.Located.t) : string Set.Poly.t = + (Stmt.{pattern; meta} : Stmt.Located.t) : string Set.Poly.t = + let linenum = meta.end_loc.line_num in let query_expr (accum : string Set.Poly.t) = - query_initial_demotable_expr in_loop ~acc:accum in + query_initial_demotable_expr in_loop linenum ~acc:accum in match pattern with | Stmt.Pattern.Assignment ( lval @@ -299,11 +352,14 @@ let rec query_initial_demotable_stmt (in_loop : bool) (acc : string Set.Poly.t) List.fold ~init:acc ~f:(fun accum x -> Index.folder accum - (fun acc -> query_initial_demotable_expr in_loop ~acc) + (fun acc -> query_initial_demotable_expr in_loop linenum ~acc) x) idx in match is_uni_eigen_loop_indexing in_loop ut idx with - | true -> Set.add idx_list name + | true -> + user_warning_op SoA linenum "Accessed by element in a for loop:" + (if Set.mem acc name then "" else name); + Set.add idx_list name | false -> idx_list in let rhs_demotable_names = query_expr acc rhs in let rhs_and_idx_demotions = Set.union idx_demotable rhs_demotable_names in @@ -311,9 +367,10 @@ let rec query_initial_demotable_stmt (in_loop : bool) (acc : string Set.Poly.t) let tuple_demotions = match lval with | LTupleProjection _, _ -> - Set.add - (Set.union rhs_and_idx_demotions (query_var_eigen_names rhs)) - name + let tuple_set = query_var_eigen_names rhs in + let fail_set = concat_set_str tuple_set in + user_warning_op SoA linenum "Used in tuple:" fail_set; + Set.add (Set.union rhs_and_idx_demotions tuple_set) name | _ -> rhs_and_idx_demotions in let assign_demotions = let is_eigen_stmt = UnsizedType.contains_eigen_type rhs.meta.type_ in @@ -327,15 +384,15 @@ let rec query_initial_demotable_stmt (in_loop : bool) (acc : string Set.Poly.t) (extract_nonderived_admatrix_types rhs)) | _ -> false in (* LHS (3) rhs unsupported function*) - let is_not_supported_func = + let non_supported_func_name = match rhs.pattern with - | FunApp (UserDefined _, _) -> true - | FunApp (CompilerInternal _, _) -> false - | FunApp (StanLib (name, _, _), exprs) -> - not - (query_stan_math_mem_pattern_support name - (List.map ~f:Expr.Typed.fun_arg exprs)) - | _ -> false in + | FunApp (UserDefined (name, _), _) -> Some name + | FunApp (StanLib (name, _, _), exprs) + when not + (query_stan_math_mem_pattern_support name + (List.map ~f:Expr.Typed.fun_arg exprs)) -> + Some name + | _ -> None in (* LHS (3) all rhs aos*) let is_all_rhs_aos = is_nonzero_subset @@ -343,14 +400,36 @@ let rec query_initial_demotable_stmt (in_loop : bool) (acc : string Set.Poly.t) ~set:rhs_demotable_names in if is_all_rhs_aos || is_rhs_not_promoteable_to_soa - || is_not_supported_func - then - Set.add (Set.union tuple_demotions (query_var_eigen_names rhs)) name + || Option.is_some non_supported_func_name + then ( + let rhs_set = query_var_eigen_names rhs in + let all_rhs_warn = + if is_all_rhs_aos then "Right hand side of assignment is all AoS:" + else "" in + let rhs_not_promotable_to_soa_warn = + if is_rhs_not_promoteable_to_soa then + "The right hand side of the assignment only contains data and \ + scalar operations that are not promotable to SoA:" + else "" in + let not_supported_func_warn = + match non_supported_func_name with + | Some fname -> + "Function '" ^ fname + ^ "' on right hand side of assignment is not supported by \ + SoA:" + | None -> "" in + let rhs_name_set = Set.add rhs_set name in + let rhs_name_set_str = concat_set_str rhs_name_set in + user_warning_op SoA linenum all_rhs_warn rhs_name_set_str; + user_warning_op SoA linenum rhs_not_promotable_to_soa_warn + rhs_name_set_str; + user_warning_op SoA linenum not_supported_func_warn rhs_name_set_str; + Set.add (Set.union tuple_demotions rhs_set) name) else tuple_demotions else tuple_demotions in Set.union acc assign_demotions | NRFunApp (kind, exprs) -> - query_initial_demotable_funs in_loop acc kind exprs + query_initial_demotable_funs in_loop linenum acc kind exprs | IfElse (predicate, true_stmt, op_false_stmt) -> let predicate_acc = query_expr acc predicate in Set.union acc @@ -386,7 +465,10 @@ let rec query_initial_demotable_stmt (in_loop : bool) (acc : string Set.Poly.t) | Decl {decl_type= Type.Sized st; decl_id; initialize; _} -> let complex_name = match SizedType.is_complex_type st with - | true -> Set.Poly.singleton decl_id + | true -> + user_warning_op SoA linenum "Complex-valued types cannot be SoA:" + decl_id; + Set.Poly.singleton decl_id | false -> Set.Poly.empty in let init_names = match initialize with @@ -408,24 +490,44 @@ let rec query_initial_demotable_stmt (in_loop : bool) (acc : string Set.Poly.t) @param pattern The Stmt pattern to query. *) let query_demotable_stmt (aos_exits : string Set.Poly.t) - (pattern : (Expr.Typed.t, int) Stmt.Pattern.t) : string Set.Poly.t = - match pattern with + (stmt : Stmt.Located.Non_recursive.t) : string Set.Poly.t = + let linenum = stmt.meta.end_loc.line_num in + match stmt.pattern with | Stmt.Pattern.Assignment (lval, (_ : UnsizedType.t), (rhs : Expr.Typed.t)) -> ( let assign_name = Stmt.Helpers.lhs_variable lval in let all_rhs_eigen_names = query_var_eigen_names rhs in - if Set.mem aos_exits assign_name then - Set.add all_rhs_eigen_names assign_name + if Set.mem aos_exits assign_name then ( + user_warning_op SoA linenum + "Right hand side contains only AoS expressions:" assign_name; + Set.add all_rhs_eigen_names assign_name) else match is_nonzero_subset ~set:aos_exits ~subset:all_rhs_eigen_names with - | true -> Set.add all_rhs_eigen_names assign_name + | true -> + let warn = + Fmt.( + str "Right hand side contains AoS expressions (%s):" + (concat_set_str (Set.inter aos_exits all_rhs_eigen_names))) + in + user_warning_op SoA linenum warn assign_name; + Set.add all_rhs_eigen_names assign_name | false -> Set.Poly.empty) | Decl {decl_id; initialize= Assign e; _} -> ( let all_rhs_eigen_names = query_var_eigen_names e in - if Set.mem aos_exits decl_id then Set.add all_rhs_eigen_names decl_id + if Set.mem aos_exits decl_id then ( + user_warning_op SoA linenum + "Right hand side contains only AoS expressions:" decl_id; + Set.add all_rhs_eigen_names decl_id) else match is_nonzero_subset ~set:aos_exits ~subset:all_rhs_eigen_names with - | true -> Set.add all_rhs_eigen_names decl_id + | true -> + let warn = + Fmt.( + str "Right hand side contains AoS expressions (%s):" + (concat_set_str (Set.inter aos_exits all_rhs_eigen_names))) + in + user_warning_op SoA linenum warn decl_id; + Set.add all_rhs_eigen_names decl_id | false -> Set.Poly.empty) (* All other statements do not need logic here*) | _ -> Set.Poly.empty diff --git a/src/analysis_and_optimization/Optimize.ml b/src/analysis_and_optimization/Optimize.ml index f9ad24c80..578f220ef 100644 --- a/src/analysis_and_optimization/Optimize.ml +++ b/src/analysis_and_optimization/Optimize.ml @@ -1228,8 +1228,7 @@ let optimize_soa (mir : Program.Typed.t) = (flowgraph_to_mir : (int, Stmt.Located.Non_recursive.t) Map.Poly.t) (l : int) (aos_variables : string Set.Poly.t) = let mir_node mir_idx = Map.find_exn flowgraph_to_mir mir_idx in - match (mir_node l).pattern with - | stmt -> Memory_patterns.query_demotable_stmt aos_variables stmt in + Memory_patterns.query_demotable_stmt aos_variables (mir_node l) in let initial_variables = List.fold ~init:Set.Poly.empty ~f:(Memory_patterns.query_initial_demotable_stmt false) diff --git a/src/driver/Entry.ml b/src/driver/Entry.ml index a8ea7525b..eb14c8b0c 100644 --- a/src/driver/Entry.ml +++ b/src/driver/Entry.ml @@ -127,7 +127,11 @@ let stan2cpp model_name model (flags : Flags.t) (output : other_output -> unit) tx_mir in if flags.debug_settings.print_mem_patterns then output - (Memory_patterns (Fmt.str "%a" Memory_patterns.pp_mem_patterns opt_mir)); + (Memory_patterns + (Fmt.str "%a%a@\n" Memory_patterns.pp_mem_patterns opt_mir + (* TODO should be better associated with the names from above? *) + Fmt.(list string) + (Memory_patterns.get_warnings ()))); debug_output_mir output opt_mir flags.debug_settings.print_optimized_mir; let cpp = Lower_program.lower_program diff --git a/test/integration/good/compiler-optimizations/mem_patterns/transformed_mir.expected b/test/integration/good/compiler-optimizations/mem_patterns/transformed_mir.expected index 71ce415ea..91e0df14f 100644 --- a/test/integration/good/compiler-optimizations/mem_patterns/transformed_mir.expected +++ b/test/integration/good/compiler-optimizations/mem_patterns/transformed_mir.expected @@ -10,6 +10,14 @@ matrix[N, N] soa_mat_rep: SoA matrix[N, N] soa_mat_rep_vec: SoA matrix[N, N] aos_mat_rep: AoS matrix[2, 2] aos_mat_from_vecs: AoS +Optimization hazard warning (Line 13): SoA warning: Right hand side contains only AoS expressions: aos_deep +Optimization hazard warning (Line 13): SoA warning: The right hand side of the assignment only contains data and scalar operations that are not promotable to SoA: aos_deep +Optimization hazard warning (Line 17): SoA warning: Right hand side contains only AoS expressions: aos_from_data +Optimization hazard warning (Line 17): SoA warning: The right hand side of the assignment only contains data and scalar operations that are not promotable to SoA: aos_from_data +Optimization hazard warning (Line 20): SoA warning: Right hand side contains AoS expressions (aos_deep): aos_mat_rep +Optimization hazard warning (Line 20): SoA warning: Right hand side contains only AoS expressions: aos_mat_rep +Optimization hazard warning (Line 21): SoA warning: Right hand side contains only AoS expressions: aos_mat_from_vecs +Optimization hazard warning (Line 21): SoA warning: The right hand side of the assignment only contains data and scalar operations that are not promotable to SoA: aos_mat_from_vecs ((functions_block ()) (input_vars ((N SInt) @@ -1673,6 +1681,9 @@ matrix[2, 2] aos_mat_from_vecs: AoS [exit 0] $ ../../../../../../install/default/bin/stanc -fsoa --debug-optimized-mir --debug-mem-patterns complex-fails.stan matrix[10, 10] A_p: AoS +Optimization hazard warning (Line 2): SoA warning: Right hand side contains only AoS expressions: A_p +Optimization hazard warning (Line 6): SoA warning: Complex-valued types cannot be SoA: A_complex_tp +Optimization hazard warning (Line 6): SoA warning: Right hand side contains only AoS expressions: A_complex_tp ((functions_block ()) (input_vars ()) (prepare_data ()) (log_prob (((pattern @@ -2024,6 +2035,7 @@ vector[Nr] h_i_mean: SoA vector[Nr] h_i_sigma: SoA vector[Nr] h_sigma: SoA vector[N] means_ordered: SoA + ((functions_block ()) (input_vars ((N SInt) (K SInt) @@ -9039,6 +9051,16 @@ matrix[10, 10] X_tp4: AoS matrix[10, 10] X_tp5: AoS matrix[10, 10] X_tp6: AoS matrix[10, 10] X_tp7: AoS +Optimization hazard warning (Line 6): SoA warning: Right hand side contains only AoS expressions: X_p +Optimization hazard warning (Line 10): SoA warning: Right hand side contains only AoS expressions: X_tp1 +Optimization hazard warning (Line 11): SoA warning: Right hand side contains only AoS expressions: X_tp2 +Optimization hazard warning (Line 12): SoA warning: Right hand side contains only AoS expressions: X_tp3 +Optimization hazard warning (Line 13): SoA warning: Right hand side contains only AoS expressions: X_tp4 +Optimization hazard warning (Line 14): SoA warning: Right hand side contains only AoS expressions: X_tp5 +Optimization hazard warning (Line 15): SoA warning: Right hand side contains only AoS expressions: X_tp6 +Optimization hazard warning (Line 16): SoA warning: Right hand side contains only AoS expressions: X_tp7 +Optimization hazard warning (Line 19): SoA warning: Accessed by element in a for loop: X_tp7 +Optimization hazard warning (Line 19): SoA warning: Right hand side contains only AoS expressions: X_tp7 ((functions_block ()) (input_vars ()) (prepare_data ()) (log_prob (((pattern @@ -9961,6 +9983,31 @@ vector[N] tp_soa_single_assign: SoA vector[N] tp_soa_single_assign_from_soa: SoA vector[N] tp_aos_loop_vec_v_uni_idx: AoS vector[N] tp_aos_loop_vec_v_multi_uni_idx: AoS +Optimization hazard warning (Line 33): SoA warning: Right hand side contains only AoS expressions: p_aos_vec_v_assign_to_aos +Optimization hazard warning (Line 35): SoA warning: Right hand side contains only AoS expressions: p_aos_vec_v_tp_fails_func +Optimization hazard warning (Line 37): SoA warning: Right hand side contains only AoS expressions: p_aos_loop_vec_v_uni_idx +Optimization hazard warning (Line 39): SoA warning: Right hand side contains only AoS expressions: p_aos_fail_assign_from_top_idx +Optimization hazard warning (Line 40): SoA warning: Right hand side contains only AoS expressions: p_aos_loop_mat_uni_uni_idx +Optimization hazard warning (Line 43): SoA warning: Right hand side contains only AoS expressions: p_aos_mat +Optimization hazard warning (Line 45): SoA warning: Right hand side contains only AoS expressions: p_aos_mat_pass_func_outer_single_indexed1 +Optimization hazard warning (Line 46): SoA warning: Right hand side contains only AoS expressions: p_aos_mat_pass_func_outer_single_indexed2 +Optimization hazard warning (Line 49): SoA warning: Right hand side contains only AoS expressions: p_aos_mat_fail_uni_uni_idx1 +Optimization hazard warning (Line 50): SoA warning: Right hand side contains only AoS expressions: p_aos_mat_fail_uni_uni_idx2 +Optimization hazard warning (Line 59): SoA warning: Function 'udf_fun' on right hand side of assignment is not supported by SoA: p_aos_vec_v_assign_to_aos, tp_aos_vec_v +Optimization hazard warning (Line 59): SoA warning: Right hand side contains only AoS expressions: tp_aos_vec_v +Optimization hazard warning (Line 59): SoA warning: Right hand side of assignment is all AoS: p_aos_vec_v_assign_to_aos, tp_aos_vec_v +Optimization hazard warning (Line 66): SoA warning: Right hand side contains only AoS expressions: tp_aos_fail_func_vec_v +Optimization hazard warning (Line 68): SoA warning: Right hand side contains only AoS expressions: tp_aos_fail_func_vec_v +Optimization hazard warning (Line 71): SoA warning: Right hand side contains only AoS expressions: tp_aos_fail_assign_from_top_idx +Optimization hazard warning (Line 80): SoA warning: Used in user defined function: p_aos_vec_v_assign_to_aos, tp_aos_vec_v +Optimization hazard warning (Line 81): SoA warning: Used in user defined function: p_aos_vec_v_assign_to_aos, tp_aos_vec_v +Optimization hazard warning (Line 82): SoA warning: Used in user defined function: p_aos_vec_v_assign_to_aos, tp_aos_vec_v +Optimization hazard warning (Line 83): SoA warning: Used in user defined function: p_aos_vec_v_assign_to_aos, tp_aos_vec_v +Optimization hazard warning (Line 101): SoA warning: Used in user defined function: p_aos_vec_v_assign_to_aos, tp_aos_vec_v +Optimization hazard warning (Line 111): SoA warning: Accessed by element in a for loop: tp_aos_loop_vec_v_uni_idx +Optimization hazard warning (Line 111): SoA warning: Right hand side contains only AoS expressions: tp_aos_loop_vec_v_uni_idx +Optimization hazard warning (Line 112): SoA warning: Accessed by element in a for loop: tp_aos_loop_vec_v_multi_uni_idx +Optimization hazard warning (Line 112): SoA warning: Right hand side contains only AoS expressions: tp_aos_loop_vec_v_multi_uni_idx ((functions_block (((fdrt (ReturnType UInt)) (fdname mask_fun) (fdsuffix FnPlain) (fdargs ((AutoDiffable i UInt))) @@ -16576,6 +16623,7 @@ vector[N] tp_aos_loop_vec_v_multi_uni_idx: AoS vector[10] p_aos_loop_single_idx: AoS vector[N] tp_soa_multi_idx_assign_in_loop: SoA vector[N] tp_soa_single_idx_in_upfrom_idx: SoA +Optimization hazard warning (Line 9): SoA warning: Right hand side contains only AoS expressions: p_aos_loop_single_idx ((functions_block ()) (input_vars ((N SInt) (M SInt) @@ -17155,6 +17203,14 @@ matrix[5, 10] aos_x: AoS matrix[5, 10] aos_y: AoS matrix[5, 10] tp_matrix_aos_from_mix: AoS matrix[5, 10] tp_matrix_from_udf_reduced_soa: AoS +Optimization hazard warning (Line 17): SoA warning: Right hand side contains only AoS expressions: aos_x +Optimization hazard warning (Line 18): SoA warning: Right hand side contains only AoS expressions: aos_y +Optimization hazard warning (Line 23): SoA warning: Right hand side contains only AoS expressions: tp_matrix_aos_from_mix +Optimization hazard warning (Line 23): SoA warning: Right hand side of assignment is all AoS: aos_x, aos_y, tp_matrix_aos_from_mix +Optimization hazard warning (Line 24): SoA warning: Function 'okay_reduction' on right hand side of assignment is not supported by SoA: aos_x, tp_matrix_from_udf_reduced_soa +Optimization hazard warning (Line 24): SoA warning: Right hand side contains only AoS expressions: tp_matrix_from_udf_reduced_soa +Optimization hazard warning (Line 24): SoA warning: Right hand side of assignment is all AoS: aos_x, tp_matrix_from_udf_reduced_soa +Optimization hazard warning (Line 24): SoA warning: Used in user defined function: aos_x, aos_y, tp_matrix_aos_from_mix ((functions_block (((fdrt (ReturnType UMatrix)) (fdname nono_func) (fdsuffix FnPlain) (fdargs ((AutoDiffable x UMatrix))) @@ -18187,6 +18243,20 @@ matrix[10, 10] empty_user_func_aos: AoS matrix[10, 10] inner_empty_user_func_aos: AoS matrix[10, 10] int_aos_mul_aos: AoS matrix[10, 10] mul_two_aos: AoS +Optimization hazard warning (Line 21): SoA warning: Right hand side contains only AoS expressions: udf_input_aos +Optimization hazard warning (Line 25): SoA warning: Function 'mat_ret_user_func' on right hand side of assignment is not supported by SoA: udf_input_aos, user_func_aos +Optimization hazard warning (Line 25): SoA warning: Right hand side contains only AoS expressions: user_func_aos +Optimization hazard warning (Line 25): SoA warning: Right hand side of assignment is all AoS: udf_input_aos, user_func_aos +Optimization hazard warning (Line 26): SoA warning: Function 'empty_user_func' on right hand side of assignment is not supported by SoA: empty_user_func_aos +Optimization hazard warning (Line 26): SoA warning: Right hand side contains only AoS expressions: empty_user_func_aos +Optimization hazard warning (Line 26): SoA warning: Used in user defined function: udf_input_aos, user_func_aos +Optimization hazard warning (Line 27): SoA warning: Right hand side contains only AoS expressions: inner_empty_user_func_aos +Optimization hazard warning (Line 27): SoA warning: Right hand side of assignment is all AoS: inner_empty_user_func_aos, udf_input_aos +Optimization hazard warning (Line 27): SoA warning: Used in user defined function: empty_user_func_aos, udf_input_aos, user_func_aos +Optimization hazard warning (Line 28): SoA warning: Right hand side contains only AoS expressions: int_aos_mul_aos +Optimization hazard warning (Line 28): SoA warning: Right hand side of assignment is all AoS: empty_user_func_aos, int_aos_mul_aos +Optimization hazard warning (Line 29): SoA warning: Right hand side contains only AoS expressions: mul_two_aos +Optimization hazard warning (Line 29): SoA warning: Right hand side of assignment is all AoS: int_aos_mul_aos, mul_two_aos, user_func_aos ((functions_block (((fdrt (ReturnType UMatrix)) (fdname empty_user_func) (fdsuffix FnPlain) (fdargs ()) @@ -19115,6 +19185,7 @@ matrix[10, 10] aos_p: AoS matrix[10, 10] soa_p: SoA row_vector[10] tp_row_vector_from_soa_loop: SoA matrix[10, 10] tp_matrix_from_soa_loop: SoA +Optimization hazard warning (Line 6): SoA warning: Right hand side contains only AoS expressions: aos_p ((functions_block ()) (input_vars ()) (prepare_data ()) (log_prob (((pattern @@ -19844,6 +19915,12 @@ matrix[10, 10] tp_matrix_from_soa_loop: SoA matrix[5, 10] first_pass_soa_x: AoS matrix[5, 10] aos_x: AoS matrix[5, 10] tp_matrix_aos: AoS +Optimization hazard warning (Line 16): SoA warning: Right hand side contains only AoS expressions: first_pass_soa_x +Optimization hazard warning (Line 17): SoA warning: Right hand side contains only AoS expressions: aos_x +Optimization hazard warning (Line 21): SoA warning: Right hand side contains only AoS expressions: tp_matrix_aos +Optimization hazard warning (Line 22): SoA warning: Function 'nono_func' on right hand side of assignment is not supported by SoA: aos_x, tp_matrix_aos +Optimization hazard warning (Line 22): SoA warning: Right hand side contains only AoS expressions: tp_matrix_aos +Optimization hazard warning (Line 22): SoA warning: Right hand side of assignment is all AoS: aos_x, tp_matrix_aos ((functions_block (((fdrt (ReturnType UMatrix)) (fdname nono_func) (fdsuffix FnPlain) (fdargs ((AutoDiffable x UMatrix))) @@ -20440,6 +20517,10 @@ matrix[5, 10] tp_matrix_aos: AoS $ ../../../../../../install/default/bin/stanc -fsoa --debug-optimized-mir --debug-mem-patterns tuple_test.stan tuple(array[matrix[1, 1], 1], matrix[1, 2], matrix[1, 3]) xx: AoS matrix[1, 1] x: AoS +Optimization hazard warning (Line 3): SoA warning: Right hand side contains only AoS expressions: xx +Optimization hazard warning (Line 6): SoA warning: Right hand side contains only AoS expressions: x +Optimization hazard warning (Line 6): SoA warning: Right hand side of assignment is all AoS: x, xx +Optimization hazard warning (Line 6): SoA warning: The right hand side of the assignment only contains data and scalar operations that are not promotable to SoA: x, xx ((functions_block ()) (input_vars ()) (prepare_data (((pattern @@ -21444,6 +21525,10 @@ matrix[1, 1] x: AoS matrix[3, 3] m1: AoS matrix[3, 3] m2: AoS tuple(matrix[2, 2], matrix[3, 3]) temp: AoS +Optimization hazard warning (Line 5): SoA warning: Right hand side contains only AoS expressions: m1 +Optimization hazard warning (Line 5): SoA warning: Right hand side contains only AoS expressions: m2 +Optimization hazard warning (Line 8): SoA warning: Right hand side contains only AoS expressions: temp +Optimization hazard warning (Line 8): SoA warning: Right hand side of assignment is all AoS: m1, m2, temp ((functions_block ()) (input_vars ((x