google / highway

Performance-portable, length-agnostic SIMD with runtime dispatch
Apache License 2.0
3.95k stars 305 forks source link

Question about API #2253

Closed boxerab closed 1 week ago

boxerab commented 1 week ago

It's nice that operator+ is overloaded, so I can write

(current + res) * Set(d, finalScale)

where current and res are vectors, and finalScale is a scalar. Is it possible to automagically convert finalScale to a vector, so that

(current + res) * finalScale

is compilable ?

jan-wassenberg commented 1 week ago

hm, we prefer to avoid invisible conversions, that could have a surprisingly high cost if done often.

I think this would also fail with SVE/RVV: there we'd have svfloat_t * float, which would require a user-defined overload of svfloat_t, but compilers decided to disallow that and only provide builtin operator*(svfloat_t, svfloat_t).

boxerab commented 1 week ago

OK, thanks for the explanation, would not want to sacrifice performance for readability