[code-reflection] RFR: Proposal for Vector Types for GPUs (OpenCL and CUDA backends)
Juan Fumero
jfumero at openjdk.org
Tue Oct 14 09:41:14 UTC 2025
This PR opens a new proposal to integrate an API for representing explicit vector types in HAT.
The way to operate is as follows:
Float4 vA = a.float4View(index * 4);
Float4 vB = b.float4View(index * 4);
Float4 vC = Float4.add(vA, vB);
c.storeFloat4View(vC, index * 4);
Java programmers can load/store float4 chunks within one instruction by using array views. These views operate on GPU's global memory, but we can add similar concepts for local/shared and private memory.
Additionally, Java/HAT developers can access lanes within the vector instance by name:
vA.x(myNewValue);
float foo = vA.z();
```
We will iterate over this proposal.
How to test?
For CUDA
HAT=SHOW_CODE,INFO,SHOW_COMPILATION_PHASES java @hat/otest ffi-cuda oracle.code.hat.TestVectorTypes
For OpenCL:
HAT=SHOW_CODE,INFO,SHOW_COMPILATION_PHASES java @hat/otest ffi-opencl oracle.code.hat.TestVectorTypes
This PR also introduces a new option to debug the HAT Dialect Phases.
HAT=SHOW_COMPILATION_PHASES ...
-------------
Commit messages:
- [hat] clean-up old code
- [hat] float4 support for the CUDA backend types generalized
- [hat] Padding for copyFrom/copyTo functions
- Merge branch 'code-reflection' into hat/vector/types
- [hat] Example of matmul with 2D RT + vector loads
- [hat] Matmul with 2D register tiling + vector loads/stores working
- [hat] clean-up test
- [hat] CUDA backend with the right accessor for loading/storing float4 views
- [hat] Allow float4 to/from local/private memory
- [hat] Offsets for S32Arrays fixed
- ... and 14 more: https://git.openjdk.org/babylon/compare/e5dfd23b...5f37c6f7
Changes: https://git.openjdk.org/babylon/pull/606/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=606&range=00
Stats: 3350 lines in 44 files changed: 3219 ins; 86 del; 45 mod
Patch: https://git.openjdk.org/babylon/pull/606.diff
Fetch: git fetch https://git.openjdk.org/babylon.git pull/606/head:pull/606
PR: https://git.openjdk.org/babylon/pull/606
More information about the babylon-dev
mailing list