Refactoring tools, whether fully automated or semi-automated, are essential components of the software development life cycle. As software libraries and frameworks evolve over time, it’s crucial for programs utilizing them to also evolve to remain compatible with modern advancements. Take, for example, NVIDIA CUDA’s platform for general-purpose GPU programming. Embracing the more contemporary unified memory architecture offers several benefits, such as simplifying program source code, reducing bugs stemming from manual memory management between host and device memory, and optimizing memory transfer through automated memory handling. This paper describes our development of a refactoring tool based on Clang’s Libtooling to facilitate this transition automatically, thereby relieving developers from the burden and risks associated with manually refactoring large code bases.
References
[1]
Murphy-Hill, E. and Black, A.P. (2008) Refactoring Tools: Fitness for Purpose. IEEE Software, 25, 38-44. https://doi.org/10.1109/MS.2008.123
[2]
Kaur, A. and Kaur, M. (2016) Analysis of Code Refactoring Impact on Software Quality. MATEC Web of Conferences, 57, 6. https://doi.org/10.1051/matecconf/20165702012
[3]
(2021) 2to3—Automated Python 2 to 3 Code Translation. https://docs.python.org/3/library/2to3.html
[4]
Hylton, A., Henselman-Petrusek, G., Sang, J. and Short, R. (2019) Tuning the Performance of a Computational Persistent Homology Package. Software: Practice and Experience, 49, 885-905. https://doi.org/10.1002/spe.2678
[5]
Hojnacki, M., Leeseberg, A., O’Shaughnessy, J., Dauchy, M., Hylton, A., Gold, L. and Sang, J. (2020) Parallel Computation of Grobner Bases on a Graphics Processing Unit. Proceedings of the International Conference on Parallel and Distributed Processing Techniques and Applications, 417-432.
[6]
Steinkraus, D., Buck, I. and Simard, P.Y. (2005) Using GPUs for Machine Learning Algorithms. Eighth International Conference on Document Analysis and Recognition, 2, 1115-1120. https://doi.org/10.1109/ICDAR.2005.251
[7]
Sang, J., Lee, C., Rego, V. and King, C. (2019) Experiences with Implementing Parallel Discrete-Event Simulation on GPU. Journal of Supercomputing, 75, 4132-4149. https://doi.org/10.1007/s11227-018-2254-4
[8]
Kirk, D.B. and Hwu, W.M.W. (2016) Programming Massively Parallel Processors: A Hands-on Approach. 3rd ed., Morgan Kaufmann Publishers Inc., Burlington.
[9]
Harris, M. (2013) Unified Memory in CUDA 6. https://developer.nvidia.com/blog/unified-memory-in-cuda-6/
[10]
(2020) The LLVM Compiler Infrastructure. http://llvm.org/
[11]
Clang Tooling (2020) Choosing the Right Interface for Your Application. https://clang.llvm.org/docs/Tooling.html
[12]
Damevski, K. and Muralimanohar, M. (2011) A Refactoring Tool to Extract GPU Kernels. Proceedings of the 4th Workshop on Refactoring Tools, May 2011, 29-32. https://doi.org/10.1145/1984732.1984739
[13]
Wu, J., Belevich, A., Bendersky, E., Heffernan, M., Leary, C., Pienaar, J., Roune, B., Springer, R., Weng, X. and Hundt, R. (2016) GPUCC—An Open-Source GPGPU Compiler. Proceedings of the 2016 International Symposium on Code Generation and Optimization, February 2016, 105-116. https://doi.org/10.1145/2854038.2854041
[14]
(2020) Clang: A C Language Family Frontend for LLVM. https://clang.llvm.org/
[15]
Bertolli, C., Betts, A., Mudalige, G., Giles, M. and Kelly, P. (2011) Design and Performance of the OP2 Library for Unstructured Mesh Applications. In: Alexander, M., et al., Eds., Euro-Par 2011: Parallel Processing Workshops. Euro-Par 2011. Lecture Notes in Computer Science. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-29737-3_22
[16]
Balogh, G.D., Mudalige, G.R., Reguly, I.Z., Antao, S.F. and Bertolli, C. (2018) OP2-Clang: A Source-to-Source Translator Using Clang/LLVM LibTooling. 2018 IEEE/ACM 5th Workshop on the LLVM Compiler Infrastructure in HPC (LLVM-HPC), Dallas, 12 November 2018, 59-70. https://doi.org/10.1109/LLVM-HPC.2018.8639205
[17]
Barlas, G. (2015) Chapter 7—The Thrust Template Library. In: Barlas, G., Ed., Multicore and GPU Programming, Morgan Kaufmann, Boston, 527-573. https://doi.org/10.1016/B978-0-12-417137-4.00007-1
[18]
(2020) CUDA Sample Code. https://github.com/NVIDIA/cuda-samples
[19]
Bendersky, E. (2020) AST Matchers and Clang Refactoring Tools. https://eli.thegreenplace.net/2014/07/29/ast-matchers-and-clang-refactoring-tools