"Normalize a file containing packed quadrupes of floats:"
{ $code
"USING: kernel io.mmap math.vectors math.vectors.simd" "sequences specialized-arrays ;"
- "SIMD: float"
"SPECIALIZED-ARRAY: float-4"
""
"\"mydata.dat\" float-4 ["
[ 0 ] [ BIN: 0 bit-count ] unit-test
[ 1 ] [ BIN: 1 bit-count ] unit-test
-SIMD: uint
SPECIALIZED-ARRAY: uint
SPECIALIZED-ARRAY: uint-4
{ $code
"""USING: compiler.tree.debugger math.vectors
math.vectors.simd ;
-SIMD: double
SYMBOLS: x y ;
[
{ $code
"""USING: compiler.tree.debugger kernel.private
math.vectors math.vectors.simd ;
-SIMD: float
IN: simd-demo
: interpolate ( v a b -- w )
{ $code
"""USING: compiler.tree.debugger hints
math.vectors math.vectors.simd ;
-SIMD: float
IN: simd-demo
: interpolate ( v a b -- w )
"In the " { $snippet "interpolate" } " word, there is still a call to the " { $link <tuple-boa> } " primitive, because the return value at the end is being boxed on the heap. In the next example, no memory allocation occurs at all because the SIMD vectors are stored inside a struct class (see " { $link "classes.struct" } "); also note the use of inlining:"
{ $code
"""USING: compiler.tree.debugger math.vectors math.vectors.simd ;
-SIMD: float
IN: simd-demo
STRUCT: actor
USING: kernel locals math math.matrices.simd math.order math.vectors
math.vectors.simd prettyprint sequences typed ;
QUALIFIED-WITH: alien.c-types c
-SIMD: c:float
IN: benchmark.3d-matrix-vector
: v2min ( xy -- xx )
USING: kernel io math math.functions math.parser math.vectors
math.vectors.simd sequences specialized-arrays ;
QUALIFIED-WITH: alien.c-types c
-SIMD: c:float
SPECIALIZED-ARRAY: float-4
IN: benchmark.simd-1
! (c)Joe Groff bsd license
USING: io kernel math.vectors.simd terrain.generation threads ;
FROM: alien.c-types => float ;
-SIMD: float
IN: benchmark.terrain-generation
: terrain-generation-benchmark ( -- )
FROM: alien.c-types => float ;
SPECIALIZED-ARRAY: float
SPECIALIZED-VECTOR: uint
-SIMD: float
IN: gpu.demos.bunny
GLSL-SHADER-FILE: bunny-vertex-shader vertex-shader "bunny.v.glsl"
kernel math math.ranges math.vectors.simd opengl opengl.gl sequences
sequences.product specialized-arrays ;
FROM: alien.c-types => float ;
-SIMD: float
SPECIALIZED-ARRAY: float-4
IN: grid-meshes
literals math.constants math.functions specialized-arrays tools.test ;
QUALIFIED-WITH: alien.c-types c
FROM: math.matrices => m~ ;
-SIMD: c:float
SPECIALIZED-ARRAY: float-4
IN: math.matrices.simd.tests
math.vectors.simd sequences sequences.private specialized-arrays
typed ;
QUALIFIED-WITH: alien.c-types c
-SIMD: c:float
SPECIALIZED-ARRAY: float-4
IN: math.matrices.simd
destructors grid-meshes math.vectors.simd ;
QUALIFIED-WITH: alien.c-types c
SPECIALIZED-ARRAY: c:float
-SIMD: c:float
IN: terrain
CONSTANT: FOV $[ 2.0 sqrt 1 + ]