[code-reflection] RFR: [hat][proposal] Adding notion of local thread ids and local group sizes int HAT
Juan Fumero
duke at openjdk.org
Tue Aug 19 10:00:45 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.
-------------
Commit messages:
- [hat] Remove old kernel context code
- [hat] CUDA thread-block and block dispatch fixed
- [hat] roll back to plain kernelContext in the C99 kernel (ocl)
- [hat] Definition of local ids and local groups
- [hat] comment for future codegen of the kernelContext
- ComputeContext names simplified
- Merge branch 'code-reflection' into hat/api/local
- [hat] fix field ordering to process local/global groups and local thread ids
- [hat] Sample local ids documented
- [hat] jextracted codegen fixed
- ... and 12 more: https://git.openjdk.org/babylon/compare/bb4f7ff8...0044f814
Changes: https://git.openjdk.org/babylon/pull/527/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=527&range=00
Stats: 634 lines in 20 files changed: 469 ins; 95 del; 70 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