A Partial Evaluator for C

Hacker News Top Tools

Summary

Tempo is an off-line partial evaluator for C programs developed at IRISA/INRIA-LABRI, applying program specialization through an analysis and specialization phase across domains like operating systems, networking, and scientific computation.

No content available
Original Article
View Cached Full Text

Cached at: 11/23/26, 06:30 AM

# Tempo Specializer - A Partial Evaluator for C Source: [https://phoenix.labri.fr/software/tempo/](https://phoenix.labri.fr/software/tempo/) --- - [What is Tempo?](https://phoenix.labri.fr/software/tempo/#what) - [An overview of Tempo](https://phoenix.labri.fr/software/tempo/#Tempo) - [Applications](https://phoenix.labri.fr/software/tempo/#applications) - [Related projects](https://phoenix.labri.fr/software/tempo/#related) - [Workshop](https://phoenix.labri.fr/software/tempo/#workshop) - [Distribution](https://phoenix.labri.fr/software/tempo/#distribution) - [References](https://phoenix.labri.fr/software/tempo/#references) - [Contact information](https://phoenix.labri.fr/software/tempo/#info) --- ## What is Tempo? *Partial evaluation*is program transformation that automates a*program specialization*process\.*[Tempo](https://phoenix.labri.fr/software/tempo/#Tempo)*is a*partial evaluator*for C programs\. It has been applied in various domains such as operating systems and networking, computer graphics, scientific computation, software engineering and domain specific languages\. A first[workshop](https://phoenix.labri.fr/software/tempo/#workshop)on Tempo has been organized in March 1998\. Tempo is now being[distributed](https://phoenix.labri.fr/software/tempo/#distribution)\. Its[documentation](https://phoenix.labri.fr/software/tempo/doc/)is available on line, as well as[tutorial slides](https://phoenix.labri.fr/publications/talks/#tempo)\. --- ## An Overview of Tempo *Tempo*is a partial evaluator for C programs\. It is being developed in the Compose project at[IRISA / INRIA](http://www.irisa.fr/)\-[LABRI](http://www.labri.fr/)\(France\)\.Tempo is an*off\-line*specializer; it is divided into two phases: analysis and specialization\. For more details, please consider reading some of our papers, most of which are available at the following URL:[papers](https://phoenix.labri.fr/publications/papers/)\. #### Program Analysis As a first step, the user provides a program and specifies what arguments \(including global variables\) are static\. For example, the user provides the following code for aminiprintffunction, and specifies in this way that the first argument is static whereas the second is dynamic:miniprintf\(S,D\)\.``` miniprintf(char fmt[], int val[]) {   int i = 0;   while( *fmt != '\0' ) {     if( *fmt != '%' )        putchar(*fmt);     else       switch(*++fmt) {         case 'd' : putint(val[i++]); break;                      case '%' : putchar('%');     break;         default  : prterror(*fmt);   break;       }     fmt++;   } } ``` From this Tempo produces a program file with analysis annotations\. These annotations can be visualized using colors that highlight the propagation of the known/unknown information throughout the program\. ``` /*  LEGEND:  STATIC  DYNAMIC  */ miniprintf(char fmt[], int val[]) {   int i = 0;   while( *fmt != '\0' ) {     if( *fmt != '%' )        putchar(*fmt);     else       switch(*++fmt) {         case 'd' : putint(val[i++]); break;                       case '%' : putchar('%');     break;         default  : prterror(*fmt);   break;       }     fmt++;   } } ``` The blue color \(bold face for black and white display\) represent static constructions,*i\.e\.*values that can be computed at specialization time\. The red color \(standard font for black and white display\) is for dynamic expressions, whose value cannot be precomputed knowing only the static arguments\. Basically, everything in blue \(bold\) will disappear after specialization; only red \(standard font\) parts will remain\.The visualization of the analysis is very important for the user to assess the amount of specialization in the code\. Furthermore, the analysis speeds up the specialization process \(as opposed to*on\-line*partial evaluators\)\. The analysis is inter\-procedural and takes into account pointer aliases and side\-effects\. #### Compile\-Time Specialization When the user is satisfied with the analysis \(*i\.e\.*, what the user expects to specialize indeed appears as static\), actual specialization values must be provided\. For example, giving"<%d,%d\>"as the actual specialization value for thefmtargument of theminiprintf\(\)function yields the following specialized code\.``` miniprintf_1(int val[]) {   putchar( '<'    );   putint ( val[0] );   putchar( ','    );   putint ( val[1] );   putchar( '>'    ); } ``` Many specializations can be made, sharing the same analysis\. Only different specialization values have to be provided\.#### Runtime Specialization Tempo can also perform runtime specialization, using optimized binary code templates\. A dedicated runtime specializer is generated from the analysis of the program\. In the case of theminiprintffunction, Tempo generates a runtime specializerrts\_miniprintf\_1\(\)which can be used as in the following example\.``` /*  * Some dynamic execution context for variable 'format'  */ spec_printf = rts_miniprintf_1(format); ... (*spec_printf)(val1);   /* <=> miniprintf(format,val1) */ (*spec_printf)(val2);   /* <=> miniprintf(format,val2) */ ``` The functionrts\_miniprintf\_1\(\)is a dedicated runtime specializer\. It returns a pointer to the specialized function\. Several specialized versions can also be generated and used at the same time\. --- ## Applications of Tempo Tempo has been successfully applied in various domains, yielding substantial speedups\.- Operating system and networking: - Computer graphics \(various filtering algorithms\), - Scientific computation \(trajectory, FFT, math libraries\), - Software architectures and mechanisms: For an up\-to\-date list of non\-confidential, published applications, please browse our \`\`papers'' web page:[papers](https://phoenix.labri.fr/publications/papers/)\.Besides C, Tempo is currently being used as a back\-end for specializing Java programs using Harissa, a JavaVM\-to\-C compiler\. Fortran and C\+\+ programs have also been specialized using translators to C\. --- ## Projects Related to Tempo **[Cyclone](http://www.eecs.harvard.edu/~greg/cyclone/index.html)**Cyclone is a mobile code system being developed as part of the[SwitchWare](http://www.cis.upenn.edu/~dsl/switchware/software/)active\-network project at the[University of Pennsylvania](http://www.cis.upenn.edu/)\. Cyclone uses two ideas to make mobile code safe as well as fast: run\-time code generation and proof\-carrying code\. Cyclone relies on Tempo's analysis front\-end \(i\.e\. the binding\-time analysis\) and on TAL/T, an extension of the[TAL](http://www.cs.cornell.edu/talc/)typed assembly language\. --- ## Workshop A workshop \(actually closer to a \`\`winter school''\) on Tempo has been organized at[IRISA](http://www.irisa.fr/), March 16\-18, 1998\. The aim of this workshop was to present a three\-day tutorial on Tempo and its applications to real size programs\. We had 24 participants, coming from universities as well as industries\. We believe it was a large success\. The[talks](https://phoenix.labri.fr/publications/talks/#tempo)are now available on\-line\.Depending on request, if the[distribution](https://phoenix.labri.fr/software/tempo/#distribution)of Tempo is a success, we might organize another workshop later\. It would less be like a \`\`winter school'' but rather like a real workshop with users presenting applications and open discussions about possible improvements\. It would be preceded by an optional one\-day tutorial for people not knowing partial evaluation or Tempo\. --- ## Distribution The Tempo specializer has been made publicly available under a licence in April 1998\. At of March 99, it was being used by about thirty people around the world\. The binary version of Tempo has just \(July 2000\) been made available without any restrictions, and we expect a full unrestricted source release under GPL to follow soon\.Getting access to Tempo no longer requires signing a license agreement\. Tempo is simply available via anonymous FTP, as described below\. In any case, we would*very much*like to hear from you if you are an active Tempo user\. If you are, please also let us know if and for what purpose you are using Tempo, by sending an email to[tempo@labri\.fr](mailto:[email protected])\. We will by default add you to our tempo talk mailing list[tempo\-talk@labri\.fr](mailto:[email protected]), where future Tempo releases will be announced, and Tempo users can discuss practical problems using Tempo\. Tempo can be downloaded : - Here is a Tempo release that have been made publicly available:[i386 Linux](https://phoenix.labri.fr/software/tempo/distribution/tempo.tar.gz) - Most recent Tempo binary distribution for[i386 Linux](https://phoenix.labri.fr/software/tempo/distribution/tempo.tar.gz)\(tested on RedHat 6\.1\)\. \(Please remember to send an email to[tempo@labri\.fr](mailto:[email protected])to let us know who you are and why you are using Tempo\. Remember to explicitly indicate if you are not interested in joining the[tempo\-talk@labri\.fr](mailto:[email protected])mailing list\.\)In case of any problem with getting or installing the distribution, get in touch with us:[mailto:tempo@labri\.fr](mailto:[email protected]) --- ## References Here are general papers about Tempo and its architecture\. More focused and up\-to\-date information regarding Tempo can be found in the main[on\-line papers](https://phoenix.labri.fr/publications/papers/)tank\.\[[CHN\+96](https://phoenix.labri.fr/publications/papers/tempo-tr96.ps.gz)\]*A Uniform Approach for Compile\-Time and Run\-Time Specialization\.*Research Report 2775\. INRIA, January 1996\. C\. Consel, L\. Hornof, J\. Noyé, F\. Noel, and E\.N\. Volanschi\. Revised version in Partial Evaluation, International Seminar, Dagstuhl Castle, LNCS 1110, Springer\-Verlag, pages 54\-72\.\[[CHL\+98](https://phoenix.labri.fr/publications/papers/acm-pe98-tempo.ps.gz)\]*Tempo: Specializing Systems Applications and Beyond*C\. Consel, L\. Hornof, J\. Lawall, R\. Marlet, G\. Muller, J\. Noyé, S\. Thibault, N\. Volanschi\. To appear in ACM Computing Surveys,[Symposium on Partial Evaluation](http://www.brics.dk/~sope98/), 1998\.\[[CMVM97](https://phoenix.labri.fr/publications/papers/intro-tempo.ps.gz)\]*Adaptabilité et évaluation partielle : Tempo, un spécialiseur pour le langage C\.*C\. Consel, G\. Muller, N\. Volanschi, R Marlet\. Apr 1997\. \(In French\.\) --- ## Contact Information - Developers and maintainers:[tempo@labri\.fr](mailto:[email protected]) - Tempo Specializer home page:tempo

Similar Articles

The Magic of Partial Evaluation

Lobsters Hottest

Jimmy Miller explores the concept of partial evaluation — expanding programs at compile time to eliminate static computation — inspired by James Long's revival of Meta's Prepack, and introduces his own library for experimenting with the idea.

ParaTempo: Efficient Parallel Reasoning via Temporal Confidence

Hugging Face Daily Papers

ParaTempo is a training-free asynchronous parallel reasoning framework that uses temporal confidence to dynamically manage reasoning branches, reducing latency and token usage while maintaining accuracy in mathematical and scientific reasoning benchmarks.

Temper Language

Lobsters Hottest

Temper is a programming language that cross-translates to multiple target languages including C#, Java, JavaScript/TypeScript, Lua, and Python, enabling shared libraries across ecosystems.

TEMPO: Scaling Test-time Training for Large Reasoning Models

Hugging Face Daily Papers

TEMPO introduces a test-time training framework that alternates policy refinement with critic recalibration to prevent diversity collapse and sustain performance gains in large reasoning models, boosting AIME 2024 scores for Qwen3-14B from 42.3% to 65.8%.