[code-reflection] RFR: [hat] Proposal for bfloat16 [v2]
Gary Frost
gfrost at openjdk.org
Wed Dec 3 12:12:41 UTC 2025
On Wed, 3 Dec 2025 11:53:56 GMT, Juan Fumero <jfumero at openjdk.org> wrote:
>> This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT.
>>
>> Testing for OpenCL:
>>
>>
>> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type
>>
>>
>> Testing for CUDA:
>>
>>
>> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type
>>
>>
>> Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example.
>
> Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 22 commits:
>
> - [hat] abstracting the OpenCL and CUDA code builders
> - Merge branch 'code-reflection' into hat/type/bfloat16
> - Merge branch 'code-reflection' into hat/type/bfloat16
> - [hat] remove custom Op for bfloat
> - single line imports in hat code builders
> - single line imports in hat code builders
> - [hat] test matmul with bfloat16
> - [hat] dialect for bfloat16 removed
> - [hat] new test file included in the hat test list
> - [hat] OpenCL handler for bfloat16 via float convs
> - ... and 12 more: https://git.openjdk.org/babylon/compare/0a7929cc...ddc932c3
hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 97:
> 95: } else if (javaType instanceof ClassType classType && classType.toClassName().equals(F16.class.getCanonicalName())) {
> 96: // Check for special types (e.g., FP16)
> 97: globalPtrPrefix().suffix_t(F16Impl.class.getSimpleName()).asterisk();
We might consider overloading suffix_t with suffix_t(Class clazz) which extracts the simpleName.
T suffix_t(Class clazz){
return suffix_t(clazz.getSimpleNameI());
}
Then we can just pass .suffix_t(F16Impl.class)
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2584866769
More information about the babylon-dev
mailing list