luv

Workshop wiki

columnar-simd-tests.lisp

arithmetic/records/columnar-simd-tests.lisp

system luv/test · 3 definitions · on GitHub

in-package#:luv.tests
defunscalar-test-position-energy
buffer

Reference sum of squared positions over a generated columnar buffer.

records:with-columnar-buffer-storage
lengthrow
xsx
ysy
buffertest-position-columns
declare
ignorerow
optimize
speed3
safety1
loopwithsumof-typesingle-float=0f0forindexfixnumbelowlengthforxsingle-float=
arefxsindex
forysingle-float=
arefysindex
do
incfsum
+
*xx
*yy
finally
#+x86-64
defunsse-test-position-energy
buffer
records:with-columnar-buffer-storage
lengthrow
xsx
ysy
buffertest-position-columns
declare
ignorerow
optimize
speed3
safety0
debug0
let
wide-end
thesb-simd:index
sum
sb-simd-sse:f32.40f0
loopforindexof-typesb-simd:indexfrom0belowwide-endby4forx=
sb-simd-sse:f32.4-arefxsindex
fory=
sb-simd-sse:f32.4-arefysindex
do
setfsum
sb-simd-sse:f32.4+sum
sb-simd-sse:f32.4+
sb-simd-sse:f32.4*xx
sb-simd-sse:f32.4*yy
loopwithresultof-typesingle-float=
sb-simd-sse:f32.4-horizontal+sum
fortailfixnumfromwide-endbelowlengthdo
setfresult
sb-simd:f32+result
sb-simd:f32+
sb-simd:f32*
arefxstail
arefxstail
sb-simd:f32*
arefystail
arefystail
finally
returnresult
#+x86-64
defunavx-test-position-energy
buffer
records:with-columnar-buffer-storage
lengthrow
xsx
ysy
buffertest-position-columns
declare
ignorerow
optimize
speed3
safety0
debug0
let
wide-end
thesb-simd:index
sum
sb-simd-avx:f32.80f0
loopforindexof-typesb-simd:indexfrom0belowwide-endby8forx=
sb-simd-avx:f32.8-arefxsindex
fory=
sb-simd-avx:f32.8-arefysindex
do
setfsum
sb-simd-avx:f32.8+sum
sb-simd-avx:f32.8+
sb-simd-avx:f32.8*xx
sb-simd-avx:f32.8*yy
loopwithresultof-typesingle-float=
sb-simd-avx:f32.8-horizontal+sum
fortailfixnumfromwide-endbelowlengthdo
setfresult
sb-simd:f32+result
sb-simd:f32+
sb-simd:f32*
arefxstail
arefxstail
sb-simd:f32*
arefystail
arefystail
finally
returnresult
#+arm64 (defun neon-test-position-energy (buffer) (records:with-columnar-buffer-storage ((length row (xs x) (ys y)) buffer test-position-columns) (declare (ignore row) (optimize (speed 3) (safety 0) (debug 0))) (let ((wide-end (the sb-simd:index (* 4 (floor length 4)))) (sum (sb-simd-neon:f32.4 0f0))) (loop for index of-type sb-simd:index from 0 below wide-end by 4 for x = (sb-simd-neon:f32.4-aref xs index) for y = (sb-simd-neon:f32.4-aref ys index) do (setf sum (sb-simd-neon:f32.4+ sum (sb-simd-neon:f32.4+ (sb-simd-neon:f32.4* x x) (sb-simd-neon:f32.4* y y))))) (loop with result of-type single-float = (sb-simd-neon:f32.4-horizontal+ sum) for tail fixnum from wide-end below length do (setf result (sb-simd:f32+ result (sb-simd:f32+ (sb-simd:f32* (aref xs tail) (aref xs tail)) (sb-simd:f32* (aref ys tail) (aref ys tail))))) finally (return result)))))
defunsimd-test-position-energy
buffer

Run the native-width squared-position oracle with a scalar tail. #VKLLPR

#+x86-64
sb-simd:instruction-set-case
:avx
avx-test-position-energybuffer
:sse
sse-test-position-energybuffer
#+arm64 (sb-simd:instruction-set-case (:neon (neon-test-position-energy buffer)))#-
orx86-64arm64
(scalar-test-position-energy buffer)
deftestgenerated-columnar-lanes-feed-native-simd-kernels
let
buffer
make-test-position-columns:capacity19
dotimes
index19
test-position-columns-pushbuffer
float
1+index
0f0
float
modindex7
0f0