University of Illinois at Urbana-Champaign

Department of Electrical and Computer Engineering

ECE 511: Computer Architecture

Fall 2006

Homework 4

Purpose

The main purpose of this assignment is to give you some experience with loop transformations and to help you understand how code transformations interact with the microarchitecture.

Assignment

Download and extract the tarball ece511-hw4.tar.gz.

When you type "make" your machine should compile four executables, sa-opt, sa-unopt, mr-opt and mr-unopt. sa-unopt is a simple program that sums the elements of an array. sa-opt is a version of the same code that has been transformed in the following way: the loop has been unrolled by a factor of four, and the summation has been reassociated.


Problem 1

You should time sa-unopt and sa-opt (e.g. on a linux machine run "time sa-opt". On my machine (which has a two-year-old Athalon processor) sa-opt runs almost twice as fast as sa-unopt. Why?


Problem 2

mr-opt and mr-unopt are currently the same code: they take a matrix, sum all the rows and then find the row with the maximum sum. Through some combination of loop unrolling, renaming, loop interchange and reassociation, substantially improve the performance of the loop. The loop is in the file max_row.c.


mif@uiuc.edu