]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/v2/echosse.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / context / example / v2 / echosse.cpp
1
2 // Copyright Oliver Kowalke 2009.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 #include <cstddef>
8 #include <cstdlib>
9 #include <cstring>
10 #include <iostream>
11 #include <emmintrin.h>
12
13 #include <boost/context/all.hpp>
14
15 void echoSSE( int i) {
16 __m128i xmm;
17 xmm = _mm_set_epi32( i, i + 1, i + 2, i + 3);
18 uint32_t v32[4];
19 memcpy( & v32, & xmm, 16);
20 std::cout << v32[0];
21 std::cout << v32[1];
22 std::cout << v32[2];
23 std::cout << v32[3];
24 }
25
26 boost::context::execution_context< int > echo( boost::context::execution_context< int > ctx, int i) {
27 for (;;) {
28 std::cout << i;
29 echoSSE( i);
30 std::cout << " ";
31 std::tie( ctx, i) = ctx( 0);
32 }
33 return ctx;
34 }
35
36 int main( int argc, char * argv[]) {
37 boost::context::execution_context< int > ctx( echo);
38 for ( int i = 0; i < 10; ++i) {
39 ctx = std::get< 0 >( ctx( i) );
40 }
41 std::cout << "\nDone" << std::endl;
42 return EXIT_SUCCESS;
43 }