[code-reflection] RFR: [hat] Type transform between bfloat16 <-> float improved
Gary Frost
gfrost at openjdk.org
Tue Dec 9 13:26:58 UTC 2025
On Tue, 9 Dec 2025 10:33:53 GMT, Juan Fumero <jfumero at openjdk.org> wrote:
> [hat] Type transform between bfloat16 <-> float improved.
>
> Unittests with the OpenCL backend passing.
> CUDA backend not passing due to another error (not related to this PR). We will merge this when we patch the CUDA backed.
hat/core/src/main/java/hat/codebuilders/C99HATCodeBuilder.java line 203:
> 201: }
> 202:
> 203: public final T declareTypeBFloat16Type(String identifier) {
maybe bf16Type()
hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 571:
> 569: String identifier = "b";
> 570: return funcDef(_ -> f32Type(),
> 571: _ -> builtin_bfloat16ToFloat(),
bf16Type...
hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 574:
> 572: _ -> ushortType(parameterName),
> 573: _ -> declareTypeBFloat16Type(identifier).semicolonNl()
> 574: .identifier(identifier).dot().identifier("s").osbrace().intConstZero().csbrace().equals().constant("0x0000").semicolonNl()
why constant("0x00000") why not intConstZer(0) or intvalue(0)
Replace osbrace() . xxx() .csbrace() === sbrace(_->xxx())
hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 594:
> 592: _->builtin_float2bfloat16(),
> 593: _->f32Type(parameterName),
> 594: _-> declareTypeBFloat16Type("b").space().equals().space().obrace().identifier(parameterName).cbrace().semicolonNl()
We can reduce the chances of misaligned braces by leaning into various helpers.
I think this becomes something lik
.assign(_->fb16Type("b"),_->brace(_->identifier(parameterName)).semicolonNl()
.returnKeyword(_->identifier("b").dot().identifier("s").sbrace(_->intConstOne()))
hat/core/src/main/java/hat/codebuilders/CodeBuilder.java line 588:
> 586:
> 587: public final T ushort() {
> 588: return typeName("ushort");
u16Type ??????
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602242543
PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602247697
PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602255216
PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602225819
PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602234595
More information about the babylon-dev
mailing list