ALG0183 Algorithms & Data Structures Lecture 4 Experimental Algorithmics 8/25/20091 ALG0183 Algorithms & Data Structures by Dr Andy Brooks Case study article:

Slides:



Advertisements
Similar presentations
Analysis of Computer Algorithms
Advertisements

Turing Machines January 2003 Part 2:. 2 TM Recap We have seen how an abstract TM can be built to implement any computable algorithm TM has components:
Code Optimization and Performance Chapter 5 CS 105 Tour of the Black Holes of Computing.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Vector Processing. Vector Processors Combine vector operands (inputs) element by element to produce an output vector. Typical array-oriented operations.
ALG0183 Algorithms & Data Structures Lecture 7 Big-Oh, Big-Omega, Big-Theta, Little-Oh 8/25/20091 ALG0183 Algorithms & Data Structures by Dr Andy Brooks.
ALG0183 Algorithms & Data Structures Lecture 3 Algorithm Analysis 8/25/20091 ALG0183 Algorithms & Data Structures by Dr Andy Brooks Weiss Chapter 5 Sahni.
ALG0183 Algorithms & Data Structures Lecture 17 Quicksort 8/25/20091 ALG0183 Algorithms & Data Structures by Dr Andy Brooks comparison sort worse-case.
1 Chapter 4 Analysis Tools. 2 Which is faster – selection sort or insertion sort? Potential method for evaluation: Implement each as a method and then.
Introduction to Code Optimization Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice.
CSC401 – Analysis of Algorithms Lecture Notes 1 Introduction
Introduction to Analysis of Algorithms
CS 104 Introduction to Computer Science and Graphics Problems
Prof. Bodik CS 164 Lecture 171 Register Allocation Lecture 19.
Analysis of Algorithms
Cmpt-225 Algorithm Efficiency.
Register Allocation (via graph coloring)
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
State Machines Timing Computer Bus Computer Performance Instruction Set Architectures RISC / CISC Machines.
Register Allocation (via graph coloring). Lecture Outline Memory Hierarchy Management Register Allocation –Register interference graph –Graph coloring.
1 Liveness analysis and Register Allocation Cheng-Chia Chen.
Virtual Memory Deung young, Moon ELEC 5200/6200 Computer Architecture and Design Lectured by Dr. V. Agrawal Lectured by Dr. V.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
4/29/09Prof. Hilfinger CS164 Lecture 381 Register Allocation Lecture 28 (from notes by G. Necula and R. Bodik)
Analysis of Algorithms COMP171 Fall Analysis of Algorithms / Slide 2 Introduction * What is Algorithm? n a clearly specified set of simple instructions.
Cmpt-225 Simulation. Application: Simulation Simulation  A technique for modeling the behavior of both natural and human-made systems  Goal Generate.
COMP s1 Computing 2 Complexity
Analysis of Performance
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
Lecture No.01 Data Structures Dr. Sohail Aslam
CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a lgorithms.
Algorithm Input Output An algorithm is a step-by-step procedure for solving a problem in a finite amount of time. Chapter 4. Algorithm Analysis (complexity)
1 Computer Algorithms Lecture 3 Asymptotic Notation Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR.
ALG0183 Algorithms & Data Structures Lecture 11 Sorting Algorithms 8/25/20091 ALG0183 Algorithms & Data Structures by Dr Andy Brooks “Much of the output.
Lecture 2 Process Concepts, Performance Measures and Evaluation Techniques.
Lecture 1: Performance EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2013, Dr. Rozier.
1 Advance Computer Architecture CSE 8383 Ranya Alawadhi.
Code Optimization 1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture of a.
Complexity of Algorithms
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
Algorithms & Flowchart
Chapter 10 Algorithm Analysis.  Introduction  Generalizing Running Time  Doing a Timing Analysis  Big-Oh Notation  Analyzing Some Simple Programs.
Stored Programs In today’s lesson, we will look at: what we mean by a stored program computer how computers store and run programs what we mean by the.
Motivation: Sorting is among the fundamental problems of computer science. Sorting of different datasets is present in most applications, ranging from.
CSCI1600: Embedded and Real Time Software Lecture 33: Worst Case Execution Time Steven Reiss, Fall 2015.
Performance Tuning John Black CS 425 UNR, Fall 2000.
1  1998 Morgan Kaufmann Publishers Where we are headed Performance issues (Chapter 2) vocabulary and motivation A specific instruction set architecture.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Algorithm Analysis Lakshmish Ramaswamy. What Constitutes Good Software? Code correctness Good design Code reusability OO design can help us in achieving.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
GC 211:Data Structures Week 2: Algorithm Analysis Tools Slides are borrowed from Mr. Mohammad Alqahtani.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
©SoftMoore ConsultingSlide 1 Code Optimization. ©SoftMoore ConsultingSlide 2 Code Optimization Code generation techniques and transformations that result.
Single Static Assignment Intermediate Representation (or SSA IR) Many examples and pictures taken from Wikipedia.
What’s going on here? Can you think of a generic way to describe both of these?
Algorithm Complexity is concerned about how fast or slow particular algorithm performs.
Data Structures I (CPCS-204) Week # 2: Algorithm Analysis tools Dr. Omar Batarfi Dr. Yahya Dahab Dr. Imtiaz Khan.
Advanced Algorithms Analysis and Design
Code Optimization.
GC 211:Data Structures Week 2: Algorithm Analysis Tools
Sujata Ray Dey Maheshtala College Computer Science Department
GC 211:Data Structures Algorithm Analysis Tools
Optimization Code Optimization ©SoftMoore Consulting.
Algorithm Analysis CSE 2011 Winter September 2018.
Objective of This Course
Sujata Ray Dey Maheshtala College Computer Science Department
Analysis of Algorithms
Design and Analysis of Algorithms
Presentation transcript:

