zini icon indicating copy to clipboard operation
zini copied to clipboard

Efficient select in word

Open daniel-j-h opened this issue 10 months ago • 0 comments

Hey there, I found your repo. and studied how you implement the select operation to learn from your approach.

I stumbled upon the following fallback select-in-word implementation

https://github.com/judofyr/zini/blob/4b152afbf26c8baae16f0b9bc9da92adf38fadd0/src/darray.zig#L140-L151

and just wanted to leave this here:

https://arxiv.org/abs/1706.00990

where they provide an efficient select-in-word using the pdep instruction, as in

select(x, r) = TZCNT(PDEP(2^r,x))

There's an upstream zig ticket so I thought I'd let you know about it:

https://github.com/ziglang/zig/issues/14995

Best, Daniel

daniel-j-h avatar Mar 12 '25 17:03 daniel-j-h