There is no checkoff for this lab. It is intended to be review for a subset of the material that will be covered in the final.
Pull the final review files from the lab starter repository with
git pull staff master
One of your friends has just learned about concurrency in their computer architecture class and they wanted to try it out! They wrote the
parallel.c file to try implementing a lock in place of the OpenMP critical section. You can find the file in the
Let’s first examine your friend’s code.
ARR_SIZElocated? How about
parallel.c). Given the following assumptions, what is the hit rate of the for loop in question?
ints are 4B
partial_sumvariable is intended to be the sum that each thread computes, but you foresee some issues with how it is being declared. What issues could arise with the current implementation, and how could we fix them?
Let’s say we want to use MapReduce to calculate the frequency of every word for every document it appears in. In other words, if we have the following output:
(("I", "doc1"), 0.03)
that means that the word “I” made up 3% of the words in the document “doc1”. Suppose that documents are stored in the following object:
Document: String name list<String> text
where the first parameter is the document’s name and the second is its contents represented as a list of words. Given the following
reduce headers, come up with a method to produce the desired output. For this problem, you have access to the
len keyword which returns the length of a list.
map(Document doc): # Implementation here reduce(_____________, _____________): # Implementation here
The Power Iteration method is a way to find the largest eigenvalue of a matrix. The details of why the algorithm works don’t concern us. What does matter is that we are doing repeated matrix-vector and vector-vector multiplications, both of which can be sped up with SIMD. Your task is to fill out the
_simd implementations for each of the relevant functions in the
simd.c file. To run this file, execute the following commands:
gcc simd.c -o simd -lm -march=haswell -Wall ./simd