Some minor errors observed in while experimenting with a sample
nadeesh t v
nadeeshtv at gmail.com
Sat Dec 13 17:22:04 UTC 2025
Hello,
I was experimenting with a HAT Squares sample
<https://github.com/openjdk/babylon/blob/code-reflection/hat/examples/squares/src/main/java/squares/Main.java>
() 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.
Let me know if these kinds of minor issues should not be brought up or not.
I was using the *OpenCL* backend.
1 I can mark the argument of kernel function with any one of the RO/RW
annotations and still seem to work.
For eg: in the original example it was* void squareKernel(@RO KernelContext
kc, @RW S32Array array)*
But if I change that to `*void squareKernel(@WO KernelContext kc, @RO
S32Array array)* `, it still works. I would expect it to throw some errors
because the access byte has changed.
2 If I add a *System.out.println("Hello")* in the kernel, it is running to
the below issue.
```
*@Reflect*
*public static void squareKernel(@WO KernelContext kc, @RO S32Array array)
{*
* System.out.println("Hello");*
* if (kc.gix < kc.gsx){*
* ….*
* }*
* }*
```
Is there some rule about what should go into the kernel function?
```
*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 at 1fc32e4fjava.lang.IllegalStateException:
What is this field load
?jdk.incubator.code.dialect.java.JavaOp$FieldAccessOp$FieldLoadOp at 1fc32e4f*
* at
hat.codebuilders.C99HATKernelBuilder.fieldLoadOp(C99HATKernelBuilder.java:72)*
* at
hat.codebuilders.C99HATKernelBuilder.fieldLoadOp(C99HATKernelBuilder.java:58)*
….
```
3. If I comment out the *Reflect *on the function that is called from
kernel function
```
*// @Reflect*
public static int squareit(int v) {
return v * v;
}
```
Then *,* I am running into the familiar `c` error.
```
*UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed*
*buildStatus =failed*
*logLen = 186 log = program_source:50:37: error: implicit declaration of
function 'squareit' is invalid in OpenCL*
* array->array[(long)HAT_GIX]=squareit(value);*
```
4. If I comment out the *Reflect *on the *compute method* function that
is throwing an error from *Optional* but for that I can create a pull
request to throw the one similar to the `did you miss @Reflect
annotation?`.
--
Thanks and Regards,
Nadeesh TV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/babylon-dev/attachments/20251213/371343a8/attachment-0001.htm>
More information about the babylon-dev
mailing list