std::experi...md::copy_to(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

std::experimental::simd::copy_to β€” okay bestie, the name is literally std::experimental::simd::copy_to, and it’s also std::experimental::simd::copy_to again. We love a self-referential icon. This is the std::experi...md::copy_to(3) page from the C++ Standard Libary manual. ✨


✨ Synopsis ✨

template< class U, class Flags >      (parallelism TS v2)
void copy_to( U* mem, Flags flags );

The store function copies all elements of a simd such that the i-th element is converted to U and subsequently written to mem[i] for all i in the range of [0, size()). That’s the whole vibe. πŸ’…


🌸 Parameters 🌸

  • mem β€” a pointer into an array where [mem, mem + size()) is a valid range. Keep that range valid, periodt. 🫢
  • flags β€” if of type vector_aligned_tag, the load constructor may assume mem to point to storage aligned by memory_alignment_v<simd, U>.
yes bestie, it really says β€œload constructor” on a store function β€” we don’t ask questions, we just keep the text exactly as it is πŸ’…

πŸ¦‹ Type requirements πŸ¦‹

  • U must be a vectorizable type.
  • is_simd_flag_type_v<Flags> must be true.

No cap, those have to hold. βœ…


πŸŽ€ Example πŸŽ€

// Run this code

#include <experimental/simd>
#include <iostream>
namespace stdx = std::experimental;

int main()
{
    alignas(stdx::memory_alignment_v<stdx::native_simd<int>>)
        std::array<int, stdx::native_simd<int>::size()> mem = {};

    stdx::native_simd<int> a = 7;
    a.copy_to(&mem[0], stdx::vector_aligned);

    for (int e : mem)
        std::cout << e << ' ';
    std::cout << '\n';
}

πŸ“ Possible output: πŸ“

7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7

πŸ‘‘ See also πŸ‘‘

  • element_aligned_tag β€” flag indicating alignment of the load/store address to element; element_aligned β€” alignment; (parallelism TS v2) (class)
  • vector_aligned_tag β€” flag indicating alignment of the load/store address to vector; vector_aligned β€” alignment; (parallelism TS v2) (class)
  • overaligned_tag β€” flag indicating alignment of the load/store address to the; overaligned β€” specified alignment; (parallelism TS v2) (class template)
  • memory_alignment β€” obtains an appropriate alignment for vector_aligned; (parallelism TS v2) (class template)
  • copy_from β€” loads simd elements from contiguous memory; (parallelism TS v2) (public member function)

okay bestie, that’s the whole page πŸ’– sourced from http://cppreference.com, version/date 2024.06.10. go off and copy those simd elements with main character energy βœ¨πŸ’…

πŸ“¦ where this page comes from