} 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
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 -- )
! 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 ;
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 ]
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
! 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
<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>
] generate-vocab ;
SYNTAX: SIMD:
- scan define-simd-vocab use-vocab ;
+ scan-word define-simd-vocab use-vocab ;
: 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 ;
: 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 ;