]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/simd-1/simd-1.factor
core: Rename iota to <iota> so we can have TUPLE: iota ... ; instead of TUPLE: iota...
[factor.git] / extra / benchmark / simd-1 / simd-1.factor
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
7 IN: benchmark.simd-1
8
9 : <point> ( n -- float-4 )
10     >float [ sin ] [ cos 3 * ] [ sin sq 2 / ] tri
11     0.0 float-4-boa ; inline
12
13 : make-points ( len -- points )
14     <iota> [ <point> ] float-4-array{ } map-as ; inline
15
16 : normalize-points ( points -- )
17     [ normalize ] map! drop ; inline
18
19 : print-point ( point -- )
20     [ number>string ] { } map-as ", " join print ; inline
21
22 : simd-benchmark ( len -- )
23     >fixnum make-points [ normalize-points ] [ vsupremum ] bi print-point ;
24
25 : simd-1-benchmark ( -- )
26     10 [ 500000 simd-benchmark ] times ;
27
28 MAIN: simd-1-benchmark