SlideShare a Scribd company logo
The role of Java™ in
Heterogeneous Computing
…and how you can help!

Nandini Ramani
Vice President, Java Platform
@eyeseewaters
1

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
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.
©2013 Oracle Corporation

2

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Java

3

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
9 Million Java developers worldwide
#1 Choice for developers
#1 Development platform
5 of Top 5 OEMs ship Java ME
3 Billion mobile phones run Java
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

4

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Life of Java Program

Hello.java

5

javac

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Hello.class

Hello.jar

Java Virtual
Machine
Oracle Java Platforms Overview
Footprint
100MB+

10MB-100MB

1MB-10MB

50KB-1MB

Java Card
SECURITY

6

Java ME Embedded
SMALL EMBEDDED

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Java SE Embedded

MEDIUM EMBEDDED

LARGE EMBEDDED

Java SE
DESKTOP

SERVER
Rich Tools
Ecosystem

7

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Rich Tools Ecosystem
Choice is good
 Java has rich and competitive tools ecosystem
 Ports to many platforms and tool chains

8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Java is Open!

9

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
OpenJDK
In a Nutshell
“The place to collaborate on an open-source implementation of the
Java Platform, Standard Edition, and related projects.”

http://openjdk.java.net

10

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
OpenJDK Virtuous Cycle
Open Community – GPL v2 +
Classpath Exception

Both Gratis and Commercial
offerings (Including Support,
Enterprise tooling, etc, available)
Java 7 RI
Binaries

30+ Projects

Java for IBM
Platforms

Source contributions

Java for SAP
Platforms
Java for Red Hat
Platforms

Companies AND Individuals

11

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Customized VM for
Internal Use

...and many more
64-bit
Porting and optimizing
Oracle JDK for Linux ARM/V8
GA - H1 2015

12

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Java and
Heterogeneous
Compute

13

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
“The HSA Foundation goal is to make it
dramatically easier to program
heterogeneous parallel devices.”

14

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
“The HSA Foundation goal is to make it
dramatically easier to program
heterogeneous parallel devices.”

15

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Parallel
Java and Heterogeneous Computing

 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

16

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
History of Parallelism Support in Java
java.util.concurrent
(jsr166)
Phasers, etc
java.lang.Thread
(jsr166)

1.4
2002
17

5.0
…

2004 …

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Fork/Join Framework
(jsr166y)

7 8

6
2006

Project Lambda

….

2011

…

2014
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;
}

18

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
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();

19

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
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)

20

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
“The HSA Foundation goal is to make it
dramatically easier to program
heterogeneous parallel devices.”

21

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Heterogeneous
Java and Heterogeneous Computing

 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

22

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
New Challenges –
Array-wise programming concepts
Java and Heterogeneous Computing
Array-wise programming

Exploit the hardware

 Java is a concurrent language with  Java JDK 8 includes parallel

concurrent and parallel
programming support built into the
core

23

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

decomposition and programming
tools out of the box.
New Challenges – “WORA” Becomes Local
Java and Heterogeneous Computing
 Transitioning from write once, run anywhere “WORA” to a world where

one JVM can access multiple ISAs at once

JVM 1

JVM

OS 1

OS 2

OS

ISA 1

ISA 2

ISA 1

ISA 2

Chip 1

Chip 2

Chip 1

Chip 2

Mem 1
24

JVM 2

Mem 2

Mem 1

Mem 2

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
New Challenges – Route Work to Best Resource
Java and Heterogeneous Computing
 Some cores optimized for:
– High Throughput

JVM

– Low latency

OS ?

– Low Power

 Where should work be routed?

25

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

ISA 1

ISA 2

Chip 1

Chip 2

Mem 1

– Special Accelerators

Mem 2
New Challenges – Non-Uniform Memory Access
Java and Heterogeneous Computing
 Heterogeneous systems have

JVM

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

26

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

OS
ISA 1

ISA 2

Chip 1

Chip 2

Mem 1 Memory Mem 2
How do we meet these and other challenges?
JVM
OS
ISA 1
Chip 1

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Chip 2

Mem 1

27

ISA 2

Mem 2
How do we meet these and other challenges?

http://openjdk.java.net/projects/sumatra/

28

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Project Sumatra
Java and Heterogeneous Computing
 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

29

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
30

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Gary Frost
Software Fellow

31

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Sumatra Demo
Java and Heterogeneous Computing
 Histogram of male/female (5150) names
 Found in selected works of ‘Charles Dickens’
 So conceptually we have sequence of nested loops.
for each selected book{
for each name{
for each occurrence of ‘name’ in ‘book’{
name.count++;
}
}
}

32

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Can be done
in parallel !
Sumatra Demo
Java and Heterogeneous Computing
 Here is the actual Java 8 code at the heart of the 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++;
);
);
33

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Sumatra Demo
Java and Heterogeneous Computing
 Java 8 can efficiently dispatch the enclosed lambda across multiple

cores when the stream is marked as parallel()
Arrays.stream(T[] array)
.parallel()
.forEach(t -> /* lambda */)

 A Sumatra JVM will dispatch to CPU and HSA enabled GPU cores.
– JVM converts (JITS) bytecode to HSAIL and executes via HSA Runtime

34

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
35

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
HSA enablement of JAVA
Java 7

Java 8

Beyond Java 8

OpenCL enabled Aparapi

HSA enabled Aparapi

Sumatra

• AMD initiated Open Source project

• Java 8 Lambda based API

• Java API for data parallel algorithms

• HSA and SVM enablement

• Adds Native GPU acceleration to JVM
• Java 8 Lambda/Stream API

• No need to learn OpenCL

• JVM generates HSAIL via JIT

• No explicit buffer transfers

• JVM dispatches to CPU or GPU
depending on workload characteristics.

Java Application

Java JDK Stream + Lambda API

APARAPI
API

APARAPI / Lambda
API

OpenCL™

36

HSAIL

HSA Finalizer &
Runtime

HSA Finalizer &
Runtime
JVM

JVM

JVM
GPU ISA

CPU

JIT

HSAIIL

OpenCL™ Compiler
and Runtime

CPU ISA

Java Application

Java Application

GPU

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

GPU ISA

CPU ISA
CPU

GPU

GPU ISA

CPU ISA
CPU

GPU
How you can help!
Java and Heterogeneous Computing
 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!
http://openjdk.java.net/projects/sumatra/

37

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
38

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
39

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

