GPU Programming with Java

18
GPU programming with Java Pramuditha Aravinda. Kelum Senanayake.

description

Graphics processing unit or GPU (also occasionally called visual processing unit or VPU) is a specialized microprocessor that offloads and accelerates graphics rendering from the central (micro) processor. Modern GPUs are very efficient at manipulating computer graphics, and their highly parallel structure makes them more effective than general-purpose CPUs for a range of complex algorithms. In CPU, only a fraction of the chip does computations where as the GPU devotes more transistors to data processing. GPGPU is a programming methodology based on modifying algorithms to run on existing GPU hardware for increased performance. Unfortunately, GPGPU programming is significantly more complex than traditional programming for several reasons.

Transcript of GPU Programming with Java

Page 1: GPU Programming with Java

GPU programming with Java

Pramuditha Aravinda.

Kelum Senanayake.

Page 2: GPU Programming with Java

Outline

What is GPU.

CPU vs. GPU Architecture.

What is Stream processing.

General Purpose GPU.

CUDA.

OpenCL

Demo

Page 3: GPU Programming with Java

What is GPU Graphics processing unit.

Specialized microprocessor.

Very efficient at manipulating computer graphics.

Offloads and accelerates graphics rendering from the

CPU.

Dedicated to calculating floating point operations.

Highly parallel structure.

More effective for a range of complex algorithms.

GPU can be present on,

Video card.

Motherboard

CPU die (certain Core Intel CPUs)

Page 4: GPU Programming with Java

CPU vs. GPU Architecture

The GPU devotes more transistors to data processing.

GPU : A Highly Parallel, Multithreaded, Manycore Processor

Page 5: GPU Programming with Java

CPU vs. GPU contd…

Page 6: GPU Programming with Java

What is Stream processing

Is a computer programming paradigm, related to SIMD.

Allows applications to easily exploit a limited form of

parallel processing.

Terminology

Stream :- A set of data

Kernel functions :- A series of operations

Uniform streaming :- One kernel function is applied to all

elements in the stream.

Stream processing is driven by a data-centric model

Image, video and digital signal processing

Less efficient in general purpose processing with more

randomized data access (such as databases)

Page 7: GPU Programming with Java

General Purpose GPU

The GPU is, by design, a stream processing system.

GPGPU is a programming methodology.

Modifying algorithms to run on existing GPU hardware

Capable of performing simple operations on a stream of

input data with amazing speed.

Allows software developers to use stream processing on

non-graphics data.

Page 8: GPU Programming with Java

How hard is it?

The languages are not very easy to use. Most GPU cards

still operate on assembly language.

The process flow is unique. Typically simple branching

statement, such as if statements, offer such a performance

penalty that it is often faster to process both conditions.

The unique Stream-In-Stream-Out design is not typically

used in CPU programs.

The need to work with geometric primitives in order to

push mathematical inputs to the system.

Rapidly growing community.

Page 9: GPU Programming with Java

Programming GPUs!

Plenty of interfaces

Compute Unified Device Architecture (CUDA)

OpenCL

OpenGL Shader Language (GLSL)

DirectX/DirectCompute/HLSL

ATI Stream

Page 10: GPU Programming with Java

CUDA

Compute Unified Device Architecture.

Parallel computing architecture developed by NVIDIA.

Programmers use C for CUDA.

C with NVIDIA extensions and certain restrictions.

Third party wrappers are also available for Python, Perl,

Fortran, Java, Ruby, Lua, MATLAB and IDL.

Currently used in,

SETI@Home

Distributed Calculations, such as predicting the native

conformation of proteins

Accelerated inter conversion of video file formats

Physical simulations, in particular in fluid dynamics

Page 11: GPU Programming with Java

CUDA Processing Flow

Page 12: GPU Programming with Java

OpenCL

Open Computing Language.

Managed by the non-profit technology consortium

Khronos Group

Framework for writing programs that execute across

heterogeneous platforms consisting of CPUs, GPUs, and

other processors.

Includes a language (based on C99) for writing kernels.

APIs to define and then control the platforms.

Supports both AMD/ATI and NVIDIA.

Page 13: GPU Programming with Java

Programming GPU with Java and

OpenCL

We need to program using a GPGPU driver

However most GPGPU drivers are available as a native dll

only.

We need another layer to interface to Java runtime.

Called Java Binding

Page 14: GPU Programming with Java

Java Binding

UserProgram.class

Jocl.jar

Jocl.dll

OpenCL.dll

Page 15: GPU Programming with Java

Prerequisites - Hardware

OpenCL capable graphic card.

nVidea – All CUDA enabled GPU have OpenCL support.

GeForce 8xxx or higher with 256MB minimum.

http://www.nvidia.com/object/cuda_gpus.html

AMD ATI Radeon™ HD 5400 or higher, AMD Radeon™

HD 6800 series or higher.

AMD X86 CPU w/ SSE 2.x or later are also supported.

http://developer.amd.com/gpu/AMDAPPSDK/pages/DriverCom

patibility.aspx

Page 16: GPU Programming with Java

Prerequisites - Software

OpenCL driver. – for nVidia GPUs, Usually OpenCL

drivers are distributed with graphic card drivers.

http://developer.nvidia.com/object/opencl-download.html

Java bindings for OpenCL. – Usually there are two parts

Platform dependent dll. e.g. jocl-windows-x86.dll

Platform independent jar file. Jocl.jar

There are few Implementations.

http://jogamp.org/deployment/webstart/archive/jocl-0.9-b1-

20101213-windows-i586.zip

JDK

http://www.oracle.com/technetwork/java/javase/downloads/ind

ex.html

Page 17: GPU Programming with Java

Demo Program

Based on sample program available at

http://jogamp.org/wiki/index.php/JOCL_Tutorial

Page 18: GPU Programming with Java