Question 12.7 - thank you in advance ) (b) Write an equivalent C program that ex
ID: 3601350 • Letter: Q
Question
Question 12.7 - thank you in advance )
(b) Write an equivalent C program that executes on k processo (an for ideal speedup for the program in part (by ret ) Derive expression the program in part (a). 123 for and against invalidation and updating as strong .(D) What are the arguments maintaining cache coherence? 12.4 (D) The approaches of shared memory and message passing both support sit execution of tasks that interact with each other, Which of these two approaches get can the action of the other more easily? Briefly justify your answer 12.5 (E) with reference to Figure 12.1, assume an array size of N = 32. Let all instruce require one time unit to execute in a processor, Determine the speedup of vectorization to vector lengths of 4, 8, 16and 32. 12.6 (M) For vectorization, efficiency is defined as the ratio of the speedup to the vector lend Determine the efficiency for each of the results in Problem 12.5. Comment on the variation of the efficiency with the vector length. 12.7 IM) In the parallel program in Figure 12.8 for computing the dot product, the sum of the partial products is computed by one processor after all threads have reached the barrier Modify the program so that each thread adds its partial sum incrementally to a global sum for the dot productTo prevent two or more threads from trying to update the global sum at the same time, synchronization is required. One method is to use a shared counter variable whose value is the identifier of the thread that is granted exclusive access to the variable for the global sum. After the thread with exclusive access has updated the global sum, I can simply increment this counter to grant exclusive access to another thread. 12.8 [E) Assume that a multiprocessor has eight processors. Based on an existing program that runs , a parallel program is written run on this multiprocessor. Assu on one processorto that the warExplanation / Answer
NOte: I used java langauge .I execute this program using command prompt manually by providing the command line argument.
________________
StringReverse.java
public class StringReverse {
public static void main(String[] args) {
//Getting the string from the Command line args
String str = args[0];
//Displaying the original string
System.out.println("The Original String is :" + str);
//calling the method
String strrev = reverse(str);
//Displaying the string after reversing
System.out.println("The String After Reversing is :" + strrev);
}
//This method will reverse the string
private static String reverse(String str) {
String strrev = "";
for (int i = str.length() - 1; i >= 0; i--) {
strrev += str.charAt(i);
}
return strrev;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.