Computer Systems: Program... -Access
3rd Edition
ISBN: 9780134071923
Author: Bryant
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 5, Problem 5.13HW
A.
Program Plan Intro
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 suitable for programs that use a repetitive calculation.
- The processor’s activity sequencing is measured by a clock that provides signal of some frequency.
A.
Expert Solution
Explanation of Solution
Diagram for instruction sequence:
Explanation:
- The data dependencies between instructions are been depicted in diagram.
- The given instruction sequence is been decoded into operations.
- It creates a critical path of operations.
- The data flow between instructions is been shown in diagram.
B.
Program Plan Intro
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 suitable for programs that use a repetitive calculation.
- The processor’s activity sequencing is measured by a clock that provides signal of some frequency.
B.
Expert Solution
Explanation of Solution
Lower bound on CPE:
- The lower bound on CPE is been determined by critical path.
- For data type “double”, it denotes the float add cell.
- The lower bound on CPE is 3.0 based on the architecture.
C.
Program Plan Intro
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 suitable for programs that use a repetitive calculation.
- The processor’s activity sequencing is measured by a clock that provides signal of some frequency.
C.
Expert Solution
Explanation of Solution
Lower bound on CPE:
- The lower bound on CPE is been determined by critical path.
- For data type “integer”, it denotes the long add cell.
- The lower bound on CPE is 1.0 based on the architecture.
D.
Program Plan Intro
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 suitable for programs that use a repetitive calculation.
- The processor’s activity sequencing is measured by a clock that provides signal of some frequency.
D.
Expert Solution
Explanation of Solution
Given C Code:
// Define method inner4
void inner4(vec_ptr u, vec_ptr v, data_t *dest)
{
// Declare variable
long i;
//Compute length of
long length = vec_length(u);
//Get first vector
data_t *udata = get_vec_start(u);
//Get second vector
data_t *vdata = get_vec_start(v);
//Initialize variable
data_t sum = (data_t) 0;
//Loop
for (i = 0; i < length; i++)
{
//Compute product and add
sum = sum + udata[i] * vdata[i];
}
//Store result
*dest = sum;
}
CPE value for floating-point versions:
- The inner product computed is been accumulated in temporary.
- The float add operation is only on key path.
- The multiplication operation takes 5 clock cycles.
- The overall operation takes 3 cycles to complete on average.
- Hence, CPE value for floating-point versions is 3.0.
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Write pseudocode for a function Det-Quicksort(A, p, r) that receives array A[1..n], and indices p and r. The function should sort the subarray A[p..r] recursively (meaning you should call itself). You can also use a function LinearSearch(A, p, r, v) that searches subarray A[p..r] for an element of value v and return its index (in case it exists) in O(r − p) time. (Just to give you something to compare to, the solution has 8 lines.)
Implement the following function, without using any data structure.
/* Given two vectors of chars, check if the two vectors are permutations of each other, i.e., they contains same values, in same or different order.e.g., V1=[‘a’,’b’,’a’] and V2=[‘b’,’a’,’a’] stores same multi-set of data points: i.e., both contains two ‘a’, and one ‘b’.
e.g., V3=[‘a’,’c’,’t’,’a’] and V4=[‘a’,’c’,’t’] are not same multi-set. V3 contains two ‘a’s, while V4 has only one ‘a’.
Note: when considering multiset, the number of occurrences matters. @param list1, list2: two vectors of chars
@pre: list1, list2 have been initialized
@post: return true if list1 and list2 stores same values (in same or different order); return false, if not. */
bool SameMultiSet (vector<char> list1, vector<char> list2)
Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only when it is…
Chapter 5 Solutions
Computer Systems: Program... -Access
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Program) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters, such as zerocount, onecount, twocount, and so forth, to 0. Then generate a large number of pseudorandom integers between 0 and 9. Each time 0 occurs, increment zerocount; when 1 occurs, increment onecount; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of time they occurred.arrow_forwardconsider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only when it is…arrow_forwardconsider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only when it is…arrow_forward
- Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only when it is…arrow_forwardWrite a C++ function given an array of integers nums [passed by reference] and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. int[] twoSum(int nums[], int target)Sample Output:Input: nums = [2,7,11,15], target = 9Output: [0,1]arrow_forwardWrite a program to sort the elements in 1D array in descending order and also implement linear search on the same array. Both sorting and searching operations should be done inside user-defined function: "Task". So,for achieving the required functionality,pass,array into the function: Task () from main () using pass by reference/or address approach.arrow_forward
- Using recursion, write a Python function def before(k,A) which takes an integer k and an array A of integers as inputs and returns a new array consisting of all the integers in A which come before the last occurrence of k in A, in the same order they are in A. For example, if A is [1,2,3,6,7,2,3,4] then before(3,A) will return [1,2,3,6,7,2]. If k does not occur in A, the function should return None.arrow_forwardA set of integers 0..MAX may be implemented using an array of boolean values. This particular implementation is called a bit-vector implementation of a Set. Since C doesn’t have the Boolean data type, then substitute TRUE with 1 and FALSE with 0, or define 1 and 0 as TRUE and FALSE, respectively.For example, if the integer 3 is an element of the set, then the array element indexed by 3 is TRUE. On the other hand, if 3 is not an element, then the array element indexed by 3 is FALSE. For example, if the integer 3 is an element of the set, then the array element indexed by 3 is TRUE. On the other hand, if 3 is not an element, then the array element indexed by 3 is FALSE.For example: if s = {3,4,6,8}, the array looks like this: Implement a programmer-defined data type called BitSet to represent a set as follows:typedef int BitSet[MAX];Implement the following functions:void initialize(BitSet s); - set all array elements to FALSEvoid add(int elem,BitSet s);- set the item indexed by elem to…arrow_forwardImplement the following function, without using any data structure or #include <bits/stdc++.h> /* Given two vectors of chars, check if the two vectors are permutations of each other, i.e., they contains same values, in same or different order.e.g., V1=[‘a’,’b’,’a’] and V2=[‘b’,’a’,’a’] stores same multi-set of data points: i.e., both contains two ‘a’, and one ‘b’. e.g., V3=[‘a’,’c’,’t’,’a’] and V4=[‘a’,’c’,’t’] are not same multi-set. V3 contains two ‘a’s, while V4 has only one ‘a’. Note: when considering multiset, the number of occurrences matters. @param list1, list2: two vectors of chars @pre: list1, list2 have been initialized @post: return true if list1 and list2 stores same values (in same or different order); return false, if not. */ bool SameMultiSet (vector<char> list1, vector<char> list2) THIS IS NOT THE CORRECT SOLUTION / include headers #include <bits/stdc++.h> // deinfe the namespace using namespace std; // function fo rchecking same bool…arrow_forward
- Write a program using c# to do the following: Initialize an array A with 10 elements. Initialize an array B with 7 elements. Divide each element of array A with each element of array B that is a[0]/b[0] , a[1]/b[1] etc. Implement the same to handle divide by zero error and index out of bound error.arrow_forwardWrite a C++ program that asks the user to enter the number of students in the class followed their grades out of 100 using the keyboard. After this, the program prints the grades in reverse order. Use a dynamic array of doubles to store the entered grades. Modify the previous C++ program in question above such that it does not ask the user about the number of students, however, the program will terminate grades input when a negative grade is entered at the keyboard. Use a vector of doubles instead of a dynamic array of doubles.arrow_forwardc++ Implement a function that recursively calculates the nth number in the Fibonacci sequence of numbers. The Fibonacci sequence starts at 0 and 1. Each number thereafter is the sum of the two preceding numbers. This gives us the following first ten numbers: 0,1,1,3,5,8,13,21,34, .... Input Expected output0 01 17 139 34arrow_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 PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning