Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 9f50116

Browse files
committed
WIP f16 fma
simplify exp resolve warnings update update
1 parent 46a3bce commit 9f50116

File tree

18 files changed

+202
-6
lines changed

18 files changed

+202
-6
lines changed

crates/libm-macros/src/shared.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ const ALL_OPERATIONS_NESTED: &[(FloatTy, Signature, Option<Signature>, &[&str])]
9292
None,
9393
&["copysignf128", "fdimf128", "fmaxf128", "fminf128", "fmodf128"],
9494
),
95+
(
96+
// `(f16, f16, f16) -> f16`
97+
FloatTy::F16,
98+
Signature { args: &[Ty::F16, Ty::F16, Ty::F16], returns: &[Ty::F16] },
99+
None,
100+
&["fmaf16"],
101+
),
95102
(
96103
// `(f32, f32, f32) -> f32`
97104
FloatTy::F32,

crates/libm-test/benches/icount.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ main!(
105105
icount_bench_floorf16_group,
106106
icount_bench_floorf_group,
107107
icount_bench_fma_group,
108+
icount_bench_fmaf16_group,
108109
icount_bench_fmaf_group,
109110
icount_bench_fmax_group,
110111
icount_bench_fmaxf128_group,

crates/libm-test/benches/random.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ libm_macros::for_each_function! {
126126
| fdimf128
127127
| fdimf16
128128
| floorf128
129+
| fmaf16
129130
| floorf16
130131
| fmaxf128
131132
| fmaxf16

crates/libm-test/src/mpfloat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ libm_macros::for_each_function! {
190190
expm1 | expm1f => exp_m1,
191191
fabs | fabsf => abs,
192192
fdim | fdimf | fdimf16 | fdimf128 => positive_diff,
193-
fma | fmaf => mul_add,
193+
fma | fmaf | fmaf16 => mul_add,
194194
fmax | fmaxf | fmaxf16 | fmaxf128 => max,
195195
fmin | fminf | fminf16 | fminf128 => min,
196196
lgamma | lgammaf => ln_gamma,

crates/libm-test/src/precision.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ fn int_float_common<F1: Float, F2: Float>(
554554
impl MaybeOverride<(f32, i32)> for SpecialCase {}
555555
impl MaybeOverride<(f64, i32)> for SpecialCase {}
556556

557+
#[cfg(f16_enabled)]
558+
impl MaybeOverride<(f16, f16, f16)> for SpecialCase {}
559+
557560
impl MaybeOverride<(f32, f32, f32)> for SpecialCase {
558561
fn check_float<F: Float>(
559562
input: (f32, f32, f32),
@@ -575,6 +578,9 @@ impl MaybeOverride<(f64, f64, f64)> for SpecialCase {
575578
}
576579
}
577580

581+
#[cfg(f128_enabled)]
582+
impl MaybeOverride<(f128, f128, f128)> for SpecialCase {}
583+
578584
// F1 and F2 are always the same type, this is just to please generics
579585
fn ternop_common<F1: Float, F2: Float>(
580586
input: (F1, F1, F1),

crates/libm-test/tests/compare_built_musl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ libm_macros::for_each_function! {
8989
fdimf16,
9090
floorf128,
9191
floorf16,
92+
fmaf16,
9293
fmaxf128,
9394
fmaxf16,
9495
fminf128,

crates/util/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,17 @@ fn do_eval(basis: &str, op: &str, inputs: &[&str]) {
9696
| fdimf16
9797
| floorf128
9898
| floorf16
99+
<<<<<<< HEAD
99100
| fmaxf128
100101
| fmaxf16
101102
| fminf128
102103
| fminf16
103104
| fmodf128
104105
| fmodf16
106+
||||||| parent of f5a6da1 (WIP f16 fma)
107+
=======
108+
| fmaf16
109+
>>>>>>> f5a6da1 (WIP f16 fma)
105110
| rintf128
106111
| rintf16
107112
| roundf128

etc/function-definitions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,12 @@
376376
],
377377
"type": "f32"
378378
},
379+
"fmaf16": {
380+
"sources": [
381+
"src/math/fmaf16.rs"
382+
],
383+
"type": "f16"
384+
},
379385
"fmax": {
380386
"sources": [
381387
"src/libm_helper.rs",

etc/function-list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ floorf128
5353
floorf16
5454
fma
5555
fmaf
56+
fmaf16
5657
fmax
5758
fmaxf
5859
fmaxf128

etc/update-api-list.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
functions are covered by our macros.
44
"""
55

6+
# TOOD: also match with `${name}_any_suffix` so we pick up `fma_big`.
7+
68
import difflib
79
import json
810
import subprocess as sp

0 commit comments

Comments
 (0)