ALG0183 Algorithms & Data Structures Lecture 4 Experimental Algorithmics 8/25/20091 ALG0183 Algorithms & Data Structures by Dr Andy Brooks Case study article: “What Do We Learn from Experimental Algorithmics? “, Camil Demetrescu and Giuseppe F. Italiano, Lecture Notes in Computer Science, Volume 1893, pages 36-51, 2000 (ISBN ).

Experimental Algorithmics Experiments are performed to evaluate the relative performance of two or more algorithms to find the best one to use in an application. Problems are taken from the real world. Problem generators may also be used to create artificial test data. – The simplest problem generator is a program which generates a list of random numbers. Experiments may also be performed to discover the benefits of parallel algorithms, to study the influence of a machine´s memory hierarchy (e.g. cache use), to find out where bottlenecks occur, to determine how much a heuristic helps, etc. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 2 experiment/tilraun real world/raunheimur random number generator/slembitalnagjafi cache/skyndiminni heuristic/brjóstvitsaðferð

Why experiment? Many algorithms have been theoretically analysed for asymptotic worst-case behaviour. – “Big-Oh”. Many algorithms have not been theoretically analysed for their asymptotic bounds. In the absence of a theoretical analysis, we must experiment to determine the growth function. – There are, however, several other reasons for performing experiments. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 3

Reasons for experiments: confirming theoretical analysis. “The best-fit curve is plotted with a cubic polynomial. As shown on the graph, the actual running-time reasonably follows the theoretical analysis of the complexity of the algorithm.” 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 4 RNA Folding with Nossinov-Jacobson Algorithm

Reasons for experiments: large constants in growth functions. A theoretical analysis might provide asymptotic behaviour, but the actual value of the constants in growth functions are unknown. – The constants in a growth function may be so large that no implementation will run to completion on a practical timescale. – An algorithm with poor asymptotic behaviour might outperform another algorithm over a very large range of input size because the other algorithm has large constants in its growth function. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 5

Reasons for experiments: worse-case may not occur or occur rarely. Algorithms can behave better than worse-case in practical situations. Relying on worse-case bounds of the growth function can underestimate an algorithm´s practical utility. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 6

Reasons for experiments: check implementations earlier rather than later. A theoretical analysis of the asymptotic behaviour of a very, very complex algorithm might be built upon the theoretical analysis of an earlier, very complex algorithm, which might be built upon the theoretical analysis of an earlier, complex algorithm. – Trying to understand and code several layers of previously unimplemented algorithms can be extremely difficult. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 7

Reasons for experiments: helps establish the correctness of the code. Code is the most accurate representation of an algorithm. To help establish that the algorithm is correct, execute the code and compare expected with actual results over a range of input sizes and over a range of structure in the input. If buggy code is found for certain problem instances (certain combinations of size and structure), these problem instances make good test cases for later implementations. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 8

There are four different sizes of input available for testing: – 20, 30, 40, and 50. There are four different input structures available for testing: – random, nearly sorted, reversed, and few unique. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 9

Reasons for experiments: exploit an ad-hoc heuristic or local hack in code. Sometimes coding an ad-hoc heuristic or local hack can dramatically improve performance. – Experimenting with the code is the only way to discover the scale of any improvement in performance. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 10

Reasons for experiments: as a smoke test of reasonable behaviour. Large constants in growth functions might mean that running time is unacceptable for practical purposes. Experimental growth curves might be discontinuous, indicating that bottlenecks occur for small changes to a problem instance. Experimental growth curves might be discontinuous or unrepeatable indicating that the machine´s memory hierarchy and loading (e.g. cache use) or network environment play an important role in determining the problem instances that can be solved in practice. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 11 Replication/Endurtekning

Generalisability of experimental results Unfortunately, experimental results may not be generalisable i.e. applicable to other contexts. There are many threats. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 12

Threat to generalisability: machine factors. CPU speed affects program execution times. Data bus speed affects program execution times. Memory hierarchy (e.g. cache use) affects program execution times. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 13

Threat to generalisability: compiler optimisation level. Which compiler was used and how much built-in code optimisation did it perform? Were any code optimisation options used at compile time? 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 14 optimisation: common subexpression elimination In the expression “(a+b)-(a+b)/4,” “(a+b)” need be calculated only once. optimisation: register allocation The most frequently used variables should be kept in processor registers. “Register allocation and spilling via graph coloring” by Gregory Chaitin, in SIGPLAN '82: Proceedings of the 1982 SIGPLAN symposium on Compiler Construction. Was any dead code removed by static analysis?

Threat to generalisability: time measurements. What is the granularity of the time measurement? – Is the measurement accurate to ± 1µsec or ±10 msec? What time is actually being measured and reported on? – clock time in the real world? – time used by the user´s process? Is the time to perform start-up and wind-down I/O included? – Loading several Megabytes of data into RAM might take different times on different machines. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 15 measurement error/mælingarvilla

class System, method currentTimeMillis 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 16

Threat to generalisability: programming experience and knowledge. Programmers differ in programming experience and the knowledge they have of a particular language, its API, and ways to tune performance in that language. – Different programmers can implement an algorithm in different ways which may lead them to different conclusions about algorithm performance. – Are the different implementations really different algorithms? (Question for dicussion.) 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 17

Threat to generalisability: poor coverage of problem instances. A wide range of input size should be explored. – (steps of 100), (steps of 1000), (steps of 10000),... Several input structures should be explored. – For example, sorting algorithms should consider: random, nearly sorted, reversed, and few unique. Real-life as well as randomly generated problem instances should be explored. 8/25/2009 ALG0183 Algorithms & Data Structures by Dr Andy Brooks 18 Don´t forget the operating system.