From 5781370bf16f26b80283b8c04e59bfde84fc5712 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Mon, 7 Aug 2023 12:32:48 +0200 Subject: [PATCH] Use back_inserter in permutations to only do one pass over perm_arr/perm_offseted --- include/dlaf/permutations/general/impl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/dlaf/permutations/general/impl.h b/include/dlaf/permutations/general/impl.h index fa6947cf88..45f2890d5c 100644 --- a/include/dlaf/permutations/general/impl.h +++ b/include/dlaf/permutations/general/impl.h @@ -462,9 +462,9 @@ void unpackLocalOnCPU(const matrix::Distribution& subm_dist, const matrix::Distr // at index 1 in mat_recv. const int a_r = std::accumulate(recv_counts.cbegin(), recv_counts.cbegin() + rank, 0); const SizeType offset = to_SizeType(a - a_r); - // TODO: back_insert directly into perm_offseted? - std::vector perm_offseted(perm_arr, perm_arr + subm_dist.size().get()); - std::transform(perm_offseted.begin(), perm_offseted.end(), perm_offseted.begin(), + std::vector perm_offseted; + perm_offseted.reserve(to_sizet(subm_dist.size().get())); + std::transform(perm_arr, perm_arr + subm_dist.size().get(), std::back_inserter(perm_offseted), [offset](const SizeType perm) { return perm + offset; }); constexpr auto OC = orthogonal(C);