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

float conversion emulation routines #2985

Open
sjoerdmeijer opened this issue Aug 14, 2024 · 1 comment
Open

float conversion emulation routines #2985

sjoerdmeijer opened this issue Aug 14, 2024 · 1 comment

Comments

@sjoerdmeijer
Copy link

I see several floating-point conversion routines, for example this float32 to float16 helper function:

static inline float16 cpu_float2half_rn(float f) {

But most modern AArch64 CPUs (Armv8.2a and up) and I believe x86 too have native support for FP16, and have different instructions for up and down converts. I believe that whole function can be replaced with just one FCVT instruction. The different rounding modes should be supported too.

@excelle08
Copy link
Contributor

I think the cpu_float2half_rn function is a reference implementation that intentionally implement the algorithm manually. Currently we rely on the compiler to do the optimized CPU float conversion (see line 222 and 232) if the compiler has fp16 data type extension and the CPU supports native fp16 conversion.

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