Awesome Open Source
Awesome Open Source

TornadoVM

TornadoVM is a plug-in to OpenJDK and GraalVM that allows programmers to automatically run Java programs on heterogeneous hardware. TornadoVM currently targets OpenCL-compatible devices and it runs on multi-core CPUs, dedicated GPUs (NVIDIA, AMD), integrated GPUs (Intel HD Graphics and ARM Mali), and FPGAs (Intel and Xilinx).

Website: tornadovm.org

For a quick introduction please read the following FAQ.

Current Release: TornadoVM 0.8 - 19/11/2020 : See CHANGELOG

Previous Releases can be found here

1. Installation

TornadoVM can be installed either from scratch or by using Docker.

You can also run TornadoVM on Amazon AWS CPUs, GPUs, and FPGAs following the instructions here.

2. Usage Instructions

TornadoVM is currently being used to accelerate machine learning and deep learning applications, computer vision, physics simulations, financial applications, computational photography, and signal processing.

We have a use-case, kfusion-tornadovm, for accelerating a computer-vision application implemented in Java using the Tornado-API to run on GPUs.

We also have a set of examples that includes NBody, DFT, KMeans computation and matrix computations.

Additional Information

Benchmarks

Reductions

Execution Flags

FPGA execution

Profiler Usage

3. Programming Model

TornadoVM exposes to the programmer task-level, data-level and pipeline-level parallelism via a light Application Programming Interface (API). TornadoVM uses single-source property, in which the code to be accelerated and the host code live in the same Java program.

The following code snippet shows a full example to accelerate Matrix-Multiplication using TornadoVM.

public class Compute {
    private static void mxm(Matrix2DFloat A, Matrix2DFloat B, Matrix2DFloat C, final int size) {
        for (@Parallel int i = 0; i < size; i++) {
            for (@Parallel int j = 0; j < size; j++) {
                float sum = 0.0f;
                for (int k = 0; k < size; k++) {
                    sum += A.get(i, k) * B.get(k, j);
                }
                C.set(i, j, sum);
            }
        }
    }

    public void run(Matrix2DFloat A, Matrix2DFloat B, Matrix2DFloat C, final int size) {
        TaskSchedule ts = new TaskSchedule("s0")
                .streamIn(A, B)                            // Stream data from host to device
                .task("t0", Compute::mxm, A, B,  C, size)  // Each task points to an existing Java method
                .streamOut(C);                             // sync arrays with the host side
        ts.execute();   // It will execute the code on the default device (e.g. a GPU)
    }
}

4. Dynamic Reconfiguration

Dynamic reconfiguration is the ability of TornadoVM to perform live task migration between devices, which means that TornadoVM decides where to execute the code to increase performance (if possible). In other words, TornadoVM switches devices if it knows the new device offers better performance. With the task-migration, the TornadoVM's approach is to only switch device if it detects an application can be executed faster than the CPU execution using the code compiled by C2 or Graal-JIT, otherwise it will stay on the CPU. So TornadoVM can be seen as a complement to C2 and Graal. This is because there is no single hardware to best execute all workloads efficiently. GPUs are very good at exploiting SIMD applications, and FPGAs are very good at exploiting pipeline applications. If your applications follow those models, TornadoVM will likely select heterogeneous hardware. Otherwise, it will stay on the CPU using the default compilers (C2 or Graal).

To use the dynamic reconfiguration, you can execute using TornadoVM policies. For example:

// TornadoVM will execute the code in the best accelerator.
ts.execute(Policy.PERFORMANCE);

Further details and instructions on how to enable this feature can be found here.

5. How to Use it in your Projects?

You can import the API and start using TornadoVM. Set this in the pom.xml file.

   <repositories>
     <repository>
       <id>universityOfManchester-graal</id>
       <url>https://raw.githubusercontent.com/beehive-lab/tornado/maven-tornadovm</url>
     </repository>
   </repositories>
  
   <dependencies>   
      <dependency>
         <groupId>tornado</groupId>
         <artifactId>tornado-api</artifactId>
         <version>0.8</version>
      </dependency>
      <dependency>
         <groupId>tornado</groupId>
         <artifactId>tornado-matrices</artifactId>
         <version>0.8</version>
      </dependency>
   </dependencies>

To run TornadoVM, you need to either install the TornadoVM extension for GraalVM/OpenJDK, or run with our docker images.

6. Additional Resources

Here you can find videos, presentations, and articles and artefacts describing TornadoVM and how to use it.

7. Academic Publications

Selected publications and citations can be found here.

8. Acknowledgments

This work was initially supported by the EPSRC grants PAMELA EP/K008730/1 and AnyScale Apps EP/L000725/1, and now it is funded by the EU Horizon 2020 E2Data 780245 and the EU Horizon 2020 ACTiCLOUD 732366 grants.

9. Contributions and Collaborations

We welcome collaborations! Please see how to contribute in the CONTRIBUTING.

A mailing list is also available to discuss TornadoVM related issues:

[email protected]

For collaborations please contact Christos Kotselidis.

10. TornadoVM Team

This work was originated by James Clarkson under the joint supervision of Mikel Luján and Christos Kotselidis. Currently, this project is maintained and updated by the following contributors:

11. Licenses

To use TornadoVM, you can link the TornadoVM API to your application which is under the CLASSPATH Exception of GPLv2.0.

Each TornadoVM module is licensed as follows:

Module License
Tornado-Runtime License: GPL v2 + CLASSPATH Exception
Tornado-Assembly License: GPL v2 + CLASSPATH Exception
Tornado-Drivers License: GPL v2 + CLASSPATH Exception
Tornado-API License: GPL v2 + CLASSPATH Exception
Tornado-Drivers-OpenCL-Headers License: MIT
Tornado-scripts License: GPL v2
Tornado-Annotation License
Tornado-Unittests License
Tornado-Benchmarks License
Tornado-Examples License
Tornado-Matrices License

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
java (30,358
fpga (142
opencl (110
gpgpu (60
graalvm (32

Find Open Source By Browsing 7,000 Topics Across 59 Categories