From 7acd9d5688c675f61eec5ca512d5ec9bcfa949f0 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 10 Nov 2022 22:21:47 -0500 Subject: [PATCH] Indices/Replicate implementation comments --- src/builtins/slash.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/builtins/slash.c b/src/builtins/slash.c index fa0ddc8b..b19c0d21 100644 --- a/src/builtins/slash.c +++ b/src/builtins/slash.c @@ -1,3 +1,43 @@ +// Indices and Replicate (/) +// In the notes 𝕨 might indicate 𝕩 for Indices too + +// Boolean 𝕨 (Where/Compress) general case based on result type width +// COULD use AVX-512 +// Size 1: pext, or bit-at-a-time +// SHOULD emulate pext if unavailable +// COULD return boolean result from Where +// Size 8, 16: pdep/pext, or branchless +// SHOULD try vector lookup-shuffle if unavailable or old AMD +// Size 32, 64: 16-bit indices from where_block_u16 +// Other sizes: always used grouped code +// Adaptivity based on 𝕨 statistics +// None for 8-bit Where, too short +// COULD try per-block adaptivity for 16-bit Compress +// Sparse if +´𝕨 is small, branchless or branching if very small +// Chosen per-argument for 8, 16 and per-block for larger +// Careful when benchmarking, branch predictor has a long memory +// Grouped if +Β΄Β»βŠΈβ‰ π•¨ is small, always branching +// Chosen per-argument with a threshold that gives up early +// SHOULD implement grouped Where + +// Arbitrary 𝕨 is slower, squeezes if (+Β΄<β‰ )𝕨 to avoid this +// Dense cases (large +´𝕨) use obvious loop, expand 𝕨 to i32 +// Boolean Replicate overwrites to avoid trailing boundary +// Sparse Indices uses ⌈` with Singeli and +` otherwise, i32 output only +// COULD specialize on result type +// Sparse Replicate +// β‰ ` for booleans, +` for CPU types +// TRIED β‰ ` generally, slightly worse +// COULD consolidate refcount updates for nested 𝕩 + +// Replicate by constant +// Boolean uses pdep, β‰ `, or overwriting +// SHOULD make a shift/mask replacement for pdep +// Others use +`, or lots of Singeli +// Fixed shuffles, factorization, partial shuffles, self-overlapping + +// SHOULD do something for odd cell widths in Replicate + #include "../core.h" #include "../utils/mut.h" #include "../utils/calls.h"