|
From: Heisig, M. <mar...@fa...> - 2019-12-14 15:15:20
|
Hello everyone, I started working on a high-level SIMD interface for SBCL at SBCL20 (https://github.com/marcoheisig/sb-simd). So far, I got Lisp wrappers for AVX2 loads, stores, casts and arithmetic operations working. Before I continue, I'd like to discuss some things: 1. Since 50% of this library is tied to SB-VM or SB-C, I'd like to move the VOP definitions and deftransforms to sbcl/src/compiler, and the remaining code into a contrib. Is that appropriate? 2. I'd like to introduce more subtypes of SIMD-PACK and SIMD-PACK-256. Currently there is only support for double-floats, single-floats and unsigned-byte-64s. I'd like to add the remaining integer types (unsigned-byte-{8,16,32} and signed-byte-{8,16,32,64}. Would you be willing to merge such a pull request into SBCL? Or is there a particular reason SBCL only distinguishes single, double and int? 3. The current naming convention for primitive SIMD types is confusing (e.g., SIMD-PACK-DOUBLE and SIMD-PACK-256-UB64). And also the mapping from type specifiers to primitive types is not obvious (e.g., (SB-EXT:SIMD-PACK INTEGER) has the primitive type SIMD-PACK-INT, which actually contains 64bit unsigned integers). I'd like to introduce a more uniform naming convention. I have two proposals: LONG-NAMES Every primitive type is named 'SIMD-PACK-' followed by the number of bits, followed by the SIMD pack element type. Examples: SIMD-PACK-128-DOUBLE-FLOAT, SIMD-PACK-256-UNSIGNED-BYTE-32, SIMD-PACK-256-SIGNED-BYTE-8 CONCISE-NAMES SIMD pack element types are abbreviated as U{8,16,32,64}, S{8,16,32,64} and F{32,64}, and the name of each primitive SIMD pack type is then simply the element type, followed by a dot, followed by the number of elements. Examples: F64.4, U32.8, S8.32 I have no strong opinions on which naming scheme we should adopt, but I think there should be a consistent naming scheme. 4. I encountered a bug when loading AVX2 floating point zero immediates (vxorps takes three arguments): Bug: (compile nil '(lambda () (sb-ext:%simd-pack-256-doubles (sb-ext:%make-simd-pack-256-double 0d0 0d0 0d0 0d0)))) Fix: diff --git a/src/compiler/x86-64/simd-pack-256.lisp b/src/compiler/x86-64/simd-pack-256.lisp index 2c688cd11..fd0952cfe 100644 --- a/src/compiler/x86-64/simd-pack-256.lisp +++ b/src/compiler/x86-64/simd-pack-256.lisp @@ -48,7 +48,7 @@ (p2 (%simd-pack-256-2 x)) (p3 (%simd-pack-256-3 x))) (cond ((= p0 p1 p2 p3 0) - (inst vxorps y y)) + (inst vxorps y y y)) ((= p0 p1 p2 p3 (ldb (byte 64 0) -1)) (inst vpcmpeqd y y y)) (t Best regards, Marco Heisig |