[code-reflection] Integrated: Second Proposal to generalize handling of Vector Types based on 644
Juan Fumero
jfumero at openjdk.org
Fri Oct 31 09:43:43 UTC 2025
On Tue, 28 Oct 2025 14:24:05 GMT, Juan Fumero <jfumero at openjdk.org> wrote:
> 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.
This pull request has now been integrated.
Changeset: cb06b855
Author: Juan Fumero <jfumero at openjdk.org>
URL: https://git.openjdk.org/babylon/commit/cb06b8551bcf9ca02c02023161c78a142ed70dc9
Stats: 679 lines in 24 files changed: 423 ins; 147 del; 109 mod
Second Proposal to generalize handling of Vector Types based on 644
-------------
PR: https://git.openjdk.org/babylon/pull/647
More information about the babylon-dev
mailing list