hw4_cse490-590-su2021_sol
.pdf
keyboard_arrow_up
School
SUNY Buffalo State College *
*We aren’t endorsed by this school
Course
590LR
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
6
Uploaded by SuperHumanWombatMaster946
CSE 490/590 Summer 2021 Homework 4 1.
For the code sequence shown below. loop: l.d $f12, 0($f5) add.d $f6, $f6, $f12 daddui $f5, $f5, -8 bne $f5, $f9, loop // $f9 holds the address of the last value to be operated on a) Show loop unrolling so that there are four copies of the loop body Assume $f5, $f9 (that is, the size of the array) are initially a multiple of 32, which means that the number of loop iterations is a multiple of 4. Eliminate any obviously redundant computations and do not reuse any of the registers. l.d $f12, 0($f5) add.d $f7, $f7, $f12 l.d $f13, -8($f5) add.d $f8, $f8, $f13 l.d $f14, -16($f5) add.d $f10, $f10, $f14 l.d $f15, -24($f5) add.d $f11, $f11, $f15 daddui $f5, $f5, -32 bne $f5, $f9, loop add.d $f16, $f7, $f8 add.d $f17, $f10, $f11 add.d $f18, $f16, $f17 or l.d $f12, 0($f5) add.d $f6, $f6, $f12 l.d $f13, -8($f5) add.d $f6, $f6, $f13 l.d $f14, -16($f5) add.d $f6, $f6, $f14 l.d $f15, -24($f5) add.d $f6, $f6, $f15 daddui $f5, $f5, -32 bne $f5, $f9, loop
b) Computer the number of cycles needed for 4 iterations 1. l.d $f12, 0($f5) 2. stall 3. add.d $f7, $f7, $f12
CSE 490/590 Summer 2021 Homework 4 4. l.d $f13, -8($f5) 5. stall 6. add.d $f8, $f8, $f13 7. l.d $f14, -16($f5) 8. stall 9. add.d $f10, $f10, $f14 10. l.d $f15, -24($f5) 11. stall 12. add.d $f11, $f11, $f15 13. daddui $f5, $f5, -32 14. stall 15. bne $f5, $f9, loop 16. add.d $f16, $f7, $f8 17. add.d $f17, $f10, $f11 18. stall 19. stall 20. stall 21. add.d $f18, $f16, $f17 or 1. l.d $f12, 0($f5) 2. stall 3. add.d $f6, $f6, $f12 4. stall 5. l.d $f13, -8($f5) 6. stall 7. add.d $f6, $f6, $f13 8. stall 9. l.d $f14, -16($f5) 10. stall 11. add.d $f6, $f6, $f14 12. stall 13. l.d $f15, -24($f5) 14. stall 15. add.d $f6, $f6, $f15 16. daddui $f5, $f5, -32 17. stall 18. bne $f5, $f9, loop 2.
For the code sequence shown below L.D F0,0(R1) ADD.D F4,F0,F2 S.D F4,0(R1)
CSE 490/590 Summer 2021 Homework 4 L.D F0,-8(R1) ADD.D F4,F0,F2 S.D F4,-8(R1)
Rename the registers as needed and schedule the sequence to minimize the stalls L.D F0,0(R1) stall ADD.D F4,F0,F2 Stall stall S.D F4,0(R1) L.D F5,-8(R1) stall ADD.D F6,F5,F2 Stall stall S.D F6,-8(R1) Schedulling L.D F0,0(R1) L.D F5,-8(R1) ADD.D F4,F0,F2 ADD.D F6,F5,F2 stall S.D F4,0(R1) S.D F6,-8(R1) 3.
For the given code sequence below executed on a 2-issue processor. I1: LW r2, 0(r1) I2: LW r3, 4(r1) I3: LW r4, 8(r1) I4: LW r4, 12(r1) I5: ADD r6, r4, r5 I6: ADD r7, r2, r3 I7: ADD r8, r7, r6 I8: LW r9, 4(r8) a) Draw a pipeline diagram [Consider Data Forwarding] You can also follow datapath design in lecture
b) Calculate IPC
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Range for loop should be used even the block code needs to access index.
Group of answer choices
True
False
arrow_forward
while_enter_zero at
Submit Assignment
Due Friday by 11:59pm
Points 20
Submitting a file upload
While loop to check a number is zero or not.
Often the number of times a loop is executed is not predetermined. You may use an input value to signify the end of
the loop. Such a value is known as a sentinel value.
Write a program that reads and calculates the sum of an unspecified number of integers. The input 0 signifies the end
of the input.
ons
• Previous
Next
rive
onnect: Stu-
port
tv
W
MacBook Air
888
DD
F2
F3
F4
F5
F6
F7
F8
F9
F10
%23
&
2
6.
7
8.
W
T
Y
U
S
F
G
H
J
K
arrow_forward
You may define a(n) ________ in the initialization expression of a for loop.
arrow_forward
QUESTION 26
Write code that uses a while loop to display the powers of 2 exactly as shown below:
1248163264128
arrow_forward
2 PMOV
3
Summary
4 This program allows each theater patron to enter a value from
5 0 to 4 indicating the number of stars that the patron awards
In this lab, you write a while loop that uses a sentinel value to
6 to the Guide's featured movie of the week. The program
control a loop in a Python program. You also write the statements
7 executes continuously until the theater manager enters a
8 negative number to quit. At the end of the program, the
that make up the body of the loop.
9 average star rating for the movie is displayed.
The source code file already contains the necessary assignment
11
and output statements. Each theater patron enters a value from 0
12 # Initialize variables.
13 totalStars = 0
# total of star ratings.
# keep track of number of patrons
to 4 indicating the number of stars that the patron awards to the
14 numPatrons = 0
Guide's featured movie of the week. The program executes
15
continuously until the theater manager enters a negative number
16
to quit. At the end…
arrow_forward
//for loop practice/*create a program, called aveRaceTime.cpp, for runners that wish to know their average race time.ask the user how many races they ran, and use their input in your for loop,for the limit on the number of loops (for example, if the user inputs three,that means your for loop should run three times.) Each time the loop runs, itwill ask the user what their race time was in minutes. Keep a running total ofall of the race times added together. After the loop, compute the user's average racetime, and display it in a sentence. Format the average time so it always shows two decimal points.
arrow_forward
C# programming
Write a program that prints decrements of 7 on a single* line. The program prompts the user for the starting* value the end value will be 0 or the first negative* number.
Type of loop-> for
arrow_forward
In this assignment, you will design a program in which you will ask the user to enter a number and usea while loop to see if the number entered by the user is a palindrome number or not. A palindromenumber is a number which remains the same, even when the digits are reversed. For example: 121 is apalindrome number. 277 is not a palindrome number.
StartStart of main function§ Prompt the user a number ‘n’§ Assign ‘n’ to another temporary variable ‘temp’§ Initialize a variable ‘rev’ to 0§ While ‘n’ is greater than 0divide ‘n’ by by 10 and assign the remainder to a variable ‘dig’multiply ‘rev’ by 10 and add to ‘dig’ and assign result to ‘rev’divide ‘n’ by 10 to get the quotient and assign to ‘n’§ If ‘temp’ is equal to variable ‘rev’Print ‘The number is a palindrome’§ ElsePrint ‘The number is not a palindrome’End of main functionEnd
arrow_forward
T F
Any for loop can be written using a while loop
arrow_forward
In For loop
for (statement 1; statement 2; statement 3)
{
// code block to be executed
}
The first statement is executed ?!
One Time
Two Times
Every Time
Not executed
arrow_forward
Looping Construct with Floating Point Numbers
Write a program that utilizes a while-loop to read a set of five floating-point values from user
input. Include code to prevent an endless loop. Ask the user to enter the values, then print the
following data:
Total
Average
Maximum
Minimum
Interest on total at 20%
Answer:
arrow_forward
C++ programming
Write a program that reads the grades of 3 students in three different courses and displays the average grade of each student in these three courses, as well as the average grade of all students. You can use any loop method of your preference. (Hint: This is a nested loop technique)
arrow_forward
The continue statement in a while loop would be used to do what?
O Reset the loop.
Go back to the beginning of the loop.
O Enter the loop.
O Exit the loop.
arrow_forward
Never modify the value of a loop index within the body of the loop.
O True
O False
arrow_forward
In C++
What type of loop requires the user to manually terminate the loop?
a. counter-controlled while loop
b. sentinel-controlled while loop
c. eof-controlled while loop
d. counter-controlled for loop
arrow_forward
Question#2. The distance a vehicle travels can be calculated as fallout:
Distance = Speed * Time
For example, if a train travels 60 miles-per-hour for three hours, the distance [raveled is 120
miles. Write a program that asks for the speed of a vehicle (in miles-per-hour) and the
number of hours it has traveled. It should use a loop to display the distance a vehicle has
traveled for each hour of a time period specified by the user. For example, if a vehicle is
traveling at 40 mph far a three-hour time period, it should display a report similar to the one
chat follows:
Hour
Distance Traveled
1
90
2
100
3
150
Input Validation: Do not accept a negative number for speed and do not accept any value les
than 1 for time traveled.
arrow_forward
JAVA
If the for loop counter variable is declared and initialized in the for loop header the variable only has scope inside the for loop body.
True
False
arrow_forward
Part A: While Loop ProgramWrite a program that detects Fibonacci numbers. Prompt the user to input a positive integer. Upon input, the program will determine if the number is either a Fibonacci number or not. If a Fibonacci number, then the order of the number in the sequence must be output. If not a Fibonacci number, then the Fibonacci numbers above and below it (including their order in the sequence) must be output. Once it finishes, the program will prompt the user for a new number. The program will exit if the user enters a non-integer number or string (such as “quit”) instead of an integer. Use the sample output file, fib-seq-det.txt, to view a sample session
For both the above problems, the first four numbers of the Fibonacci sequence are 0, 1, 1, and 2.
Part A must use While loops only.
Invalid (negative) numbers should be flagged and handled.
Output should be like:
Welcome to the Fibonacci Sequence Detector
Please input a number for analysis >> 00 is a…
arrow_forward
The following while loop should be converted to a for loop:
i=88
while(i>=8):
I print out
i- is equal to eight.
arrow_forward
Part B: For Loop ProgramWrite a program to compute the sum of the first N Fibonacci numbers, where N is an integer that is input by the user. Once it computes the sum, the program will prompt the user for a new value of N. The program will exit if the user enters a non-integer number or string (such as “quit”) instead of an integer.
For both the above problems, the first four numbers of the Fibonacci sequence are 0, 1, 1, and 2.
Part B must use at least one For loop, but may also use while loops.
Invalid (negative) numbers should be flagged and handled.
Output should be like :
Welcome to the Fibonacci AdderTo quit, end a non-integer number or string
How many Fibonacci numbers should be summed? >> 10The sum of the first 10 Fibonacci numbers is: 88
How many Fibonacci numbers should be summed? >> xxx
Thank You for Using the Fibonacci Adder
arrow_forward
c++ prob
Write a loop to request integer values from the console until the value is greater than 100.
Example OutputEnter a number greater than 100: 20Enter a number greater than 100: 50Enter a number greater than 100: 150
arrow_forward
We use For loop instead of a while loop when we know exactly how many times you want to loop through a block of code.
True
False
arrow_forward
True or False:
C++ uses negative values to represent "False" and positive values to represent "True".
It is possible that the body of a while loop may not execute at all.
arrow_forward
DAVAD CITY
ULO (2-c): While loop- Task B
1946
/ This program illustrates the use of a sentinel in a while loop.
/ The user is asked for monthly rainfall totals until a sentinel
/ value of -1 is entered. Then the total rainfall is displayed.
#include
using namespace std,
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
![Text book image](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Related Questions
- Range for loop should be used even the block code needs to access index. Group of answer choices True Falsearrow_forwardwhile_enter_zero at Submit Assignment Due Friday by 11:59pm Points 20 Submitting a file upload While loop to check a number is zero or not. Often the number of times a loop is executed is not predetermined. You may use an input value to signify the end of the loop. Such a value is known as a sentinel value. Write a program that reads and calculates the sum of an unspecified number of integers. The input 0 signifies the end of the input. ons • Previous Next rive onnect: Stu- port tv W MacBook Air 888 DD F2 F3 F4 F5 F6 F7 F8 F9 F10 %23 & 2 6. 7 8. W T Y U S F G H J Karrow_forwardYou may define a(n) ________ in the initialization expression of a for loop.arrow_forward
- QUESTION 26 Write code that uses a while loop to display the powers of 2 exactly as shown below: 1248163264128arrow_forward2 PMOV 3 Summary 4 This program allows each theater patron to enter a value from 5 0 to 4 indicating the number of stars that the patron awards In this lab, you write a while loop that uses a sentinel value to 6 to the Guide's featured movie of the week. The program control a loop in a Python program. You also write the statements 7 executes continuously until the theater manager enters a 8 negative number to quit. At the end of the program, the that make up the body of the loop. 9 average star rating for the movie is displayed. The source code file already contains the necessary assignment 11 and output statements. Each theater patron enters a value from 0 12 # Initialize variables. 13 totalStars = 0 # total of star ratings. # keep track of number of patrons to 4 indicating the number of stars that the patron awards to the 14 numPatrons = 0 Guide's featured movie of the week. The program executes 15 continuously until the theater manager enters a negative number 16 to quit. At the end…arrow_forward//for loop practice/*create a program, called aveRaceTime.cpp, for runners that wish to know their average race time.ask the user how many races they ran, and use their input in your for loop,for the limit on the number of loops (for example, if the user inputs three,that means your for loop should run three times.) Each time the loop runs, itwill ask the user what their race time was in minutes. Keep a running total ofall of the race times added together. After the loop, compute the user's average racetime, and display it in a sentence. Format the average time so it always shows two decimal points.arrow_forward
- C# programming Write a program that prints decrements of 7 on a single* line. The program prompts the user for the starting* value the end value will be 0 or the first negative* number. Type of loop-> forarrow_forwardIn this assignment, you will design a program in which you will ask the user to enter a number and usea while loop to see if the number entered by the user is a palindrome number or not. A palindromenumber is a number which remains the same, even when the digits are reversed. For example: 121 is apalindrome number. 277 is not a palindrome number. StartStart of main function§ Prompt the user a number ‘n’§ Assign ‘n’ to another temporary variable ‘temp’§ Initialize a variable ‘rev’ to 0§ While ‘n’ is greater than 0divide ‘n’ by by 10 and assign the remainder to a variable ‘dig’multiply ‘rev’ by 10 and add to ‘dig’ and assign result to ‘rev’divide ‘n’ by 10 to get the quotient and assign to ‘n’§ If ‘temp’ is equal to variable ‘rev’Print ‘The number is a palindrome’§ ElsePrint ‘The number is not a palindrome’End of main functionEndarrow_forwardT F Any for loop can be written using a while looparrow_forward
- In For loop for (statement 1; statement 2; statement 3) { // code block to be executed } The first statement is executed ?! One Time Two Times Every Time Not executedarrow_forwardLooping Construct with Floating Point Numbers Write a program that utilizes a while-loop to read a set of five floating-point values from user input. Include code to prevent an endless loop. Ask the user to enter the values, then print the following data: Total Average Maximum Minimum Interest on total at 20% Answer:arrow_forwardC++ programming Write a program that reads the grades of 3 students in three different courses and displays the average grade of each student in these three courses, as well as the average grade of all students. You can use any loop method of your preference. (Hint: This is a nested loop technique)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
![Text book image](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage