Presentation of Research Results

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

description

Presentation of Research Results. Simplified Gated Assignment Surinder Jain Supervisor : Bernhard Scholz Assignment 3 – INFO5993. Motivation and Context. Programs have bugs Fully testing of a program is not feasible Bugs get through and cause havoc - PowerPoint PPT Presentation

Transcript of Presentation of Research Results

Page 1: Presentation of Research Results

Simplified Gated Assignment

Surinder JainSupervisor : Bernhard Scholz

Assignment 3 – INFO5993

Page 2: Presentation of Research Results

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

Page 3: Presentation of Research Results

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

Page 4: Presentation of Research Results

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

Page 5: Presentation of Research Results

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

Page 6: Presentation of Research Results

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

Page 7: Presentation of Research Results

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

Page 8: Presentation of Research Results

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

Page 9: Presentation of Research Results

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

Page 10: Presentation of Research Results

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

Page 11: Presentation of Research Results

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

Page 12: Presentation of Research Results

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

Page 13: Presentation of Research Results

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

Page 14: Presentation of Research Results

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

Page 15: Presentation of Research Results

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

Page 16: Presentation of Research Results

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

Page 17: Presentation of Research Results

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

Page 18: Presentation of Research Results

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

Page 19: Presentation of Research Results

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

Page 20: Presentation of Research Results

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

Page 21: Presentation of Research Results

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