#with simd, is it possible to have an array `ar` where i could index on with a vector `ar[vector]`?

1 messages · Page 1 of 1 (latest)

velvet gulch
#

each element of vector would be a index in ar
the ar contains f32's which i would want to sum with @reduce (i think)

halcyon briar
#

you’ve discovered gathering, use @shuffle for exactly this
although if you’re summing them up, why do you need to gather?

#

or uh, to revise my original answer, i’d vector comptime known?

velvet gulch
halcyon briar
#

then just do like
for (0..N) |i| out[i] = ar[vector[i]]

velvet gulch
halcyon briar
#
  1. not really? it’ll still generate a vpshuf
  2. what are you actually trying to achieve?
velvet gulch
halcyon briar
#
  1. x86 instruction that does gather
  2. you need to sum the values at the given indices? is it a constant amount of items per line?
velvet gulch
#
  1. ah so it would still do some performance optimizations?
  2. the items per line differ
velvet gulch