Efficient Parallel Knuth-Morris-Pratt Algorithm for Multi-GPUs with CUDA

Part of the Smart Innovation, Systems and Technologies book series (SIST, volume 21)


String matching is an important technique among various applications. The traditional string matching algorithm needs the backtracking procedure and does the comparison repeatedly, thus these factors affect its efficiency. Knuth-Morris-Pratt (KMP) is one of well-known and efficient string matching algorithms. However, the computation time of KMP algorithm still is large for processing thousands of pattern strings. Current high-end graphics processing units (GPUs), contain up to hundreds cores per chip, are very popular in the high performance computing community. In this paper, we proposed an efficient parallel KMP algorithm, called KMP-GPU, for multi-GPUs with CUDA. The experimental results showed that the proposed KMP-GPU algorithm can achieve 97x speedups compared with the CPU-based KMP algorithm.


String matching Knuth-Morris-Pratt CUDA Graphics Processing Units Parallel Processing 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Cao, P.: Parallel research on KMP algorithm. CECNet, 4253–4255 (2011)Google Scholar
  2. 2.
    Duan, G.: The implementation of KMP algorithm based on MPI and OpenMP. In: 9th International Conference on Fuzzy Systems and Knowledge Discovery, pp. 2511–2514 (2012)Google Scholar
  3. 3.
    Tumeo, A.: Accelerating DNA analysis applications on GPU clusters. In: 8th IEEE Symposium on Application Specific Processors, pp. 71–76 (2010)Google Scholar
  4. 4.
    Knuth, D.E., Morris, J.H., Pratt, V.R.: Fast pattern matching in strings. SIAM J. Comput. 6, 323–350 (1977)MathSciNetMATHCrossRefGoogle Scholar
  5. 5.
    Bayer, R.S., Moore, J.S.: A fast string searching algorithm. Communication of ACM, 762–772 (1977)Google Scholar
  6. 6.
    Cheng, L.L.: Approximate string matching in DNA sequences. In: 8th International Conference on Database Systems for Advanced Applications, pp. 303–310 (2003)Google Scholar
  7. 7.
  8. 8.
    Peiravi, A.: Application of string matching in Internet security and Reliability. Journal of American Science, 25–3 (2010)Google Scholar
  9. 9.
    Flynn, M.: Some Computer Organizations and Their Effectiveness. IEEE Trans. Comput. C-21, 948 (1972)Google Scholar
  10. 10.
    SaiKrishna, V., Rasool, A., Khare, N.: String Matching and its Applications in Diversified Fields. International Journal of Computer Science Issues 9 (2012)Google Scholar
  11. 11.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction To Algorithm. The MIT Press (2009)Google Scholar
  12. 12.
    Nickolls, J., Buck, I., Garland, M., Skandron, K.: Scalable parallel programming with CUDA. ACM Queue 6, 40–53 (2008)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  1. 1.Department of Computer Science and Information EngineeringChang Gung UniversityTaoyuanTaiwan, ROC

Personalised recommendations