Download presentation

Presentation is loading. Please wait.

Published byHarold Elm Modified over 2 years ago

1
Simplified Gated Assignment Surinder Jain Supervisor : Bernhard Scholz Assignment 3 – INFO5993

2
Programs have bugs Fully testing of a program is not feasible Bugs get through and cause havoc Ariane rocket blows up after take-off (zero underflow error) Spacecraft goes to safe mode – successive commands at a multiple of 1000 seconds Cancer treatment machine gives overdose of radiation and kills a patient

3
Static compile time techniques Predicts safe and computable approximations to program behaviour arising dynamically at run- time, without ever running the program Static Program Analysis

4
SSA, a technique of Static Program Analysis Simplifies variable definition and use analysis Is used as an Intermediate Representation by many compilers including LLVM Static Single Assignment

5
A variable should be assigned only once in a program Change the variable name on second assignment Use the second variable name in rest of the program Since each variable is defined only once, it has only one static value. It is easy to search for that definition during program analysis Static Single Assignment

6
X=1; Y=X+2; X=2; Z=X+3 X is being assigned twice, once as 1 and then as 2. To change the program to SSA form X=1;Y=X+2; X2=2 ;Z= X2 +3 Static Single Assignment - Example

7
X=1 ;If Y>0 then X=2 ;Z=Z+X; Second assignment of X is conditional SSA form converts the program as X=1;If Y>0 then X2=2 ; X3=gamma(Y>0,X,X2); Z=Z+ X3 Gamma is iif function, if first parameter is true, return second otherwise return third parameter as result. Static Single Assignment – Conditionals

8
W=0;While Z>0;W=W+X;Z=Z-1;EndWhile;Print (W); Gated SA form converts it as W=0;L :W1= Beta (W,W2);If Z>0 then W2=W1+X;Z=Z-1;Goto L; W3= EtaFalse (W,W2);Print(W3); Beta returns first parameter when called first time, subsequent calls, it returns second parameter. EtaFalse returns W2 if loop was entered otherwise it returns W. Static Single Assignment – Loops

9
Beta returns first parameter when called first time, subsequent calls, it returns second parameter Beta is a contextual function Its result does not depend on its parameters alone Its result depends on the context in which it has been called It can, however, be programmed separately for each location it is used in What is wrong with gated beta function

10
EtaFalse returns W2 if loop was entered otherwise it returns W EtaFalse is a contextual function Its result does not depend on its parameters alone Its result depends on the context in which it has been called It can, however, be programmed separately for each location it is used in What is wrong with gated Eta function

11
Gamma is iif function, if first parameter is true, return second otherwise returns third parameter as its result. Gamma is a non-contextual function Its result depends on its parameters alone and on nothing else It can be programmed once and use everywhere else What is wrong with Gamma function

12
But for Gamma, other two functions behave differently in different contexts and in different calls in the same context They are not static defined functions They can not be used in formulating static program analysis equations They hinder symbolic analysis of the program once it has been converted into Gated SSA form Problem Description

13
Can we combine the benefits of SSA form with Symbolic Analysis techniques Can we define an SSA form that does not use Beta and EtaFalse Can we define an SSA form using non- contextual pure functions only

14
1. Static Single Assignment – Cytron shows how to compute it efficiently with a contextual phi function 2. Various (too many) papers showing its use in compiler construction, code translation and in compiler optimizations 3. Ferriere et al improved phi function to psi function for predication based compilers 4. Balance et all separated phi function into three separate gating functions called gamma, mu and eta functions. 5. Campbell el al found problems and inaccuracies with gamma, mu and eta functions. They made a fix and renamed mu as beta. SSA and gating functions are contextual but are being used widely by compilers and optimizers

15
Definition of gating functions by Balance et al and their improvements by Campbell have been studied. Mechanism of their implementation by compilers and code generated for these functions has been studied It was seen that some of this code can be moved out of gating functions into program source code This resulted in elimination of contextual beta and eta functions by non-contextual gamma function

16
A new form called Simplified Gated Assignment (SGA) form is being proposed An explanation of how to deduce them from existing work has been given An example has been worked out step by step No formal proof or algorithms to compute it have been provided as it is derived by simply moving out some code of mu and eta function to program

17
Programs can be converted into SGA form The SGA form is very close to existing SSA form SSA form requires that each variable is assigned only once SGA form enforces it for all programmer defined variables It permits exception for one specific type of control variable which can be defined using a specific protocol

18
Duplicate assignment of control variable can be removed for languages that permit dynamic allocation of variables For other languages, it does not increase the complexity as the duplicate definition is defined only twice and used only once All existing methods of compiler construction and optimization that use SSA as an intermediate representation can also use GSA

19
Have simplified SSA with non-contextual functions permitting more opportunities for optimization Changes to SSA form are transparent to compilers Symbolic Analysis and abstract interpretation techniques can use GSA function and compute equations for exact results rather than inequalities that compute approximate results

20
SGA preserves all benefits of SSA and GSA forms without having to use any non- contextual function It can be used by compilers with equal ease Another step to remove reasons for approximate results from Symbolic Analysis

21
Algorithm to convert from SSA to SGA and a formal proof of its correctness can be constructed and shown to be O(n logn) Symbolic Analysis can simplify its inequations and convert them into equations by using GSA form of the program

Similar presentations

OK

Testing Programs with Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.

Testing Programs with Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Html tutorial free download ppt on pollution Ppt on economy of uk Ppt on pi in maths class Ppt on functional requirements Ppt on span of control Ppt on second law of thermodynamics youtube Ppt on op amp circuits examples Ppt on pricing policy in international marketing Ppt on festivals of india download Paper presentation ppt on nanotechnology