HW1 Project Will be assigned tonight Proposal due next Wed - - PDF document

hw1 project
SMART_READER_LITE
LIVE PREVIEW

HW1 Project Will be assigned tonight Proposal due next Wed - - PDF document

HW1 Project Will be assigned tonight Proposal due next Wed (2/16) Due on 2/24 (Wed), 5pm Do you have a team? Submit to hand-in bins outside Lopata 408. Do you have an idea? Homework will NOT be accepted after due


slide-1
SLIDE 1

Chenyang Lu CSE 467S 1

HW1

  • Will be assigned tonight
  • Due on 2/24 (Wed), 5pm
  • Submit to hand-in bins outside Lopata 408.
  • Homework will NOT be accepted after due

date/time.

  • Collaboration is NOT allowed.

Chenyang Lu CSE 467S 2

Project

  • Proposal due next Wed (2/16)
  • Do you have a team?
  • Do you have an idea?
  • Have you started reading related

materials?

  • Welcome to discuss with me!

Chenyang Lu CSE 467S 3

More project ideas

  • Program applications on Agilla
  • Existing examples:
  • Fire tracking (see today’s demo)
  • Intruder tracking
  • Network exploration
  • Implement power management modules
  • n TinyDB

Chenyang Lu CSE 467S 4

Now, we head to MobiLab!

Chenyang Lu CSE 467S 5

Software Optimization and Analysis

Chenyang Lu CSE 467S 6

Transformation of Software

compile assembly assemble assembly assembly link load assembly assembly

  • bject

HLL HLL HLL Relative Address Absolute Address Physical Address executable

  • ptimize

Analyze

slide-2
SLIDE 2

Chenyang Lu CSE 467S 7

Program design and analysis

  • Optimizing for execution time.
  • Optimizing for energy/power.
  • Optimizing for program size.
  • They may conflict with each other!

Chenyang Lu CSE 467S 8

Optimization for Performance

Chenyang Lu CSE 467S 9

Why do we need to know?

  • Understand various optimization levels (-O1, -

O2, etc.)

  • Look at mixed compiler/assembler output.
  • Modifying compiler output requires care:
  • correctness;
  • loss of hand-tweaked code.

Chenyang Lu CSE 467S 10

Expression simplification

  • Constant folding:
  • 8+1 = 9
  • Algebraic:
  • a*b + a*c = a*(b+c)
  • Strength reduction:
  • a*2 = a<<1

Chenyang Lu CSE 467S 11

Dead code elimination

  • Dead code:

#define DEBUG 0 if (DEBUG) dbg(p1);

  • Can be eliminated by

analysis of control flow, constant folding.

dbg(p1); 1

Chenyang Lu CSE 467S 12

Function calls

slide-3
SLIDE 3

Chenyang Lu CSE 467S 13

ARM

  • Branch and link instruction:

BL foo == MOV r14, r15 B foo

  • r15 contains the current PC
  • Copies current PC to r14.
  • To return from subroutine:

MOV r15,r14

Chenyang Lu CSE 467S 14

Function calls

  • Understand the overhead of function calls
  • Caller and callee must follow a consistent

protocol (order) to access the stack

  • Different compilers and programmers may follow

different orders

  • Access the stack (ARM)
  • Push: STR r0, [r13, #4]!
  • Pop: SUB r13, #4

Chenyang Lu CSE 467S 15

Example Protocol for ARM

  • R13 always points to the top of stack
  • Caller: call a function
  • Push parameters to stack
  • BL (R15 (PC) R14; jump)
  • Callee: receive a call
  • Read parameters from stack
  • Overwrite top of stack with return address (R14)
  • Callee: return
  • Load PC with return address (on top of stack)
  • Caller: receive a return
  • Pop callee’s return address from stack
  • SHARC: PC stack no need to push/pop return addresses

Chenyang Lu CSE 467S 16

Nested function calls

int main() { f1(int x); } void f1(int a) { f2(a); } ; f1 is called by main() f1 LDR r0, [r13] ; load para. into r0 from stack STR r14, [r13] ; store f1’s return addr. ; f1 calls f2() STR r0, [r13, #4]! ; push para. for f2 to stack BL f2 ; branch and link to f2 ; f1 receives return from f2() SUB r13, #4 ; pop f2’s para. off stack ; f1 returns to main() LDR r15, [r13] ; restore register and return Correct p. 82 of textbook!

Chenyang Lu CSE 467S 17

Function inlining

int foo(a,b,c) { return a + b - c;} z = foo(w,x,y);

  • z = w + x - y;

Improve performance

  • Eliminates procedure linkage overhead:

May increase code size

  • Not always…
  • Affect instruction cache behavior

Chenyang Lu CSE 467S 18

Reading

  • Sec 5.5, 5.6, 5.7