<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p class="elementToProof" style="line-height: normal; margin: 0px;"><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Hello Nadesh. <br>
<br>
Thanks for checking out HAT and for the feedback. <br>
<br>
Basicallyference the question numbers in your email in my response. <br>
<br>
1) The access annotations for kernel args (and compute args) are currently needed, but will soon be unnecessary. These annotations indicate a contract with the kernel, indicating how the kernel expects to access its 'buffer' args (MemorySegments) . <br>
<br>
We have code which can determine the access patterns by static analysis of the kernel call tree (a closure over the kernel and all methods reachable from it) and at present we are validating that our analysis matches the annotations. So you should endeavour
to annotate corrrectly. Failure to do so, will mean that we will treat it as RW. So we may copy unnecessarily to the GPU. <br>
<br>
2) Kernels are intended to be run on the GPU (or FPGA or some other accelerator device). So code should be restricted to code that can be executed on those devices. <br>
<br>
Basically kernels should only receive primitives and memory segments. It should only operate on its received args using the 'identity' communicated via the KernelContext. <br>
<br>
Generally you should not <br>
Allocate any Object (or array) , either directly (via <code>new)</code>or by calling methods that will allocate an object or array.<br>
So sadly no Strings (* 1 see below) <br>
<br>
Call any method (static or instance) that is not itself code reflectable via @Reflect annotation. (* 2 see below)<br>
<br>
Reference any fields (static or instance) not under HAT's control. (* 3 below again) <br>
We can map certain Math.xxx() methods. but generally even this may need to be controlled<br>
<br>
Throw any exceptions or call any method that throws an exception. <br>
<br>
You can only call static methods which follow the rules above, <br>
<br>
<br>
3) System.out.println(...) in a kernel fails for multiple reasons (#1, #2 and #3) above :) because it references a static field of System and then tries to call println() on the object that is retrieved from that field and it tries to pass a String which
is allocated (the "literal") <br>
<br>
The first check fails because of the field load on System.out ... hence the (sadly cryptic)
</span><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">"What is this field load"?</span><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"> <br>
<br>
Regarding ...<br>
</span><span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><i> UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed</i></span></p>
<p class="elementToProof" style="line-height: normal; margin: 0px;"><span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><i> buildStatus =failed</i></span></p>
<p class="elementToProof" style="line-height: normal; margin: 0px;"><span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><i> logLen = 186 log = program_source:50:37: error: implicit declaration of function 'squareit' is invalid
in OpenCL</i></span></p>
<p class="elementToProof" style="line-height: normal; margin: 0px;"><span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><i> array->array[(long)HAT_GIX]=squareit(value);</i></span></p>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
Can you send a (small as possible) example that creates this error? If we follow all the rules above (and the ones I have forgotten to include ;) ) you shoduring see this. And<br>
<br>
The change from @CodeReflection -> @Reflect and requiring lambdas to cast to Compute or Kernel Quotable's is very new. You may have pulled babylon and HAT during a sequence of checkins. Can you try to pull the latest (and rebuild your Babylon enabled JDK)
.. and just check that you have the latest version. <br>
<br>
Regards <br>
Gary </div>
<div id="appendonsend"></div>
<div><br>
<div style="font-family: Calibri; text-align: left; color: rgb(0, 0, 0); margin-left: 5pt; font-size: 10pt;">
Confidential- Oracle Internal</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> babylon-dev <babylon-dev-retn@openjdk.org> on behalf of nadeesh t v <nadeeshtv@gmail.com><br>
<b>Sent:</b> Saturday, December 13, 2025 5:22 PM<br>
<b>To:</b> babylon-dev@openjdk.org <babylon-dev@openjdk.org><br>
<b>Subject:</b> Some minor errors observed in while experimenting with a sample</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
Hello,</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<br>
</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
I was experimenting with a HAT <a href="https://github.com/openjdk/babylon/blob/code-reflection/hat/examples/squares/src/main/java/squares/Main.java">
Squares sample</a> ()<span class="x_gmail-Apple-converted-space"> </span>and noticed a couple of minor issues ( at least I think). Since this is still in the development stage, I am not sure whether it’s right to bring it up or not.</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
Let me know if these kinds of minor issues should not be brought up or not. I was using the
<b>OpenCL</b> backend.</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal; min-height:15px">
<br>
</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
1 I can mark the argument of<span class="x_gmail-Apple-converted-space"> </span>
kernel function with any one of the RO/RW annotations<span class="x_gmail-Apple-converted-space">
</span>and still seem to work.</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
For eg: in the original example it was<b><span class="x_gmail-Apple-converted-space"> </span>void squareKernel(@RO KernelContext kc, @RW S32Array array)</b></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
But if I change that<span class="x_gmail-Apple-converted-space"> </span>to<span class="x_gmail-Apple-converted-space">
</span>`<b>void squareKernel(@WO KernelContext kc, @RO S32Array array)</b> `, it still works. I would expect it to throw some errors because the access byte has changed.</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal; min-height:15px">
<br>
</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
2 If I add a <b>System.out.println("Hello")</b> in the kernel, it is running to the below issue.<span class="x_gmail-Apple-converted-space"> </span></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
```</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i>@Reflect</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i>public static void squareKernel(@WO KernelContext kc, @RO S32Array array) {</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i><span class="x_gmail-Apple-converted-space"> </span>System.out.println("Hello");</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i><span class="x_gmail-Apple-converted-space"> </span>if (kc.gix < kc.gsx){</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i><span class="x_gmail-Apple-converted-space"> </span>….</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i><span class="x_gmail-Apple-converted-space"> </span>}</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i><span class="x_gmail-Apple-converted-space"> </span>}</i><br>
```</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
Is there some rule about what should go into the kernel function?<br>
</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
```</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i>what?org.example.MainWithHAT::squareKernel(hat.KernelContext, hat.buffer.S32Array):void java.lang.IllegalStateException: What is this field load ?jdk.incubator.code.dialect.java.JavaOp$FieldAccessOp$FieldLoadOp@1fc32e4fjava.lang.IllegalStateException: What
is this field load ?jdk.incubator.code.dialect.java.JavaOp$FieldAccessOp$FieldLoadOp@1fc32e4f</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i><span class="x_gmail-Apple-converted-space"> </span>at hat.codebuilders.C99HATKernelBuilder.fieldLoadOp(C99HATKernelBuilder.java:72)</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i><span class="x_gmail-Apple-converted-space"> </span>at hat.codebuilders.C99HATKernelBuilder.fieldLoadOp(C99HATKernelBuilder.java:58)</i><br>
….</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<br>
```</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
3. If I comment out the<span class="x_gmail-Apple-converted-space"> </span><i><b>Reflect</b>
</i>on<i><span class="x_gmail-Apple-converted-space"> </span></i>the function that is called from kernel function</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
```</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i>// @Reflect</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i><span class="x_gmail-Apple-converted-space"> </span></i>public static int squareit(int v) {</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<span class="x_gmail-Apple-converted-space"> </span>return<span class="x_gmail-Apple-converted-space">
</span>v * v;</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<span class="x_gmail-Apple-converted-space"> </span>}</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
```</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
Then <i>,</i> I am running into the familiar<span class="x_gmail-Apple-converted-space">
</span>`c` error.</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
```<br>
<i>UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i>buildStatus =failed</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i>logLen = 186 log<span class="x_gmail-Apple-converted-space"> </span>= program_source:50:37: error: implicit declaration of function 'squareit' is invalid in OpenCL</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<i><span class="x_gmail-Apple-converted-space"> </span>array->array[(long)HAT_GIX]=squareit(value);</i></p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<br>
```</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal">
<span class="x_gmail-Apple-converted-space"> </span>4. If I comment out the<span class="x_gmail-Apple-converted-space">
</span><i><b>Reflect</b> </i>on<i><span class="x_gmail-Apple-converted-space"> </span>
</i>the<span class="x_gmail-Apple-converted-space"> </span><b>compute method</b> function that is throwing an error from
<b>Optional</b> but for that I can create a pull request to throw the one similar to the<span class="x_gmail-Apple-converted-space">
</span>`did you miss @Reflect annotation?`.</p>
<p style="margin:0px; font-size:13px; line-height:normal; font-family:"Helvetica Neue"; font-size-adjust:none; font-kerning:auto; font-variant-alternates:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-variant-east-asian:normal; font-feature-settings:normal; min-height:15px">
<br>
</p>
</div>
<div><br>
</div>
<span class="x_gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="x_gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div>Thanks and Regards,<br>
Nadeesh TV<br>
</div>
<br>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>