Paste: SIMD benchmark

Author: slava
Mode: factor
Date: Fri, 4 Sep 2009 06:54:26
Plain Text |
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel io math math.functions math.parser
math.vectors math.vectors.simd sequences ;
IN: benchmark.simd-1

: <point> ( n -- float-4 )
    >float [ sin ] [ cos 3 * ] [ sin sq 2 / ] tri
    0.0 float-4-boa ; inline

: make-points ( len -- points )
    iota [ <point> ] float-4-array{ } map-as ; inline

: normalize-points ( points -- )
    [ normalize ] change-each ; inline

: max-points ( points -- )
    [ ] [ vmax ] map-reduce ; inline

: print-point ( point -- )
    [ number>string ] { } map-as ", " join print ; inline

: simd-benchmark ( len -- )
    >fixnum make-points [ normalize-points ] [ max-points ] bi print-point ;

: main ( -- )
    5000000 simd-benchmark ;

MAIN: main

New Annotation

Summary:
Author:
Mode:
Body: