proffreda

CS6068 Midterm Practice w Solutions

Oct 16th, 2016
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.00 KB | None | 0 0
  1. CS6068 Midterm Practice Exam - With SOLUTIONS
  2.  
  3. 1.What are three traditional ways that hardware designers make computers run faster? Please circle all that are true.
  4. -faster clocks
  5. -longer clock periods
  6. -more work per clock cycle
  7. -a larger hard disk
  8. -adding more processors
  9. -reducing the amount of memory
  10.  
  11. ans: 1,3,5
  12.  
  13. 2.What are David Pattersonís Three Walls of Computer Architecture?
  14. ans: Power, Memory, ILP
  15.  
  16. 3. For a class of GPUs, what is appropiate measure to compare power consumption of different devices?
  17. ans:Flops per watt
  18.  
  19. 4.What techniques are computer designers today using to build more power-efficient devices? Please circle all that are true.
  20. -having fewer, but more complex processors,
  21. -having more, but less complex processors,
  22. -maximizing the speed of the processor clock
  23. -increasing the complexity of the control hardware
  24.  
  25. ans:2
  26.  
  27. 5. Name four common patterns of parallel computation? For each pattern, discuss whether the many-core or multi-core architecture model is more appropriate.
  28.  
  29. ans:
  30. Map redude: manycore
  31. Pipe-and-filter: multi
  32. Agents: multi
  33. iterative: many
  34.  
  35. 6. What is concurrency control, and discuss what is the difference between pessimistic an optimistic concurrency control?
  36.  
  37. ans: addresses conflict in simult access, pessimistic locks, optimistic transactions STM
  38.  
  39.  
  40. 7. How does Fork/Join parallelism differ from Kernel data-parallelism?
  41.  
  42. ans: in F/J main thread spawns to complete complex parallel tasks then joins mains, kernels uses large index sets and map simple tasks to threads
  43.  
  44. 8. Circle all the true statements.
  45. -A thread block contains many threads.
  46. -An SM might run more than one thread block.
  47. -A thread block may run on more than one SM.
  48. -All the threads in a thread block might cooperate to solve a subproblem.
  49. -All the threads that run on a given SM may cooperate to solve a subproblem.
  50.  
  51. ans:1,2,4
  52.  
  53. 9. If we have a single kernel that is launched on many thread blocks, including block x and block y, the programmer can do which of the following: Circle all the true statements.
  54. -specify that block x will run at the same time as block y
  55. -specify that block x will run after block y.
  56. -specify that block x will run on same SM as y
  57. -none of the above
  58.  
  59. ans: none
  60.  
  61. 10. Circle all the statements that are true.
  62. -All threads from a block can access the same variable in that block's shared memory.
  63. -Threads from two different blocks can access the same variable in global memory
  64. -Threads from different blocks have their own copy of local variables in local memory.
  65. -Threads from the same block have their own copy of local variables in local memory.
  66.  
  67. ans:1,2,3,4
  68.  
  69. 11. At what level can barrier synchronizations be executed in CUDA:
  70. -thread -block -grid -device -multi-device?
  71.  
  72. ans: block
  73.  
  74. 12. What is a parallel map operation? Circle all problems that can be solved using map.
  75. -sort an array -add one to each element of an array -sum elements in array -move data based on array of scatter addresses
  76.  
  77. ans: 2,4
  78.  
  79. 13. Circle which operators are both binary and associative and therefore can be used in a reduction or scan.
  80. -multiply -minimum -factorial -exclusive or -bitwise and -exponentiation -integer division
  81.  
  82. ans: 1,2,4,5
  83.  
  84. 14. Using 1D global indexing, how would you specify the parallel execution mapping the ith thread to the task of reading and then squaring the ith item from an large array X in global memory.
  85.  
  86. int i = blockIdx.x * blockDim.x + threadIdx.x;
  87. float x = X[i]
  88. X[i] = x * x;
  89.  
  90.  
  91. 15.Circle all statements that are true. When running reduction code running on an input of size n?
  92. -it takes at least n operations
  93. -its work complexity is order of n
  94. -its work complexity is order n*n
  95. -its step-complexity is order of 1, independent of the size of the input.
  96.  
  97. ans: 2
  98.  
  99. 16. Circle the correct answer. The number of steps in a reduction as a function of n is:
  100. - square root of n
  101. - log base 2 of n
  102. - n
  103. - n times log base 2 of n
  104. ans: 2
  105.  
  106.  
  107. 17. Circle all that are true
  108. - map operations have arguments that are functions with a single argument
  109. - map operations can be applied to arrays of any number of dimensions
  110. - map operations are generally very efficient on GPUs
  111. - a compact operation requires a map operation to be performed.
  112.  
  113. ans:1,2,3,4
  114.  
  115. 18. What is the impact of granularity on performance when considering the latency of global memory communication? What is the granularity of dot product of two vectors that reside in global memory?
  116.  
  117. Ans: The higher the granularity (computation to communication ratio) the greater the opportunities for latency hiding. The dot product has 1:1 computation to communication ratio.
  118.  
  119. 19. What is the output of a max scan operation on the list of unsigned ints [5 4 7 3 1 8 2 6]?
  120. Provide a solution to both inclusive and exclusive scans.
  121.  
  122. inc-scan
  123. 5 5 7 7 7 8 8 8
  124. exc-scan
  125. 0 5 5 7 7 7 8 8
  126.  
  127.  
  128. 20. Compute the max (inclusive) scan of this input sequence 2 1 4 3 showing all work when using
  129. a) the Hillis-Steele algorithm
  130. b) the Blelloch algorithm
  131.  
  132. 21. Explain which scan algorithm (Hillis-Steele or Blelloch algorithm) is best suited and why?
  133. You are scanning a 512 element vector and a GPU that has 512 processors.
  134.  
  135. ans: Hillis-Steele would probably perform better, since its step complexity is half that of Blelloch.
  136.  
  137. 22. Explain which scan (Hillis-Steele or Blelloch algorithm) is best suited and why?
  138. You are scanning a 1 million element input vector in 512 processors machine.
  139.  
  140. ans: Hillis-Steele would probably perform worse, since its work complexity is logn times that of Blelloch.
  141.  
  142. 23. Suppose you are computing a histogram with less than 10 bins. Discuss an efficient GPU solution. Indicate whether or not you need to use atomics to manage access to bins of the histogram.
  143.  
  144. ans: atomics would limit the parallelism to speedup of 10 = #bins. Using per thread private bin counts, followed by a reduction would be efficient.
  145.  
  146. 24. True or false - In a scatter operation a syncthreads command is needed to overcome write conflicts.
  147.  
  148. ans: False
  149.  
  150. 25. Is the compact parallel operation going to be most useful in scenarios where we delete a (small number) or a (large number) of elements?
  151.  
  152. ans:large
  153.  
  154. 26. Is the compact parallel operation going to be most useful in scenarios where we need to run (cheap) or (expensive) function on filtered elements.
  155.  
  156. ans: expensive
  157.  
  158. 27. Suppose we are running compact operations on a list of numbers with range from 1 to 1 million. Compact operation A, filters elements that are divisible by 17, and thus is only going to keep a very few of the input items. Compact operation B filters elements not divisible by 31, and thus is going to keep most of the input items. For each of the three phases of compact: predicate map, scan, and scatter phases of the compact operation, will A run faster, B run faster or will they take the same amount of time?
  159. a. Predicate map b. Scan c. Scatter
  160.  
  161. ans:
  162. a. same b. same c. A faster
  163.  
  164. 28. What is the difference between latency and bandwidth? Which is more easily enhanced by advanced architectures? Given a sports-car traveling 100mph with 2 passengers versus a bus traveling 50mph with 20 people. Say the task is to tranport people 200 miles. How do the Bandwidths(in people deliverd per hour) and Latency (in hours) compare between the two vehicles?
  165.  
  166. ans: Sport-car latency: 2 hrs, bw: 1/hr; bus latency: 4 hrs, bw: 5/hr
  167.  
  168. 29. How is Occupancy defined in Cuda, and why does it have an impact on performance?
  169.  
  170. ans: percent of active thread by total threads. High occupancy increases potential bandwidth hiding latency.
  171.  
  172. 30. Show the contents of the CSR (Compressed Sparse Row) format for the following 5x5 matrix:
  173. 02300
  174. 10050
  175. 00400
  176. 00020
  177.  
  178. 31. Consider the sparse matrix dense vector product problem, and the two different parallel methods tpr(thread per row) or tpe (thread per element).
  179. a. Which approach will launch more threads?
  180. b. Which approach will require more communication between threads?
  181. c. Which approach will do more work per thread?
  182. d. Which approach is more load balanced?
  183.  
  184. ans:
  185. a. tpe
  186. b. tpe
  187. c. tpr
  188. d. tpe
Advertisement
Add Comment
Please, Sign In to add comment