From 0ec6b425e63e828455641de64e2abcd08e6340a1 Mon Sep 17 00:00:00 2001 From: conrad Date: Sat, 18 Jan 2025 23:16:11 +1000 Subject: [PATCH] avoid using the proxy if we have direct memory access --- include/armadillo_bits/op_reshape_meat.hpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/include/armadillo_bits/op_reshape_meat.hpp b/include/armadillo_bits/op_reshape_meat.hpp index 2948e041..0b207d24 100644 --- a/include/armadillo_bits/op_reshape_meat.hpp +++ b/include/armadillo_bits/op_reshape_meat.hpp @@ -34,7 +34,7 @@ op_reshape::apply(Mat& out, const Op& in) const uword new_n_rows = in.aux_uword_a; const uword new_n_cols = in.aux_uword_b; - if((is_Mat::value) || (is_Mat::stored_type>::value) || (arma_config::openmp && Proxy::use_mp)) + if(is_Mat::value) { const unwrap U(in.m); const Mat& A = U.M; @@ -48,6 +48,24 @@ op_reshape::apply(Mat& out, const Op& in) op_reshape::apply_mat_noalias(out, A, new_n_rows, new_n_cols); } } + else + if((is_Mat::stored_type>::value) || (arma_config::openmp && Proxy::use_mp)) + { + const quasi_unwrap U(in.m); + + if(U.is_alias(out)) + { + Mat tmp; + + op_reshape::apply_mat_noalias(tmp, U.M, new_n_rows, new_n_cols); + + out.steal_mem(tmp); + } + else + { + op_reshape::apply_mat_noalias(out, U.M, new_n_rows, new_n_cols); + } + } else { const Proxy P(in.m);