Expectations from the top talent in application development grow as the need for high-performing devices goes up—within the application development community and consumers at large.
Table of Contents
But before performance can improve, the tasks that enable it need to improve. Currently, a single form of computer architecture that supports all types of efficient task performance does not exist.
To counter this bottleneck, elite software engineers came up with the idea of using heterogenous hardware. ‘Using heterogenous hardware’ means that a computer system is equipped with a variety of computing elements. And every element is equipped with different hardware characteristics to execute different tasks in parallel. Heterogeneous hardware is now used in almost every computing system. For instance, our smartphones have a CPU as well as a GPU, both with multiple cores. PCs and laptops have a CPU as well as an integrated GPU. Now, datacenters are also adding Field Programmable Gate Arrays (FPGAs), another type of heterogeneous hardware, to their systems to speed up some tasks with parallelism.
TornadoVM enables top developers to improve the performance of their applications while decreasing energy consumption. Many technology companies have also started creating their personalized hardware for better performance. For instance, top software engineers from Google have developed a processor for faster processing called Tensor Processing Unit (TPU).
When diverse elements are brought together this way, they work well. However, to ensure they keep running well, developers need to write efficient code for these new devices too. Each heterogeneous hardware has its own unique programming model and its own programming language standards as well.
Most potential programmers of this new heterogeneous hardware are not necessarily experts on parallel computing. In fact, they probably have some expertise in their preferred programming language. That’s where the need for an easier solution came up.
Java technology and its diverse developer community are known for finding solutions to contemporary development problems. So it’s no surprise that one enthusiastic Java Coder came up with the solution to the aforesaid problem. That is how TornadoVM was born.
TornadoVM began as a research project at the University of Manchester. It is a plugin for OpenJDK that lets Java Developers run Java programs on heterogeneous hardware, without any significant pre-requisite knowledge about heterogeneous programming models or parallel computing. It is fully open-sourced, just like Java and is available on Github.
Currently, TornadoVM supports hardware acceleration on multi-core CPUs, GPUs. And also, Field Programmable Gate Arrays (FPGAs) which we find growing in popularity. One of the significant features of TornadoVM is that it can perform live task migration across different computing devices.
See Also: Getting Comfortable With FPGAs
TornadoVM was introduced to make coding easier for Java Programmers. With TornadoVM, a Java Developer will have to write or change as few lines of code as possible, and he or she can automatically execute this code on accelerators.
TornadoVM’s architecture is made on a hybrid concept. It combines the traditional layered architecture with a microkernel architecture, and the core component is the runtime system.
At the top level, TornadoVM exposes an API to Java Developers. Due to that fact that TornadoVM currently does not detect parallelism, it needs a way to identify which methods or functions can be used for running on GPUs and FPGAs.
Secondly, TornadoVM contains a core-runtime, which is divided into several components such as the:
TornadoVM currently supports Java 8 and OpenJDK 11 via GraalVM 19.3.0. TornadoVM is also compatible with OpenCL 1.2, which lets it run on different devices such as GPUs (dedicated as well as integrated), FPGAs and multi-core CPUs.
CUDA and OpenCL are two very commonly used heterogeneous programming languages. They perform well if programmers master their basics. But they still require many low-level features in the API. This makes it difficult for a non-expert developer to use them. Especially one who just wants to try out programming applications for heterogeneous systems.
Java Developers generally prefer using a high-level programming language. Usually, an object-oriented programming language, like Java, Python, or JavaScript. The reason, obviously, is that the features offered in languages like Java are not found in low-level languages. Developers think that low-level languages are used for more transparency on heterogeneous hardware. The reality is that high-level languages would be used if they offered more development support.
TornadoVM fills the gap between heterogeneous hardware and high-level programming languages (like Java). It is a parallel programming framework for Java Virtual Machine (JVM) languages that can transparently and dynamically offload Java bytecodes into OpenCL, and then execute the code on heterogeneous hardware. TornadoVM also integrates an optimizing runtime that can repeatedly utilize device buffers, saving data transfers across devices. It performs live task migration across computing devices.
If you want to start working on TornadoVM, matrix multiplication is a good place to start. The code shown below is the simple matrix multiplication program in Java:
class Calculate { public static void findMatrixMultiplication(final int[] arrA, final int[] arrB, final int[] arrC, final int size) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float sum = 0.0f; for (int k = 0; k < size; k++) sum += A[(i * size) + k] * B[(k * size) + j]; C[(i * size) + j] = sum; } } } }
To accelerate this code performance with TornadoVM, we have to first annotate the loops in the code that can be parallelized. Here, we can completely parallelize the two outermost loops, as there are no dependencies between the iterations.
We use TornadoVM annotations @Parallel for annotations.
@Parallel
The following illustration shows the code after applying TornadoVM:
class Calculate { public static void findMatrixMultiplication(final int[] arrA, final int[] arrB, final int[] arrC, final int size) { for (@Parallel int i = 0; i < size; i++) { for (@Parallel int j = 0; j < size; j++) { int sum = 0; for (int k = 0; k < size; k++) sum += A[(i * size) + k] * B[(k * size) + j]; C[(i * size) + j] = sum; } } } }
The @Parallel annotation is like a hint by the TornadoVM JIT Compiler.
The TornadoVM JIT Compiler does not force parallelization. Instead, it first checks for the possibility of annotated loops to be parallelized. It then replaces the for-loops for the equivalent parallel indexing in OpenCL. If the for-loops are not independent and cannot be parallelized, TornadoVM exits the code and the code runs in a sequential manner.
TornadoVM is a plugin for OpenJDK that lets a Java Developer implement JVM applications into a heterogeneous hardware system. General users may see it as just another Java feature. But top developers know that this plugin accelerates the journey of Java Coders towards programming for heterogeneous hardware systems. It not only increases performance, but also saves time. In no small measure, either way.
We have only scratched the surface when it comes to what TornadoVM is and what it can do. There are still many other uses of TornadoVM that promise to enhance the performance of systems manifold.
Shaharyar Lalani is a developer with a strong interest in business analysis, project management, and UX design. He writes and teaches extensively on themes current in the world of web and app development, especially in Java technology.
Create a free profile and find your next great opportunity.
Sign up and find a perfect match for your team.
Xperti vets skilled professionals with its unique talent-matching process.
Connect and engage with technology enthusiasts.
© Xperti.io All Rights Reserved
Privacy
Terms of use