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
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
In MIPS assembly, implement integer division using rounding (rather than truncation). This is accomplished by taking the remainder of the division and dividing it by the original divisor. If the new quotient is higher than or equal to one, multiply it by one.Otherwise, leave the original quotient alone.In MIPS assembly, implement integer division using rounding (rather than truncation). This is accomplished by taking the remainder of the division and dividing it by the original divisor. If the new quotient is higher than or equal to one, multiply it by one.Otherwise, leave the original quotient alone.In MIPS assembly, implement integer division using rounding (rather than truncation). This is accomplished by taking the remainder of the division and dividing it by the original divisor. If the new quotient is higher than or equal to one, multiply it by one.Otherwise, leave the original quotient alone.In MIPS assembly, implement integer division using rounding (rather than truncation).…
Using any digital flowcharting tool ( Lucidchart, Vizio), write 4 UML functions. Each one should take in a pair of numbers and then print out all integer values between (and including) those two numbers. You may assume the lower number comes first.
Use these 4 types of loop for each of the four functions: while, do-while, automatic counter, and recursion. Clearly identify each one.
Please do it on your own , do not get the answer from chegg
Chapter 5 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Knowledge Booster
Similar questions
- With c programming and without pointer and function Harry and Larry are now bored playing with numbers. Now they want to play with plus and minus signs. This time they don’t want to give signs one by one. Anyone can give any number of signs at a time but at most N signs. Can you tell the maximum of all signs that they gave sequentially? For example: If the input is 7 + + - + - - - , then the answer is 3 as 3 minus signs are given sequentially and it is the maximum. If the input is 7 + + + + + - - , then the answer is 5. Input Format First line will contain a positive integer N Second line will contain N signs (+ or -) Constraints 0 < N <= 100 Output Format Output a single integer, the maximum of all signs that came sequentially. Sample Input 0 7++++--- Sample Output 0 4arrow_forwardNote: Please Answer in C++ programming language. Kulyash is given an integer N. His task is to break Ninto some number of (integer) powers of 2. To achieve this, he can perform the following operation several times (possibly, zero): Choose an integer X which he already has, and break X into 2 integer parts (Y and Z) such that X = Y + Z. Find the minimum number of operations required by Kulyash to accomplish his task. Input 1 3 Output 1arrow_forward2. There is a more efficient algorithm (in terms of the number of multiplications and additions used) for evaluating polynomials than the conventional algorithm described in the previous exercise. It is called Horner's method. This pseudocode shows how to use this method to find the value of anx" + an-1xn ++ a₁x + ao = 0 at x = c. procedure Horner(c, ao, a₁, a2,..., an: real numbers) y := an for i:=1 to n y := y*c+an-i return y(y = anc" +an-1c"1+...+ a₁c + ao} 2.a Evaluate 3x² + x + 1 at x = 2 by working through each step of the algorithm showing the values assigned at each assignment step. 2.b Exactly how many multiplications and additions are used by this algorithm to evaluate a polynomial of degree n at x = c? (Do not count additions used to increment the loop variable.)arrow_forward
- Could you help me write a python program for this: Apply the composite Gaussian Quadrature to approximate the integral (shown below) using N=10 subintervals. Calculate the absolute error using the exact integral. Repeat your calculation forN=10,20,30,40,50. Observe the error as N gets largerarrow_forwardgive solution in c++ langauge with sourcecode and its output secreen secreenshots and also give relative theoryarrow_forwardmake mathlab codearrow_forward
- Using MIPS in assembly language, you are to create a MIPS program that demonstrates that the associative law fails in addition for floating point numbers (single or double precision). You only need to demonstrate it for single precision. Remember the associative law is a + (b + c) = (a + b) + c. *Include a screenshot of the code running, Also have a lot of comments in your program as this is an assembly language program. Make the code neat and readable.arrow_forwardWrite a Python function that computes the Fourier series expansion for a square wave for a given value of n. Ensure that your plot includes the expansion for n=1, 5 and 100. You should assume that h = 1, and T = 1 to simplify the task of plotting this series expansion.arrow_forwardImplement the modular exponentiation (a.k.a. fast exponentiation) function mod_exp (b, n, m) to compute bn (mod m) more efficiently. (Hint: to read n bit-by-bit, use / and % operations repeatedly) a) Test your function for b = 3, n = 231 – 2, m = 231 – 1. b) Report the result and the time (in seconds) it takes to find the result. Q3. [30 pts] Modify your is_prime function to use the mod_exp (b, n, m) instead of the standard power operation (b**n % m). Rename it as is_prime2. Modify the mersenne (p) function to use is_prime2, and call it mersenne2. a) Use the modified function mersenne2 to print all the Mersenne primes Mp for p between 2 and 31 if possible, (with k = 3 in the is_prime function). Compare the results with the ones found in Q1. b) Gradually increase the range of p to find more Mersenne primes (say up to p = 101 if possible). What is the largest Mersenne prime you can achieve here? c) Extend the work in part (b) and find the maximum Mersenne prime you can get from this…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