[code-reflection] RFR: [hat][proposal] Adding notion of local thread ids and local group sizes int HAT [v2]

Juan Fumero duke at openjdk.org
Tue Aug 19 12:17:16 UTC 2025


> This PR extends the `KernelContext` API to access local thread ids and group sizes. 
> 
> It keeps compatibility with the prev. API, thus, it maintains the `kernelcontext.x` and `kernelcontext.maxX` thread accessors. However, we might remove this in near future in favour for the kernelContext.gix and `kernelcontext.gsx`. 
> This is just a proposal.
> 
> Simple example:
> 
> 
> @CodeReflection
>     private static void assign(@RO KernelContext context, @RW S32Array arrayA, @RW S32Array arrayB, @RW S32Array arrayC) {
>         int gix = context.gix;
>         int lix = context.lix;
>         int lsx = context.lsx;
>         int bsx = context.bsx;
>         arrayA.array (gix, lix);    // Store local thread id
>         arrayB.array(gix, lsx);    // Store local size
>         arrayC.array(gix, bsx);   // Store thread block id
>     }
> 
> 
> How to test:
> 
> 
> 
> # For OpenCL
>  java -cp job.jar hat.java exp ffi-opencl $@                                                                                            
>  
> # For CUDA                                                                                                                                        
>  java -cp job.jar hat.java exp ffi-cuda $@ 
> 
> 
> Still a draft PR until double checking with the CUDA backend.

Juan Fumero has updated the pull request incrementally with two additional commits since the last revision:

 - [hat] Fix hat jextracted build
 - [hat] Fix block id and global size indexing for OpenCL

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

Changes:
  - all: https://git.openjdk.org/babylon/pull/527/files
  - new: https://git.openjdk.org/babylon/pull/527/files/0044f814..1206a15a

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

  Stats: 87 lines in 8 files changed: 41 ins; 14 del; 32 mod
  Patch: https://git.openjdk.org/babylon/pull/527.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/527/head:pull/527

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


More information about the babylon-dev mailing list