[code-reflection] RFR: [hat][proposal] Analysis for constants before the codegen [v4]

Juan Fumero jfumero at openjdk.org
Wed Sep 24 13:53:36 UTC 2025


> How to test?
> 
> 
> HAT=SHOW_CODE java @hat/test ffi-opencl oracle.code.hat.TestConstants
> 
> 
> Whole suite:
> 
> 
> HAT=SHOW_CODE java @hat/test suite ffi-opencl
> 
> 
> Example:
> 
> 
>     @CodeReflection
>     public static void vectorWithConstants(@RO KernelContext kc, @RO S32Array arrayA, @RO S32Array arrayB, @RW S32Array arrayC) {
>         final int BM = 100;
>         if (kc.x < kc.gsx) {
>             final int valueA = arrayA.array(kc.x);
>             final int valueB = arrayB.array(kc.x);
>             arrayC.array(kc.x, (BM + valueA + valueB));
>         }
>     }
> 
> 
> Generated code:
> 
> 
> __kernel void vectorWithConstants(
>     __global KernelContext_t* kc,
>     __global S32Array_t* arrayA,
>     __global S32Array_t* arrayB,
>     __global S32Array_t* arrayC
> ){
>     const int BM = 100;
>     if(get_global_id(0)<get_global_size(0)){
>         const int valueA = arrayA->array[(long)get_global_id(0)];
>         const int valueB = arrayB->array[(long)get_global_id(0)];
>         arrayC->array[(long)get_global_id(0)]=BM+valueA+valueB;
>     }
>     return;
> }

Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains six commits:

 - Merge branch 'code-reflection' into hat/finals/codegen
 - Merge branch 'code-reflection' into hat/finals/codegen
 - clean-up
 - [hat] Proposal for analysing final values in HAT
 - Revert back
 - Generate constants from final for OpenCL and CUDA

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

Changes: https://git.openjdk.org/babylon/pull/575/files
  Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=575&range=03
  Stats: 155 lines in 7 files changed: 147 ins; 5 del; 3 mod
  Patch: https://git.openjdk.org/babylon/pull/575.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/575/head:pull/575

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


More information about the babylon-dev mailing list