1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel io math math.functions math.parser math.vectors
4 math.vectors.simd sequences specialized-arrays ;
5 QUALIFIED-WITH: alien.c-types c
6 SPECIALIZED-ARRAY: float-4
9 : <point> ( n -- float-4 )
10 >float [ sin ] [ cos 3 * ] [ sin sq 2 / ] tri
11 0.0 float-4-boa ; inline
13 : make-points ( len -- points )
14 iota [ <point> ] float-4-array{ } map-as ; inline
16 : normalize-points ( points -- )
17 [ normalize ] map! drop ; inline
19 : print-point ( point -- )
20 [ number>string ] { } map-as ", " join print ; inline
22 : simd-benchmark ( len -- )
23 >fixnum make-points [ normalize-points ] [ vsupremum ] bi print-point ;
25 : simd-1-benchmark ( -- )
26 10 [ 500000 simd-benchmark ] times ;
28 MAIN: simd-1-benchmark