CS 221 – May 22 Timing (sections 2.6 and 3.6) Speedup Amdahl’s law – What happens if you can’t parallelize everything Complexity Commands to put in your.

Slides:



Advertisements
Similar presentations
2.3 Modeling Real World Data with Matrices
Advertisements

Section 13-4: Matrix Multiplication
Dependence Precedence. Precedence & Dependence Can we execute a 1000 line program with 1000 processors in one step? What are the issues to deal with in.
Matrices: Inverse Matrix
Computability Start complexity. Motivation by thinking about sorting. Homework: Finish examples.
Matrix Multiplication To Multiply matrix A by matrix B: Multiply corresponding entries and then add the resulting products (1)(-1)+ (2)(3) Multiply each.
Maths for Computer Graphics
Examples of Two- Dimensional Systolic Arrays. Obvious Matrix Multiply Rows of a distributed to each PE in row. Columns of b distributed to each PE in.
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
Insertion Sort for (i = 1; i < n; i++) {/* insert a[i] into a[0:i-1] */ int t = a[i]; int j; for (j = i - 1; j >= 0 && t < a[j]; j--) a[j + 1] = a[j];
Time Complexity s Sorting –Insertion sorting s Time complexity.
CS 280 Data Structures Professor John Peterson. Big O Notation We use a mathematical notation called “Big O” to talk about the performance of an algorithm.
Analysis of Algorithm.
1 Matrix Addition, C = A + B Add corresponding elements of each matrix to form elements of result matrix. Given elements of A as a i,j and elements of.
Insertion Sort for (int i = 1; i < a.length; i++) {// insert a[i] into a[0:i-1] int t = a[i]; int j; for (j = i - 1; j >= 0 && t < a[j]; j--) a[j + 1]
Determinants 2 x 2 and 3 x 3 Matrices. Matrices A matrix is an array of numbers that are arranged in rows and columns. A matrix is “square” if it has.
Exercise problems for students taking the Programming Parallel Computers course. Janusz Kowalik Piotr Arlukowicz Tadeusz Puzniakowski Informatics Institute.
Sequences Informally, a sequence is a set of elements written in a row. – This concept is represented in CS using one- dimensional arrays The goal of mathematics.
1 Lecture 2: Parallel computational models. 2  Turing machine  RAM (Figure )  Logic circuit model RAM (Random Access Machine) Operations supposed to.
IE 212: Computational Methods for Industrial Engineering
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Parallel Algorithms Sorting and more. Keep hardware in mind When considering ‘parallel’ algorithms, – We have to have an understanding of the hardware.
Using Arrays and File Handling
Overview Definitions Basic matrix operations (+, -, x) Determinants and inverses.
Matrix Arithmetic. A matrix M is an array of cell entries (m row,column ) and it must have rectangular dimensions (Rows x Columns). Example: 3x x.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Parallel Processing Sharing the load. Inside a Processor Chip in Package Circuits Primarily Crystalline Silicon 1 mm – 25 mm on a side 100 million to.
Defining a 2d Array A 2d array implements a MATRIX. Example: #define NUMROWS 5 #define NUMCOLS 10 int arr[NUMROWS][NUMCOLS];
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
4.5 Inverse of a Square Matrix
Matrix Algebra Section 7.2. Review of order of matrices 2 rows, 3 columns Order is determined by: (# of rows) x (# of columns)
Learning Objectives for Section 4.5 Inverse of a Square Matrix
Computer Organization CS224 Fall 2012 Lesson 52. Introduction  Goal: connecting multiple computers to get higher performance l Multiprocessors l Scalability,
CS 162 Intro to Programming II Insertion Sort 1. Assume the initial sequence a[0] a[1] … a[k] is already sorted k = 0 when the algorithm starts Insert.
CS 115 Lecture 17 2-D Lists Taken from notes by Dr. Neil Moore.
A rectangular array of numeric or algebraic quantities subject to mathematical operations. The regular formation of elements into columns and rows.
Python Fundamentals: Complex Data Structures Eric Shook Department of Geography Kent State University.
Matrices. Matrix A matrix is an ordered rectangular array of numbers. The entry in the i th row and j th column is denoted by a ij. Ex. 4 Columns 3 Rows.
Embedded Systems MPSoC Architectures OpenMP: Exercises Alberto Bosio
Measuring Performance II and Logic Design
What would happen to this problem if there weren’t parentheses?
13.4 Product of Two Matrices
Multiplying Matrices.
What would happen to this problem if there weren’t parentheses?
Matrix Operations.
Dynamic Array Multidimensional Array Matric Operation with Array
Matrix Multiplication
Matrix Operations Monday, August 06, 2018.
Matrix Operations.
Multiplication of Matrices
Multiplying Matrices.
Numerical Algorithms Quiz questions
Section 3.2 – Determinant of a SQUARE Matrix
Multiplying Matrices.
Section 10.4 – Determinant of a SQUARE Matrix
Insertion Sort for (int i = 1; i < n; i++)
Multiplication of Matrices
Determinants 2 x 2 and 3 x 3 Matrices.
Determinants 2 x 2 and 3 x 3 Matrices.
Matrix Addition, C = A + B Add corresponding elements of each matrix to form elements of result matrix. Given elements of A as ai,j and elements of B as.
Multiplying Matrices.
Insertion Sort for (int i = 1; i < n; i++)
Multiplying Matrices.
Multiplying Matrices.
Presentation transcript:

CS 221 – May 22 Timing (sections 2.6 and 3.6) Speedup Amdahl’s law – What happens if you can’t parallelize everything Complexity Commands to put in your program to measure time

Amdahl’s law A factor of n improvement to some aspect of your program doesn’t improve total performance this much. Only applies to the feature being improved. – Improving half of your program  you can’t expect even to double performance. – Ex. A factor of 10 improvement on a computation that originally took 40% of the time. The other 60% was unaffected. The “40” becomes 4, so the total time is 4+60 rather than So the speedup is only 100/64 = 1.56, not 10! Loss leader doesn’t bankrupt a store

Complexity You have 8 processors working for you. This means up to an 8x speedup What works against you? Algorithm complexity Nested loops – If the problem/input size is n, we must perform n 2 steps – Or even n 3 steps if we have 3 nested loops. – What does this mean if we double or quadruple the input size? Square matrix operations: add and multiply

2-D as 1-D To help with the process communication, it helps to represent our 2-D arrays as 1-D. Much easier to dynamically allocate 1-D array. In our example, we’ll assume the matrix is square, so size = # rows = # columns. If you want to refer to the element at row i,column j, then say a[i * size + j].

Timing your code Insert a call to MPI_Wtime() – Returns a double, representing current time in seconds But we actually want elapsed time – Early in program: start = MPI_Wtime() – End of program: finish = MPI_Wtime() – start – Any other place also: milestone = MPI_Wtime() – start – At end, print values of all timings (from each process) Where should we insert these timing probes? Re-run your program with: – 1 or multiple processes on 1 processor – Multiple processes on multiple processors