]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/math/vectors/simd/intrinsics/intrinsics.factor
factor: trim using lists
[factor.git] / basis / math / vectors / simd / intrinsics / intrinsics.factor
index 3ceba49ec2b0f41a3b0df92e2647b9dedeb4b926..21e691f3e2dd124bbeb003cabe21e2b22d5b14b9 100644 (file)
@@ -1,6 +1,7 @@
-! (c)2009 Slava Pestov, Joe Groff bsd license
-USING: accessors alien alien.data combinators cpu.architecture fry
-grouping kernel libc locals math math.libm math.order math.ranges
+! Copyright (C) 2009 Slava Pestov, Joe Groff.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors alien alien.data combinators cpu.architecture
+grouping kernel libc math math.libm math.order ranges
 sequences sequences.cords sequences.generalizations sequences.private
 sequences.unrolled sequences.unrolled.private specialized-arrays
 vocabs ;
@@ -11,6 +12,7 @@ SPECIALIZED-ARRAYS:
     c:float c:double ;
 IN: math.vectors.simd.intrinsics
 
+! Word props are added later
 : assert-positive ( x -- y ) ;
 
 <PRIVATE
@@ -136,7 +138,7 @@ GENERIC: native/ ( x y -- x/y )
 M: integer native/ /i ; inline
 M: float native/ /f ; inline
 
-: ((vgetmask)) ( a rep -- b )
+: (vgetmask) ( a rep -- b )
     0 [ [ 1 shift ] [ zero? 0 1 ? ] bi* bitor ] bitwise-components-reduce* ; inline
 
 PRIVATE>
@@ -183,9 +185,9 @@ PRIVATE>
 : (simd-vmin)              ( a b rep -- c ) [ min ] components-2map ;
 : (simd-vmax)              ( a b rep -- c ) [ max ] components-2map ;
 ! XXX
-: (simd-v.)                ( a b rep -- n )
+: (simd-vdot)              ( a b rep -- n )
     [ 2byte>rep-array [ [ first ] bi@ * ] 2keep ] keep
-    1 swap rep-length [a,b) [ '[ _ swap nth-unsafe ] bi@ * + ] 2with each ;
+    1 swap rep-length [a..b) [ '[ _ swap nth-unsafe ] bi@ * + ] 2with each ;
 : (simd-vsqrt)             ( a   rep -- c ) [ fsqrt ] components-map ;
 : (simd-vsad)              ( a b rep -- c ) 2byte>rep-array [ - abs ] [ + ] 2map-reduce ;
 : (simd-sum)               ( a   rep -- n ) [ + ] components-reduce ;
@@ -245,7 +247,7 @@ PRIVATE>
 : (simd-vnone?)            ( a   rep -- ? ) [ bitor  ] bitwise-components-reduce zero?     ;
 : (simd-vgetmask)          ( a   rep -- n )
     { float-4-rep double-2-rep } member?
-    [ uint-4-rep ((vgetmask)) ] [ uchar-16-rep ((vgetmask)) ] if ;
+    [ uint-4-rep (vgetmask) ] [ uchar-16-rep (vgetmask) ] if ;
 : (simd-v>float)           ( a   rep -- c )
     [ [ byte>rep-array ] [ rep-length ] bi [ >float ] ]
     [ >float-vector-rep <rep-array> ] bi unrolled-map-as-unsafe underlying>> ;
@@ -266,16 +268,16 @@ PRIVATE>
 : (simd-vunpack-tail)      ( a   rep -- c )
     [ byte>rep-array ] [ widen-vector-rep [ rep-length ] [ '[ _ >rep-array ] ] bi ] bi
     [ tail-slice ] dip call( a' -- c' ) underlying>> ;
-: (simd-with)              (   n rep -- v )
+: (simd-with)              ( n rep -- v )
     [ rep-length swap '[ _ ] ] [ <rep-array> ] bi replicate-as
     underlying>> ;
 : (simd-gather-2)          ( m n rep -- v ) <rep-array> [ 2 set-firstn-unsafe ] keep underlying>> ;
 : (simd-gather-4)          ( m n o p rep -- v ) <rep-array> [ 4 set-firstn-unsafe ] keep underlying>> ;
 : (simd-select)            ( a n rep -- x ) swapd byte>rep-array nth-unsafe ;
 
-: alien-vector     (       c-ptr n rep -- value )
+: alien-vector     ( c-ptr n rep -- value )
     [ swap <displaced-alien> ] dip rep-size memory>byte-array ;
-: set-alien-vector ( value c-ptr n rep --       )
+: set-alien-vector ( value c-ptr n rep -- )
     [ swap <displaced-alien> swap ] dip rep-size memcpy ;
 
 "compiler.cfg.intrinsics.simd" require