]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/benchmark/nbody-simd/nbody-simd.factor
factor: trim using lists
[factor.git] / extra / benchmark / nbody-simd / nbody-simd.factor
index 37fb1d0ce3a5b2fefb9c75d020d17b6f117dd916..c50481de5d08ecbe773cc45df3ca8d0f90bb62c5 100644 (file)
@@ -1,9 +1,8 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types fry kernel locals math
-math.constants math.functions math.vectors math.vectors.simd
-math.vectors.simd.cords prettyprint combinators.smart sequences
-hints classes.struct specialized-arrays ;
+USING: accessors alien.c-types kernel math math.constants
+math.functions math.vectors math.vectors.simd.cords math.parser
+combinators.smart sequences classes.struct specialized-arrays io ;
 IN: benchmark.nbody-simd
 
 : solar-mass ( -- x ) 4 pi sq * ; inline
@@ -17,7 +16,7 @@ STRUCT: body
 SPECIALIZED-ARRAY: body
 
 : <body> ( location velocity mass -- body )
-    [ days-per-year v*n ] [ solar-mass * ] bi* body <struct-boa> ; inline
+    [ days-per-year v*n ] [ solar-mass * ] bi* body boa ; inline
 
 : <jupiter> ( -- body )
     double-4{ 4.84143144246472090e00 -1.16032004402742839e00 -1.03622044471123109e-01 0.0 }
@@ -45,7 +44,7 @@ SPECIALIZED-ARRAY: body
 
 : <sun> ( -- body )
     double-4{ 0 0 0 0 } double-4{ 0 0 0 0 } 1 <body> ;
-    
+
 : offset-momentum ( body offset -- body )
     vneg solar-mass v/n >>velocity ; inline
 
@@ -58,7 +57,7 @@ SPECIALIZED-ARRAY: body
     body-array{ } output>sequence
     dup init-bodies ; inline
 
-:: each-pair ( bodies pair-quot: ( other-body body -- ) each-quot: ( body -- ) -- )
+:: each-pair ( ... bodies pair-quot: ( ... other-body body -- ... ) each-quot: ( ... body -- ... ) -- )
     bodies [| body i |
         body each-quot call
         bodies i 1 + tail-slice [
@@ -94,8 +93,10 @@ SPECIALIZED-ARRAY: body
 : nbody ( n -- )
     >fixnum
     <nbody-system>
-    [ energy . ] [ '[ _ 0.01 advance ] times ] [ energy . ] tri ;
+    [ energy number>string print ]
+    [ '[ _ 0.01 advance ] times ]
+    [ energy number>string print ] tri ;
 
-: nbody-main ( -- ) 1000000 nbody ;
+: nbody-simd-benchmark ( -- ) 1000000 nbody ;
 
-MAIN: nbody-main
+MAIN: nbody-simd-benchmark