Abstract
We present a program transformation approach to convert procedural code into functionally equivalent code adapted to a given platform. Our framework is based on the application of guarded transformation rules that capture semantic conditions to ensure the soundness of their application. Our goal is to determine a sequence of rule applications which transform some initial code into final code which optimizes some non-functional properties. The code to be transformed is adorned with semantic annotations, either provided by the user or by external analysis tools. These annotations give information to decide whether applying a transformation rule is or is not sound. In general, there are several rules applicable at several program points and, besides, transformation sequences do not monotonically change the optimization function. Therefore, we face a search problem that grows exponentially with the length of the transformation sequence. In our experience with even small examples, that becomes impractical very quickly. In order to effectively deal with this issue, we have adopted a machine-learning approach using classification trees and reinforcement learning. It learns from successful transformation sequences and produces encodings of strategies which can provide long-term rewards for a given characteristic, avoiding local minima. We have evaluated the proposed technique in a series of benchmarks, adapting standard C code to GPU execution via OpenCL. We have found the automatically produced code to be as efficient as hand-written code generated by an expert human programmer.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Note, however, that some can not. The standard for floating point arithmetic does not guarantee the preservation of numerical results under the transformation in Step 4 of Fig. 1, and it is therefore not enabled by default in C compilers. However, if this transformation is interesting for some particular domain or application, it can be enabled in our framework by adding the corresponding rule to the ruleset.
- 2.
Properties of the generated code can also be included, but we are not showing them for simplicity.
- 3.
- 4.
- 5.
Not only in theory: in our experience, it is often necessary to apply transformations that temporarily reduce performance because they enable further transformations.
- 6.
References
Agakov, F., et al.: Using machine learning to focus iterative optimization. In: Proceedings of the International Symposium on Code Generation and Optimization, CGO ’06, pp. 295–305. IEEE Computer Society, Washington, DC (2006). doi:10.1109/CGO.2006.37
Bagge, O.S., Kalleberg, K.T., Visser, E., Haveraaen, M.: Design of the CodeBoost transformation system for domain-specific optimisation of C++ programs. In: Third International Workshop on Source Code Analysis and Manipulation (SCAM 2003), pp. 65–75. IEEE (2003). doi:10.1109/SCAM.2003.1238032
Bondhugula, U., Hartono, A., Ramanujam, J., Sadayappan, P.: A practical automatic polyhedral parallelizer and locality optimizer. SIGPLAN Not. 43 (6), 101–113 (2008). doi:10.1145/1379022.1375595
Danalis, A., et al.: The Scalable Heterogeneous Computing (SHOC) benchmark suite. In: Proceedings of the 3rd Workshop on General-Purpose Computation on Graphics Processing Units, pp. 63–74. ACM (2010). doi:10.1145/1735688.1735702
Dave, C., Bae, H., Min, S., Lee, S., Eigenmann, R., Midkiff, S.P.: Cetus: a source-to-source compiler infrastructure for multicores. IEEE Comput. 42 (11), 36–42 (2009). doi:10.1109/MC.2009.385
Huber, B.: The Language.C Package. https://hackage.haskell.org/package/language-c (2014)
Jacobs, B., Smans, J., Philippaerts, P., Vogels, F., Penninckx, W., Piessens, F.: Verifast: A powerful, sound, predictable, fast verifier for C and Java. In: Proceedings of the Third International Symposium on NASA Formal Methods, NFM 2011, Pasadena, CA, 18–20 April 2011, pp. 41–55 (2011). doi:10.1007/978-3-642-20398-5_4
Jacquard Computing Inc.: ROCCC 2.0 User’s Manual, revision 0.74 edn. (2012). http://roccc.cs.ucr.edu/UserManual.pdf
Kaelbling, L.P., Littman, M.L., Moore, A.P.: Reinforcement learning: a survey. J. Artif. Intell. Res. 4, 237–285 (1996). doi:10.1613/jair.301
Kuper, J., Schubert, L., Kempf, K., Glass, C., Bonilla, D.R., Carro, M.: Program transformations in the POLCA project. In: Giorgi, R., Silvano, C. (eds.) Proceedings of Design, Automation and Test in Europe (2016)
Lammel, R., Jones, S.P., Magalhaes, J.P.: The SYB Package. https://hackage.haskell.org/package/syb (2009)
Lindtjorn, O., Clapp, R.G., Pell, O., Fu, H., Flynn, M.J., Mencer, O.: Beyond traditional microprocessors for geoscience high-performance computing applications. IEEE Micro 31 (2), 41–49 (2011). doi:10.1109/MM.2011.17
Mariani, G., Palermo, G., Meeuws, R., Sima, V.M., Silvano, C., Bertels, K.: Druid: designing reconfigurable architectures with decision-making support. In: 19th Asia and South Pacific Design Automation Conference, Singapore, 20–23 January 2014, pp. 213–218 (2014). doi:10.1109/ASPDAC.2014.6742892
Marsland, S.: Machine Learning: An Algorithmic Perspective, 1st edn. Chapman & Hall/CRC, Boca Raton, FL (2009). doi:10.1111/j.1751-5823.2010.00118_11.x
Maxeler Technologies: Max Compiler MPT. https://www.maxeler.com/solutions/low-latency/maxcompilermpt/ (2016)
Pedregosa, F., et al.: Scikit-Learn: machine learning in Python. J. Mach. Learn. Res. 12, 2825–2830 (2011)
Pekhimenko, G., Brown, A.: Efficient program compilation through machine learning techniques. In: Naono, K., Teranishi, K., Cavazos, J., Suda, R. (eds.) Software Automatic Tuning, pp. 335–351. Springer, New York (2010). doi:10.1007/978-1-4419-6935-4_19
Schaul, T., Bayer, J., Wierstra, D., Sun, Y., Felder, M., Sehnke, F., Rückstieß, T., Schmidhuber, J.: PyBrain. J. Mach. Learn. Res. (2010). doi:10.1145/1756006.1756030
Schupp, S., Gregor, D., Musser, D., Liu, S.M.: Semantic and behavioral library transformations. Inf. Softw. Technol. 44 (13), 797–810 (2002). doi:10.1016/S0950-5849(02)00122-2
Tamarit, S., Mariño, J., Vigueras, G., Carro, M.: Towards a semantics-aware code transformation toolchain for heterogeneous systems. In: Villanueva, A. (ed.) Proceedings of XIV Jornadas sobre Programación y Lenguajes (PROLE 2016), pp. 17–32 (2016). http://hdl.handle.net/11705/PROLE/2016/014
Verdoolaege, S., Grosser, T.: Polyhedral extraction tool. In: Second International Workshop on Polyhedral Compilation Techniques (IMPACT’12), Paris, pp. 1–16 (2012). http://impact.gforge.inria.fr/impact2012/workshop_IMPACT/verdoolaege.pdf
Visser, E.: Program transformation with Stratego/XT: rules, strategies, tools, and systems in StrategoXT-0.9. In: Lengauer, C., Batory, D., Consel, C., Odersky, M. (eds.) Domain-Specific Program Generation. Lecture Notes in Computer Science, vol. 3016, pp. 216–238. Springer (2004). doi:10.1007/978-3-540-25935-0_13
Acknowledgements
This work has been partially funded by EU FP7-ICT-2013.3.4 project 610686 POLCA, Comunidad de Madrid project S2013/ICE-2731 N-Greens Software, Generalitat Valenciana grant APOSTD/2016/036 and MINECO Projects TIN2012-39391-C04-03/TIN2012-39391-C04-04 StrongSoft, TIN2013-44742-C4-1-R CAVI-ROSE, and TIN2015-67522-C3-1-R TRACES.
We are also grateful to the various members of the POLCA project consortium for many fruitful discussions and feedback. We are in particular indebted to Jan Kuper, Lutz Schubert, Daniel Rubio, Colin Glass, Lotfi Guedria, and Robert de Groote.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2017 Springer International Publishing AG
About this paper
Cite this paper
Tamarit, S., Vigueras, G., Carro, M., Mariño, J. (2017). Machine Learning-Driven Automatic Program Transformation to Increase Performance in Heterogeneous Architectures. In: Niethammer, C., Gracia, J., Hilbrich, T., Knüpfer, A., Resch, M., Nagel, W. (eds) Tools for High Performance Computing 2016. Springer, Cham. https://doi.org/10.1007/978-3-319-56702-0_7
Download citation
DOI: https://doi.org/10.1007/978-3-319-56702-0_7
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-56701-3
Online ISBN: 978-3-319-56702-0
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)