Adaptive Mobile Applications 4/21/2009 Richard Yang
Admin. Project
Challenges in Developing Mobile, Wireless Applications Need to adapt to heterogeneous, dynamic device/network status Need to optimize resource usage given that resources are often limited
Motivation for Service Adaptation Service delivered should depend on device status (e.g., display capability, input method, memory size, remaining battery level) network status in-building campus-area packet radio metro-area regional-area
Adaptation: Who and How? request client service result Adaptation need support of the client, the server, and/or a third party (proxy or gateway) Server and third party adaptation is also called content adaptation
Adaptation: Client Responsibility Client informs server its device capability and connection status Client makes best use of available resources and available result data
Content Adaptation Server/third party adapts service/content according to client capability
Client Adaptation
Client Capability Negotiation and Monitoring Rudimentary capability already exists, but far from complete
Two Examples of Client Makes Best Use of Resources/Results Adaptive CPU scheduling Adaptive playout
Example 1: Adaptive CPU Power Management
Big Picture: Power Management
Power Model
Some Techniques of Power Management
Dynamic Voltage Scaling Dynamic Voltage Scaling (DVS) allows voltage to be dynamically adjusted DVS-enabled processors, e.g., StrongARM SA-2 (500mW at 600MHz; 40mW at 150MHz) AMD (PowerNow!) http://www.amd.com/us-en/assets/content_type/DownloadableAssets/Power_Now2.pdf Intel (SpeedStep, XScale) Texas Instrument Transmata
CPU Power Consumption When the supply voltage V is lower, charging/discharging time is longer; thus frequency should be lower
CPU Power Consumption Model The power consumption rate P of a CMOS processor satisfies where k is a constant, C the capacitance of the circuit, f the CPU frequency, and V the voltage -> P ~ O(V3)
Voltage Scaling throughput Discussion: what voltage to operate on?
Dynamic Voltage Scaling Basic idea: determining voltage according to program response time requirement For normal applications, give reasonable response time For multimedia applications, use the deadline to determine voltage
multimedia applications Architecture multimedia applications monitoring requirements scheduling scheduler demand distribution profiler time constraint speed adaptor speed scaling CPU
Demand Prediction Online profiling and estimation: count number of cycles used by each job 1 CDF F(x) = P [X x] cumulative probability Cmin=b0 b1 b2 br-1 br=Cmax
Demand distribution is stable or changes slowly Observations Demand distribution is stable or changes slowly
CPU Resource Allocation How many cycles to allocate to a multimedia job? Application should meet percent of deadlines each job meets deadline with probability allocate C cycles, such that F (C ) =P [X C ] b1 b2 b0 br 1 br-1 cumulative probability F(x) C
How Fast to Run the CPU? Assume the strategy is to run job i at a fix (also called uniform) speed Si Assume it needs Ci cycles during a time duration of Pi Fact: since power is a convex function of frequency, if a job needs C cycles in a period P, then the optimal frequency is C/P, namely the lowest constant frequency.
Why Not Uniform Speed? Intuitively, uniform speed achieves - minimum energy if use the allocated exactly However, jobs use cycles statistically - often complete before using up the allocated - potential to save more energy stochastic DVS
Stochastic DVS For each job such that find speed Sx for each allocated cycle x time is 1/Sx and energy is (1 - F(x))S3x such that
Observation: speed up the processor with increasing clock cycles Example Speed Schedule cycle: speed: 100 MHz 200 MHz 400 MHz Job 1 2.5x106 cycles speed (MHz) 100 400 200 Job 2 1.2x106 cycles Observation: speed up the processor with increasing clock cycles
DVS A1 B1 A1 A1 A2 context switch Store speed for switched-out New speed for switched-in speed up within job switch back A1 B1 A1 speed A1 A2 execution
Extension to Linux kernel 2.4.18 Implementation Hardware: HP N5470 laptop Athlon CPU (300, 500, 600, 700, 800, 1000MHz) round speed schedule to upper bound system call process control block DVS modules PowerNow speed scaling Soft real-time scheduling standard Linux scheduler Extension to Linux kernel 2.4.18 716 lines of C code
Evaluation: Normalized Energy Reduces power consumption However, limited due to few speed options
Example 2: Deal with Variable Delay
Example: Deal with Variable Delay Consider multimedia applications Packets arrive with variable delay (why?) Variable delay does not work well for multimedia application
Client Playout Buffer Basic idea: delay playing out packets to accommodate delay jitter Question: how to determine the playout delay? packets number time packets generated p p' delay 1 r received
Odyssey: An Example Client Architecture Application indicates resource capabilities in its request to service Operating system maintains/monitors available resources no need to have each application re-implement the monitoring An application registers a resource descriptor and an upcall event handler with the OS OS notifies the application upon detecting resource changes Application adjusts requests to the server
Client System Model
Content Adaptation
Objective: automating adaptation Content Adaptation: Examples Objective: automating adaptation
Example: Adapting Audio Content 2 3 Send a lower resolution stream as the redundant information, e.g. nominal stream at 64 kbps and redundant stream at 13 kbps (such as GSM)
Example: Adapting Fidelity of Video/Image Content? Potentially many dimensions frame rate (for video) image size quality of image Usage: e.g., data acceleration offered by many carriers
Frame Encoding: Block Transform Encoding DCT Zig-zag Quantize Huffman Code Run-length Code 011010001011101...
Discrete Cosine Transform 4C(u)C(v) n-1 n-1 (2j+1)up (2k+1)vp å å f(j,k) cos F[u,v] = cos n2 2n 2n j=0 k=0 where 1 for w=0 Ö 2 C(w) = for w=1,2,…,n-1 1 DCT is better at reducing redundancy than Discrete Fourier Transform but it is more computationally expensive
Basis Functions of DCT An image is a superposition of basis functions DCT computes the contribution of each basis function - F[u,v]: for the basis function at position [u, v] more detail
Example: MPEG Block Encoding DC component Quantize DCT original image AC components zigzag run-length and Huffman encoding of the stream 10011011100011... coded bitstream < 10 bits (0.55 bits/pixel) Discussion: how to generate different encoding rates?
Examples Uncompressed (262 KB) Compressed (22 KB, 12:1)