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

Juan Fumero jfumero at openjdk.org
Wed Sep 24 09:16:00 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 incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:

 - 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:
  - all: https://git.openjdk.org/babylon/pull/575/files
  - new: https://git.openjdk.org/babylon/pull/575/files/d4648792..365d97fe

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

  Stats: 1323 lines in 57 files changed: 801 ins; 130 del; 392 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