Modeling and Simulating Social Systems with MATLAB

Size: px
Start display at page:

Download "Modeling and Simulating Social Systems with MATLAB"

Transcription

1 Modeling and Simulating Social Systems with MATLAB Lecture 6 Optimization and Parallelization Olivia Woolley, Tobias Kuhn, Dario Biasini, Dirk Helbing Chair of Sociology, in particular of Modeling and Simulation ETH Zürich

2 Schedule of the course Introduction to MATLAB Working on projects (seminar thesis) Introduction to social-science modeling and simulations Handing in seminar thesis and giving a presentation canceled Modeling and Simulating Social Systems with MATLAB 2

3 How to Optimize your Program General Remarks: Carefully plan the workflow of your program Store intermediate results and re-use them Do not visualize in real time if not necessary Modeling and Simulating Social Systems with MATLAB 3

4 How to Optimize your Program Strategy: The design and structure of your program is the place to most easily gain performance - Try to have an overall plan of your code before you start writing in Matlab Use matlab functions to run your program, they are best performance-optimized - Make your code as modular as possible. Divide it into independent functions and put these together to generate your simulation. In a second step optimize each routine for individual speed & test its performance Modeling and Simulating Social Systems with MATLAB 4

5 MATLAB-specific Performance Issues Vectorizing: A large performance gain can achieved by vectorizing for or while loops Instead of iteratively calculating the results, the loops are expressed as matrix operations for which MATLAB is optimized e.g. instead of: simply use: for i=1:n indices=1:n x(i)=i^2 x=indices.^2 end For large N, differences in speed can be quite large Modeling and Simulating Social Systems with MATLAB 5

6 MATLAB-specific Performance Issues Vectorizing: There are a number of functions specifically used in the context of vectorized computations, examples are meshgrid or reshape - Meshgrid is useful if you are representing functions in many dimensions: will create a mesh for each dimension (vectors to matrix) and you can use these to matrify your operations - Reshape can be used to represent matrices as vectors (also useful in certain circumstances) There is an exhaustive documentation of vectorizing techniques available on the web Modeling and Simulating Social Systems with MATLAB 6

7 MATLAB-specific Performance Issues Memory Preallocation: Data structures (arrays, cell arrays) in MATLAB have a default memory allocated when created without specified size Resizing data structures is both bad for performance and memory efficiency Whenever possible initialize a data structure such that it does not have to be resized while the program is running Use commands zeros(n,m) and cell(n,m) - Speedup is significant (orders of magnitude) Modeling and Simulating Social Systems with MATLAB 7

8 MATLAB-specific Performance Issues Reusing Variables: If you need to store data structures outside your program, use the MATLAB save and load commands (superior to routines like fread or fwrite ) - Generally easiest to store data in.mat types. There are limits to amount of memory Matlab can use (this can be changed), in case this becomes an issue write variables to files. Can assign name dynamically: filename=[ iteration_ int2str(iteratorvar).mat ] save(filename, variabletosave ) %saves in iteration_iterator.mat file - This is also useful in case (for some reason) your program crashes in a next iteration- will not have lost all previous results. - Use clear varname to free up memory Modeling and Simulating Social Systems with MATLAB 8

9 Measuring Performance MATLAB has a profiler that tracks the performance of your code at the resolution of lines Start profiler with profile on, then you can see the results by calling profile viewer will give an overview of the time different functions take within your code It is often helpful to decide whether the number of times the code calls a particular function is reasonable. Because programs often have several layers, your code might not explicitly call the most time-consuming functions It is important to test the code for the full load of the program; performance might be very different for large data structures, and full number of iterations then for small testing iterations Especially true for parallelization where it may take time to set up the pool, and speed-ups may only be noticed in full model Modeling and Simulating Social Systems with MATLAB 9

10 Measuring Performance Alternatively use the tic and toc commands to test a particular routine tic starts the time counter toc stops the timer and displays the elapsed time Store the timer result in a variable: elapsedtime = toc You can also test several routines simultaneously using the ticid and the specific timing command toc(ticid) Can manually check which computation are taking the most time, and see if you can improve speed Modeling and Simulating Social Systems with MATLAB 10

11 Parallelization in MATLAB Normal Parallel Running in parallel means exactly what is sounds like: several iterations are run at the same time Of course if iterations take long time we can save a lot of time by running them parallely Matlab offers no built-in synchronization, but very easy to parallelize things Modeling and Simulating Social Systems with MATLAB 11

12 Parallelization in MATLAB Parallelization Toolbox: Note that there is always a computational overhead that needs paying when you go parallel and if your problem is too trivial then this overhead costs more than the calculation itself. - Split iterations, call parallel scheduler, put outputs together again. MATLAB's parallelization toolbox comes with a number of functions such as the parfor loop (only one we look at) A number of Matlab functions automatically parallelize their work stream if used in a pool - Look at: for a list of functions that suppot built-in parallelization Modeling and Simulating Social Systems with MATLAB 12

13 Parallelization in MATLAB When can I parallelize a loop? When performing large number of independent operations (no synch) - Generally things are parallelizable if the order the computations are done in does not matter: clearly this is the case for checking different parameter combinations and running a (stochastic) simulation several times. If you plan on parallelizing parameter sweeps, make sure you dont use global variables in your loop - Clearly cannot work. In general Matlab will let you know if the loop is parallelizable once you use a parallel function. Very useful for checking parameter combinations, may be able to check all combinations at once Modeling and Simulating Social Systems with MATLAB 13

