]> gitweb.factorcode.org Git - factor.git/commitdiff
math.vectors.simd: add intrinsic for int-4-boa, uint-4-boa, fix tests for C type...
authorSlava Pestov <slava@shill.local>
Mon, 28 Sep 2009 11:34:22 +0000 (06:34 -0500)
committerSlava Pestov <slava@shill.local>
Mon, 28 Sep 2009 11:34:22 +0000 (06:34 -0500)
basis/cpu/x86/x86.factor
basis/math/vectors/simd/functor/functor.factor
basis/math/vectors/simd/simd-tests.factor
basis/math/vectors/simd/simd.factor
basis/math/vectors/vectors.factor

index fd8dc70f89c78061fd0ec136490e187116567944..63356aa5bbbdffe4366e214d562f141990182016 100644 (file)
@@ -592,9 +592,9 @@ M: x86 %broadcast-vector-reps
     } available-reps ;
 
 M:: x86 %gather-vector-4 ( dst src1 src2 src3 src4 rep -- )
-    rep {
+    {
         {
-            float-4-rep
+            [ rep float-4-rep eq? ]
             [
                 dst src1 float-4-rep %copy
                 dst src2 UNPCKLPS
@@ -602,13 +602,22 @@ M:: x86 %gather-vector-4 ( dst src1 src2 src3 src4 rep -- )
                 dst src3 MOVLHPS
             ]
         }
-    } case ;
+        {
+            [ rep { int-4-rep uint-4-rep } memq? ]
+            [
+                dst src1 int-4-rep %copy
+                dst src2 PUNPCKLDQ
+                src3 src4 PUNPCKLDQ
+                dst src3 PUNPCKLQDQ
+            ]
+        }
+    } cond ;
 
 M: x86 %gather-vector-4-reps
     {
         ! Can't do this with sse1 since it will want to unbox
         ! double-precision floats and convert to single precision
-        { sse2? { float-4-rep } }
+        { sse2? { float-4-rep int-4-rep uint-4-rep } }
     } available-reps ;
 
 M:: x86 %gather-vector-2 ( dst src1 src2 rep -- )
index 6ed74caa1f744c8429e73634cc66e8b9d3f4161c..bc42bddf02e68302374027aee1168a715889bade 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types assocs byte-arrays classes
-effects fry functors generalizations kernel literals locals
-math math.functions math.vectors math.vectors.simd.intrinsics
+USING: accessors alien.c-types assocs byte-arrays classes effects fry
+functors generalizations kernel literals locals math math.functions
+math.vectors math.vectors.private math.vectors.simd.intrinsics
 math.vectors.specialization parser prettyprint.custom sequences
 sequences.private strings words definitions macros cpu.architecture
 namespaces arrays quotations ;
@@ -141,6 +141,8 @@ M: A set-nth-unsafe underlying>> SET-NTH call ; inline
 
 M: A like drop dup \ A instance? [ >A ] unless ; inline
 
+M: A new-underlying drop \ A boa ; inline
+
 M: A new-sequence
     drop dup N =
     [ drop 16 <byte-array> \ A boa ]
index 001f1be8148c95b358542e951442f6b7befa0f84..c1428b9c33ec283d7994ec18d09af6bc2d4f9c9b 100644 (file)
@@ -6,18 +6,18 @@ tools.test vocabs assocs compiler.cfg.debugger words
 locals math.vectors.specialization combinators cpu.architecture
 math.vectors.simd.intrinsics namespaces byte-arrays alien
 specialized-arrays classes.struct eval ;
-FROM: alien.c-types => c-type-boxed-class ;
-SPECIALIZED-ARRAY: float
-SIMD: char
-SIMD: uchar
-SIMD: short
-SIMD: ushort
-SIMD: int
-SIMD: uint
-SIMD: longlong
-SIMD: ulonglong
-SIMD: float
-SIMD: double
+QUALIFIED-WITH: alien.c-types c
+SPECIALIZED-ARRAY: c:float
+SIMD: c:char
+SIMD: c:uchar
+SIMD: c:short
+SIMD: c:ushort
+SIMD: c:int
+SIMD: c:uint
+SIMD: c:longlong
+SIMD: c:ulonglong
+SIMD: c:float
+SIMD: c:double
 IN: math.vectors.simd.tests
 
 ! Make sure the functor doesn't generate bogus vocabularies
index 71936b2657da14242ecb532a8bd9e7a1642cb254..e7d4f0e94bd84ebf8067b35a5dc711ff3b95e0dd 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types combinators fry kernel lexer math math.parser
+USING: alien.c-types combinators fry kernel parser math math.parser
 math.vectors.simd.functor sequences splitting vocabs.generated
-vocabs.loader vocabs.parser words ;
+vocabs.loader vocabs.parser words accessors ;
 QUALIFIED-WITH: alien.c-types c
 IN: math.vectors.simd
 
@@ -11,22 +11,11 @@ ERROR: bad-base-type type ;
 <PRIVATE
 
 : simd-vocab ( base-type -- vocab )
-    "math.vectors.simd.instances." prepend ;
+    name>> "math.vectors.simd.instances." prepend ;
 
-: parse-base-type ( string -- c-type )
-    {
-        { "char" [ c:char ] }
-        { "uchar" [ c:uchar ] }
-        { "short" [ c:short ] }
-        { "ushort" [ c:ushort ] }
-        { "int" [ c:int ] }
-        { "uint" [ c:uint ] }
-        { "longlong" [ c:longlong ] }
-        { "ulonglong" [ c:ulonglong ] }
-        { "float" [ c:float ] }
-        { "double" [ c:double ] }
-        [ bad-base-type ]
-    } case ;
+: parse-base-type ( c-type -- c-type )
+    dup { c:char c:uchar c:short c:ushort c:int c:uint c:longlong c:ulonglong c:float c:double } memq?
+    [ bad-base-type ] unless ;
 
 PRIVATE>
 
@@ -38,4 +27,4 @@ PRIVATE>
     ] generate-vocab ;
 
 SYNTAX: SIMD:
-    scan define-simd-vocab use-vocab ;
+    scan-word define-simd-vocab use-vocab ;
index 1dcff8e8a9c11fe606c58cb2c8ea4541a8e3157a..de9ba51aecfb06b1fcf43e74bba551c40ca239e4 100644 (file)
@@ -64,6 +64,8 @@ PRIVATE>
 
 : bitandn ( x y -- z ) [ bitnot ] dip bitand ; inline
 
+GENERIC: new-underlying ( underlying seq -- seq' )
+
 PRIVATE>
 
 : vbitand ( u v -- w ) over '[ _ [ bitand ] fp-bitwise-op ] 2map ;
@@ -90,12 +92,10 @@ PRIVATE>
 : vrshift ( u n -- w ) neg '[ _ shift ] map ;
 
 : hlshift ( u n -- w )
-    [ clone ] dip
-    '[ _ <byte-array> append 16 tail* ] change-underlying ;
+    [ [ underlying>> ] dip <byte-array> prepend 16 head ] [ drop ] 2bi new-underlying ;
 
 : hrshift ( u n -- w )
-    [ clone ] dip
-    '[ _ <byte-array> prepend 16 head* ] change-underlying ;
+    [ [ underlying>> ] dip <byte-array> append 16 tail* ] [ drop ] 2bi new-underlying ;
 
 : vfloor    ( u -- v ) [ floor ] map ;
 : vceiling  ( u -- v ) [ ceiling ] map ;