Integer in kernelContext.globalIds causes generation of Unbox/PiNodes #515
Replies: 2 comments 3 replies
-
Hi @andrii0lomakin . Can you provide a test case that breaks? As far as I remember, we decided to use the wrapper types due to optmizations in the Graal Compiler. If it is a primitive final, Graal will provide directly the constant value (which makes sense). In TornadoVM, to prevent this, we have at least two options:
We preferred the style of fields to access the thread-ids. However, we are open to suggestions. |
Beta Was this translation helpful? Give feedback.
-
Another possible motivation for changing this API by using functions would be the ability to emulate the running kernels using Kernel API on the CPU. Imho the concept of barriers does not fit well in the JVM concurrency model. Still, modern support of virtual threads in JDK 21 will allow the implementation of barriers in the case of many workers and a limited amount of threads(read cores) for debugging purposes. I already have a sketch of such emulation based on TornadoVM API, but the usage of Integer instead of methods makes it impossible, it seems like reflection API conflicts with the TornadoVM compiler, and I can not write tests that use both GPU and CPU scheduled kernels. Usage of CPU scheduled kernels will greatly simplify debugging, of course, in case of usage of kernel API. |
Beta Was this translation helpful? Give feedback.
-
Hi.
Because KernelContext uses
Integer
s for KernelContext variables.Code like that
var i = kernelContext.globalIdx;
causes cryptic compilation errors, which, in the core, are caused by the fact that TornadoVM generates not alive PiNode's that can not be replaced during compiler optimizations.Is it possible instead to use
final int
fields to avoid such confusion?What is the root cause of this decision to use wrappers instead?
Beta Was this translation helpful? Give feedback.
All reactions