Extending Code Genera/on to Support Pla6orm-Independent Event-B - - PowerPoint PPT Presentation

extending code genera on to support pla6orm independent
SMART_READER_LITE
LIVE PREVIEW

Extending Code Genera/on to Support Pla6orm-Independent Event-B - - PowerPoint PPT Presentation

Extending Code Genera/on to Support Pla6orm-Independent Event-B Models Asieh Salehi, Michael Butler, Colin Snook University of Southampton, Southampton, United Kingdom 6th Rodin User and Developer Workshop, 23 May, 2016, Linz, Austria


slide-1
SLIDE 1

Extending Code Genera/on to Support Pla6orm-Independent Event-B Models

Asieh Salehi, Michael Butler, Colin Snook University of Southampton, Southampton, United Kingdom

6th Rodin User and Developer Workshop, 23 May, 2016, Linz, Austria

slide-2
SLIDE 2

Overview

  • MoHvaHon
  • Background:
  • Code GeneraHon (CG) with Tasking Event-B
  • Branching Control Flow
  • Case Study (PRiME project*):
  • Embedded Run-Time Management (RTM) system
  • PlaVorm Dependencies
  • Modelling and Tasking by Restricted CG
  • Modelling and Tasking by Extended CG
  • Extending Code GeneraHon Plugin
  • Case Study Overview
  • Summary and Future work

1 * Power-efficient, Reliable, Many-core Embedded systems. h[p://www.prime-project.org

slide-3
SLIDE 3

Mo/va/on

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 2

  • a single implementaHon for the Event-B model
  • dependency between the Event-B model and

target plaVorm architecture

  • different plaVorm-specific implementaHons

from the same Event-B model

  • plaVorm-independent Event-B model

plaVorm-specific implementaHons

Platform)I+Dependent

Event+B)Model Platform)I)+Specific Implementation)Code Code)Generation

Platform)II+Dependent

Event+B)Model Platform)II)+Specific Implementation)Code Code)Generation

Platform)Independent

Event)B2Model Platform2I2)Specific Implementation2Code Instantiation2and2 Code2Generation Platform2II2)Specific Implementation2Code

Previous CG approach Extended CG approach

slide-4
SLIDE 4

Background: Code Genera/on with Tasking Event-B

  • Code generaHon in Event-B addresses the gap between

the lowest level Event-B refinement and an implementa7on.

  • Tasking Event-B is an extension of Event-B to introduce

control flows:

  • Sequence
  • Branch
  • Loop

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 3

Implementation Refinements Tasking Abstraction

slide-5
SLIDE 5

Background (cont.): Branching Control Flow

  • Task body:
  • TranslaHon (pseudocode):

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 4

if evt_1 [ elseif evt_i ]* else evt_n if (g_1) then a_1 [else (g_i) then a_i end ]* else a_n end

(where g_i and a_i indicate guard and acHon of the evt_i respecHvely)

slide-6
SLIDE 6

Case Study: Embedded Run-Time Management (RTM) system

  • ApplicaHon provides the required

deadline (frame-per-second (FPS))

  • RTM decides about the opHmal value of

Voltage-Frequency (VF)

  • The workload (cpu-cycles) to decode the

frame is monitored.

  • RTM aims to choose the opHmal value of

VF which meets deadline while saving power.

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 5

Application* Layer Video&Decoder OS Layer Run-Time&Manager Hardware Layer CPU FPS VF&setting CPU&cycles

slide-7
SLIDE 7

Case Study (cont.): Predic/on and Machine Learning at Run-/me

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 6

RTM

read_deadline select_vf control_vf monitor_workload predict_workload select_vf

Abstract8Model ranGenerator updateE xor VFGenerator explore exploit Decision8Making8 Refinement

monitor_workload update_prediction

ran8>8 ε ran8≤8ε

monitor_workload update_qTable Prediction8 Refinement

RTM uses predic7on and machine learning algorithms to decide about the opHmal value of VF.

  • First Refinement: PredicHon
  • Second Refinement: Machine

Learning (using a learning table)

slide-8
SLIDE 8

Case Study(Cont.): Pla6orm Dependencies

  • An RTM model can require adjustments across different hardware

plaVorms due to the diversity of architecture characteris7cs.

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 7

Frequencies freq1 freq2 freq3 freq4 workload 1 0.8 0.2 0.2 0.1 2 ,0.1 0.6 0.4 0.2 3 ,0.4 ,0.2 0.7 0.3 4 ,1.0 ,0.8 ,0.1 0.8

  • The number of supported frequencies by

each plaVorm determines the number of columns in the learning table used to record the rewards and penalHes for each VF seing decision.

slide-9
SLIDE 9

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 8

update_col1_qTable

