[code-reflection] RFR: Second Proposal to generalize handling of Vector Types based on 644
Juan Fumero
jfumero at openjdk.org
Fri Oct 31 09:28:16 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.
-------------
Commit messages:
- Merge branch 'code-reflection' into hat/vectors/generalv2
- Merge remote-tracking branch 'refs/remotes/personal/hat/vectors/generalv2' into hat/vectors/generalv2
- Merge remote-tracking branch 'refs/remotes/personal/hat/vectors/generalv2' into hat/vectors/generalv2
- [hat] CUDA backend fixed
- [hat] RW vector float4 sample added
- [hat] missing header license added
- [hat] Generalise vectorisation type system and dialectify for HAT v2
- [hat] refactor for vector phases and scaffolding for vectors and interfaces
- minor change
- [hat] Proposal to generalise dialect for vector types
- ... and 14 more: https://git.openjdk.org/babylon/compare/420c933a...6166cd63
Changes: https://git.openjdk.org/babylon/pull/647/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=647&range=00
Stats: 724 lines in 25 files changed: 468 ins; 147 del; 109 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