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

Juan Fumero jfumero at openjdk.org
Wed Sep 17 14:26:45 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 incrementally with one additional commit since the last revision:

  clean-up

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

Changes:
  - all: https://git.openjdk.org/babylon/pull/575/files
  - new: https://git.openjdk.org/babylon/pull/575/files/9ce4ea2c..d4648792

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

  Stats: 23 lines in 1 file changed: 15 ins; 1 del; 7 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