Post on 10-May-2015
description
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1
The role of Java™ in Heterogeneous Computing …and how you can help! Nandini Ramani Vice President, Java Platform @eyeseewaters
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 2
©2013 Oracle Corporation
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions.
The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 3
Java
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 4
5 of Top 5 OEMs ship Java ME #1 Development platform
9 Million Java developers worldwide
3 Billion mobile phones run Java
#1 Choice for developers
80% of mobile developers use Java 100% of Blu-Ray players ship with Java 97% of enterprise desktops run Java 89% of desktops in USA run Java 7 Billion Java Cards sold 5 Billion Java Cards in use 115 Million TV devices run Java
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 5
Hello.java javac Hello.jar Hello.class Java Virtual
Machine
Life of Java Program
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 6
Java ME Embedded
Oracle Java Platforms Overview
Java Card
SECURITY SMALL EMBEDDED MEDIUM EMBEDDED LARGE EMBEDDED DESKTOP SERVER
50KB-1MB
1MB-10MB
10MB-100MB
Footprint
Java SE Embedded
100MB+
Java SE
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 7
Rich Tools Ecosystem
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 8
Rich Tools Ecosystem
Java has rich and competitive tools ecosystem Ports to many platforms and tool chains
Choice is good
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 9
Java is Open!
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 10
OpenJDK
“The place to collaborate on an open-source implementation of the Java Platform, Standard Edition, and related projects.”
In a Nutshell
http://openjdk.java.net
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 11
30+ Projects
Java 7 RI Binaries
Open Community – GPL v2 + Classpath Exception
OpenJDK Virtuous Cycle
Java for IBM Platforms
Java for SAP Platforms
Customized VM for Internal Use
...and many more
Both Gratis and Commercial offerings (Including Support, Enterprise tooling, etc, available)
Java for Red Hat Platforms
Source contributions
Companies AND Individuals
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 12
Porting and optimizing Oracle JDK for Linux ARM/V8 GA - H1 2015
64-bit
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 13
Java and Heterogeneous Compute
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 14
“The HSA Foundation goal is to make it dramatically easier to program heterogeneous parallel devices.”
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 15
“The HSA Foundation goal is to make it dramatically easier to program heterogeneous parallel devices.”
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 16
Parallel
Power usage is leading to parallel throughput Programmers need to execute a mix of parallel and sequential tasks Java remains the tool of choice as hardware tilts toward the parallel
Java and Heterogeneous Computing
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 17
2002 … 2004 … 2006 …. 2011 … 2014
1.4 5.0 6 7 8 java.lang.Thread
java.util.concurrent (jsr166)
Fork/Join Framework (jsr166y)
Project Lambda History of Parallelism Support in Java
Phasers, etc (jsr166)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 18
Parallelism Support in Java 8 – Lambdas Simplifying the code to write parallel actions
// The OLD way. Simplistic, Brittle, and Serialized // Find Total Salary of all California Employees public static int californiaSalary(List<Employee> employees, int salary) { int sum=0; for (Employee e : employees) { if (e.getStateCode() == CALIFORNIA) sum += e.getSalary(); } return sum; }
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 19
Parallelism Support in Java 8 – Lambdas Simplifying the code to write parallel actions
// Total Salary of all California Employees int sum = employees.parallelStream() .filter(e -> e.getStateCode() == CALIFORNIA) .mapToInt(e -> e.getSalary()) .sum();
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 20
Parallelism Support in Java 8 – Arrays Simplifying the code to write parallel actions
// New Parallel Methods added to Array // In place cumulation Array.parallelPrefix(anArray, BinaryOperator) // Sort Array.parallelSort(anArray); // In place mutations Array.parallelSetAll(anArray, UnaryOperator) // Special Iterator for decomposition in addition to single-element Array.spliterator(anArray)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 21
“The HSA Foundation goal is to make it dramatically easier to program heterogeneous parallel devices.”
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 22
Heterogeneous
Future is power-constrained Tradeoff is latency vs. throughput Typical system will be a few low latency cores, many high throughput cores, some special accelerators
Java and Heterogeneous Computing
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 23
New Challenges – Array-wise programming concepts
Java is a concurrent language with concurrent and parallel programming support built into the core
Exploit the hardware Array-wise programming
Java JDK 8 includes parallel decomposition and programming tools out of the box.
Java and Heterogeneous Computing
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 24
New Challenges – “WORA” Becomes Local
Transitioning from write once, run anywhere “WORA” to a world where one JVM can access multiple ISAs at once
Java and Heterogeneous Computing
JVM 1 OS 1 ISA 1 Chip 1 Mem 1
JVM 2 OS 2 ISA 2 Chip 2 Mem 2
JVM OS
ISA 1 Chip 1 Mem 1
ISA 2 Chip 2 Mem 2
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 25
Some cores optimized for: – High Throughput – Low latency – Low Power – Special Accelerators
Where should work be routed?
JVM OS
ISA 1 Chip 1 Mem 1
ISA 2 Chip 2 Mem 2
New Challenges – Route Work to Best Resource Java and Heterogeneous Computing
?
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 26
New Challenges – Non-Uniform Memory Access
Heterogeneous systems have bumpy costs with non-uniform memory
– JVM can manage memory on the fly in response to program dynamics
– Manage memory access and data flow across ISAs
Java and Heterogeneous Computing
JVM
OS
ISA 1
Chip 1
Mem 1
ISA 2
Chip 2
Mem 2 Memory
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 27
How do we meet these and other challenges?
JVM
OS
ISA 1
Chip 1
Mem 1
ISA 2
Chip 2
Mem 2
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 28
How do we meet these and other challenges?
http://openjdk.java.net/projects/sumatra/
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 29
Project Sumatra
OpenJDK Project with leadership from AMD and Oracle Goal is to simplify Heterogeneous Compute (via multiple ISAs) for
nine million+ Java developers Oracle team includes Labs and SPARC expertise HSA Standards are important:
– HSAIL helps with common back end notation – HSA helps with portability
Java and Heterogeneous Computing
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 30
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 31
Gary Frost Software Fellow
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 32
Histogram of male/female (5150) names Found in selected works of ‘Charles Dickens’ So conceptually we have sequence of nested loops.
Sumatra Demo
for each selected book{ for each name{ for each occurrence of ‘name’ in ‘book’{ name.count++; } } }
Java and Heterogeneous Computing
Can be done in parallel !
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 33
Here is the actual Java 8 code at the heart of the demo
Sumatra Demo
Arrays.stream(library) .filter(Book::isSelected) .forEach(book-> Arrays.stream(names) .parallel() // <-- Loop over the names in parallel. .forEach(name -> // for each occurrence of ‘name’ in ‘book’ // name.count++; ); );
Java and Heterogeneous Computing
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 34
Java 8 can efficiently dispatch the enclosed lambda across multiple cores when the stream is marked as parallel()
A Sumatra JVM will dispatch to CPU and HSA enabled GPU cores.
– JVM converts (JITS) bytecode to HSAIL and executes via HSA Runtime
Sumatra Demo
Arrays.stream(T[] array) .parallel() .forEach(t -> /* lambda */)
Java and Heterogeneous Computing
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 35
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 36
HSA enablement of JAVA
CPU ISA GPU ISA
JVM
Java Application
GPU CPU
OpenCL™
OpenCL™ Compiler and Runtime
APARAPI API
Java 7 OpenCL enabled Aparapi • AMD initiated Open Source project • Java API for data parallel algorithms • No need to learn OpenCL • No explicit buffer transfers
CPU ISA GPU ISA
JVM
Java Application
GPU CPU
HSAIIL
HSA Finalizer & Runtime
APARAPI / Lambda API
Java 8 HSA enabled Aparapi
• Java 8 Lambda based API
• HSA and SVM enablement
Beyond Java 8 Sumatra • Adds Native GPU acceleration to JVM • Java 8 Lambda/Stream API • JVM generates HSAIL via JIT • JVM dispatches to CPU or GPU
depending on workload characteristics.
GPU ISA
JVM
Java Application
GPU CPU
HSAIL
HSA Finalizer & Runtime
Java JDK Stream + Lambda API
JIT
CPU ISA
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 37
How you can help!
Project Sumatra is Open Source We can always use help:
– Test builds – Track progress – Are you a VM or Compiler super star? We
can always use more help!
Java and Heterogeneous Computing
http://openjdk.java.net/projects/sumatra/
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 38
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 39