[foreign-abi] RFR: JDK-8243669: Improve library loading for Panama libraries

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue May 5 23:36:30 UTC 2020


On 05/05/2020 23:56, Samuel Audet wrote:
> I'm just trying to drive the point home that we need some sort of 
> solution. GPUs, FPGAs, DSPs, and other accelerators in general are not 
> going to become magically irrelevant simply because OpenJDK does not 
> consider them important! They are important, they are here to stay, 
> and their importance is only going to continue to grow.

We are aware of that, and nobody has really mentioned that said devices 
are not considered as important (and I think you should really stop 
making absurd claims without any evidence to back them up). I think the 
memory access API makes it fairly easy to create an ad-hoc memory 
segment backed by e.g. GPU memory - I've demonstrated how easy it is to 
wire things up and create your own memory sources:

https://gist.github.com/mcimadamore/128ee904157bb6c729a10596e69edffd

Now, replace mmap/munmap with cudaMalloc/cudaFree and you will have a 
MemorySegment that can be used to model GPU memory. All the lifecycle 
aspects of "traditional", off-heap memory segments can in fact translate 
onto this ad-hoc segment, so that its use can be made safe.

Of course the memory access API is a building block - together with ABI 
support (another building block) it allows you to model and manipulate 
memory sources (of all kinds, provided you have some native library to 
interact with it); if you are looking for an high-end Cuda-like GPU 
library port written in Java, Panama simply isn't the place to look for 
it. But it should be possible (and hopefully easier) to build one given 
the tools we're building.

Maurizio



More information about the panama-dev mailing list