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 <cstdlib>
|
---|
8 | #include <iostream>
|
---|
9 | #include <emmintrin.h>
|
---|
10 |
|
---|
11 | #include <boost/bind.hpp>
|
---|
12 | #include <boost/coroutine/all.hpp>
|
---|
13 |
|
---|
14 | typedef boost::coroutines::coroutine< void() > coro_t;
|
---|
15 |
|
---|
16 | void echoSSE( int i)
|
---|
17 | {
|
---|
18 | __m128i xmm;
|
---|
19 | xmm = _mm_set_epi32(i, i+1, i+2, i+3);
|
---|
20 | uint32_t v32[4];
|
---|
21 |
|
---|
22 | memcpy(&v32, &xmm, 16);
|
---|
23 |
|
---|
24 | std::cout << v32[0];
|
---|
25 | std::cout << v32[1];
|
---|
26 | std::cout << v32[2];
|
---|
27 | std::cout << v32[3];
|
---|
28 | }
|
---|
29 |
|
---|
30 | void echo( coro_t & ca, int i)
|
---|
31 | {
|
---|
32 | std::cout << i;
|
---|
33 | echoSSE(i);
|
---|
34 | ca();
|
---|
35 | }
|
---|
36 |
|
---|
37 | void runit( coro_t & ca)
|
---|
38 | {
|
---|
39 | std::cout << "started! ";
|
---|
40 | for ( int i = 0; i < 10; ++i)
|
---|
41 | {
|
---|
42 | coro_t c( boost::bind( echo, _1, i) );
|
---|
43 | while ( c)
|
---|
44 | c();
|
---|
45 | ca();
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | int main( int argc, char * argv[])
|
---|
50 | {
|
---|
51 | {
|
---|
52 | coro_t c( runit);
|
---|
53 | while ( c) {
|
---|
54 | std::cout << "-";
|
---|
55 | c();
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | std::cout << "\nDone" << std::endl;
|
---|
60 |
|
---|
61 | return EXIT_SUCCESS;
|
---|
62 | }
|
---|