Real-Time Embedded Processor Systems – ACOE343 – Experiment #7

Computer Engineering Department

Real-Time Embedded Processor Systems (ACOE343)

Experiment #7

High-Level Transformations for Embedded Computing

Student’s Name:
Semester: Fall 2008 / Date:

Assessment:

Assessment Point / Weight / Grade
Methodology
Presentation and discussion of results
Participation

Assessment Points’ Grade

Comments:

Experiment #7:High-Level Code Transformations for Embedded Computing

Conventions:

The symbol indicates an operation that must be done in hardware e.g. pressing a button or switch, making a connection on the board, a jumper etc.

The symbol indicates an operation that must be done in software e.g. a command that must be entered, a window that must be opened etc.

Objectives:

To use high-level code transformations for improving code performance and exploring performance/code size trade-offs.

To profile code and measure execution time of programs.

PART A

Procedure:

Step 1:

Write a program that calculates the inner product of a row vector and a column vector of 1000 elements, v1[1000] = [0,1,2,3,…999] and v2[1000] = [0,1,2,3,..999]T. Print the result on the serial monitor. Use the micros() function to measure the execution time of the program. Display the execution time on the serial monitor.

Figure 1. Code for vector inner product

Step 2:

Compile the program (From the “Sketch” menu select “Verify/Compile”. If the compiler shows any errors, correct them and re-compile the program.

Compile the program once without the loop that calculates the result to measure the loop code size.

Step 3:

  • Select "Tools=> Board=> Chipkit MAX32""
  • Select "File=>Upload to I/O Board".
  • Wait until you see a "Done uploading" message. An LED in the shield should be flashing.

Question 1:What is the execution time of the program? What is the code size of your program?

PART B

Procedure:

Step 1: Modify your program by unrolling the loop by a factor of two. Again, measure the execution time of your modified program. Make sure the result of the program remains the same after modification.

Figure 2. Loop unrolling by 2 program

Step 2:

Compile the program (From the “Sketch” menu select “Verify/Compile”. If the compiler shows any errors, correct them and re-compile the program.

Step 3:

  • Select "Tools=> Board=> Chipkit MAX32""
  • Select "File=>Upload to I/O Board".
  • Wait until you see a "Done uploading" message. An LED in the shield should be flashing.

Question 2:What is the execution time of the program? What is the code size of your program?

PART C

Procedure:

Step 1: Modify your program by unrolling the loop by a factor of four. Again, measure the execution time of your modified program. Make sure the result of the program remains the same after modification.

Figure 3. Loop unrolling by 4 program

Step 2:

Compile the program (From the “Sketch” menu select “Verify/Compile”. If the compiler shows any errors, correct them and re-compile the program.

Step 3:

  • Select "Tools=> Board=> Chipkit MAX32""
  • Select "File=>Upload to I/O Board".
  • Wait until you see a "Done uploading" message. An LED in the shield should be flashing.

Question 3: What is the execution time of the program? What is the code size of your program?

PART D

Procedure:

Step 1: Modify your program by unrolling the loop by a factor of eight. Again, measure the execution time of your modified program. Make sure the result of the program remains the same after modification.

Figure 4. Loop unrolling by 8 program

Step 2:

Compile the program (From the “Sketch” menu select “Verify/Compile”. If the compiler shows any errors, correct them and re-compile the program.

Step 3:

  • Select "Tools=> Board=> Chipkit MAX32""
  • Select "File=>Upload to I/O Board".
  • Wait until you see a "Done uploading" message. An LED in the shield should be flashing.

Question 4: What is the execution time of the program? What is the code size of your program?

PART E

Procedure:

Create an .xls file and write the unrolling factors in one column, the execution times in a second column and the code sizes on a third column. Create two graphs, one showing the execution time (y axis) as a function of the unroll factor (x axis) and the other showing the code size (y axis) as a function of the unroll factor (x axis).

Figure 5. Execution as a function of the unroll factor

Figure 6. Execution as a function of the unroll factor

Question 5:How does execution time and code size scale with the unroll factor? Is it sensible to unroll the loop any further?

1