Why GraalVM compiler instance is integrated in JVM CI #522
Replies: 4 comments 26 replies
-
I am asking because I am thinking about an intern project for the winners of the famous code contest (but no promises). If that is possible, then it is better to disjoint those instances that simplify both the installation and usage of TornadoVM. |
Beta Was this translation helpful? Give feedback.
-
TornadoVM extends the Graal JIT compiler to generate low-level code that be used to continue the execution on heterogenous hardware, including GPUs, and FPGAs. TornadoVM uses Graal JIT as a library, and this compilation & optimization path is only selected when TornadoVM execution is involved. What does this mean? It means that, if you have TornadoVM expressions (Task-Graphs and execution plans) that are never invoked, you will run with the default compiler, whatever this is (if you choose OpenJDK will be C2, if you choose Graal, it will be Graal for the CPU, etc). If you run execution plans, only the specialized compilation for heterogenous hardware will use the TornadoVM JIT compiler, The rest of the program will run with the default JIT compiler from the JDK distibution you are running (again, if you choose OpenJDK-based, quite likely is going to be C2). TornadoVM does not interfere with JVM. It is just another Java program with the capability to compile at runtime for OpenCL, PTX and SPIR-V. The path is as follows:
So the process: Tasks -> Graaal IR -> Sketch IR -> Specialized IR (per backend) -> Target Code There is no integration with the the JVM, The rest of the Java application that it is not reachable from the TornadoVM Execution Plans are compiled with the default JDK-vendor compiler. Regarding Runtime Information, TornadoVM performs a sort of Partial Evalulation, and it can evaluate expressions at runtime to perform more aggressive optimizations (similar to Truffle programs on top of the Graal JIT compiler). JVMCI (Java Virtual Machine Compiler Interface) is just that, an interface. Graal is an implementation of this interface. Thus, to access Graal, we need to access it through JVMCI. Hope this clarifies your questions. |
Beta Was this translation helpful? Give feedback.
-
Hi @jjfumero I decided to give this conversation the highest priority because I am going to provide a proposal for my management for an internship project dedicated to TornadoVM development. I have a couple of ideas, and one of them is simplification of the installation of TornadoVM , ideally till the level of maven dependency. So answering your question:
To start to run tests in my Gradle project, I had to write the specialized script https://github.com/babylonml/tornadovm-bugs/blob/main/build.gradle.kts#L80 , it performs the following steps:
Let us stop here. Because it is already a very complicated process that is hard for ordinary developers to follow, and even more than this it makes:
There are other steps that are not as puzzling for normal developers. But I propose to start with a simplification of the steps above.
That is an extended version of my original question. Probably you already answered it, in such case, my apologies if I missed it. So, how do I see the ideal process?
To achieve this aim, I am going to create a request for an internship project in my company, but before that, I need to clarify whether it is even possible to not register the GraalVM compiler as a JIT for JVM or for TorandoVM to work it is a mandatory step. If that is a mandatory step, which parts of the JVM infrastructure does TorandoVM use to achieve its target? |
Beta Was this translation helpful? Give feedback.
-
Just a few clarifications:
[1] https://github.com/jjfumero/llama2.tornadovm.java/blob/main/src/main/java/io/github/mikepapadim/MatrixVectorCollection.java#L41-L89 |
Beta Was this translation helpful? Give feedback.
-
Good day.
I have a newbie question, though I am curious.
If I got it correctly, the Graall VM compiler is used to create IR and produce a compiled kernel from it.
But this process does not need runtime information from JVM.
Why is an instance of the GrallVM compiler integrated into JVM?
Why not use a separate instance that can be freely modified without fear that it will affect the JIT compilation process or code used in JVM JIT?
What are the advantages of using shared instances of compilers? AFAIK Graal compiler, in a nutshell, takes one array of bytes and converts them into another. So can work as a separate instance not attached to JVMCI.
Beta Was this translation helpful? Give feedback.
All reactions