Lets get you started.
Youll need to put the macstl library where your favorite supported ompiler will find it usually at /usr/include/
, or with the appropriate -I
compiler option, or just use the macstl.framework
as built on Mac OS X.
Then code the following in your favorite editor or IDE:
#include <iostream>
#include <macstl/vec.h>
int main ()
{
using namespace std;
using namespace macstl;
// put "Hello, World!!!" into a SIMD register
vec <unsigned char, 16> message =
vec <unsigned char, 16>::set <'H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!', '!', '!', '!'> ();
// output the SIMD register
cout << message << '\n';
return 0;
}
Compile the above with the appropriate SIMD compiler options on. For Mac OS X, its usually -faltivec
from the command line or check Enable Altivec Extensions from Xcode. For Windows, you need to predefine the right macros __MMX__
, __SSE__
, __SSE2__
and/or __SSE3__
.
Run the snippet and you should see:
H e l l o , W o r l d ! ! ! !
Congratulations, youre now a fully fledged SIMD programmer.