ModularM
Modular16mo ago
8 replies
asosoman

Fastest way to count trailing zeros from a SIMD[Bool,32]?

The summary says it all.
I have a SIMD with 32 bools, and would like to find the first appearance of a True value.

Right now I'm doing the following:

TRUE_CASE = SIMD[DType.uint8,32](0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) FALSE_CASE = SIMD[DType.uint8,32](32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32) SIMD[Bool,32].select(TRUE_CASE, FALSE_CASE).reduce_min())
I would like to cast the SIMD[Bool,32] into an Int32 and then count trailing zeroes. But have been unable to do the conversion.
Was this page helpful?