Optimizing the SPARK TM Program Slicer Ricky E. Sward and Leemon C. Baird III Dept of Computer Science USAF Academy

Slides:



Advertisements
Similar presentations
The University of Adelaide, School of Computer Science
Advertisements

Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Fortran Jordan Martin Steven Devine. Background Developed by IBM in the 1950s Designed for use in scientific and engineering fields Originally written.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
The Assembly Language Level
Design & Analysis of Algoritms
Principles of programming languages 4: Parameter passing, Scope rules Department of Information Science and Engineering Isao Sasano.
© SERG Dependable Software Systems (Slicing) Dependable Software Systems Topics in Program Slicing Material drawn from [Weiser84,Gallagher91,DeMillo96]
Chapter 10 Introduction to Arrays
Chapter 9 Subprograms Sections 1-5 and 9. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Introduction Two fundamental abstraction facilities.
CIS 101: Computer Programming and Problem Solving Lecture 9 Usman Roshan Department of Computer Science NJIT.
Recursive Algorithms Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Validating High-Level Synthesis Sudipta Kundu, Sorin Lerner, Rajesh Gupta Department of Computer Science and Engineering, University of California, San.
Extracting Objects From Legacy Imperative Code Ricky E. “Ranger” Sward Dept of Computer Science USAF Academy
1 Lecture 7 Topics –Problems about program behavior At least problem input is a program/algorithm –Halting Problem Fundamental problem about program behavior.
Chapter 9: Subprogram Control
Center for Embedded Computer Systems University of California, Irvine and San Diego SPARK: A Parallelizing High-Level Synthesis.
Fundamental in Computer Science Recursive algorithms 1.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Objects Real and Java COMP.
CH07: Writing the Programs Does not teach you how to program, but point out some software engineering practices that you should should keep in mind as.
Optimizing Compilers Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
5.3 Machine-Independent Compiler Features
MATH 224 – Discrete Mathematics
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
CSE 2341 Honors Professor Mark Fontenot Southern Methodist University Note Set 04.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Computer Science and Software Engineering University of Wisconsin - Platteville 9. Recursion Yan Shi CS/SE 2630 Lecture Notes Partially adopted from C++
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
Computer Science and Software Engineering University of Wisconsin - Platteville 2. Pointer Yan Shi CS/SE2630 Lecture Notes.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Design and Implementation.
1 Scope Rules (Section 3.3) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos and Michael Scott.
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Recursion. What is recursion? Rules of recursion Mathematical induction The Fibonacci sequence Summary Outline.
AdaSlicer: An Ada Program Slicer Ricky E. Sward Department of Computer Science USAF Academy, CO A.T. Chamillard Computer Science.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
CSC 221: Recursion. Recursion: Definition Function that solves a problem by relying on itself to compute the correct solution for a smaller version of.
Ch. 5 Ch. 51 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (more notes) Dr. Carter Tiernan.
Implementing Subprograms What actions must take place when subprograms are called and when they terminate? –calling a subprogram has several associated.
1 CS 201 Computer Systems Programming Chapter 18 “Parameter Passing” Herbert G. Mayer, PSU CS Status 1/23/2913.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Chapter 13: Structures. In this chapter you will learn about: – Single structures – Arrays of structures – Structures as function arguments – Linked lists.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Topic 3: C Basics CSE 30: Computer Organization and Systems Programming Winter 2011 Prof. Ryan Kastner Dept. of Computer Science and Engineering University.
Review 1 List Data Structure List operations List Implementation Array Linked List.
Ch. 5 Ch. 51 jcmt Summer 2003Programming Languages CSE3302 Programming Languages (more notes) Summer 2003 Dr. Carter Tiernan.
PLC '06 Experience in Testing Compiler Optimizers Using Comparison Checking Masataka Sassa and Daijiro Sudo Dept. of Mathematical and Computing Sciences.
1 2/21/2016 MATH 224 – Discrete Mathematics Sequences and Sums A sequence of the form ar 0, ar 1, ar 2, ar 3, ar 4, …, ar n, is called a geometric sequence.
1 CSC103: Introduction to Computer and Programming Lecture No 16.
ENEE150 – 0102 ANDREW GOFFIN More With Pointers. Importance of Pointers Dynamic Memory (relevant with malloc) Passing By Reference Pointer Arithmetic.
TCSS 342 Autumn 2004 Version TCSS 342 Data Structures & Algorithms Autumn 2004 Ed Hong.
Procedure Definitions and Semantics Procedures support control abstraction in programming languages. In most programming languages, a procedure is defined.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Operational Semantics (Slides mainly.
Memory Management in Java Mr. Gerb Computer Science 4.
C++ for Engineers and Scientists Second Edition Chapter 12 Pointers.
Introduction to Optimization
Code Optimization.
COSC 5V90 Functional Programming and Interactive Theorem Proving
Functions.
Types for Programs and Proofs
Pointers and References
CSC 253 Lecture 8.
METHODS AND BEHAVIORS AKEEL AHMED.
CSC 253 Lecture 8.
Introduction to Optimization
Programming Languages 2nd edition Tucker and Noonan
Introduction to Optimization
Intermediate Code Generation
SPL – PS3 C++ Classes.
Presentation transcript:

Optimizing the SPARK TM Program Slicer Ricky E. Sward and Leemon C. Baird III Dept of Computer Science USAF Academy

Overview Background on program slicing SPARK program slicer Glue code Useful SPARK features Proving functional equivalence Optimizations

Previous Work Weiser [1] first defined program slicing –Slicers exist for C and Java –AdaSlicer has been built using ASIS [2] Program slicing is used in –Reengineering [3] –Program understanding –Testing and debugging

Program Slicing A B C E D Foo A B D Foo_D A C E Foo_E

Functional Equivalence Must preserve functionality during slicing Avoid huge test suites Prove mathematically that functionality of original procedure is equivalent to functionality of collection of slices We need some way to “glue” slices back together to prove functional equivalence

SPARK Program Slicer Num_Students Min_Choice Max_Choice Highest_Max Lowest_Min Gather_Summary_Info Increment_Local : Integer := Increment_In; begin Increment_Local := Increment_Local + 1; Increment_Out := Increment_Local; end Gather_Summary_Info_Increment; Increment_In Increment_Out Gather_Summary_Info_Increment Increment Gather_Summary_Info_Highest_Max Gather_Summary_Info_Lowest_Min

Glue Code Increment_Local : Integer := Increment; begin Gather_Summary_Info_Highest_Max( Num_Students, Max_Choice, Highest_Max); Gather_Summary_Info_Lowest_Min( Num_Students, Min_Choice, Lowest_Min); Gather_Summary_Info_Increment( Increment_Local, Increment); end Gather_Summary_Info_Glue; Num_Students Min_Choice Max_Choice Highest_Max Lowest_Min Gather_Summary_Info_Glue Increment

Useful SPARK Features Dynamic storage allocations not allowed –No pointers or dynamic allocation of memory –Can determine which variables are given values in the procedure for slicing No aliasing of variables or parameters –Inputs and outputs of procedures are clearly defined

Useful SPARK Features No recursive procedures –Slicing algorithms for recursive procedures is not defined –Build our proof for non-recursive procedures Limiting statements such as goto... No tasking... No exceptions... No generics...

Proving Functional Equivalence P’ is P with any in/out parameter, X, replaced with X_in and X_out. X_local := X when declared in P’. X_local replaces X in P’. X_out := X_local at end of P’. P 0 is glue procedure Slices called in arbitrary order. X_local := X when declared in P 0. X_local passed to X_in params. X passed to X_out params.

Proving Functional Equivalence Theorem: P 0 is functionally equivalent to P Proof P and P’ will return same outputs given same inputs since SPARK does not allow aliasing. Assume slicing produces correct projection of behavior to produce the output parameter For P’ and P 0 consider the three types of parameters...

Proving Functional Equivalence –The “in” parameters are the same in P’ and P 0 –Each “out” parameter is changed by only one of the slices, thus the same in P’ and P 0 –For “in out” parameters, glue code: First copies parameter X to a local variable, X_local X_local is passed as “in” parameter when needed Original “in out” parameter, X, passed as “out” Only one of the slices will change X Thus, P and P 0 are functionally equivalent QED

Proving Functional Equivalence In English please... P’ and P 0 designed to prevent slices from interfering when called in arbitrary order Not a problem for “in” or “out” parameters P 0 provides original “in” value as needed for any “in out” parameters This means it doesn’t matter when a slice changes the value of an “in out” parameter

Optimizations Examine REF and DEF sets for slices –Use copy-in and copy-out only when needed –Much more efficient for arrays and records Build hash table of changes –Roll back changes between slices

Glue Code Increment_Local : Integer := Increment; begin Gather_Summary_Info_Highest_Max( Num_Students, Max_Choice, Highest_Max); Gather_Summary_Info_Lowest_Min( Num_Students, Min_Choice, Lowest_Min); Gather_Summary_Info_Increment( Increment_Local, Increment); end Gather_Summary_Info_Glue; Num_Students Min_Choice Max_Choice Highest_Max Lowest_Min Gather_Summary_Info_Glue Increment Increment is needed only in one slice, so no need to copy in & copy out

Proving Functional Equivalence P 0 is glue procedure Slices called in arbitrary order. No need to copy in/out parameters. May need to track changes.

Proving Functional Equivalence In English please... P’ and P 0 designed to prevent slices from interfering when called in arbitrary order Not a problem for “in” or “out” parameters With REF/DEF analysis, determine overlap of slice parameters Track changes in hash table if needed This means it doesn’t matter when a slice changes the value of an “in out” parameter

Future Work Possibly slice the SPARK annotations Rewrite SPARKSlicer in SPARK

Conclusions SPARK features quite useful Proved functional equivalence Proof technique may be useful to other transformations ASIS very useful

Questions?

References [1] Weiser, M. Program slicing. IEEE Transactions on Software Engineering, SE-10(4): , July [2] Sward, R.E. and Chamillard, A. T. AdaSlicer: A Program Slicer for Ada. Proceedings of the ACM International SIGAda 03 Conference, Dec 2003, San Diego, CA. [3] The Wisconsin Program-Slicing Tool, Version 1.1. Retrieved June 4, 2003, from