jjfumero / qconlondon2020-tornadovm

Code Examples explained in QCon-London 2020 about TornadoVM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TornadoVM QCon-London 2020 - Demos

Artefact & demos used for QCon-London presentation 2020: TornadoVM @ QCon-London

Pre-requisites
  • Install TornadoVM. Full guideline here
  • OpenCL device with OpenCL >= 1.2 installed
  • Maven 3.6

1) Live Task Migration

Demo using the Client-Server application to change the devices through the client:

$ export JAVA_HOME=/PATH/TO/graal-jvmci-8/jdk1.8.0/product
$ export TORNADO_ROOT=/PATH/TO/TORNADOVM/ROOT
$ export PATH="${PATH}:${TORNADO_ROOT}/bin/bin/"
$ export TORNADO_SDK=${TORNADO_ROOT}/bin/sdk

## Compile the application
$ mvn clean install

How to reproduce?:

## Run Server in one terminal
./runServer.sh

## Client in another terminal
./runClient.sh

2) Matrix Multiplication

$ export CLASSPATH=target/tornado-1.0-SNAPSHOT.jar

# Run sequential code (without TornadoVM acceleration)
tornado qconlondon.MatrixMultiplication 512 seq

# Run with TornadoVM acceleration on the default device
tornado qconlondon.MatrixMultiplication 512 tornado

# Run with TornadoVM on the default device with debug information
tornado --threadInfo qconlondon.MatrixMultiplication 512 tornado

# Run with TornadoVM and print the generated OpenCL kernel
tornado --printKernel qconlondon.MatrixMultiplication 512 tornado

# See all devices available
tornado --devices 

# Run with TornadoVM on the device 1
# Convention: -D<taskScheduleName>.<taskName>.device=0:<deviceID> 
tornado --printKernel --threadInfo -Ds0.t0.device=0:1 qconlondon.MatrixMultiplication 512 tornado

# Run with TornadoVM on the device 3 
# Convention: -D<taskScheduleName>.<taskName>.device=0:<deviceID> 
tornado --printKernel --threadInfo -Ds0.t0.device=0:3 qconlondon.MatrixMultiplication 512 tornado

# Run TornadoVM with IGV (Ideal Graph Visualizer) to see the compiled graphs 
tornado --igv qconlondon.MatrixMultiplication 512 

3) Node.js and TornadoVM

See install guidelines for running TornadoVM with GraalVM here

$ cd nodejs
$ export BASE=/path/to/tornadovm-graal
$ export PATH=$BASE/bin/bin:$PATH
$ export TORNADO_SDK=$BASE/bin/sdk

## JDK 8 - last Graal
$ export JAVA_HOME=/path/to/oracleGraal/19.3.0/graalvm-ce-java8-19.3.0

## Install the NPM dependencies
$ $JAVA_HOME/bin/npm install express
$ $JAVA_HOME/bin/npm install jimp
$ $JAVA_HOME/bin/npm install fs

Compile the user-code using the alias for javac provided by TornadoVM:

$ javac.py Mandelbrot.java
Running with docker?
$ docker run \
 --runtime=nvidia \
 --rm -it -v \
 "$PWD":/data \
 beehivelab/tornado-gpu-graalvm-jdk11 \
 bash node.sh server.js

## Access
http://172.17.0.2:3000/ 

## Access the sequential execution
http://172.17.0.2:3000/java
Running stand-alone?
$ bash node.sh server.js

## Access
http://127.0.0.1:3000/

## Access the sequential execution
http://127.0.0.1:3000/java

About

Code Examples explained in QCon-London 2020 about TornadoVM

License:Apache License 2.0


Languages

Language:Java 55.7%Language:Shell 38.1%Language:JavaScript 6.2%