ITC Research Computing Support Using Matlab Effectively By: Ed Hall Research Computing Support Center Phone: 243-8800 Φ Fax: 243-8765

Slides:



Advertisements
Similar presentations
Operating-System Structures
Advertisements

Memory.
Part IV: Memory Management
Chapter 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.
Computer Science in Practice This course is an introduction to problems (and solutions) that arise in applied fields of computer science such as machine.
Chapter 7 Introduction to Arrays Part I Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Memory ManagementCS-502 Fall Memory Management CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th.
Chapter 5: Memory Management Dhamdhere: Operating Systems— A Concept-Based Approach Slide No: 1 Copyright ©2005 Memory Management Chapter 5.
Programming in MATLAB Week 14 – 4/28/09 Kate Musgrave
Lecture 9: SHELL PROGRAMMING (continued) Creating shell scripts!
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 9 – Real Memory Organization and Management Outline 9.1 Introduction 9.2Memory Organization.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Weizmann 2010 © 1 Introduction to Matlab & Data Analysis Tutorial 10: How to Write Efficient Programs in Matlab Please change directory to directory E:\Matlab.
Chapter 91 Memory Management Chapter 9   Review of process from source to executable (linking, loading, addressing)   General discussion of memory.
 Introduction Introduction  Definition of Operating System Definition of Operating System  Abstract View of OperatingSystem Abstract View of OperatingSystem.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
1 © 2012 The MathWorks, Inc. Speeding up MATLAB Applications.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
Introduction to M ATLAB EE 100 – EE Dept. - JUST.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Eng Ship Structures 1 Introduction to Matlab.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
1 ENERGY 211 / CME 211 Lecture 26 November 19, 2008.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
OSes: 11. FS Impl. 1 Operating Systems v Objectives –discuss file storage and access on secondary storage (a hard disk) Certificate Program in Software.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
CSCI Rational Purify 1 Rational Purify Overview Michel Izygon - Jim Helm.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Matlab for Engineers Gari Clifford © Centre for Doctoral Training in Healthcare Innovation Institute of Biomedical Engineering Department of.
Improving Matlab Performance CS1114
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Main Memory CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Processes and threads.
Chapter 2 Memory and process management
Chapter 3: Process Concept
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 9 – Real Memory Organization and Management
Introduction to Operating System (OS)
Scripts & Functions Scripts and functions are contained in .m-files
MATLAB DENC 2533 ECADD LAB 9.
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Matlab review Matlab is a numerical analysis system
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Memory Allocation CS 217.
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Chapter 8: Memory Management strategies
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Chapter 3: Processes.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Presentation transcript:

ITC Research Computing Support Using Matlab Effectively By: Ed Hall Research Computing Support Center Phone: Φ Fax:

Matlab Overview

UVA Matlab Resource webpage Matlab tutorial: Getting Started arn_matlab.shtml arn_matlab.shtml

Matlab Programming

Matlab M-files

Matlab Function M-files

Maximizing MATLAB Performance Techniques for Improving Performance Performance Acceleration Sample Accelerated Program Measuring Performance Making Efficient Use of Memory

Techniques for Improving Performance Vectorizing loops

Vectorization (cont.) Logical indexing of arrays

Vectorization (cont.)

Preallocating Arrays Avoids overhead of dynamic resizing Reduces memory fragmentation Use array appropriate preallocation

Preallocation (cont.) Preallocating a Nondouble Matrix Use repmat to enlarge arrays

Other Ways to Speed Performance Coding loops in a MEX-file for speed using Matlab compiler Functions M-files are faster than scripts Load and Save are faster than File I/O Functions Avoid large background processes

Performance Acceleration JIT-Accelerator, new in Matlab 6.5 Make MATLAB as fast as C and Fortran Most improvement in self-contained loops As fast as vectorized code Improvement may vary depending on code

What MATLAB Accelerates Performance enhancement supported on subset of Matlab

What Matlab Accelerates (cont.) Arrays shapes of <= 3 dimensions for loops faster as long as: Conditional statements (if, elseif, while, switch) that evaluate to a scalar Overhead of manipulating small arrays

What MATLAB Doesn’t Accelerate Some data types and array shapes Calls to other functions (M-File of MEX) More than one operation on a line First instruction disqualifies entire line

What MATLAB Doesn’t Accelerate Changing data types or variable shapes Using complex constants in scripts

Perfomance Acceleration (cont.) How Vectorization and Preallocation fit in Acceleration functionally equivalent to vectorization Choose method most understandable Preallocation still important Avoid running in debug mode Aviod command echoing

Measuring Performance Profiling measure where program spends the most time Create simple implementation dealing with obvious performance issues Use profiler to identify performance bottlenecks (80/20 rule) Identify time-costly functions and where they are called

Measuring Performance (cont.) Problems identified by profiler solved by: Avoiding unnecessary computation Changing algorithm to avoid time-costly functions Avoiding recomputation by storing results for future use Want most time spent on calls to small number of builtin functions

Matlab Profiler GUI interface to profile function See “Matlab News & Notes” example Process for Improving Performance

Matlab Profiler (cont.)

Matlab Profile Function Command line profiler >>profile on –detail builtin –history >>(Execute your M-file) >>profile report >>profile off Some features not in GUI Profiler

Making Efficient Use of Memory Memory management functions

Memory Management Functions (cont.)

Ways to Conserve Memory

Compressing data in memory Memory fragmentaion prevents contiguous memory block to store new large variable “Out of Memory” message Pack function compresses data in memory, freeing large contiguous blocks

Ways to Conserve Memory

Unix-Specific Memory Topics Freeing clear memory on Unix Matlab does not free up cleared memory in Unix until it Matlab exits Save workspace variables Exit Matlab Startup Matlab Load variables back in new workspace

Unix-Specific Memory Topics Additional Memory used to execute external commands “Out of Memory” error when executing Unix command from within Matlab (using shell escape (!) operator) Unix allocates as much memory to subprocess as parent process

Unix-Specific Memory Topics Reusing Heap Memory Matlab request memory from Unix when not enough available in Matlab heap

Matlab Compiler Converts function M-files to C or C++ source code Uses native compiler to create executables Creates MEX-file from function M-file, e.g. function.m >>mcc –x function Creates stand-alone executable from function M-file >>mcc –m function

Matlab Compiler

Unix-Specific Compiler Topics Setting LD_LIBRARY_PATH (e.g. in.kshrc) to locate shared libraries for stand-alone executables

Running Matlab in Batch Mode On a Unix platform

Further Resources Using Matlab: Programming and Data Types b_prog.shtml Code Vectorization Guide Matlab Compiler User’s Guide ler3.pdf ler3.pdf