hw_3
Use breadth first search using example code provided in section to design a queue.
- Each thread has a maximum chunk size, with chunk calculated based on a heuristic (prevents overdoing omp lock).
- While private stack length not longer than, use endpoints to determine maximum value
- If not larger than
add to deletion stack
- If larger, then divide the interval into two and add it to the continue stack
- If not larger than
- After processing the chunk
- request deletion stack lock and prepend deletion stack
- request continuation stack lock and prepend
Useful lemma:
Suppose we have a global maximum . If we wrap each thread's read of this value in an atomic
clause, and we have a mutex-protected lock on writing
which ensures monotonicity (prove this in final code)
then if we determine that on an interval
our function
cannot be more than
, then
we also know that it cannot be more than any
determined during processing of the interval
. Therefore to keep
consistent,
we start the processing step by reading
and at the end of this step we can call the thread-safe method to write
.
Develop library of functions and test heuristics on this library of functions