Domain-Specific Program Generation pp 291-306

Part of the Lecture Notes in Computer Science book series (LNCS, volume 3016)

Runtime Code Generation in C++ as a Foundation for Domain-Specific Optimisation

  • Olav Beckmann
  • Alastair Houghton
  • Michael Mellor
  • Paul H. J. Kelly


The TaskGraph Library is a C++ library for dynamic code generation, which combines specialisation with dependence analysis and loop restructuring. A TaskGraph represents a fragment of code which is constructed and manipulated at runtime, then compiled, dynamically linked and executed. TaskGraphs are initialised using macros and overloading, which forms a simplified, C-like sub-language with first-class arrays and no pointers. Once a TaskGraph has been constructed, we can analyse its dependence structure and perform optimisations. In this Chapter, we present the design of the TaskGraph library, and two sample applications to demonstrate its use for runtime code specialisation and restructuring optimisation.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Wilson, R.P., French, R.S., Wilson, C.S., Amarasinghe, S.P., Anderson, J.M., Tjiang, S.W.K., Liao, S.W., Tseng, C.W., Hall, M.W., Lam, M.S., Hennessy, J.L.: SUIF: an infrastructure for research on parallelizing and optimizing compilers. ACM SIGPLAN Notices 29, 31–37 (1994)CrossRefGoogle Scholar
  2. 2.
    Engler, D.R., Hsieh, W.C., Kaashoek, M.F.: C: a language for high-level, efficient, and machine-independent dynamic code generation. In: POPL 1996: Principles of Programming Languages, pp. 131–144 (1996)Google Scholar
  3. 3.
    Grant, B., Mock, M., Philipose, M., Chambers, C., Eggers, S.J.: DyC: An expressive annotation-directed dynamic compiler for C. Theoretical Computer Science 248, 147–199 (2000)MATHCrossRefGoogle Scholar
  4. 4.
    McCarthy, J.: History of LISP. In: The first ACM SIGPLAN Conference on History of Programming Languages. ACM SIGPLAN Notices, vol. 13(8), pp. 217–223 (1978)Google Scholar
  5. 5.
    Grant, B., Philipose, M., Mock, M., Chambers, C., Eggers, S.J.: An evaluation of staged run-time optimizations in DyC. In: PLDI 1999: Programming Language Design and Implementation, pp. 293–304 (1999)Google Scholar
  6. 6.
    Jones, N.D.: Mix Ten Years Later. In: PEPM 1995: Partial Evaluation and Semantics-Based Program Manipulation (1995)Google Scholar
  7. 7.
    Intel Corporation: Integrated Performance Primitives for Intel Architecture. Reference Manual, vol. 2: Image and Video Processing (200–2001)Google Scholar
  8. 8.
    Intel Corporation: Intel Pentium 4 and Intel Xeon Processor Optimization Reference Manual (1999–2002) Available via Scholar
  9. 9.
    Whaley, R.C., Petitet, A., Dongarra, J.J.: Automated empirical optimizations of software and the ATLAS project. Parallel Computing 27, 3–35 (2001)MATHCrossRefGoogle Scholar
  10. 10.
    Batory, D., Lofaso, B., Smaragdakis, Y.: JTS: Tools for Implementing Domain- Specific Languages. In: Fifth International Conference on Software Reuse. IEEE Computer Society Press, Los Alamitos (1998)Google Scholar
  11. 11.
    Taha, W., Sheard, T.: MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science 248, 211–242 (2000)MATHCrossRefGoogle Scholar
  12. 12.
    Taha, W.: A gentle introduction to multi-stage programming. In: Gelenbe, E., Kaiser, C. (eds.) Operating Systems. LNCS, vol. 16. Springer, Heidelberg (1981)Google Scholar
  13. 13.
    Sheard, T., Peyton-Jones, S.: Template meta-programming for Haskell. ACM SIGPLAN Notices 37, 60–75 (2002)CrossRefGoogle Scholar
  14. 14.
    Veldhuizen, T.L.: Arrays in Blitz++. In: Caromel, D., Oldehoeft, R.R., Tholburn, M. (eds.) ISCOPE 1998. LNCS, vol. 1505, pp. 223–230. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  15. 15.
    Karmesin, S., Crotinger, J., Cummings, J., Haney, S., Humphrey, W.J., Reynders, J., Smith, S., Williams, T.: Array design and expression evaluation in POOMA II. In: Caromel, D., Oldehoeft, R.R., Tholburn, M. (eds.) ISCOPE 1998. LNCS, vol. 1505, pp. 231–238. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  16. 16.
    Marlet, R., Consel, C., Boinot, P.: Efficient incremental run-time specialization for free. ACM SIGPLAN Notices 34, 281–292 (1999); Proceedings of PLDI 1999CrossRefGoogle Scholar
  17. 17.
    Consel, C., Hornof, L., Marlet, R., Muller, G., Thibault, S., Volanschi, E.N.: Tempo: Specializing systems applications and beyond. ACM Computing Surveys 30 (1998)Google Scholar
  18. 18.
    Glück, R., Jørgensen, J.: Fast binding-time analysis for multi-level specialization. In: Bjorner, D., Broy, M., Pottosin, I.V. (eds.) PSI 1996. LNCS, vol. 1181, pp. 261–272. Springer, Heidelberg (1996)Google Scholar
  19. 19.
    Sharma, S., Acharya, A., Saltz, J.: Deferred Data-Flow Analysis. Technical Report TRCS98-38, University of California, Santa Barbara (1998)Google Scholar
  20. 20.
    Bala, V., Duesterwald, E., Banerjia, S.: Dynamo: A transparent dynamic optimization system. In: PLDI 2000: Programming Language Design and Implementation, pp. 1–12 (2000)Google Scholar
  21. 21.
    Fordham, P.: Transparent run-time cross-component loop fusion. MEng Thesis, Department of Computing, Imperial College London (2002)Google Scholar
  22. 22. OpenMP C and C++ Application Program Interface, Version 2.0 (2002)
  23. 23.
    Liniker, P., Beckmann, O., Kelly, P.H.J.: Delayed evaluation, self-optimising software components as a programming model. In: Monien, B., Feldmann, R.L. (eds.) Euro-Par 2002. LNCS, vol. 2400, pp. 666–673. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  24. 24.
    Subramanian, M.: A C++ library to manipulate parallel computation plans. Msc thesis, Department of Computing, Imperial College London, U.K. (2001)Google Scholar
  25. 25.
    Lengauer, C.: Program optimization in the domain of high-performance parallelism. In: Lengauer, C., Batory, D., Consel, C., Odersky, M. (eds.) Domain-Specific Program Generation. LNCS, vol. 3016, pp. 73–91. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  26. 26.
    Veldhuizen, T.L.: C++ templates as partial evaluation. In: PEPM 1999: Partial Evaluation and Semantic-Based Program Manipulation, pp. 13–18 (1999)Google Scholar
  27. 27.
    Czarnecki, K., O’Donnell, J., Striegnitz, J., Taha, W.: DSL Implementation in MetaOCaml, Template Haskell, and C++. In: Lengauer, C., Batory, D., Consel, C., Odersky, M. (eds.) Domain-Specific Program Generation. LNCS, vol. 3016, pp. 51–72. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  28. 28.
    Visser, E.: Program Transformation with Stratego/XT: Rules, Strategies, Tools, and Systems in Stratego/XT 0.9. In: Lengauer, C., Batory, D., Consel, C., Odersky, M. (eds.) Domain-Specific Program Generation. LNCS, vol. 3016, pp. 216–238. Springer, Heidelberg (2004)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Olav Beckmann
    • 1
  • Alastair Houghton
    • 1
  • Michael Mellor
    • 1
  • Paul H. J. Kelly
    • 1
  1. 1.Department of ComputingImperial College LondonLondonUK

Personalised recommendations