Namespaces
Variants
Actions

std::experimental::simd<T,Abi>::copy_from

From cppreference.com
< cpp‎ | experimental‎ | simd‎ | simd
 
 
Experimental
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
 
 
 
 
template< class U, class Flags >
void copy_from( const U* mem, Flags flags );
(parallelism TS v2)

The load function replaces all elements of a simd such that the ith element is assigned with static_cast<T>(mem[i]) for all i in the range of [0size() ).

[edit] Parameters

mem - a pointer into an array where [memmem + size()) is a valid range
flags - if of type vector_aligned_tag, the load constructor may assume mem to point to storage aligned by memory_alignment_v<simd, U>
Type requirements
-U must be a vectorizable type.
-is_simd_flag_type_v<Flags> must be true.

[edit] 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

[edit] See also

(parallelism TS v2)
obtains an appropriate alignment for vector_aligned
(class template) [edit]
(parallelism TS v2)
stores simd elements to contiguous memory
(public member function) [edit]
(parallelism TS v2)
constructs a simd object
(public member function) [edit]
Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/simd/simd/copy_from&oldid=159776"

AltStyle によって変換されたページ (->オリジナル) /