Question
Using the C Programming language, write a program that sums an array of 50 elements. Next, optimize the code using loop unrolling. Loop unrolling is
Using the C Programming language, write a program that sums an array of 50 elements. Next, optimize the code using loop unrolling. Loop unrolling is a program transformation that reduces the number of iterations for a loop by increasing the number of elements computed on each iteration. Generate a graph of performance improvement. Tip: Figure 5.17 in the textbook provides an example of a graph depicting performance improvements associated with loop unrolling.
**My Question is how do I generate the CPE graph? I don't need to write the C program as I already have it. I'm curious bout how this graph is actually created. See below.
The normal loop
#includeint main() { int array[50]; int i,j; int value = 5; int sum = 0; //Create the Array for(j=0;j
The Unrolled Loop
#includeint main() { int array[50]; int i,j; int value = 5; int sum = 0; //Create the Array for(j=0;j Section 5.8 Loop Unrolling 5 Figure 5.17 CPE performance for different degrees of kx 1 loop unrolling. Only integer addition improves with this transformation. double double + CPE long long + 2 1 0 2 T 5 6 3 4 Unrolling factor k Practice Problem 5.7 (solution page 611) Modify the code for combines to unroll the loop by a factor k = 5. When we measure the performance of unrolled code for unrolling factors k=2(combine5) and k = 3, we get the following results: Integer Floating point Function Page Method combine4 551 No unrolling 1.27 3.01 3.01 5.01 combine5 568 2 x 1 unrolling 1.01 3.01 3.01 5.01 3 x 1 unrolling 1.01 3.01 3.01 5.01 Latency bound 1.00 3.00 3.00 5.00 Throughput bound 0.50 1.00 1.00 0.50
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started