Name (print *CLEARLY*): _________________________________________________
Student ID (print *CLEARLY*; 1 digit per underline): _____ _____ _____ _____ _____ _____
CSE 231s Quiz 22: K-mer, Slices, Contention, Atomicity
1) An approach to balanced k-mer counting is to slice up the large sequences and then to:
slices = createThresholdSlices(sequences, kMerLength)
loop over the slices:
loop over the k-mers in the slice
count the k-mer
Which loop (slices or k-mers) should be parallelized?
2) Imagine you have written
ThresholdSlices such that it splits up long sections of chromosome data into
nicely sized Slices.
The code below works just fine (and contains a huge hint to the previous
question):
slices = createThresholdSlices(sequences, kMerLength)
forall(slices, (slice) -> {
for each kMer in slice:
count the kMer
});
While
createThresholdSlices would solve the
problem created by sequences which were too long, what if there were thousands
upon thousands of teeny tiny sections. While they would not be sliced, how
can we avoid creating a task for each of these tiny sections?
|
 |
***
Write pseudocode below
that will create EXACTLY 5 times the number of available processors tasks to
perform this work.
slices = createThresholdSlices(sequences, kMerLength)
3) Given a list of byte[] sequences, describe an algorithm to calculate a
reasonable threshold for N available
processors:
4) Given the following features introduced in Unit 5:
-
global isolation,
-
object-based isolation, and
-
atomic variables
According to Prof. Sarkar, what should you do when:
you have low contention _______________________________________________
you have medium contention: _______________________________________________
you have high contention: _______________________________________________
5a) Is the code below thread safe? Yes: ______ No: _______
Map<String, Integer> mapWordToCount = new HashMap<>();
forall(words, (String word) -> {
Integer prevCount = mapWordToCount.get(word);
int nextCount;
if (prevCount != null) {
nextCount = prevCount + 1;
} else {
nextCount = 1;
}
mapWordToCount.put(word, nextCount);
});
return mapWordToCount;
5b) Why or why not?
6a) Is the code below thread safe? Yes: ______ No: _______
Map<String, Integer> mapWordToCount = new ConcurrentHashMap<>();
forall(words, (String word) -> {
Integer prevCount = mapWordToCount.get(word);
int nextCount;
if (prevCount != null) {
nextCount = prevCount + 1;
} else {
nextCount = 1;
}
mapWordToCount.put(word, nextCount);
});
6b) Why or why not?