Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing Scalbn/ScaleF ops #2266

Closed
johnplatts opened this issue Jun 28, 2024 · 3 comments
Closed

Implementing Scalbn/ScaleF ops #2266

johnplatts opened this issue Jun 28, 2024 · 3 comments

Comments

@johnplatts
Copy link
Contributor

johnplatts commented Jun 28, 2024

I have been working on implementations of the Scalbn/ScaleF ops.

The Scalbn(V v, VFromD<RebindToUnsigned<DFromV<V>>> exp) op is equivalent to std::scalbn(v[i], exp[i]).

The ScaleF(V v, V exp) op is equivalent to Scalbn(v, ConvertTo(RebindToUnsigned<DFromV<V>>(), Floor(exp))) or AVX3 _mm*_scalef_ps/_mm*_scalef_pd.

I have added a FloorInt op in pull request #2265 that allows ScaleF to be more efficiently implemented on SSE2/SSSE3/AArch64 NEON.

Should the Scalbn/ScaleF ops be renamed to something else?

@jan-wassenberg
Copy link
Member

Nice, it seems useful to be able to generate the scalef instructions.
On the naming: I think scalbn is defined in terms of FLT_RADIX, but we only care about FLT_RADIX=2, right?
If so, this is equivalent to ldexp, right? I don't love either of those names. Seems like MulByPow2 would be more clear?

@johnplatts
Copy link
Contributor Author

Nice, it seems useful to be able to generate the scalef instructions. On the naming: I think scalbn is defined in terms of FLT_RADIX, but we only care about FLT_RADIX=2, right? If so, this is equivalent to ldexp, right? I don't love either of those names. Seems like MulByPow2 would be more clear?

scalbn is equivalent to ldexp for F16/F32/F64 floating point types.

I agree that MulByPow2(V v, VI exp) would be more clear for the scalbn/ldexp wrapper and MulByFloorPow2(V v, V exp) would make more sense for the wrapper around AVX3 _mm_scalef_ps/pd/ph.

@jan-wassenberg
Copy link
Member

Implemented, thanks @johnplatts :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants