Webrev for unloading kernels after class unloading

Caspole, Eric Eric.Caspole at amd.com
Mon Jul 21 20:52:29 UTC 2014


Hi everybody,
I put up a new webrev that allows GPU kernels to be unloaded when their class loader context gets unloaded, when used with the latest Sumatra JDK.

http://cr.openjdk.java.net/~ecaspole/unload_kernels/01/

There was already a notion of "external nmethod" in the Graal side and in the nmethod, but they had not been connected before. Here, the kernel nmethods get the external flag set, and if the class loader context of the kernel is getting unloaded it will call to the GPU::Hsail class to unload the kernel from the HSA runtime, using the API in the latest version of Okra we added last week. There is a new test case in the webrev to create an offloadable kernel in a custom class loader and see that it gets Gc-ed and collected using jmx APIs.

One shortcoming in this version I want to get comments on is how to distinguish HSAIL vs PTX nmethods so the unload code calls the correct GPU runtime to do the dispose. We don't use "make not entrant" style flagging of kernel nmethods but this change is the first step in making the kernels more proper members in the code cache.

I also added the call to dispose the HSA GPU context similar to what the PTX version had for a long while now.
Let me know your comments,
Thanks,
Eric



More information about the graal-dev mailing list