[code-reflection] RFR: [hat] Proposal for bfloat16 [v4]
Gary Frost
gfrost at openjdk.org
Wed Dec 3 14:14:58 UTC 2025
On Wed, 3 Dec 2025 13:57:21 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 incrementally with one additional commit since the last revision:
>
> [hat] bfloat16 codegen refactored
hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 126:
> 124: if (OpTk.isAssignable(buildContext.lookup, javaType, MappableIface.class) && javaType instanceof ClassType classType) {
> 125: globalPtrPrefix().suffix_t(classType).asterisk();
> 126: } else if (javaType instanceof ClassType classType && classType.toClassName().equals(F16.class.getCanonicalName())) {
Can we leverage OpTk.isAssignable ? or at least avoid string comparisons on Class.getCanonicalName
Something like
OpTK.isAssignable(lookup, classType, F16.class) ?
I think we have access to the lookup in the context...
hat/core/src/main/java/hat/codebuilders/HATCodeBuilder.java line 84:
> 82: }
> 83:
> 84: public T suffix_t(Class<?> klass) {
Can we compose using existing methods?
return suffix_t(class.getSimpleName());
hat/core/src/main/java/hat/codebuilders/HATCodeBuilder.java line 89:
> 87:
> 88: public T suffix_u(Class<?> klass) {
> 89: return identifier(klass.getSimpleName()).identifier("_u");
Same as above
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585272419
PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585257810
PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585259258
More information about the babylon-dev
mailing list