News for hackers. Stuff that matters.
Re:TornadoVM: Running Java on GPUs and FPGAs by pjmlp on Tuesday March 10, 2020 @03:34AM (#22533469)
CUDA can dynamically allocate, more recente versions even support unified shared memory blocks with the host processor.

It is also possible to do native memory allocation in Java.

Imposing restrictions on a Java subset is hardly any different of imposing restrictions on C and C++, which apparently is ok to do.

Re:TornadoVM: Running Java on GPUs and FPGAs by whizzter on Tuesday March 10, 2020 @08:48AM (#22534929)
The big difference that makes Java cumbersome is that you always have object references (ie pointers), thus an array of objects is really an array of pointers to objects that are in another memory location.

C/C++ structs(classes) on the other hand represents a memory layout so an array of "objects" would be laid out as a single contigious block of memory. (and this works well for a GPU)

There is/was a propsal for Java for value types but it hasn't yet been approved. https://openjdk.java.net/jeps/169

(As a side note, C# classes are used as refernces like in Java but they also have "struct" in C# that behaves like C structs, and this is what the Unity boost compiler leverages and could be used for a GPU variant with less restrictions)

Re:TornadoVM: Running Java on GPUs and FPGAs by pjmlp on Tuesday March 10, 2020 @11:39AM (#22536351)
Not necessarily, although the language does not guarantee it, flattening to structs does happen in some JITs.

Grated it isn't perfect, hence the value types proposal.

Here is one of the CUDA commercial offerings for Java and .NET,

https://developer.nvidia.com/altimesh-hybridizer

Re:TornadoVM: Running Java on GPUs and FPGAs by kllrnohj on Tuesday March 10, 2020 @01:30PM (#22537464)
> Not necessarily, although the language does not guarantee it, flattening to structs does happen in some JITs.

Only if escape analysis says it didn't go anywhere. Which works for iterators but it's not going to work for input & output arrays to this system, especially since it's asynchronous meaning it did escape the stack frame.