From e0162f0a845d66d6f4b22df32aaa7e455ece18d6 Mon Sep 17 00:00:00 2001 From: conrad Date: Tue, 28 Jan 2025 14:24:53 +1000 Subject: [PATCH] take into account use_mp flag --- include/armadillo_bits/op_sum_meat.hpp | 52 +++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/include/armadillo_bits/op_sum_meat.hpp b/include/armadillo_bits/op_sum_meat.hpp index 5aee7536..4a903a11 100644 --- a/include/armadillo_bits/op_sum_meat.hpp +++ b/include/armadillo_bits/op_sum_meat.hpp @@ -106,6 +106,24 @@ op_sum::apply(Mat& out, const Op< eOp, op op_sum::apply_mat_square_noalias(out, U.M, dim); } } + else + if(arma_config::openmp && Proxy::use_mp) + { + const quasi_unwrap U(in.m); // force evaluation of compound inner expression + + if(U.is_alias(out)) + { + Mat tmp; + + op_sum::apply_mat_noalias(tmp, U.M, dim); + + out.steal_mem(tmp); + } + else + { + op_sum::apply_mat_noalias(out, U.M, dim); + } + } else { const Proxy P(in.m); @@ -141,15 +159,37 @@ op_sum::apply(Mat& out, const Op< eOp, op_su typedef Op< eOp, op_sum > modified_whole_expr_type; op_sum::apply(out, reinterpret_cast(in) ); + + return; + } + + typedef eOp inner_expr_type; + + typedef typename inner_expr_type::proxy_type::stored_type inner_expr_P_stored_type; + + const uword dim = in.aux_uword_a; + + arma_conform_check( (dim > 1), "sum(): parameter 'dim' must be 0 or 1" ); + + if( (is_Mat::value) || (arma_config::openmp && Proxy::use_mp) ) + { + const quasi_unwrap U(in.m); // force evaluation of eop_pow + + if(U.is_alias(out)) + { + Mat tmp; + + op_sum::apply_mat_noalias(tmp, U.M, dim); + + out.steal_mem(tmp); + } + else + { + op_sum::apply_mat_noalias(out, U.M, dim); + } } else { - const uword dim = in.aux_uword_a; - - arma_conform_check( (dim > 1), "sum(): parameter 'dim' must be 0 or 1" ); - - typedef eOp inner_expr_type; - const Proxy P(in.m); if(P.is_alias(out))