This article presents a line of development of formal design methods that is based on the concepts of algebraic programming and algebraic dynamic program models using rewriting rules for the automated design of efficient programs for graphics processing units. The developed formal methods are illustrated by examples that show high efficiency of transformations.
Наведено огляд результатів розробки формальних та адаптивних методів і програмних засобів, досягнутих за останні роки в Інституті програмних систем НАН України, що ґрунтуються на алгеброалгоритмічному підході та техніці переписувальних правил. Методи призначені для автоматизації проектування, генерації та перетворень паралельних програм для широкого діапазону мультипроцесорних обчислювальних платформ і знаходять застосування для різних прикладних областей, зокрема, для ефективної реалізації задач метеорологічного прогнозування. Ключові слова: автоматизація програмування, алгебра алгоритмів, метеорологічне прогнозування, паралельні обчислення, техніка переписувальних правил.
Python is a popular programming language used in many areas, but its performance is significantly lower than many compiled languages. We propose an approach to increasing performance of Python code by transforming fragments of code to more efficient languages such as Cython and C++. We use high-level algebraic models and rewriting rules technique for semi-automated code transformation. Performance-critical fragments of code are transformed into a low-level syntax model using Python parser. Then this low-level model is further transformed into a high-level algebraic model that is language-independent and easier to work with. The transformation is automated using rewriting rules implemented in Termware system. We also improve the constructed high-level model by deducing additional information such as data types and constraints. From this enhanced high-level model of code we generate equivalent fragments of code using code generators for Cython and C++ languages. Cython code is seamlessly integrated with Python code, and for C++ code we generate a small utility file in Cython that also integrates this code with Python. This way, the bulk of program code can stay in Python and benefit from its facilities, but performance-critical fragments of code are transformed into more efficient equivalents, improving the performance of resulting program. Comparison of execution times between initial version of Python code, different versions of transformed code and using automatic tools such as Cython compiler and PyPy demonstrates the benefits of our approach – we have achieved performance gains of over 50x compared to the initial version written in Python, and over 2x compared to the best automatic tool we have tested.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.