Solving Dynamic Programming Problem by Pipeline Implementation on GPU

Susumu Matsumae,Makoto Miyazaki
DOI: https://doi.org/10.14569/IJACSA.2018.091272
2020-08-05
Abstract:In this paper, we show the effectiveness of a pipeline implementation of Dynamic Programming (DP) on GPU. As an example, we explain how to solve a matrix-chain multiplication (MCM) problem by DP on GPU. This problem can be sequentially solved in $O(n^3)$ steps by DP where $n$ is the number of matrices, because its solution table is of size $n \times n$ and each element of the table can be computed in $O(n)$ steps. A typical speedup strategy for this is to parallelize the $O(n)$ step computation of each element, which can be easily achieved by parallel prefix computation, i.e., an $O(\log n)$ step computation with $n$ threads in a tournament fashion. By such a standard parallelizing method, we can solve the MCM problem in $O(n^2 \log n)$ steps with $n$ threads. In our approach, we solve the MCM problem on GPU in a pipeline fashion, i.e., we use GPU cores for supporting pipeline-stages so that many elements of the solution table are partially computed in parallel at one time. Our implementation determines one output value per one computational step with $n$ threads in a pipeline fashion and constructs the solution table totally in $O(n^2)$ steps with $n$ threads.
Distributed, Parallel, and Cluster Computing
What problem does this paper attempt to address?
This paper aims to explore the effectiveness of implementing dynamic programming (DP) through pipelining on GPU. Specifically, taking the Matrix - Chain Multiplication (MCM) problem as an example, the author shows how to utilize the parallel processing capabilities of GPU to accelerate the execution of the dynamic programming algorithm. ### Problems Solved by the Paper 1. **Improve the Efficiency of Dynamic Programming Algorithm**: - Dynamic programming (DP) is a commonly - used algorithmic technique for solving problems with overlapping sub - problems and optimal sub - structures. However, traditional dynamic programming algorithms have a high time complexity when executed sequentially. For example, the time complexity of the matrix chain multiplication problem is \(O(n^3)\), where \(n\) is the number of matrices. - To improve efficiency, the author proposes a pipelined implementation method based on GPU, reducing the total computation time through parallel computing. 2. **Avoid Memory Access Conflicts**: - In parallel computing, multiple threads accessing the same memory location simultaneously will lead to memory access conflicts, which can significantly degrade performance. The author designs a conflict - free memory access strategy to ensure the efficiency of parallel computing. 3. **Optimize the Performance of Parallel Algorithms**: - The author not only proposes the pipelined implementation method but also verifies the performance improvement of this method in practical applications through experiments. The experimental results show that, despite some limitations in memory bandwidth, this method can still significantly improve the execution speed of the dynamic programming algorithm. ### Main Contributions - **Pipelined Implementation**: - The author proposes a pipelined method for implementing dynamic programming on GPU. By decomposing the computing tasks into multiple stages and using different GPU cores for parallel processing at each stage, efficient parallel computing is achieved. - For the matrix chain multiplication problem, the author shows how to map a two - dimensional solution table into a one - dimensional array and apply pipelining techniques on this basis. - **Conflict - Free Memory Access**: - The author proves that in the pipelined implementation, the memory location accessed by each thread is unique, thus avoiding memory access conflicts. This feature ensures the efficiency of parallel computing. - **Performance Evaluation**: - The author compares the performance of sequential implementation, simple parallel implementation, and pipelined implementation through experiments. The experimental results show that the pipelined implementation method performs well in large - scale problems, especially when \(n\geq 2^{18}\), and its performance is significantly better than other methods. ### Conclusion By adopting the pipelined implementation method on GPU, the author successfully improves the execution efficiency of the dynamic programming algorithm, especially when solving the matrix chain multiplication problem. This method not only has a theoretically low time complexity of \(O(n^2)\) but also shows good performance in practical applications. Future work will focus on further optimizing the utilization of memory bandwidth to further improve the performance of the algorithm.