Storage Allocation for Embedded Processors By Jan Sjodin & Carl von Platen Present by Xie Lei ( PLS Lab)

Slides:



Advertisements
Similar presentations
Virtual Memory Basics.
Advertisements

Memory.
Part IV: Memory Management
Instruction Set Design
Instruction Set-Intro
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
The Assembly Language Level
ΜP rocessor Architectures To : Eng. Ahmad Hassan By: Group 18.
CMPE 421 Parallel Computer Architecture MEMORY SYSTEM.
Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2009, Prentice.
Eliminating Stack Overflow by Abstract Interpretation John Regehr Alastair Reid Kirk Webb University of Utah.
Embedded Systems Programming
Chapter 7 Memory Management
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
Memory Management 2010.
Memory Organization.
Memory Management Chapter 5.
State Machines Timing Computer Bus Computer Performance Instruction Set Architectures RISC / CISC Machines.
Chapter 7 Memory Management
Software Development and Software Loading in Embedded Systems.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Revised: Aug 1, ECE 263 Embedded System Design Lesson 1 68HC12 Overview.
Basics and Architectures
1 The Performance Potential for Single Application Heterogeneous Systems Henry Wong* and Tor M. Aamodt § *University of Toronto § University of British.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Memory Management Chapter 7.
Memory Management. Process must be loaded into memory before being executed. Memory needs to be allocated to ensure a reasonable supply of ready processes.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Microprocessor-based systems Curse 7 Memory hierarchies.
Software Pipelining for Stream Programs on Resource Constrained Multi-core Architectures IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEM 2012 Authors:
Overloading Binary Operators Two ways to overload –As a member function of a class –As a friend function As member functions –General syntax Data Structures.
Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
Subject: Operating System.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Pointer Analysis as a System of Linear Equations. Rupesh Nasre (CSA). Advisor: Prof. R. Govindarajan. Jan 22, 2010.
Authors – Jeahyuk huh, Doug Burger, and Stephen W.Keckler Presenter – Sushma Myneni Exploring the Design Space of Future CMPs.
Lecture 5 Page 1 CS 111 Online Processes CS 111 On-Line MS Program Operating Systems Peter Reiher.
DIGITAL SIGNAL PROCESSORS. Von Neumann Architecture Computers to be programmed by codes residing in memory. Single Memory to store data and program.
Instruction Sets: Addressing modes and Formats Group #4  Eloy Reyes  Rafael Arevalo  Julio Hernandez  Humood Aljassar Computer Design EEL 4709c Prof:
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
The Instruction Set Architecture. Hardware – Software boundary Java Program C Program Ada Program Compiler Instruction Set Architecture Microcode Hardware.
Lx: A Technology Platform for Customizable VLIW Embedded Processing.
Workload Clustering for Increasing Energy Savings on Embedded MPSoCs S. H. K. Narayanan, O. Ozturk, M. Kandemir, M. Karakoy.
Embedded Systems Seminar Heterogeneous Memory Management for Embedded Systems By O.Avissar, R.Barua and D.Stewart. Presented by Kumar Karthik.
Basic Concepts Computer Organization & Assembly Language Programming Instructor: Maram Alsahafi [Some of the contents Adapted from slides Dr Adnan Gutub,
Memory Management Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only storage.
1 of 14 Lab 2: Formal verification with UPPAAL. 2 of 14 2 The gossiping persons There are n persons. All have one secret to tell, which is not known to.
1 of 14 Lab 2: Design-Space Exploration with MPARM.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Addressing modes, memory architecture, interrupt and exception handling, and external I/O. An ISA includes a specification of the set of opcodes (machine.
Virtual memory.
Muen Policy & Toolchain
GPU Memory Details Martin Kruliš by Martin Kruliš (v1.1)
Database Performance Tuning and Query Optimization
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Practice Six Chapter Eight.
Lecture 4: MIPS Instruction Set
CISC AND RISC SYSTEM Based on instruction set, we broadly classify Computer/microprocessor/microcontroller into CISC and RISC. CISC SYSTEM: COMPLEX INSTRUCTION.
Objective of This Course
2.C Memory GCSE Computing Langley Park School for Boys.
Introduction to Microprocessor Programming
Chapter 11 Database Performance Tuning and Query Optimization
CPU Structure CPU must:
Lecture 4: Instruction Set Design/Pipelining
6- General Purpose GPU Programming
Presentation transcript:

Storage Allocation for Embedded Processors By Jan Sjodin & Carl von Platen Present by Xie Lei ( PLS Lab)

Memory In Embedded Sys Several memory areas (on-chip, off-chip) Several memory areas (on-chip, off-chip) SRAM SRAM DRAM DRAM E 2 PROM … E 2 PROM … Different properties Different properties access time access time size size restricted to native pointer types restricted to native pointer types

Pointer Types Different in length Different in length 8-bit 8-bit 16-bit bit... Different in cost Different in cost 8-bit is cheaper than 16-bit 8-bit is cheaper than 16-bit

Problem to solve Allocate data and select pointer types in the most efficient way Allocate data and select pointer types in the most efficient way Frequently accessed data in fast memory Frequently accessed data in fast memory Frequently used pointers & expression have cheap pointer type Frequently used pointers & expression have cheap pointer type Manual  Automatic Manual  Automatic

Road Map Brief Background Brief Background Memory Organization & Model Memory Organization & Model Cost Model Cost Model Formulation & Discussion Formulation & Discussion Implementation Implementation Experiments & Results Experiments & Results Conclusion Conclusion

Why Allocation ? Different pointer types to access different types of memories improves performance : execution speed execution speed program size program size energy consumption energy consumption production cost... production cost...

Allocation Problem Allocating each variable of a program in a memory segment Allocating each variable of a program in a memory segment Assigning a native pointer type to each pointer expression of the same program Assigning a native pointer type to each pointer expression of the same program Dependency : latter depends on former Dependency : latter depends on former ---take both into consider simultaneously ---take both into consider simultaneously

Current solution & Drawback Manually locate variables and select native pointer types: pragmas or keywords Manually locate variables and select native pointer types: pragmas or keywords Drawbacks Drawbacks time-consuming time-consuming source code non-portable source code non-portable

New Solution A model which can describe architectures with irregular memory organization and several pointer types. A model which can describe architectures with irregular memory organization and several pointer types. Derive integer linear program from the model Derive integer linear program from the model Solve the program = Solve the allocation problem Solve the program = Solve the allocation problem Optimal solution ( under assumption ) Optimal solution ( under assumption )

An Important Condition Condition : All memory accesses in the program should be known Condition : All memory accesses in the program should be known -- whole program optimization ( WPO ) -- whole program optimization ( WPO ) points-to set : Set of the objects a restricted pointer may point to points-to set : Set of the objects a restricted pointer may point to Reason Reason The points-to set of a pointer must be allocated where that pointer can reach The points-to set of a pointer must be allocated where that pointer can reach

Road Map Brief Background Brief Background Memory Organization & Model Memory Organization & Model Cost Model Cost Model Formulation & Discussion Formulation & Discussion Implementation Implementation Experiment & Results Experiment & Results Conclusion Conclusion

Features in Embedded Processors On-chip memory : efficiently On-chip memory : efficiently Zero page : use smaller pointer types, fast, compact code Zero page : use smaller pointer types, fast, compact code Harvard architectures : different native pointer representations and addressing mode are used for program and data address space Harvard architectures : different native pointer representations and addressing mode are used for program and data address space

AVR RAM Configuration

Separate VS Single address space (1) Separate address space Separate address space  disjoint sets of pointer types  know points-to sets to allocate data  use separate address buses  different memory access instructions use different pointer types as operands

Separate VS Single address space (2) Single address space Single address space  A general native pointer type  No restriction on allocation  Try to use cheaper pointer type ( need to know the point-to set to decide if that pointer type can work)

Code Size Contrast

An Abstract Memory Model Memory Model : Memory Segments, Pointer Types, Relation Memory Model : Memory Segments, Pointer Types, Relation Memory Segments : subsets of the total memory space, uniform with properties( speed, addressing modes). M 1, M 2, M 3... M S Memory Segments : subsets of the total memory space, uniform with properties( speed, addressing modes). M 1, M 2, M 3... M S Pointer Types : P 1, P 2, P 3... P T Pointer Types : P 1, P 2, P 3... P T Relation : Pointer Type to Memory Segments Relation : Pointer Type to Memory Segments

Memory Model Size( M j ) : number of addressable units of storage in Memory Segment M j Size( M j ) : number of addressable units of storage in Memory Segment M j Relation function Relation function Mem( P k )={ j | P k can point to M j } Mem( P k )={ j | P k can point to M j } In which P k Pointer Type In which P k Pointer Type Memory Model can be expressed by a table Memory Model can be expressed by a table

Example: AVR

Road Map Brief Background Brief Background Memory Organization & Model Memory Organization & Model Cost Model Cost Model Formulation & Discussion Formulation & Discussion Implementation Implementation Experiment & Results Experiment & Results Conclusion Conclusion

Two Kinds of Cost Cost : Static cost + Dynamic cost Cost : Static cost + Dynamic cost Static cost : the size of a program, expressed by the sum of all statements in instruction set STMTR Static cost : the size of a program, expressed by the sum of all statements in instruction set STMTR Dynamic cost : execution time, for each statement need to be scaled by the estimate execution frequency of the statement Dynamic cost : execution time, for each statement need to be scaled by the estimate execution frequency of the statement

Expressions V = {v 1, v 2... v N } : set of variables referred to in the source program V = {v 1, v 2... v N } : set of variables referred to in the source program Size(v) : number of allocation units required by v Size(v) : number of allocation units required by v STMTR : set of individual occurrences of instructions STMTR : set of individual occurrences of instructions E = {e 1, e 2... e M } : set of pointer expressions E = {e 1, e 2... e M } : set of pointer expressions

Functions PtrExp : STMTR  E PtrExp : STMTR  E allow the client of the storage allocator to modify the type of single pointer expressions independently allow the client of the storage allocator to modify the type of single pointer expressions independently Seg(v) : V  M, the segment where a variable is allocated Seg(v) : V  M, the segment where a variable is allocated PtrT(e) : E  P, the pointer type a pointer expression is assigned PtrT(e) : E  P, the pointer type a pointer expression is assigned

Cost of A Statement ( 1 ) For each statement in STMTR, we can have pointer cost and variable cost For each statement in STMTR, we can have pointer cost and variable cost ptrcost S ( e, t ) : pointer cost, the cost contribution of selecting “ t ” as the pointer type for pointer expression “ e ” ptrcost S ( e, t ) : pointer cost, the cost contribution of selecting “ t ” as the pointer type for pointer expression “ e ” varcost S ( v, m ) : variable cost, the cost contribution of variable “ v ” if it is located in memory segment “ m ” varcost S ( v, m ) : variable cost, the cost contribution of variable “ v ” if it is located in memory segment “ m ”

Cost of A Statement ( 2 ) The cost of a particular solution is defined in terms of the cost contribution of each statement in STMTR The cost of a particular solution is defined in terms of the cost contribution of each statement in STMTR Cost(S) = ∑ (e  E) ptrcost S ( e, PtrT (e) ) Cost(S) = ∑ (e  E) ptrcost S ( e, PtrT (e) ) + ∑ (v  V) varcost S ( v, Seg(v) ) + ∑ (v  V) varcost S ( v, Seg(v) )

Road Map Brief Background Brief Background Memory Organization & Model Memory Organization & Model Cost Model Cost Model Formulation & Discussion Formulation & Discussion Implementation Implementation Experiment & Results Experiment & Results Conclusion Conclusion

BIP Formulation BIP : Binary Integer Program BIP : Binary Integer Program The storage allocation problem is formulated as a BIP The storage allocation problem is formulated as a BIP Based on the model of Memory Organization and the cost model Based on the model of Memory Organization and the cost model

Feasible Solution Two condition must be satisfied Two condition must be satisfied Total size of the variables in a single memory segment ≤ size of the segment Total size of the variables in a single memory segment ≤ size of the segment Pointer expression that may point to a variable must be assigned a type that can access the segment where that variable is Pointer expression that may point to a variable must be assigned a type that can access the segment where that variable is Find a feasible solution with minimal cost ! Find a feasible solution with minimal cost !

BIP ( 1 ) Each variable can be placed in exactly one memory segment Each variable can be placed in exactly one memory segment x i1 + x i x iS =1, 1 ≤ i ≤ N x i1 + x i x iS =1, 1 ≤ i ≤ N Total size of the variables in a segment can not be greater than the size of the segment Total size of the variables in a segment can not be greater than the size of the segment Size(v 1 ) x 1m + Size(v 2 ) x 2m Size(v N ) x Nm Size(v 1 ) x 1m + Size(v 2 ) x 2m Size(v N ) x Nm ≤ Size(M m ), 1 ≤ m ≤ S

BIP ( 2 ) Each pointer expression have a unique pointer type Each pointer expression have a unique pointer type y j1 + y j y jT = 1, 1 ≤ j≤ M y j1 + y j y jT = 1, 1 ≤ j≤ M Type of a pointer expression be general enough for all the variables in its points-to set Type of a pointer expression be general enough for all the variables in its points-to set Seg(v)  Mem ( PtrT( e j ) ), v  Pt ( e j ) Seg(v)  Mem ( PtrT( e j ) ), v  Pt ( e j )

BIP ( 3 ) Objective function is the cost of the solution Objective function is the cost of the solution

Discussion : Scalability Discussion : Scalability Number of variables and number of pointer expressions grow linearly in the size of the program Number of variables and number of pointer expressions grow linearly in the size of the program Number of memory segments and the number of pointer types depend on target architecture, so can be regarded as constants Number of memory segments and the number of pointer types depend on target architecture, so can be regarded as constants

Discussion : Accuracy Fundamental to the model : cost of a statement can be expressed as linear combination of cost from variables and pointer expressions ---- Not precise Fundamental to the model : cost of a statement can be expressed as linear combination of cost from variables and pointer expressions ---- Not precise Some architectures may represent pointers with multiple machine words, so loading a pointer need several instructions Some architectures may represent pointers with multiple machine words, so loading a pointer need several instructions

Road Map Brief Background Brief Background Memory Organization & Model Memory Organization & Model Cost Model Cost Model Formulation & Discussion Formulation & Discussion Implementation Implementation Experiment & Results Experiment & Results Conclusion Conclusion

Compiler Framework

WPO Prototype Points-to analysis Points-to analysis estimate the points-to set of each pointer estimate the points-to set of each pointer ILP solver ILP solver Information about all global variables and pointers is put into the solver to get an allocation Information about all global variables and pointers is put into the solver to get an allocation

Modified ICCAVR Compile the C source code and use the allocation information by WPO to modify the memory attributes of variables Compile the C source code and use the allocation information by WPO to modify the memory attributes of variables Allocation information is used during the parsing stage to modify the memory attributes of variables Allocation information is used during the parsing stage to modify the memory attributes of variables

Road Map Brief Background Brief Background Memory Organization & Model Memory Organization & Model Cost Model Cost Model Formulation & Discussion Formulation & Discussion Implementation Implementation Experiments & Results Experiments & Results Conclusion Conclusion

Experiments Measure the execution time and code size of 6 benchmarks Measure the execution time and code size of 6 benchmarks Results are compared with code compiled on the standard ICCAR compiler Results are compared with code compiled on the standard ICCAR compiler Different version of AVR microcontroller, internal memory vary from 0 to 4KB or more ( 64KB and 16KB) Different version of AVR microcontroller, internal memory vary from 0 to 4KB or more ( 64KB and 16KB)

Results Results vary a lot with benchmarks Results vary a lot with benchmarks CPU intensive or Memory intensive CPU intensive or Memory intensive Code size decreased slightly for most benchmarks ( Special : statemate ) Code size decreased slightly for most benchmarks ( Special : statemate ) Execution time improved for most benchmarks( also Statemate ) Execution time improved for most benchmarks( also Statemate )

Road Map Brief Background Brief Background Memory Organization & Model Memory Organization & Model Cost Model Cost Model Formulation & Discussion Formulation & Discussion Implementation Implementation Experiments & Results Experiments & Results Conclusion Conclusion

Conclusion Model of memory hierarchies for storage allocation for embedded system processors Model of memory hierarchies for storage allocation for embedded system processors Implement a memory allocator using ILP to get an optimal allocation under the memory model Implement a memory allocator using ILP to get an optimal allocation under the memory model Improve program size and speed Improve program size and speed Automatically done, portable, robust : no need to include target-specific information in source code Automatically done, portable, robust : no need to include target-specific information in source code

The End The End Thank You ! Thank You !