Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/xcl/src/gpu/dxil/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ pub fn is_f16_rounded_op(name: &str) -> bool {
name,
"v_interp_p2_f16" | "v_cvt_f16_f32" | "v_fma_mixlo_f16" | "v_fma_mixhi_f16" | "v_pk_add_f16" | "v_pk_mul_f16" | "v_pk_fma_f16"
| "v_pk_fmac_f16" | "v_pk_min_f16" | "v_pk_max_f16" | "v_add_f16" | "v_sub_f16" | "v_subrev_f16" | "v_mul_f16" | "v_min_f16"
| "v_max_f16" | "v_fma_f16" | "v_med3_f16" | "v_min3_f16" | "v_max3_f16" | "v_frexp_mant_f16" | "v_mad_f16" | "v_fmac_f16"
| "v_max_f16" | "v_fma_f16" | "v_med3_f16" | "v_min3_f16" | "v_max3_f16" | "v_frexp_mant_f16" | "v_mad_f16" | "v_div_fixup_f16" | "v_fmac_f16"
| "v_fmamk_f16" | "v_fmaak_f16" | "v_ldexp_f16" | "v_rcp_f16" | "v_rsq_f16" | "v_sqrt_f16" | "v_log_f16" | "v_exp_f16"
| "v_sin_f16" | "v_cos_f16" | "v_fract_f16" | "v_floor_f16" | "v_ceil_f16" | "v_trunc_f16" | "v_rndne_f16" | "v_cvt_f16_u16"
| "v_cvt_f16_i16"
Expand Down
1 change: 1 addition & 0 deletions crates/xcl/src/gpu/dxil/lower_wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ impl Lw {
"v_max_f16" => f2!(|s: &mut Self, x, y| s.fmax(x, y)),
"v_fma_f16" => f3!(|s: &mut Self, x, y, w| s.fmad(x, y, w)),
"v_med3_f16" => f3!(|s: &mut Self, x, y, w| s.med3f(x, y, w)),
"v_div_fixup_f16" => f3!(|s: &mut Self, x, y, w| s.div_fixup(x, y, w)),
"v_min3_f16" => f3!(|s: &mut Self, x, y, w| {
let t = s.fmin(x, y);
s.fmin(t, w)
Expand Down
2 changes: 2 additions & 0 deletions crates/xcl/src/gpu/recomp/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ fn is_f16_rounded_op(name: &str) -> bool {
| "v_max3_f16"
| "v_frexp_mant_f16"
| "v_mad_f16"
| "v_div_fixup_f16"
| "v_fmac_f16"
| "v_fmamk_f16"
| "v_fmaak_f16"
Expand Down Expand Up @@ -2988,6 +2989,7 @@ impl Em {
"v_max_f16" => fr(format!("max({}, {})", fh(0), fh(1))),
"v_fma_f16" => fr(format!("mad({}, {}, {})", fh(0), fh(1), fh(2))),
"v_med3_f16" => fr(format!("med3f({}, {}, {})", fh(0), fh(1), fh(2))),
"v_div_fixup_f16" => fr(format!("div_fixup({}, {}, {})", fh(0), fh(1), fh(2))),
"v_min3_f16" => fr(format!("min(min({}, {}), {})", fh(0), fh(1), fh(2))),
"v_max3_f16" => fr(format!("max(max({}, {}), {})", fh(0), fh(1), fh(2))),
"v_med3_u16" => format!("med3u({a}, {b}, {c})"),
Expand Down
10 changes: 10 additions & 0 deletions crates/xcl/src/gpu/recomp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,16 @@ fn cvt_norm_f16_instructions() {
assert!(t.hlsl.contains("cvt_norm_u16_f16((0x00003C00u & 0xFFFFu))") && t.hlsl.contains("cvt_norm_u16_f16((0x0000BC00u & 0xFFFFu))"), "{}", t.hlsl);
}

/// `v_div_fixup_f16` (VOP3, three f16 sources: quotient, denominator, numerator) is translated
/// like `v_div_fixup_f32`, on half-precision operands, instead of being left as unsupported.
#[test]
fn div_fixup_f16_instruction() {
let code = prog(&[("V_DIV_FIXUP_F16", "ENC_VOP3", &[("VDST", 1), ("SRC0", V + 9), ("SRC1", V + 10), ("SRC2", V + 11)], None)]);
let t = translate(&code, &Options::default()).unwrap();
assert!(t.complete(), "{:?}", t.unsupported);
assert!(t.hlsl.contains("div_fixup(f16tof32(((v9) & 0xFFFFu)), f16tof32(((v10) & 0xFFFFu)), f16tof32(((v11) & 0xFFFFu)))"), "{}", t.hlsl);
}

/// GPU verification of exact RNE rounding and edge cases for `V_CVT_NORM_*_F16` and
/// `V_CVT_PKNORM_*_F16`: catches binary32 double-rounding (`0x3801`/`0xB801`), DXIL
/// `clamp(NaN, -1, 1)` returning ±32767 instead of 0, ±Inf, ±0, subnormals, and VOP3 abs/neg.
Expand Down
Loading