14 Setting up Configurations Manager : Go to parallel -> ManageConfigurations If running things on your local computer, go to your local configuration manager, and use the right click to get to `properties` Change the number of workers available to the number you want (default is two) Modeling and Simulating Social Systems with MATLAB 14

15 How to use parallel for loops: Parfor Can use parfor loops in exactly the same way as regular for loops: matlabpool open N clear A parfor (i = 1:8, M) A(i) = i; end A matlabpool close Once matlabpool open is called, functions with built-in parallelization will also use their parallel versions Can also tell parfor how many cores to run on using M. Can use this to run nested parfor loops Note that you cannot break a parfor loop Modeling and Simulating Social Systems with MATLAB 15

16 How to use parallel for loops: Parfor matlabpool open N clear A parfor i = 1:8 A(i) = i; end A matlabpool close How many parallel workers? You can use up to 12 workers (more even in ver. 2014). Note that you are not limited to using at most the same number of workers as you have processors (or threads) on your comp. You can use more. How to choose number of cores? Test different pool sizes, and compare computation times. Mainly depends on how often you have to access memory in your loop: If often better fewer workers, if rarely can use many. For example adding two matrices, need to access values in matrix often. But only need to access memory once to initialize a simulation - can use many workers Modeling and Simulating Social Systems with MATLAB 16

17 The Multi-Agent Simulator Revisited Typical steps of an agent-based simulator: Initialization: - Initial state; parameters; environment Time loop: - Processing each time step Agents loop: - Processing each agent Update: - Updating agent i at time t Save data for further analysis Initialization Time loop Agents loop Update state end end Save data Modeling and Simulating Social Systems with MATLAB 17

18 The Multi-Agent Simulator Revisited Main Program 1. Initialization 2. Simulation 3. Saving Results Data Analysis Keep 1, 2, and 3 separated (as much as possible) Use structs for bundling different variable types Separate data generation and data analysis Modeling and Simulating Social Systems with MATLAB 18

19 The Multi-Agent Simulator Revisited Structs: Structs (structured arrays) can contain different kinds of data and can be used for input and output of functions: data = struct( property_a, 1, property_b, 'foo'); %create a struct data.property_a %call value stored in propery_a data.property_a=2 %set the value of propery_a to Modeling and Simulating Social Systems with MATLAB 19

20 Example of vectorization of parameter sets % set up parameter loops matlabpool open N % open cluster parfor i1=1:length(param_as) param_a = param_as(i1); for i2=1:length(param_bs) % set up loop for second parameter (could also parallelize this loop) param_b = param_bs(i2); % Repeat the same simulation nruns times for rcount=1:nruns simulation(param_a, param_b); end end end Modeling and Simulating Social Systems with MATLAB 20

