Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
Question
Book Icon
Chapter 5.8, Problem 5.7PP
Program Plan Intro

Given C code:

void combine5(vec_ptr v, data_t *dest)

{

long i;

long length = vec_length(v);

long limit = length – 1;

data_t *data = get_vec_start(v);

data_t acc = IDENT;

for(i=0; i<limit ; i+=2)

{

acc = (acc OP data[i]) OP data[i+1];

}

for(; i<length ; i++)

{

acc = acc OP data[i];

}

*dest = acc;

}

Memory aliasing:

  • It denotes a case where two pointers might designate to memory location that is same.
  • The compiler should assume that unlike pointers might be aliased for safe optimizations.
  • The program aspects that could limit chances for a compiler in generating optimized code denote optimization blockers.
  • If a compiler is unable to determine whether two pointers might be aliased, it should adopt that either case would be possible.
  • The possible optimization set is been limited in this case.

Loop unrolling:

  • It denotes a program transformation that would reduce count of iterations for a loop.
  • It increases count of elements computed in each iteration.
  • It reduces number of operations that is not dependent to program directly.
  • It reduces count of operations in critical paths of overall computations.

Blurred answer
Students have asked these similar questions
Using C++ programming
1. (Shortest Path) Please find the shortest path between the blue triangle and red tri- angle as Figure 1. Please explain your approach and develop the computationally efficient algorithm to get the results. Can you obtain (or estimate) the time com- plexity and memory complexity of your algorithm? 麗
(a) Assume that five generation units with third order cost function (F, (R) = A; P+ B;P+C; P; + D;) are in the circuit. Write a computer program using any abitrary programming longuage (MATLAB, C++, C#, Python,.) to calculate economic load dipatch (ELD) using first order gradient method. Note that all parameters and variables should be defined inside the program (at tirst lines) such that units' characteristics and demand can be changed easily. Neglect grid losses. jusing dynamic programming (DP) methed.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr