You are on page 1of 25

Parallel Computing on the Desktop

Dave Forstot Senior Application Engineer

2011 The MathWorks, Inc. 1

A Question to Consider

Do you want to speed up your algorithms?


If so
Do you have a multi-core or multi-processor computer? Do you have a high-end graphics processing unit (GPU)?

Agenda

Introduction to the Parallel Computing Tools


Using Multi-core/Multi-processor Machines

Using Graphics Processing Units (GPUs)

Utilizing Additional Processing Power

Built-in multithreading
In core MATLAB For specific matrix operations Automatically enabled since R2008a

Parallel Computing Tools


Controlled by the MATLAB user For a variety of applications Leverage CPUs and GPUs to speed applications further

Parallel Computing on the Desktop


Use Parallel Computing Toolbox
Speed up parallel applications on local computer Take full advantage of desktop power by using CPUs and GPUs Separate computer cluster not required

Desktop Computer

Parallel Computing Toolbox

Scale Up to Clusters, Grids and Clouds

Computer Cluster Desktop Computer MATLAB Distributed Computing Server

Parallel Computing Toolbox

Scheduler

Parallel Computing enables you to

Task-Parallel

Data-Parallel

Speed up computations

Work with large data


11 26 41 12 27 42 13 28 43 14 29 44 15 30 45 16 31 46 17 32 47 17 33 48 19 34 49 20 35 50 21 36 51 22 37 52

Task 1

Task 2

Task 3

Task 4

Agenda

Introduction to the Parallel Computing Tools


Using Multi-core/Multi-processor Machines

Using Graphics Processing Units (GPUs)

Going Beyond Serial MATLAB Applications

Worker

Worker Worker

TOOLBOXES

Worker Worker

BLOCKSETS

Worker
Worker

Worker

Programming Parallel Applications

Greater Control

Ease of Use

10

Using Additional Cores/Processors (CPUs)

Support built into Toolboxes


Ease of Use

Greater Control
11

Example:
Built-in Support for Parallelism in Other Tools

Use built-in support for Parallel Computing Toolbox in Optimization Toolbox


Run optimization in parallel

Use pool of MATLAB workers

12

Other Tools Providing Parallel Computing Support


Optimization Toolbox Global Optimization Toolbox Statistics Toolbox SystemTest Simulink Design Optimization Bioinformatics Toolbox Model-Based Calibration Toolbox

Worker
Worker

TOOLBOXES BLOCKSETS

Worker Worker

Worker
Worker

Worker

Directly leverage functions in Parallel Computing Toolbox


13

Using Additional Cores/Processors (CPUs)

Support built into Toolboxes


Ease of Use

Greater Control

Simple programming constructs:

parfor

14

Task Parallel Applications

Worker

TOOLBOXES

BLOCKSETS

Worker Worker

Worker

Task 1

Task 2

Task 3

Task 4

Time

Time
15

Example:
Multiple Independent Simulations
1.2 1 0.8

Displacement (x)

Parameter sweep of ODE system Use pool of MATLAB workers Convert for to parfor Interleave serial and parallel code

0.6 0.4 0.2 0 -0.2

m = 5, b = 2, k = 2

m = 5, b = 5, k = 5
0 5 10 15 20 25

-0.4

Time (s)

5 m b x k x 0 x 1, 2,... 1, 2 ,...

16

Using Additional Cores/Processors (CPUs)

Support built into Toolboxes


Ease of Use

Greater Control

Simple programming constructs:

parfor
Full control of parallelization:

jobs and tasks

18

Agenda

Introduction to the Parallel Computing Tools


Using Multi-core/Multi-processor Machines

Using Graphics Processing Units (GPUs)

19

Gaining Performance with More Hardware


Using More Cores (CPUs) Using GPUs

Core 1

Core 2

Core 3 Cache

Core 4 Device Memory

20

What is a Graphics Processing Unit (GPU)

Originally used for graphics acceleration, now available for scientific calculations Parallel array of integer and floating point processors
Dozens to hundreds of processors per card Less flexible than regular CPU cores

Separate memory from system


21

* Parallel Computing Toolbox requires NVIDIA GPU with Compute Capability 1.3 or greater

Summary of Options for Targeting GPUs

Ease of Use

Use GPU array interface with MATLAB built-in functions Execute custom functions on elements of the GPU array Create kernels from existing CUDA code and PTX files

Greater Control

23

Performance: A\b with Double Precision

24

Performance Acceleration Options in the Parallel Computing Toolbox


Technology Example
parfor

MATLAB Workers
Required

Execution Target

matlabpool

CPU cores

user-defined tasks

createTask

Required

CPU cores

GPU-based parallelism

GPUArray

No

NVIDIA GPU with Compute Capability 1.3 or greater

25

Summary

Speed up parallel applications on desktop by using Parallel Computing Toolbox


Take full advantage of CPU and GPU hardware If required, use MATLAB Distributed Computing Server to
Scale up to clusters, grids and clouds Work with data that is too large to fit on to desktop computers

26

For more information

Visit www.mathworks.com/products/parallel-computing

27

You might also like