21 The Multi-Agent Simulator Revisited Saving the results: Like shown before can save outputs and specify name dynamically, based on parameter or iteration (this way you are sure to know for what parameter you got the secific output). Can also set up directories to save outputs for different simulations dirname=['foldername_param' num2str(parametervalue)] %specify directory name %using the parameter, for example mkdir(dirname) %make the directory... filename=[ iteration int2str(iteratorvar).mat ] fullpath=[dirname '/' filename] %specify full path where to save output (for windows) save(fullpath, vartosave') %save the output Modeling and Simulating Social Systems with MATLAB 21

22 Overview Vectorize as many operations as possible Preallocate memory Reuse variables Make code modular Parallelize if possible Use profiler and tic/toc to improve performance Modeling and Simulating Social Systems with MATLAB 22

23 Debugging Debugging can be very useful to figure out where problems are arising in your code. Useful, especially for long codes Basic debugging involves printing out values and double checking if these match values computed independently Matlab offers good debugging features to go through code and find sources of errors Modeling and Simulating Social Systems with MATLAB 23

24 Setting a Break Point Setting a break point will let you navigate through your code, and check values of variables The code is paused at the location of the break point, so typically you place a breakpoint right before the lines where you think you might have an error From there one can move down the code and test values of variables without having to print them all out Clearly cant debug parallel codes Modeling and Simulating Social Systems with MATLAB 24

25 Add a break point to the code where you want your simulation to halt by simply clicking next to the line # Then run the function in the Command Window as usual Use toolbar to move around in code Green arrow shows you where you are in code Modeling and Simulating Social Systems with MATLAB 25

26 Test the values assigned by simply calling the variable name(s) in Command Window and stepping through the code Here ran the function in debug mode 27 shows line at which break point was placed. Here checked value of the variable param. Can set several break points Modeling and Simulating Social Systems with MATLAB 26

27 References MATLAB Parallel Computing Toolbox section optimization Modeling and Simulating Social Systems with MATLAB 27

Speeding up MATLAB Applications The MathWorks, Inc.

Speeding up MATLAB Applications The MathWorks, Inc. Speeding up MATLAB Applications 2009 The MathWorks, Inc. Agenda Leveraging the power of vector & matrix operations Addressing bottlenecks Utilizing additional processing power Summary 2 Example: Block

More information

Parallel Computing with MATLAB

Parallel Computing with MATLAB Parallel Computing with MATLAB CSCI 4850/5850 High-Performance Computing Spring 2018 Tae-Hyuk (Ted) Ahn Department of Computer Science Program of Bioinformatics and Computational Biology Saint Louis University

More information

Parallel Processing Tool-box

Parallel Processing Tool-box Parallel Processing Tool-box Start up MATLAB in the regular way. This copy of MATLAB that you start with is called the "client" copy; the copies of MATLAB that will be created to assist in the computation

More information

SECTION 5: STRUCTURED PROGRAMMING IN MATLAB. ENGR 112 Introduction to Engineering Computing

SECTION 5: STRUCTURED PROGRAMMING IN MATLAB. ENGR 112 Introduction to Engineering Computing SECTION 5: STRUCTURED PROGRAMMING IN MATLAB ENGR 112 Introduction to Engineering Computing 2 Conditional Statements if statements if else statements Logical and relational operators switch case statements

More information

Daniel D. Warner. May 31, Introduction to Parallel Matlab. Daniel D. Warner. Introduction. Matlab s 5-fold way. Basic Matlab Example

Daniel D. Warner. May 31, Introduction to Parallel Matlab. Daniel D. Warner. Introduction. Matlab s 5-fold way. Basic Matlab Example to May 31, 2010 What is Matlab? Matlab is... an Integrated Development Environment for solving numerical problems in computational science. a collection of state-of-the-art algorithms for scientific computing

More information

MATLAB Parallel Computing Toolbox Benchmark for an Embarrassingly Parallel Application

MATLAB Parallel Computing Toolbox Benchmark for an Embarrassingly Parallel Application MATLAB Parallel Computing Toolbox Benchmark for an Embarrassingly Parallel Application By Nils Oberg, Benjamin Ruddell, Marcelo H. García, and Praveen Kumar Department of Civil and Environmental Engineering

More information

Matlab s Parallel Computation Toolbox

Matlab s Parallel Computation Toolbox Matlab s Parallel Computation Toolbox And the Parallel Interpolation of Commodity Futures Curves William Smith, March 2010 Verson 1.0 (check www.commoditymodels.com for any updates) Introduction Matlab

More information

Programming with MPI

Programming with MPI Programming with MPI p. 1/?? Programming with MPI Miscellaneous Guidelines Nick Maclaren Computing Service nmm1@cam.ac.uk, ext. 34761 March 2010 Programming with MPI p. 2/?? Summary This is a miscellaneous

More information

Modeling and Simulating Social Systems with MATLAB

Modeling and Simulating Social Systems with MATLAB Modeling and Simulating Social Systems with MATLAB Lecture 4 Cellular Automata Olivia Woolley, Tobias Kuhn, Dario Biasini, Dirk Helbing Chair of Sociology, in particular of Modeling and Simulation ETH

More information

Programming with MPI

Programming with MPI Programming with MPI p. 1/?? Programming with MPI Miscellaneous Guidelines Nick Maclaren nmm1@cam.ac.uk March 2010 Programming with MPI p. 2/?? Summary This is a miscellaneous set of practical points Over--simplifies

More information

This is the basis for the programming concept called a loop statement

This is the basis for the programming concept called a loop statement Chapter 4 Think back to any very difficult quantitative problem that you had to solve in some science class How long did it take? How many times did you solve it? What if you had millions of data points

More information

1 Motivation for Improving Matrix Multiplication

1 Motivation for Improving Matrix Multiplication CS170 Spring 2007 Lecture 7 Feb 6 1 Motivation for Improving Matrix Multiplication Now we will just consider the best way to implement the usual algorithm for matrix multiplication, the one that take 2n

More information

MATLAB Parallel Computing

MATLAB Parallel Computing MATLAB Parallel Computing John Burkardt Information Technology Department Virginia Tech... FDI Summer Track V: Using Virginia Tech High Performance Computing http://people.sc.fsu.edu/ jburkardt/presentations/fdi

More information

Modeling and Simulating Social Systems with MATLAB

Modeling and Simulating Social Systems with MATLAB Modeling and Simulating Social Systems with MATLAB Lecture 2 Statistics and Plotting in MATLAB Olivia Woolley, Tobias Kuhn, Dario Biasini, Dirk Helbing Chair of Sociology, in particular of Modeling and

More information

Parallel Computing with MATLAB

Parallel Computing with MATLAB Parallel Computing with MATLAB Jos Martin Principal Architect, Parallel Computing Tools jos.martin@mathworks.co.uk 2015 The MathWorks, Inc. 1 Overview Scene setting Task Parallel (par*) Why doesn t it

More information

Parallel Computing with MATLAB

Parallel Computing with MATLAB Parallel Computing with MATLAB Jos Martin Principal Architect, Parallel Computing Tools jos.martin@mathworks.co.uk 1 2013 The MathWorks, Inc. www.matlabexpo.com Code used in this presentation can be found

More information

Matlab for Engineers

Matlab for Engineers Matlab for Engineers Alistair Johnson 31st May 2012 Centre for Doctoral Training in Healthcare Innovation Institute of Biomedical Engineering Department of Engineering Science University of Oxford Supported

More information

Using Parallel Computing Toolbox to accelerate the Video and Image Processing Speed. Develop parallel code interactively

Using Parallel Computing Toolbox to accelerate the Video and Image Processing Speed. Develop parallel code interactively Using Parallel Computing Toolbox to accelerate the Video and Image Processing Speed Presenter: Claire Chuang TeraSoft Inc. Agenda Develop parallel code interactively parallel applications for faster processing

More information

Lecture x: MATLAB - advanced use cases

Lecture x: MATLAB - advanced use cases Lecture x: MATLAB - advanced use cases Parallel computing with Matlab s toolbox Heikki Apiola and Juha Kuortti February 22, 2018 Aalto University juha.kuortti@aalto.fi, heikki.apiola@aalto.fi Parallel

More information

Speeding up MATLAB Applications Sean de Wolski Application Engineer

Speeding up MATLAB Applications Sean de Wolski Application Engineer Speeding up MATLAB Applications Sean de Wolski Application Engineer 2014 The MathWorks, Inc. 1 Non-rigid Displacement Vector Fields 2 Agenda Leveraging the power of vector and matrix operations Addressing

More information

Matlab: Parallel Computing Toolbox

Matlab: Parallel Computing Toolbox Matlab: Parallel Computing Toolbox Shuxia Zhang University of Mineesota e-mail: szhang@msi.umn.edu or help@msi.umn.edu Tel: 612-624-8858 (direct), 612-626-0802(help) Outline Introduction - Matlab PCT How

More information

TUNING MATLAB FOR BETTER PERFORMANCE. Keith Ma Boston University Research Computing Services

TUNING MATLAB FOR BETTER PERFORMANCE. Keith Ma Boston University Research Computing Services TUNING MATLAB FOR BETTER PERFORMANCE Keith Ma Boston University Research Computing Services 2 Tutorial Overview General advice about optimization A typical workflow for performance optimization MATLAB's

More information

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Comp 541 Digital Logic and Computer Design Prof. Montek Singh Fall 2017 Lab #3A: Sequential Design: Counters Issued Wed 9/6/17; Due Wed 9/13/17 (11:59pm)

More information

Optimizing and Accelerating Your MATLAB Code

Optimizing and Accelerating Your MATLAB Code Optimizing and Accelerating Your MATLAB Code Sofia Mosesson Senior Application Engineer 2016 The MathWorks, Inc. 1 Agenda Optimizing for loops and using vector and matrix operations Indexing in different

More information

Supplement: Visual C++ Debugging

Supplement: Visual C++ Debugging Supplement: Visual C++ Debugging For Introduction to C++ Programming By Y. Daniel Liang Note: The screen shots are taken from VC++ 2010. It is the same for the later version. 1 Introduction The debugger

More information

Using the MATLAB Parallel Computing Toolbox on the UB CCR cluster

Using the MATLAB Parallel Computing Toolbox on the UB CCR cluster Using the MATLAB Parallel Computing Toolbox on the UB CCR cluster N. Barlow, C. Cornelius, S. Matott Center for Computational Research University at Buffalo State University of New York October, 1, 2013

More information

Notes: Parallel MATLAB

Notes: Parallel MATLAB Notes: Parallel MATLAB Adam Charles Last Updated: August 3, 2010 Contents 1 General Idea of Parallelization 2 2 MATLAB implementation 2 2.1 Parallel Workspaces and Interactive Pools........................

More information

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Comp 541 Digital Logic and Computer Design Fall 2014 Lab #4: Sequential Design: Counters Issued Wed 9/10/14; Due Wed 9/17/14 (11:59pm) This lab assignment

More information

Designing Applications that See Lecture 4: Matlab Tutorial

Designing Applications that See Lecture 4: Matlab Tutorial stanford hci group / cs377s Designing Applications that See Lecture 4: Matlab Tutorial Dan Maynes-Aminzade 23 January 2007 Designing Applications that See http://cs377s.stanford.edu Reminders Assignment

More information

CMSC 714 Lecture 6 MPI vs. OpenMP and OpenACC. Guest Lecturer: Sukhyun Song (original slides by Alan Sussman)

CMSC 714 Lecture 6 MPI vs. OpenMP and OpenACC. Guest Lecturer: Sukhyun Song (original slides by Alan Sussman) CMSC 714 Lecture 6 MPI vs. OpenMP and OpenACC Guest Lecturer: Sukhyun Song (original slides by Alan Sussman) Parallel Programming with Message Passing and Directives 2 MPI + OpenMP Some applications can

More information

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Objectives To introduce the notion of a

More information

Accelerating System Simulations

Accelerating System Simulations Accelerating System Simulations 김용정부장 Senior Applications Engineer 2013 The MathWorks, Inc. 1 Why simulation acceleration? From algorithm exploration to system design Size and complexity of models increases

More information

Parallel and Distributed Computing Programming Assignment 1

Parallel and Distributed Computing Programming Assignment 1 Parallel and Distributed Computing Programming Assignment 1 Due Friday, February 7 (Note Change in Due Date) For programming assignment 1, you should write two C programs. One should provide an estimate

More information

Summer 2009 REU: Introduction to Some Advanced Topics in Computational Mathematics

Summer 2009 REU: Introduction to Some Advanced Topics in Computational Mathematics Summer 2009 REU: Introduction to Some Advanced Topics in Computational Mathematics Moysey Brio & Paul Dostert July 4, 2009 1 / 18 Sparse Matrices In many areas of applied mathematics and modeling, one

More information

Performance Analysis of Matlab Code and PCT

Performance Analysis of Matlab Code and PCT p. 1/45 Performance Analysis of Matlab Code and PCT Xiaoxu Guan High Performance Computing, LSU March 21, 2018 1 tic; 2 nsize = 10000; 3 for k = 1:nsize 4 B(k) = sum( A(:,k) ); 5 6 toc; p. 2/45 Overview

More information

Parallel MATLAB at VT

Parallel MATLAB at VT Parallel MATLAB at VT Gene Cliff (AOE/ICAM - ecliff@vt.edu ) James McClure (ARC/ICAM - mcclurej@vt.edu) Justin Krometis (ARC/ICAM - jkrometis@vt.edu) 11:00am - 11:50am, Thursday, 25 September 2014... NLI...

More information

Data Analysis with MATLAB. Steve Lantz Senior Research Associate Cornell CAC

Data Analysis with MATLAB. Steve Lantz Senior Research Associate Cornell CAC Data Analysis with MATLAB Steve Lantz Senior Research Associate Cornell CAC Workshop: Data Analysis on Ranger, October 12, 2009 MATLAB Has Many Capabilities for Data Analysis Preprocessing Scaling and

More information

Why C? Because we can t in good conscience espouse Fortran.

Why C? Because we can t in good conscience espouse Fortran. C Tutorial Why C? Because we can t in good conscience espouse Fortran. C Hello World Code: Output: C For Loop Code: Output: C Functions Code: Output: Unlike Fortran, there is no distinction in C between

More information

High Performance Computing for BU Economists

High Performance Computing for BU Economists High Performance Computing for BU Economists Marc Rysman Boston University October 25, 2013 Introduction We have a fabulous super-computer facility at BU. It is free for you and easy to gain access. It

More information

Gustavo Alonso, ETH Zürich. Web services: Concepts, Architectures and Applications - Chapter 1 2

Gustavo Alonso, ETH Zürich. Web services: Concepts, Architectures and Applications - Chapter 1 2 Chapter 1: Distributed Information Systems Gustavo Alonso Computer Science Department Swiss Federal Institute of Technology (ETHZ) alonso@inf.ethz.ch http://www.iks.inf.ethz.ch/ Contents - Chapter 1 Design

More information

LabView instrumentoinnissa, 55492, 3op Labview in instrumentation

LabView instrumentoinnissa, 55492, 3op Labview in instrumentation LabView instrumentoinnissa, 55492, 3op Labview in instrumentation Lecturer: Heikki Ojala, heikki.ojala@helsinki.fi, room C204a Physicum Teaching assistant: Hannu Koskenvaara, hannu.koskenvaara@helsinki.fi,

More information

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation Why are threads useful? How does one use POSIX pthreads? Michael Swift 1 2 What s in a process? Organizing a Process A process

More information

Lecture #8: Performance or How I Learned to Stop Worrying and Love the Parallelism

Lecture #8: Performance or How I Learned to Stop Worrying and Love the Parallelism Lecture #8: Performance or How I Learned to Stop Worrying and Love the Parallelism Paul Hartke Phartke@stanford.edu Stanford EE183 April 29, 2002 Lab Stuff Lab #1 writeup due TODAY at midnight Keep considering

More information

Introduction. Like other programming languages, MATLAB has means for modifying the flow of a program

Introduction. Like other programming languages, MATLAB has means for modifying the flow of a program Flow control 1 Introduction Like other programming languages, MATLAB has means for modying the flow of a program All common constructs are implemented in MATLAB: for while then else switch try 2 FOR loops.

More information

Parallel and Distributed Computing with MATLAB Gerardo Hernández Manager, Application Engineer

Parallel and Distributed Computing with MATLAB Gerardo Hernández Manager, Application Engineer Parallel and Distributed Computing with MATLAB Gerardo Hernández Manager, Application Engineer 2018 The MathWorks, Inc. 1 Practical Application of Parallel Computing Why parallel computing? Need faster

More information

ˆ Note that we often make a trade-off between time and space. ˆ Time complexity ˆ Space complexity. ˆ Unlike time, we can reuse memory.

ˆ Note that we often make a trade-off between time and space. ˆ Time complexity ˆ Space complexity. ˆ Unlike time, we can reuse memory. ˆ We use O-notation to describe the asymptotic 1 upper bound of complexity of the algorithm. ˆ So O-notation is widely used to classify algorithms by how they respond to changes in its input size. 2 ˆ

More information

Lecture 3: MATLAB advanced use cases

Lecture 3: MATLAB advanced use cases Lecture 3: MATLAB advanced use cases Efficient programming in MATLAB Juha Kuortti and Heikki Apiola February 17, 2018 Aalto University juha.kuortti@aalto.fi Before we begin On this lecture, we will mostly

More information

Designing experiments Performing experiments in Java Intel s Manycore Testing Lab

Designing experiments Performing experiments in Java Intel s Manycore Testing Lab Designing experiments Performing experiments in Java Intel s Manycore Testing Lab High quality results that capture, e.g., How an algorithm scales Which of several algorithms performs best Pretty graphs

More information

Modeling a 4G LTE System in MATLAB

Modeling a 4G LTE System in MATLAB Modeling a 4G LTE System in MATLAB Part 2: Simulation acceleration Houman Zarrinkoub PhD. Signal Processing Product Manager MathWorks houmanz@mathworks.com 2011 The MathWorks, Inc. 1 Why simulation acceleration?

More information

Optimization and Implementation of Embedded Signal Processing Algorithms Jonas Rutström Senior Application Engineer

Optimization and Implementation of Embedded Signal Processing Algorithms Jonas Rutström Senior Application Engineer Optimization and Implementation of Embedded Signal Processing Algorithms Jonas Rutström Senior Application Engineer 2016 The MathWorks, 1 Inc. Two important questions in embedded design... 1. What s your

More information

Parallel and Distributed Computing with MATLAB The MathWorks, Inc. 1

Parallel and Distributed Computing with MATLAB The MathWorks, Inc. 1 Parallel and Distributed Computing with MATLAB 2018 The MathWorks, Inc. 1 Practical Application of Parallel Computing Why parallel computing? Need faster insight on more complex problems with larger datasets

More information

Lecture Notes on Loop Transformations for Cache Optimization

Lecture Notes on Loop Transformations for Cache Optimization Lecture Notes on Loop Transformations for Cache Optimization 5-: Compiler Design André Platzer Lecture Introduction In this lecture we consider loop transformations that can be used for cache optimization.

More information

An Introduction to OpenACC. Zoran Dabic, Rusell Lutrell, Edik Simonian, Ronil Singh, Shrey Tandel

An Introduction to OpenACC. Zoran Dabic, Rusell Lutrell, Edik Simonian, Ronil Singh, Shrey Tandel An Introduction to OpenACC Zoran Dabic, Rusell Lutrell, Edik Simonian, Ronil Singh, Shrey Tandel Chapter 1 Introduction OpenACC is a software accelerator that uses the host and the device. It uses compiler

More information

GPU-Accelerated Beat Detection for Dancing Monkeys

GPU-Accelerated Beat Detection for Dancing Monkeys GPU-Accelerated Beat Detection for Dancing Monkeys Philip Peng University of Pennsylvania Yanjie Feng University of Pennsylvania Abstract In music-based rhythm games, the game system needs to create patterns

More information

LOADRUNNER INTERVIEW QUESTIONS

LOADRUNNER INTERVIEW QUESTIONS LOADRUNNER INTERVIEW QUESTIONS 1. Why should we automate the performance testing? It s a discipline that leverages products, people and processes to reduce the risk of application upgrade or patch deployment.

More information

MATLAB Distributed Computing Server (MDCS) Training

MATLAB Distributed Computing Server (MDCS) Training MATLAB Distributed Computing Server (MDCS) Training Artemis HPC Integration and Parallel Computing with MATLAB Dr Hayim Dar hayim.dar@sydney.edu.au Dr Nathaniel Butterworth nathaniel.butterworth@sydney.edu.au

More information

Chapter 4: Programming with MATLAB

Chapter 4: Programming with MATLAB Chapter 4: Programming with MATLAB Topics Covered: Programming Overview Relational Operators and Logical Variables Logical Operators and Functions Conditional Statements For Loops While Loops Debugging

More information

Improving the Performance of the Molecular Similarity in Quantum Chemistry Fits. Alexander M. Cappiello

Improving the Performance of the Molecular Similarity in Quantum Chemistry Fits. Alexander M. Cappiello Improving the Performance of the Molecular Similarity in Quantum Chemistry Fits Alexander M. Cappiello Department of Chemistry Carnegie Mellon University Pittsburgh, PA 15213 December 17, 2012 Abstract

More information

컴퓨터비전의최신기술 : Deep Learning, 3D Vision and Embedded Vision

컴퓨터비전의최신기술 : Deep Learning, 3D Vision and Embedded Vision 1 컴퓨터비전의최신기술 : Deep Learning, 3D Vision and Embedded Vision 김종남 Application Engineer 2017 The MathWorks, Inc. 2 Three Main Topics New capabilities for computer vision system design: Deep Learning 3-D Vision

More information

SECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB

SECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB SECTION 2: PROGRAMMING WITH MATLAB MAE 4020/5020 Numerical Methods with MATLAB 2 Functions and M Files M Files 3 Script file so called due to.m filename extension Contains a series of MATLAB commands The

More information

Parallel Computing with MATLAB on Discovery Cluster

Parallel Computing with MATLAB on Discovery Cluster Parallel Computing with MATLAB on Discovery Cluster Northeastern University Research Computing: Nilay K Roy, MS Computer Science, Ph.D Computational Physics Lets look at the Discovery Cluster Matlab environment

More information

Supporting Data Parallelism in Matcloud: Final Report

Supporting Data Parallelism in Matcloud: Final Report Supporting Data Parallelism in Matcloud: Final Report Yongpeng Zhang, Xing Wu 1 Overview Matcloud is an on-line service to run Matlab-like script on client s web browser. Internally it is accelerated by

More information

COGS 119/219 MATLAB for Experimental Research. Fall Functions

COGS 119/219 MATLAB for Experimental Research. Fall Functions COGS 119/219 MATLAB for Experimental Research Fall 2016 - Functions User-defined Functions A user-defined function is a MATLAB program that is created by a user, saved as a function file, and then can

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 4: Programming in Matlab Yasemin Bekiroglu (yaseminb@kth.se) Florian Pokorny(fpokorny@kth.se) Overview Overview Lecture 4: Programming in Matlab Wrap Up More on Scripts and Functions Wrap Up Last

More information

Debugging. CSE 2231 Supplement A Annatala Wolf

Debugging. CSE 2231 Supplement A Annatala Wolf Debugging CSE 2231 Supplement A Annatala Wolf Testing is not debugging! The purpose of testing is to detect the existence of errors, not to identify precisely where the errors came from. Error messages

More information

Modeling and Simulating Social Systems with MATLAB

Modeling and Simulating Social Systems with MATLAB Modeling and Simulating Social Systems with MATLAB Lecture 8 Introduction to Graphs/Networks Olivia Woolley, Stefano Balietti, Lloyd Sanders, Dirk Helbing Chair of Sociology, in particular of Modeling

More information

Chemical Engineering 541

Chemical Engineering 541 Chemical Engineering 541 Computer Aided Design Methods Matlab Tutorial 1 Overview 2 Matlab is a programming language suited to numerical analysis and problems involving vectors and matricies. Matlab =

More information

Shared Memory Programming Model

Shared Memory Programming Model Shared Memory Programming Model Ahmed El-Mahdy and Waleed Lotfy What is a shared memory system? Activity! Consider the board as a shared memory Consider a sheet of paper in front of you as a local cache

More information

Introduction to the ThreadX Debugger Plugin for the IAR Embedded Workbench C-SPYDebugger

Introduction to the ThreadX Debugger Plugin for the IAR Embedded Workbench C-SPYDebugger C-SPY plugin Introduction to the ThreadX Debugger Plugin for the IAR Embedded Workbench C-SPYDebugger This document describes the IAR C-SPY Debugger plugin for the ThreadX RTOS. The ThreadX RTOS awareness

More information

Comments on A structure-preserving method for the quaternion LU decomposition in quaternionic quantum theory by Minghui Wang and Wenhao Ma

Comments on A structure-preserving method for the quaternion LU decomposition in quaternionic quantum theory by Minghui Wang and Wenhao Ma Comments on A structure-preserving method for the quaternion LU decomposition in quaternionic quantum theory by Minghui Wang and Wenhao Ma Stephen J. Sangwine a a School of Computer Science and Electronic

More information

Introduction. Rehearse and Record Slide Shows. Advanced Presentation Options. Rehearsing Slide Show Timings. Page 1

Introduction. Rehearse and Record Slide Shows. Advanced Presentation Options. Rehearsing Slide Show Timings. Page 1 Advanced Presentation Options Introduction Page 1 There are many things to keep in mind when giving a presentation. How long will your presentation last? What will you say? If you're not in the same location

More information

OPEN THE HOTLINE CLIENT

OPEN THE HOTLINE CLIENT OPEN THE HOTLINE CLIENT Everything in the Hotline universe starts with the Client Toolbar; it launches all of the Client s major functions. 1 Double-click the Hotline icon on your desktop. The Hotline

More information

Scaling MATLAB. for Your Organisation and Beyond. Rory Adams The MathWorks, Inc. 1

Scaling MATLAB. for Your Organisation and Beyond. Rory Adams The MathWorks, Inc. 1 Scaling MATLAB for Your Organisation and Beyond Rory Adams 2015 The MathWorks, Inc. 1 MATLAB at Scale Front-end scaling Scale with increasing access requests Back-end scaling Scale with increasing computational

More information

Welcome to Lab! Feel free to get started until we start talking! The lab document is located on the course website:

Welcome to Lab! Feel free to get started until we start talking! The lab document is located on the course website: Welcome to Lab! Feel free to get started until we start talking! The lab document is located on the course website: https://users.wpi.edu/~sjarvis/ece2049_smj/ece2049_labs.html You do not need to keep

More information

EL2310 Scientific Programming

EL2310 Scientific Programming (pronobis@kth.se) Overview Overview Wrap Up More on Scripts and Functions Basic Programming Lecture 2 Lecture 3 Lecture 4 Wrap Up Last time Loading data from file: load( filename ) Graphical input and

More information

Amdahl s Law. AMath 483/583 Lecture 13 April 25, Amdahl s Law. Amdahl s Law. Today: Amdahl s law Speed up, strong and weak scaling OpenMP

Amdahl s Law. AMath 483/583 Lecture 13 April 25, Amdahl s Law. Amdahl s Law. Today: Amdahl s law Speed up, strong and weak scaling OpenMP AMath 483/583 Lecture 13 April 25, 2011 Amdahl s Law Today: Amdahl s law Speed up, strong and weak scaling OpenMP Typically only part of a computation can be parallelized. Suppose 50% of the computation

More information

Effective Data-Race Detection for the Kernel

Effective Data-Race Detection for the Kernel Effective Data-Race Detection for the Kernel John Erickson, Madanlal Musuvathi, Sebastian Burckhardt, Kirk Olynyk Microsoft Research Presented by Thaddeus Czauski 06 Aug 2011 CS 5204 2 How do we prevent

More information

TotalView. Debugging Tool Presentation. Josip Jakić

TotalView. Debugging Tool Presentation. Josip Jakić TotalView Debugging Tool Presentation Josip Jakić josipjakic@ipb.ac.rs Agenda Introduction Getting started with TotalView Primary windows Basic functions Further functions Debugging parallel programs Topics

More information

Shared Memory Programming With OpenMP Computer Lab Exercises

Shared Memory Programming With OpenMP Computer Lab Exercises Shared Memory Programming With OpenMP Computer Lab Exercises Advanced Computational Science II John Burkardt Department of Scientific Computing Florida State University http://people.sc.fsu.edu/ jburkardt/presentations/fsu

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 11: Structures and Memory (yaseminb@kth.se) Overview Overview Lecture 11: Structures and Memory Structures Continued Memory Allocation Lecture 11: Structures and Memory Structures Continued Memory

More information

SQL Server. Management Studio. Chapter 3. In This Chapter. Management Studio. c Introduction to SQL Server

SQL Server. Management Studio. Chapter 3. In This Chapter. Management Studio. c Introduction to SQL Server Chapter 3 SQL Server Management Studio In This Chapter c Introduction to SQL Server Management Studio c Using SQL Server Management Studio with the Database Engine c Authoring Activities Using SQL Server

More information

Parallel Processing. Majid AlMeshari John W. Conklin. Science Advisory Committee Meeting September 3, 2010 Stanford University

Parallel Processing. Majid AlMeshari John W. Conklin. Science Advisory Committee Meeting September 3, 2010 Stanford University Parallel Processing Majid AlMeshari John W. Conklin 1 Outline Challenge Requirements Resources Approach Status Tools for Processing 2 Challenge A computationally intensive algorithm is applied on a huge

More information

Introduction to Performance Tuning & Optimization Tools

Introduction to Performance Tuning & Optimization Tools Introduction to Performance Tuning & Optimization Tools a[i] a[i+1] + a[i+2] a[i+3] b[i] b[i+1] b[i+2] b[i+3] = a[i]+b[i] a[i+1]+b[i+1] a[i+2]+b[i+2] a[i+3]+b[i+3] Ian A. Cosden, Ph.D. Manager, HPC Software

More information

OpenACC Course. Office Hour #2 Q&A

OpenACC Course. Office Hour #2 Q&A OpenACC Course Office Hour #2 Q&A Q1: How many threads does each GPU core have? A: GPU cores execute arithmetic instructions. Each core can execute one single precision floating point instruction per cycle

More information

High Performance Computing for BU Economists

High Performance Computing for BU Economists High Performance Computing for BU Economists Marc Rysman Boston University November 29, 2017 Introduction We have a fabulous super-computer facility at BU. It is free for you and easy to gain access. It

More information

Mit MATLAB auf der Überholspur Methoden zur Beschleunigung von MATLAB Anwendungen

Mit MATLAB auf der Überholspur Methoden zur Beschleunigung von MATLAB Anwendungen Mit MATLAB auf der Überholspur Methoden zur Beschleunigung von MATLAB Anwendungen Frank Graeber Application Engineering MathWorks Germany 2013 The MathWorks, Inc. 1 Speed up the serial code within core

More information

L Modeling and Simulating Social Systems with MATLAB

L Modeling and Simulating Social Systems with MATLAB 851-0585-04L Modeling and Simulating Social Systems with MATLAB Lecture 4 Cellular Automata Karsten Donnay and Stefano Balietti Chair of Sociology, in particular of Modeling and Simulation ETH Zürich 2011-03-14

More information

Vectorization: An Introduction. Dr. Marco A. Arocha INGE3016-MATLAB Summer 2015

Vectorization: An Introduction. Dr. Marco A. Arocha INGE3016-MATLAB Summer 2015 Vectorization: An Introduction Dr. Marco A. Arocha INGE3016-MATLAB Summer 2015 1 Array and Matrix Operations Operation Operator Explanation Array addition a + b array addition and matrix addition are identical

More information

A Linear-Time Heuristic for Improving Network Partitions

A Linear-Time Heuristic for Improving Network Partitions A Linear-Time Heuristic for Improving Network Partitions ECE 556 Project Report Josh Brauer Introduction The Fiduccia-Matteyses min-cut heuristic provides an efficient solution to the problem of separating

More information

Exercise Session 6 Computer Architecture and Systems Programming

Exercise Session 6 Computer Architecture and Systems Programming Systems Group Department of Computer Science ETH Zürich Exercise Session 6 Computer Architecture and Systems Programming Herbstsemester 2016 Agenda GDB Outlook on assignment 6 GDB The GNU Debugger 3 Debugging..

More information

CS4023 Week06 Lab Exercise

CS4023 Week06 Lab Exercise CS4023 Week06 Lab Exercise Lab Objective: In this week s lab we will look at writing a program that reads a large matrix of numbers and then reports all numbers that are equal to a reference value (or

More information

Programs in memory. The layout of memory is roughly:

Programs in memory. The layout of memory is roughly: Memory 1 Programs in memory 2 The layout of memory is roughly: Virtual memory means that memory is allocated in pages or segments, accessed as if adjacent - the platform looks after this, so your program

More information

Clickteam Fusion 2.5 Creating a Debug System - Guide

Clickteam Fusion 2.5 Creating a Debug System - Guide INTRODUCTION In this guide, we will look at how to create your own 'debug' system in Fusion 2.5. Sometimes when you're developing and testing a game, you want to see some of the real-time values of certain

More information

Topics. File Buffer Cache for Performance. What to Cache? COS 318: Operating Systems. File Performance and Reliability

Topics. File Buffer Cache for Performance. What to Cache? COS 318: Operating Systems. File Performance and Reliability Topics COS 318: Operating Systems File Performance and Reliability File buffer cache Disk failure and recovery tools Consistent updates Transactions and logging 2 File Buffer Cache for Performance What

More information

The Mercury project. Zoltan Somogyi

The Mercury project. Zoltan Somogyi The Mercury project Zoltan Somogyi The University of Melbourne Linux Users Victoria 7 June 2011 Zoltan Somogyi (Linux Users Victoria) The Mercury project June 15, 2011 1 / 23 Introduction Mercury: objectives

More information

18-349: Introduction to Embedded Real-Time Systems

18-349: Introduction to Embedded Real-Time Systems 18-349: Introduction to Embedded Real-Time Systems Embedded Real-Time Systems Lecture 6: Timers and Interrupts Anthony Rowe Electrical and Computer Engineering Carnegie Mellon University Embedded Real-Time

More information

Skills Exam Objective Objective Number

Skills Exam Objective Objective Number Overview 1 LESSON SKILL MATRIX Skills Exam Objective Objective Number Starting Excel Create a workbook. 1.1.1 Working in the Excel Window Customize the Quick Access Toolbar. 1.4.3 Changing Workbook and

More information

INTRODUCTION TO MATLAB PARALLEL COMPUTING TOOLBOX

INTRODUCTION TO MATLAB PARALLEL COMPUTING TOOLBOX INTRODUCTION TO MATLAB PARALLEL COMPUTING TOOLBOX Keith Ma ---------------------------------------- keithma@bu.edu Research Computing Services ----------- help@rcs.bu.edu Boston University ----------------------------------------------------

More information

Adaptive Algorithms and Parallel Computing

Adaptive Algorithms and Parallel Computing Adaptive Algorithms and Parallel Computing Multicore and Multimachine Computing with MATLAB (Part 1) Academic year 2014-2015 Simone Scardapane Content of the Lecture Main points: Parallelizing loops with

More information

개발과정에서의 MATLAB 과 C 의연동 ( 영상처리분야 )

개발과정에서의 MATLAB 과 C 의연동 ( 영상처리분야 ) 개발과정에서의 MATLAB 과 C 의연동 ( 영상처리분야 ) Application Engineer Caleb Kim 2016 The MathWorks, Inc. 1 Algorithm Development with MATLAB for C/C++ Programmers Objectives Use MATLAB throughout algorithm development

More information