Computer Systems: A Programmer's Perspective Plus Mastering Engineering With Pearson Etext -- Access Card Package (3rd Edition)
3rd Edition
ISBN: 9780134123837
Author: Randal E. Bryant, David R. O'Hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 5.19HW
Program Plan Intro
Given C Code:
void psum1a(float a[], float p[], long n)
{
long i;
float last_val, val;
last_val = p[0] = a[0];
for(i=1; i<n; i++)
{
val = last_val + a[i];
p[i] = val;
last_val = val;
}
}
Cycles per element (CPE):
- The CPE denotes performance of
program that helps in improving code. - It helps to understand detailed level loop performance for an iterative program.
- It is appropriate for programs that use a repetitive computation.
- The processor’s activity sequencing is controlled by a clock that provides regular signal of some frequency.
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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
For the two statements about the running time of ALGO, I need an explanation if it is True and F if it is false
1) The increment operation in Line 6 is executed a total of n/2 times in the worst case 2) The decrement operation in Line 10 is executed O(n) times.
For Reference the Answer for 1 is False and 2 is True
There are many algorithms presented in this text that would lend themselves to beincluded as subprograms in the utils.asm file. Implement some or all of the followinginto the utils.asm file, properly documenting them, and include programs to test them.a. NOR subprogram - take two input parameters, and return the NOR operation onthose two parameter.b. NAND- take two input parameters, and return the NAND operation on those twoparameter.c. NOT- take one input parameters, and return the NOT operation on that parameter.d. Mult4 - take an input parameter, and return that parameter multiplied by 4using only shift and add operations.e. Mult10 - take an input parameter, and return that parameter multiplied by 10using only shift and add operations.f. Swap- take two input parameters, swap them using only the XOR operation.g. RightCircularShift - take an input parameter, and return two values. The firstis the value that has been shifted 1 bit using a right circular shift, and the second isthe…
I am working on a block of code and cannot figure out how to count the number of times a loop is proccessed within the stated parameters, but when the output is 0 that value is not counted in the iteration.
Here is the problem and my code
Chapter 5 Solutions
Computer Systems: A Programmer's Perspective Plus Mastering Engineering With Pearson Etext -- Access Card Package (3rd Edition)
Knowledge Booster
Similar questions
- Scenario: In a biased N-bit binary number system with bias B, positive and negative numbers are represented as their value plus the bias B. For example, for 5-bit numbers with a bias of 15, the number 0 is represented as 01111, 1 as 10000, and so forth. Biased number systems are sometimes used in floating point mathematics. Consider a biased 8-bit binary number system with a bias of 12710 Question: What is the representation and value of the most negative number?arrow_forwardYou are asked by your line manager to implement a computer code for solving the following system of linear equations using MATLAB. You need to upload your code as to be assessed as a part of this assignment. 4x1 + 1x2 + 2x3 − 3x4 + 5x5 = −16 −3x1 + 3x2 − 1x3 + 4x4 − 2x5 = 20 −1x1 + 2x2 + 5x3 + 1x4 + 3x5 = −4 5x1 + 4x2 + 3x3 − 1x4 + 2x5 = −10 1x1 − 2x2 + 3x3 − 4x4 + 5x5 = 3arrow_forwardFor the following Peterson’s solution from your textbook, for the enter_region called by process ‘0’ and process ‘1’, show all possible combinations, interleaving of the execution paths, focusing on testing the ‘while-loop’. Will there be any violation of mutual execution? Explain showing all possible casesarrow_forward
- You are designing a machine that accepts an input n, and produces anoutput p. The interface for the machine is shown in Figure 5.12. Thealgorithm follows.loopforeverz = 0x = nwhile not (x = 0) dox = x - 1z = z + 2p = zarrow_forwardAnswer the given question with a proper explanation and step-by-step solution. Write an MIPS program that computes terms of the Fibonacci series, defined as: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ... (This is sometimes started with a 0th term: 0, 1, 1, 2, etc.)The first two terms in the series are fixed, and each subsequent term in the series is the sum of the preceding two terms. So, for example, the term 13 is the sum of the terms 5 and 8.Write the program as a counting loop that terminates when the 100th term of the series has been computed. Use a register for the current term and a register for the previous term. Each execution of the loop computes a new current term and then copies the old current term to the previous term register. Count the number of passes to stop after the 100th term. Do not worry about overflow: this will FAR exceed the capacity of a register to hold the value. Stop the program with a syscall with 10 in $v0.arrow_forwardConsider the event-controlled loop in the code fragment above and the eight counter-controlled loops beneath it. Which of these counter-controlled loops will perform precisely the same operations as the event-controlled loop? This question is internally recognized as variant 221. Q.1 fragment 1 contains the correct code fragment 2 contains the correct code fragment 3 contains the correct code fragment 4 contains the correct code fragment 5 contains the correct code fragment 6 contains the correct code fragment 7 contains the correct code fragment 8 contains the correct code none of the abovearrow_forward
- Computer Systems In your implementation of the ALU there is no need to detect or handle overflow. However, it's a good mental exercise to think about when/how an overflow might occur. When adding numbers with different signs, overflow cannot occur because the sum must be no larger than one of the numbers. What happens when the signs of the numbers are the same? What happens in the case of subtraction? How do we detect when an overflow does occur?arrow_forwardmake a c++ program and compute for this A jogger starts a course at a steady rate of 8 kph. Five minutes later, a seconds later, a second jogger starts the same course at 10 kph. How long will it take for the second jogger to catch the first?arrow_forwardWhat is the complexity of the following pseudo-code * Write in two line.arrow_forward
- Realize the following approximation of the sin(x) function.. sin x ~ 00 L i=0 (-1)⁰ (2i + 1)! -x2i+1 = x x3 x5 x7 + 3! 5! 7! The approximation is based on the Maclaurin series expansion, and it becomes an equality (i.e. not only an approximation) as the summation continues to infinity. Your program will check if the approximation error falls below 1e-15, and stops if so. Otherwise, it will continue to a maximum of 100 summations. Your program should ask the user about the angle (in radians) which they want to find the sin() of. Notice that the user will only input an angle in radians and in the range [0-pi]. Use a while loop to answer the question. Use the following definition for the approximation error: Error = abs(true value - approximation) / true value Hint: you need two loops, where one goes through the summation, and the other is dedicated to calculating the factorials. Hint: The angle must be expressed in radians and must be in the range [0-pi]. Use such numbers when testing…arrow_forwardthis code wont work due to the surf, please edit it Parameters c = 0.5; n = 101; L = 1; Discretization dx = L/(n-1); dt = 0.5*dx^2/c; Initial conditions y = zeros(n,1); y(1) = 100; y(n) = 100; Time-stepping loop for t = dt:dt:1 Calculate second derivative of y excluding boundaries yxx = (y(3:n)-2*y(2:n-1)+y(1:n-2))/dx^2; y(2:n-1) = y(2:n-1) + c*dt*yxx; end Meshgrid for 3D plot including boundary points [X, T] = meshgrid(dx:dx:L-dx, 0:dt:1); Reshape solution for 3D plot Y = y(2:n-1); Y = repmat(Y,1,size(T,2)); surf(X, T, Y); xlabel('x'); ylabel('t'); zlabel('y');arrow_forwardAnswer questions (a) and (b) below: (a) How many times exactly is the code block below executed? For (i = 1, n) { For (j = 1, i) { For (k = 1, j) { code block } } } Hint: You have to start with n=1, then make assumption what you make expect for any given n = N, and check if the formula you found works for n =N+1. This is what we call prove by induction. (b) What is the theta value of this code segment?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education