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).…
Note: 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
1
2. 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.)
Chapter 5 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Knowledge Booster
Similar questions
- In Big-Θ notation, analyze the running time of the following piece of code/pseudo-code. Describe the running time as a function of the input size (here, n). You should always explain your work when solving mathematics problems.arrow_forwardDevelop pseudocode for the problem of reading in an arbitrary number of DNA (deoxyribonucleic acid) bases, one at a time, and print out the complementary base sequence in the same order as the DNA bases were input. There are four DNA bases: A (adenine), C (cytosine), G (guanine), T (thymine). You should verify that a correct base is input each time and print out an error message if it is incorrect. Assume that “!” is used as the input symbol to indicate that no more DNA bases will be entered (i.e., it is the end of the DNA base sequence). The following table shows the complementary base for each DNA base: DNA Base Complementary Base A T C G G C T A As an example, if the input is “ATGGTCA”, then the output should be “TACCAGT”.arrow_forwardNeed the solution of the code step-by-step please!arrow_forward
- Implement 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_forwardWrite an Arduino program for the following machine problems. The program sequence should run continuously. Set the delay to 1 second. (USE TINKEDCAD) Challenge Problem.Create a program that displays "AbC" one at a time. For every keypress of PB1 it should cycle from A->b->C and go back to A. For PB2, it is the opposite of PB1, from C->b ->A. PB1 and PB2 can be pressed anytime. For example, If the current display is “A” pressing PB2 would display “C” then pressing PB1 will display it back to “A” and so forth. PB3 is used to blank the display and reset the operation. Sample simulation is given belowarrow_forwardBelow C-code has a for loop which will repeat 1000 times of the operation. This code will be running on very simple machine. Change the code to reduce the number of branch instructions. You can have up to 5 lines (statements) within the for loop. What is the number of branch operations before and after? for (i=0; i<1000; i++){ y[i] = w * x[i] + b[i]; }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_forwardWrite computer program to solve a set of equation by using Gauss-Seidel Iteration.arrow_forwardImplement the modular exponentiation (a.k.a. fast exponentiation)function mod_exp (b, n, m) to compute bn (mod m) more efficiently. (Hint: toread 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. in pahtonarrow_forward
- Here is my question that my professor gave to me as a homework from my algorithm's class.arrow_forwardPlease use pythoncode 6. Evaluate as accurately as possibleIntegral 0 to 1 2x+1/square roots of x(1-x) dx hint: substitute x=(1+t)/2.arrow_forwardWrite a MIPS program that will handle calculating minifloat addition for two numbers using the rules discussed in class and storing each of the parts as a binary integer. To do this, each ‘minifloat’ number will need to be represented (I suggest hard coded) as one register for the sign, one for the exponent part, one for the ‘significand’ (which you then convert to the fraction part). Hard coding means here that you don’t need to read in the 6 parts as user input, just have something like li $s0, 0 li $s1, 12 li $s2, 5 which is equivalent to a minifloat of 0 1101 101 = 1.101 * 2^(12-7) = 1.101*2^5 This means your program will be work with at least 6 registers as variables. For testing, show that your program can correctly calculate the Lab 5 X+Y and A+B and then one other example of your choosing. Don’t worry about special cases of 0 0000 000 or 1 1111 111 or similar, but your program should detect overflow. This will involve a lot of (in your head) jumping back and forth between…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