[code-reflection] RFR: Second Proposal to generalize handling of Vector Types based on 644 [v2]

Juan Fumero jfumero at openjdk.org
Fri Oct 31 09:38:41 UTC 2025


> This PR adds another proposal for generalising HAT Vector Types. 
> 
> It is based on PR #644 as an alternative approach. So we can evaluate each proposal and device which one to move forward. 
> 
> This approach replaces the `@HATVectorType` annotation with a set of interfaces to identify base type and width of the vector type being represented. 
> 
> For instance:
> 
> 
> public interface _V {
>     PrimitiveType type();
>     int width();
> }
> 
> public interface _V4 extends _V {
> 
>     @CodeReflection
>     @Override
>     default int width() {
>         return 4;
>     }
> }
> 
> 
> public interface Float4 extends _V4 {
> 
>     float x();
>     float y();
>     float z();
>     float w();
> 
>     @CodeReflection
>     @Override
>     default PrimitiveType type() {
>         return JavaType.FLOAT;
>     }
> 
>    ...
> 
> }
> 
> 
> Note that both methods, width and type, are annotated with `@CodeReflection`. During the "dialectify" process, this approach builds the code models for both methods and inspects the meta-data values. 
> 
> Some restrictions:
> 
> - `Float4` is not an `iFace` interface due to the small granularity. 
> - Usually, these types are inspected from the kernel code, so we don't have instance objects.
> - Returning `PrimitiveType` from the `type` method allows us to be restricted in the amount of base types to support. 
> 
> 
> How to test:
> 
> For OpenCL:
> 
> 
> HAT=SHOW_CODE,SHOW_COMPILATION_PHASES java @hat/otest ffi-opencl hat.test.TestVectorTypes
> 
> 
> For CUDA:
> 
> 
> 
> HAT=SHOW_CODE,SHOW_COMPILATION_PHASES java @hat/otest ffi-cuda hat.test.TestVectorTypes
> 
> 
> This PR has been tested with both OpenCL and CUDA backends.

Juan Fumero has updated the pull request incrementally with one additional commit since the last revision:

  [hat] Cleanup phase utils

-------------

Changes:
  - all: https://git.openjdk.org/babylon/pull/647/files
  - new: https://git.openjdk.org/babylon/pull/647/files/6166cd63..0471a646

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=babylon&pr=647&range=01
 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=647&range=00-01

  Stats: 393 lines in 5 files changed: 172 ins; 217 del; 4 mod
  Patch: https://git.openjdk.org/babylon/pull/647.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/647/head:pull/647

PR: https://git.openjdk.org/babylon/pull/647


More information about the babylon-dev mailing list