Repository navigation
Parallelization
Zihao Yang edited this page Aug 28, 2017
·
12 revisions
1 - 4 processors can be used to find the final solution. If parallelization is desired, the -p N parameter can be used to determine the number of cores (N) to be used.
Theoretically, by running the algorithm in parallel, each thread will perform less work than running the algorithm sequentially. Thus, finishing at an earlier time.
Parallel Task is the library that is used to implement parallelization. Other libraries considered include Pyjamas and the standard Java concurrency library. After researching the different options, it was determined that the Parallel Task toolkit provided techniques that were the easiest to integrate into the sequential algorithm.
- The algorithm will start running sequentially until 1000 partial solutions have been collected in the priority queue.
- The queue is then split according to the number of cores specified, balanced by a round robin allocation.
- Each thread will run until a pre-optimal solution is found for its child queue.
- Following the completion of all threads, the final optimal solution will be selected from the list of pre-optimal solutions.
- After a thread finds its pre-optimal solution, help other threads find theirs.
- This can be done using the WorkStealingQueue Class - When a thread has finished, steal a PS from another thread
- However we found that we would explore much more state space than we have to, taking up a lot more time. This is because threads will be continuously stealing partial solution from others until there are no more.
- Ignore partial solution if its end time > existing pre-optimal solution from another thread
- however, we found that the pre-optimal solution for the running thread will be ignored and the entire queue would be explored.
Experimenting
- We found that the best time to switch from sequential to parallel to be at 1000 partials in the parent queue.