School of Electrical and Computer Engineering N.T.U.A. Embedded System Design Lazaros Papadopoulos Dynamic Data Type Refinement Methodology
Άδεια Χρήσης Το παρόν εκπαιδευτικό υλικό υπόκειται σε άδειες χρήσης Creative Commons. Για εκπαιδευτικό υλικό, όπως εικόνες, που υπόκειται σε άδεια χρήσης άλλου τύπου, αυτή πρέπει να αναφέρεται ρητώς.
Overview Dynamic applications DDTR Implementation in various application domains DDTR extensions
Dynamic behavior of network and multimedia applications MM WL Dynamic applications: Increased interaction with the environment Sensitivity in user input The number of data accesses is unknown The timing of data accesses is unknown 3
Dynamic applications Network algorithms Games Databases Streaming
Dynamic Data Structures Dynamic applications organize the data in dynamic data structures. The application performs requests of data insertion or removal during the execution. The selected data structure affects the memory footprint and the memory accesses needed to satisfy the application's requests. A single layer data structure: Singly Linked List of 100 nodes A multi-layer data structure: Single Linked List of Arrays of 100 nodes 1 2 3 1 2 3 Record Record Record 100 100 5
A simple motivational Example Dynamic array vs. single linked list
Power consumption in mobile devices
Library Design // Dynamic Application: We designed a library of more than 20 dynamic data structures that monitors the memory accesses and memory footprint. The interface of the library is plugged in the application. Operations such as insert and remove are performed via the data structure of the library. DDT Library Selected DDTs: SLL DLL... // Original DDT Declarations: // std:: vector<packet> ddt1; // std:: vector<node> ddt1; // Library DDT Declarations // replace the original: SingleLinkedList<Packet> ddt1 DoubleLinkedList<Node> ddt2 function() { // insert is performed through the library: ddt1.insert() } // delete is performed through the library: ddt2. Remove() Energy Mem. Accesses Energy Mem. Footprint Mem. Footprint Mem. Accesses LEGEND: Library Input Output LOGFILE Memory accesses Memory footprint Design Constraints DDT Library Pareto Point Analysis 8
Optimizing dynamic applications INPUT: Application source code Dynamic Data Type Exploration Plug DDT Library Interface to the application s source code DDT Exploration for dynamic access behavior 1 2 3 100 1 2 3 100 Record Record Record INPUT: Design Constraints Pareto Optimal Exploration Execution Time vs. Energy Memory Accesses vs. Memory Footprint... Execution Time (Normalized) 100 80 60 40 20 Pareto Curve execution time vs. energy consumption Optimized Application 100 200 300 400 Energy (mj) 500 Pareto Curve mem. accesses vs. mem. footprint Memory Accesses 8.0e7 6.0e7 4.0e7 2.0e7 3 4 5 6 60 80 90 100 9 Memory Footprint
Matisse and new DDT library Comparison Feature Absract Data Type (ADT) DDT Implementations provided Extension of the DDT Library Combination of DDTs in more complex ones Matisse profiling tool Not supported Limited (Unsorted Lists only) Not easy Supported New DDT library Supported Extended (Sorted Lists, Trees, Sets, and more) Easy (due to the object oriented design of the Library) Supported, but easier (due to the object oriented design of the Library) Interface No STL compliant STL compliant 10
Experimental Results: A 2D Strategy Game 100000 80000 2D Strategy Game Pareto curve SLL(R) Memory Accesses 60000 40000 20000 0 SLL(P) ARR 0 10 20 30 40 50 Memory Footprint (KB)
Experimental Results: A 3D Game 2.E+06 2.E+06 3D Racing Game Pareto curve SLL(P) Memory Accesses 1.E+06 8.E+05 4.E+05 SLL ARR 0.E+00 0 1 2 3 4 5 Memory Footprint (MB)
DDTR extensions Runtime data structure adaptivity. Data structure efficiency is not affected only by the application access pattern, but also by the system hardware specifications, e.g. the cache. DDTR in multicore architectures. Other extensions
DDTR in multicore architectures
DDTR in multicore architectures
DDTR Adaptive approach Methodology Runtime Manager Input: Jobs: Pareto Points Overheads Decides when to move to a new Pareto point taking into account: DDT characteristics Application demands System demands Overhead
Overheads of the Adaptive approach Design time exploration (usually takes less than 1min) Code size of runtime manager (about 1KB) Performance overhead (is configurable and usually trivial since every time consuming calculation takes place at design time) Overheads of mode changes: performance and memory footprint (can be configured by the designer)
Other extensions: DDTR in other programming languages Python list data structure is implemented as dynamic arrays. Python deque data structure is implemented as a list of arrays. typedef struct { PyObject_HEAD Py_ssize_t ob_size; /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */ PyObject **ob_item; /* ob_item contains space for 'allocated' elements. The number * currently in use is ob_size. * Invariants: * 0 <= ob_size <= allocated * len(list) == ob_size * ob_item == NULL implies ob_size == allocated == 0 */ Py_ssize_t allocated; } PyListObject;
Χρηματοδότηση Το παρόν εκπαιδευτικό υλικό έχει αναπτυχθεί στα πλαίσια του εκπαιδευτικού έργου του διδάσκοντα. Το έργο «Ανοικτά Ακαδημαϊκά Μαθήματα» του ΕΜΠ έχει χρηματοδοτήσει μόνο την αναδιαμόρφωση του υλικού. Το έργο υλοποιείται στο πλαίσιο του Επιχειρησιακού Προγράμματος «Εκπαίδευση και Δια Βίου Μάθηση» και συγχρηματοδοτείται από την Ευρωπαϊκή Ένωση (Ευρωπαϊκό Κοινωνικό Ταμείο) και από εθνικούς πόρους.