More Related Content

Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How You Can Help - by Nandini Ramani, VP, Java Platform, Oracle Corporation

  • 1. The role of Java™ in Heterogeneous Computing …and how you can help! Nandini Ramani Vice President, Java Platform @eyeseewaters 1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 2. 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. ©2013 Oracle Corporation 2 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 3. Java 3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 4. 9 Million Java developers worldwide #1 Choice for developers #1 Development platform 5 of Top 5 OEMs ship Java ME 3 Billion mobile phones run Java 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 4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 5. Life of Java Program Hello.java 5 javac Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Hello.class Hello.jar Java Virtual Machine
  • 6. Oracle Java Platforms Overview Footprint 100MB+ 10MB-100MB 1MB-10MB 50KB-1MB Java Card SECURITY 6 Java ME Embedded SMALL EMBEDDED Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Java SE Embedded MEDIUM EMBEDDED LARGE EMBEDDED Java SE DESKTOP SERVER
  • 7. Rich Tools Ecosystem 7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 8. Rich Tools Ecosystem Choice is good  Java has rich and competitive tools ecosystem  Ports to many platforms and tool chains 8 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 9. Java is Open! 9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 10. OpenJDK In a Nutshell “The place to collaborate on an open-source implementation of the Java Platform, Standard Edition, and related projects.” http://openjdk.java.net 10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 11. OpenJDK Virtuous Cycle Open Community – GPL v2 + Classpath Exception Both Gratis and Commercial offerings (Including Support, Enterprise tooling, etc, available) Java 7 RI Binaries 30+ Projects Java for IBM Platforms Source contributions Java for SAP Platforms Java for Red Hat Platforms Companies AND Individuals 11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Customized VM for Internal Use ...and many more
  • 12. 64-bit Porting and optimizing Oracle JDK for Linux ARM/V8 GA - H1 2015 12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 13. Java and Heterogeneous Compute 13 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.” 14 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.” 15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 16. Parallel Java and Heterogeneous Computing  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 16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 17. History of Parallelism Support in Java java.util.concurrent (jsr166) Phasers, etc java.lang.Thread (jsr166) 1.4 2002 17 5.0 … 2004 … Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Fork/Join Framework (jsr166y) 7 8 6 2006 Project Lambda …. 2011 … 2014
  • 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; } 18 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(); 19 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) 20 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.” 21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 22. Heterogeneous Java and Heterogeneous Computing  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 22 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 23. New Challenges – Array-wise programming concepts Java and Heterogeneous Computing Array-wise programming Exploit the hardware  Java is a concurrent language with  Java JDK 8 includes parallel concurrent and parallel programming support built into the core 23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. decomposition and programming tools out of the box.
  • 24. New Challenges – “WORA” Becomes Local Java and Heterogeneous Computing  Transitioning from write once, run anywhere “WORA” to a world where one JVM can access multiple ISAs at once JVM 1 JVM OS 1 OS 2 OS ISA 1 ISA 2 ISA 1 ISA 2 Chip 1 Chip 2 Chip 1 Chip 2 Mem 1 24 JVM 2 Mem 2 Mem 1 Mem 2 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 25. New Challenges – Route Work to Best Resource Java and Heterogeneous Computing  Some cores optimized for: – High Throughput JVM – Low latency OS ? – Low Power  Where should work be routed? 25 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. ISA 1 ISA 2 Chip 1 Chip 2 Mem 1 – Special Accelerators Mem 2
  • 26. New Challenges – Non-Uniform Memory Access Java and Heterogeneous Computing  Heterogeneous systems have JVM 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 26 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. OS ISA 1 ISA 2 Chip 1 Chip 2 Mem 1 Memory Mem 2
  • 27. How do we meet these and other challenges? JVM OS ISA 1 Chip 1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Chip 2 Mem 1 27 ISA 2 Mem 2
  • 28. How do we meet these and other challenges? http://openjdk.java.net/projects/sumatra/ 28 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 29. Project Sumatra Java and Heterogeneous Computing  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 29 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 30. 30 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 31. Gary Frost Software Fellow 31 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 32. Sumatra Demo Java and Heterogeneous Computing  Histogram of male/female (5150) names  Found in selected works of ‘Charles Dickens’  So conceptually we have sequence of nested loops. for each selected book{ for each name{ for each occurrence of ‘name’ in ‘book’{ name.count++; } } } 32 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Can be done in parallel !
  • 33. Sumatra Demo Java and Heterogeneous Computing  Here is the actual Java 8 code at the heart of the 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++; ); ); 33 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 34. Sumatra Demo Java and Heterogeneous Computing  Java 8 can efficiently dispatch the enclosed lambda across multiple cores when the stream is marked as parallel() Arrays.stream(T[] array) .parallel() .forEach(t -> /* lambda */)  A Sumatra JVM will dispatch to CPU and HSA enabled GPU cores. – JVM converts (JITS) bytecode to HSAIL and executes via HSA Runtime 34 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 35. 35 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 36. HSA enablement of JAVA Java 7 Java 8 Beyond Java 8 OpenCL enabled Aparapi HSA enabled Aparapi Sumatra • AMD initiated Open Source project • Java 8 Lambda based API • Java API for data parallel algorithms • HSA and SVM enablement • Adds Native GPU acceleration to JVM • Java 8 Lambda/Stream API • No need to learn OpenCL • JVM generates HSAIL via JIT • No explicit buffer transfers • JVM dispatches to CPU or GPU depending on workload characteristics. Java Application Java JDK Stream + Lambda API APARAPI API APARAPI / Lambda API OpenCL™ 36 HSAIL HSA Finalizer & Runtime HSA Finalizer & Runtime JVM JVM JVM GPU ISA CPU JIT HSAIIL OpenCL™ Compiler and Runtime CPU ISA Java Application Java Application GPU Copyright © 2013, Oracle and/or its affiliates. All rights reserved. GPU ISA CPU ISA CPU GPU GPU ISA CPU ISA CPU GPU
  • 37. How you can help! Java and Heterogeneous Computing  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! http://openjdk.java.net/projects/sumatra/ 37 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 38. 38 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
  • 39. 39 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.