Specialization through Dynamic Staging

Piotr Danilewski, Marcel Köster, Roland Leißa, Richard Membarth, Philipp Slusallek

In: Proceedings of the 13th International Conference on Generative Programming: Concepts & Experiences (GPCE). International Conference on Generative Programming: Concepts & Experiences (GPCE-14) September 15-16 Västerås Sweden Seiten 103-112 ACM 9/2014.


Partial evaluation allows for specialization of program fragments. This can be realized by staging, where one fragment is executed earlier than its surrounding code. However, taking advantage of these capabilities is often a cumbersome endeavor. In this paper, we present a new metaprogramming concept using staging parameters that are first-class citizen entities and define the order of execution of the program. Staging parameters can be used to define MetaML-like quotations, but can also allow stages to be created and resolved dynamically. The programmer can write generic, polyvariant code which can be reused in the context of different stages. We demonstrate how our approach can be used to define and apply domain-specific optimizations. Our implementation of the proposed metaprogramming concept generates code which is on a par with templated C++ code in terms of execution time.

Weitere Links

Deutsches Forschungszentrum für Künstliche Intelligenz
German Research Center for Artificial Intelligence