std::experi...::copy_from(3)
π std::experimental::simd::copy_from π
okay bestie, this is the C++ Standard Libary manual page for std::experimental::simd::copy_from β and it's lowkey giving "load stuff into a simd and make it make sense" energy. π
β¨
π NAME π
std::experimental::simd::copy_from β std::experimental::simd::copy_from
πΈ Synopsis πΈ
template< class U, class Flags > (parallelism TS v2)
void copy_from( const U* mem, Flags flags );
The load function replaces all elements of a simd such that the i^th element is assigned with static_cast<T>(mem[i]) for all i in the range of [0, size()).
π Parameters π
memβ a pointer into an array where[mem, mem + size())is a valid range.flagsβ if it's of typevector_aligned_tag, the load constructor may assumemempoints to storage aligned bymemory_alignment_v<simd, U>.
β¨ Type requirements β¨
Umust be a vectorizable type.is_simd_flag_type_v<Flags>must be true.
π¦ Example π¦
// Run this code
#include <cstddef>
#include <experimental/simd>
#include <iostream>
#include <numeric>
namespace stdx = std::experimental;
void print(auto const& a)
{
for (std::size_t i{}; i != std::size(a); ++i)
std::cout << a[i] << ' ';
std::cout << '\n';
}
int main()
{
alignas(stdx::memory_alignment_v<stdx::native_simd<int>>)
std::array<int, stdx::native_simd<int>::size() * 2> mem = {};
std::iota(mem.begin(), mem.end(), 0);
print(mem);
stdx::native_simd<int> a; // uninitialized
a.copy_from(&mem[0], stdx::vector_aligned);
print(a);
a.copy_from(&mem[1], stdx::element_aligned); // vector_aligned
would likely crash
print(a);
}
π« Possible output π«
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
π See also π
memory_alignmentβ obtains an appropriate alignment forvector_aligned(parallelism TS v2) (class template)copy_toβ storessimdelements to contiguous memory (parallelism TS v2) (public member function)constructorβ constructs asimdobject (parallelism TS v2) (public member function)
and that's the whole vibe, bestie π«Ά β source/version: http://cppreference.com, date: 2024.06.10, page tag: std::experi...::copy_from(3). periodt. π
β¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms