• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/continuation.hpp>
14 
15 namespace ctx = boost::context;
16 
echoSSE(int i)17 void echoSSE( int i) {
18     __m128i xmm;
19     xmm = _mm_set_epi32( i, i + 1, i + 2, i + 3);
20     uint32_t v32[4];
21     memcpy( & v32, & xmm, 16);
22     std::cout << v32[0];
23     std::cout << v32[1];
24     std::cout << v32[2];
25     std::cout << v32[3];
26 }
27 
28 
main(int argc,char * argv[])29 int main( int argc, char * argv[]) {
30     int i = 0;
31     ctx::continuation c = ctx::callcc(
32         [&i](ctx::continuation && c) {
33             for (;;) {
34                 std::cout << i;
35                 echoSSE( i);
36                 std::cout << " ";
37                 c = c.resume();
38             }
39             return std::move( c);
40         });
41     for (; i < 10; ++i) {
42         c = c.resume();
43     }
44     std::cout << "\nmain: done" << std::endl;
45     return EXIT_SUCCESS;
46 }
47