WHERE freq =&FREQ1 THEN qTable updateArray( qTable,&row, 0,&value )

update_col2_qTable

WHERE freq =&FREQ2 THEN qTable updateArray( qTable,&row, 1,&value ) …

update_coln_qTable

WHERE freq =&FREQn THEN qTable updateArray( qTable,&row, NA1,&value )

… if update_col1_qTable [&elseif update_coli_qTable ]* else update_coln_qTable … tasking&body EventAB&actions&to&modify&the&learning&table& (dependent on&the&number&of&frequencies) … if (&freq =&FREQ1&)& {& qTable[row][0]&=&value; } … else5if (&freq =&FREQi )& {& qTable[row][i]&=&value; }& … else {& qTable[row][NA1]&=&value;& } … generated&C&code&for&a& platform&with&n&number&of&frequencies

tasking code& generation

Modelling and Tasking by Restricted CG

slide-10
SLIDE 10

Modelling and Tasking by Extended CG

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 9

update_qTable ANY i WHERE i 1 N$ expanding &$ freq = F(i) THEN qTable updateArray( qTable,$row, i,$value ) … update_qTable … tasking$body EventCB$action$to$modify$the$learning$table$ (independent on$the$number$of$frequencies) … if ($freq =$FREQ1$)$ qTable[row][0]$=$value; else/if ($freq =$FREQ2$)$ qTable[row][1]$=$value$; else/if ($freq =$FREQ3$)$ qTable[row][2]$=$value$; else qTable[row][3]$=$value$; … generated$C$code$for$platform$ARM8 with$4$frequencies$

tasking code$ generation

… if ($freq =$FREQ1$)$ qTable[row][0]$=$value; . . else/if ($freq =$FREQ12$)$ qTable[row][11]$=$value$; else qTable[row][12]$=$value$; … generated$C$code$for$platform$ARM7 with$13$frequencies$

N$=$4 N$=$13

slide-11
SLIDE 11

Extending Code Genera/on Plugin

  • Expanding Guard:
  • indexed by a constant (N)
  • N is instanHated during translaHon
  • Task body TranslaHon

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 10

… expanding_evt (indexed.by.n). … … if evt_1 [.elseif evt_i ]* else evt_n … … if (.g_1.).{.a_1.} [.else&if (.g_i ).{.a_i }.]* else {.a_n } …

tasking.body expanded.tasking.body generated.C.code UI.view

slide-12
SLIDE 12

Case Study Overview

11 Event&B(Design(Level

refines refines refines refines decompose

Implementation(Level

RTM$Controller$ (Controller.c)

Automatic$ code$generation Automatic$code$generation$& interaction$APIs$call$replacement

Interaction$Interfaces$ (Environment.c) Data$Definition (Common.c)

Instantiation$& Automatic$code$generation

Abstract0Model

Interaction0interfaces between0 application,0RTM0and0hardware

Prediction0Refinement

Prediction0algorithm0details

Decision0Making0Refinement

Machine0learning0algorithm0details

Controller

RTM0algorithms: Prediction, ML

Environment

Interaction0Interfaces

Controller0Refinement

Tasking0controller

Environment0Refinement

Tasking0Environment

Context:0Platform0 Parameters

N:0number0of0VF VF:0set0of0VF0values Wl: maximum0workload Latency:0DVFS0switch0Latency

  • One abstract, two refinements
  • Model DecomposiHon:
  • Controller: RTM algorithms
  • Environment: InteracHon Interfaces
  • Code GeneraHon
  • Theory definiHons
slide-13
SLIDE 13

Case Study Overview: Theories

12

  • Array theory to specify the learning table
  • EWMA* theory to specify the predicHon operators and translaHons
  • ML theory to specify the machine learning operators and translaHons

* ExponenHally Weighted Moving Average

slide-14
SLIDE 14

Case Study Overview: Proving

13

  • Abstract specificaHon of the predicHon*:
  • Refined specificaHon of the predicHon:

*

slide-15
SLIDE 15

Case Study Overview: Proving (cont.)

14

  • Abstract specificaHon of the predicHon*:
  • Refined specificaHon of the predicHon:

*

slide-16
SLIDE 16

Summary and Future Work

  • In the PRiME project, we are extending our RTM modelling,

translaHon to support more run-Hme algorithms:

  • Extend the code generaHon in-line
  • New plugin release

Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models 15

Extending Code GeneraHon technique in the Event-B formal method provides an approach to manage pla$orm diversity by shiming the focus away from hand- wri4en pla$orm-specific code to pla$orm-independent verified models from which plaVorm-specific implementaHons are automa8cally generated.

slide-17
SLIDE 17

Thank you Any Ques/on?

16 Extending Code GeneraHon to Support PlaVorm-Independent Event-B Models