Docsity

Elcor Overview Cache-Conscious Code Layout - Lecture Slides | EECS 583, Assignments of Electrical and Electronics Engineering

Partial preview of the text

Download Elcor Overview Cache-Conscious Code Layout - Lecture Slides | EECS 583 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EECS 583 – Class 6 Elcor Overview Cache-Conscious Code Layout

University of Michigan January 26, 2005

  • 1 -

Reading Material

Y

Today’s class

“Profiled Guided Code Positioning”, K. Pettis and R. Hansen, Proc. PLDI-90, 1999

“Procedure Placement Using Temporal Ordering Information”, N. Gloy et al., Proc. MICRO-30, 1997

Y

Material for the next lecture

Compilers: Principles, Techniques, and Tools

A. Aho, R. Sethi, and J. Ullman, Addison-Wesley, 1988. (Sections: 10.5, 10.6, 10.9, 10.10)

  • 3 -

Running Elcor Manually

Y

Compiling a benchmark

tcc –bench strcpy

Y

strcpy_O directory created

impact_intermediate

elcor_intermediate

y

strcpy.O_tr.tgz – impact output / elcor input (bridge code)

X

Impact assembly (called Lcode or Mcode)

X

This is what you will run Elcor manually on

X

Untar this file

±

file1.O_tr, file2.O_tr, … ±

1 file per original C source file

y

strcpy.O_el.tgz – elcor output

X

Rebel

y

host_layout_info.md – data structure organization stuff

simu_intermediate

  • 4 -

Running Elcor Manually (2)

Y

Convert Lcode to Rebel

Get used to Rebel – no need to worry about 2 assembly codes

elcor –i strcpy.O_tr –o strcpy.O_reb –Foutput_format=rebel \ –Fdo_null_processing=yes

strcpy.O_reb is our input file

Y

Run elcor

Default input/output format is Lcode (see IO_DEFAULTS)

elcor –i strcpy.O_reb –o strcpy.O_el –Finput_format=rebel \ –Foutput_format=rebel

Can also just directly use the strcpy.O_tr file if you wish

Invokes eecs583_hw1_driver(Procedure *f)

y

Entry point for HW

In elcor/src/eecs583/hyperblock.cpp

After, perform scheduling (may want to disable this duringdebugging, see elcor/parms/DRIVER_DEFAULTS)

  • 6 -

Elcor Organization

Y

src/Tools

y

“homegrown” version of STL - list, dlist, slist, hash_set, hash_map, …

Y

src/Graph

y

All the core compiler data structs in here

y

operand.h, port.h, op.h, region.h, edge.h, *_utilities.h, opcode_properties.h

Y

Main

y

process_function.cpp is the main driver

Y

Mdes

y

target processor info – built from .lmdes2 file

Y

Analysis

y

control flow, dataflow analysis, predicate analysis, edge drawing

Y

Control

y

Control flow transformations

Y

Templates

y

Whenever you create a List that has never been done before

y

Must instantiate template – look in the files for example

y

Hw1 – add to eecs583/templates.cpp

  • 7 -

Core IR (see src/Graph)

Y

Defn – control edges

C0 = control flow (always around, even sequential flow)

C1 = control dependence (not in by default)

Y

Operation-level control flow graph

All ops connected to/from with C0 edges

Branches have multiple outgoing C0 edges

Y

Regions are layered on top

Regions must be perfectly nested

Basicblocks, Hyperblocks, and Procedures are all you need toworry about now.

Y

All basicblock/hyperblocks start with C_MERGE and endwith a branch (if no branch, then DUMMY_BR used)

Profile Guided Code Positioning

K. Pettis and R. Hansen, PLDI-90, 1990.

  • 10 -

Motivation

Y

Instruction memory critical to programperformance

» Cache line

conflicts

are one cause of misses

» Particularly for direct-mapped caches » Page faults

Y

Default code layout for most compilers is bad

» Instructions placed in source order » Procedures placed according to source file listing

Y

Compilers can

rearrange code

to reduce misses

» More performance and less power for free

  • 12 -

Example Call Graph

  • 13 -

Merging Nodes

) The heaviest weight edge is one connecting procedures A and D.They are merged. Edge weights areupdated.

  1. The next edge chosen is the onebetween C and F.
  • 15 -

Basic Block Ordering

Y

Define the order of the basic blocks in eachprocedure

Y

First, identify chains of blocks

» 2 methods

y

Top-down

y

Bottom-up

Y

Second, define precedence relation between thechains

» Want non-taken conditional branches to be forward as

much as possible

  • 16 -

Top-Down Chain Formation

Form BB chains with the following steps:

  1. First place the entry basic block for theprocedure.^ 2) The successor that is connected to the lastplaced basic block by the largest count is selected.^ 3) If all successors have been selected, pickamong the unselected blocks with the largestconnection to the already selected blocks.^ 4) Continue until all blocks are placed.
  • 18 -

Bottom-up Chain Formation

Y

Form BB chains using the following steps

» Initially consider each basic block as the head and tail

of a chain.

» Looking at the edges from largest to smallest weight,

two different chains are merged if the arc connects thetail of one chain to the head of the other.

  • 19 -

Class Problem

Create the BB chains using bottom-uppositioning