|
© 1998 IRISA / INRIA - University of Rennes 1
|
Version 1.194
|
Tempo Specializer - FAQ
MAIN
TUTOR
USER
REF
INSTALL
FAQ
LIMIT
BUGS
SUPPORT
SML
SUIF
DEMO
CONTRIB
The Tempo FAQ will keep track of the Frequently Asked Questions from
Tempo developers and users.
We follow the convention that unless specified otherwise, all
references below can be found in the User Manual, except references marked
"Variable:" and "File:", which can be found in the Reference Manual.
What does the "=" prompt mean?
In the SML top level, every command has to be terminated with a
semicolon. "=" indicates that the semicolon was not provided.
When I run the tempo command, nothing happens.
The tempo SML command requires three arguments, the name of
the file (without the .c extension), the name of the
starting phase, and the name of the ending phase. Because the
tempo function is curried, if you leave off one of the
arguments, a partially-applied function is returned.
What files are needed at minimum to specialize a program?
The C source file (file.c) and the SML file containing
configuration information (file.config.sml). The
specialization context file initializing the static parameters of the
program (file.sctx.c) is needed for compile-time
specialization. The SML file containing
configuration information must at least define the
entry_point variable.
Why doesn't ~ work to specify the path of a file
or directory?
This is currently a feature of Tempo. Use the complete path name when
changing directories. When you are in the directory of the program
to specialize, just the file name is sufficient.
How can I specify an include path for the analysis phase and
for the specialization phase?
Any flags can be provided to Suif (the parser used for the analyses)
using the scc_flags variable. Any flags can be added to the
compilation of the specializer using the ctcg_cflags variable.
How can I set my preferences (e.g. viewer
:= html rather than emacs) once
and for all rather than explicitly at each Tempo session?
Create a file named .tempo.sml in your
home directory (that is the full name, not just an file extension);
it will be loaded each time you run the the tempo top
level.
How do I get out of Tempo?
Type control-D (i.e. end-of-file character).
What are the initial binding times of global variables?
Uninitialized global variables are dynamic by default. Initialized
global variables are static by default. Global variables can be declared
static explicitly using the static_locations variable.
What are the initial alias properties of global variables?
By default, it is assumed that there are no alias relationships among
global variables. Aliases can be specified using the
set_analysis_context() function in the .actx.c file.
Why does a local variable have bottom binding time?
A local variable has binding time bottom until it is assigned.
When does a parameter become a local variable?
If a parameter value is static and its address is used at runtime,
the parameter is suppressed and a local variable is allocated.
Take for example the following program:
-
void proc2(int *p)
{
show(p);
}
void proc1(int c)
{
proc2(&c);
}
void entry()
{
proc1(1);
}
Here, show() is an external function: it can not be called at
specialization time. There is no .actx.c file, so by default this
function does not access the value stored at its parameter address.
The value of c is static. So the parameter c
could be suppressed. On the other hand, the address of c
is dynamic. So the parameter c should be
residualized. In order to reconcile both aspects, the parameter
c is suppressed and a local variable c is
introduced in proc1() (where its address is needed). The
specialized code looks like:
-
static void proc2(int *p)
{
show(p);
}
static void proc1()
{
int c;
proc2(&c);
}
extern void entry()
{
proc1();
}
After the assignment a[3] = 0, why is
a[3] still dynamic?
In Tempo, all array cells have the same binding time. Thus if
any cell is dynamic, they are all dynamic, even after a static
assignment to a particular cell.
After the assignment s.x = 0, why is
s.x still dynamic?
In Tempo, there is only one binding time description for all
instances of a structure or union of a given type. Because just
assigning the field of one instance to a static value does not ensure
that the corresponding field of all instances has a static value, the
binding time remains dynamic.
Even though there is no assignment of an array cell
(or structure or union field) to a dynamic value, why are all the array
cells (or structure or union fields) dynamic?
In Tempo, all locations are considered dynamic, unless
specified otherwise (except initialized scalar variables). This
includes the content of arrays and the fields of structures and unions.
Where does the __tmp_struct1 structure type come
from?
SUIF introduces names of this form when an anonymous structure
type is defined in the program. It is not safe to rely on Suif to
choose a particular name for a particular structure.
If s is the name of a structure with field x
, why isn't s.x a valid entry in the list static_locations ?
The entry in the static_locations list uses the type
name rather than the name of a particular instance, because of
structure monovariance.
If str is the name of a structure type declared
using typedef, why isn't str.x a valid entry in the
list static_locations ?
Typedefs are eliminated by Suif. The entry for a structure or
union field in the static_locations list has to be the name of
the structure or union type, followed by "dot", followed by the name
of the desired field.
If str is the type of a structure or union, and x
is a field of str having structure or union type, why is
it an error to include str.x in the list
static_locations ?
Structures as a whole do not have a static binding time. Instead, the
individual fields should be specified to be static.
Tempo may be applied to only part of a complete application. In this
situation it may be necessary to specify extra information about the
context in which the specialized code will be invoked, about
functions called from the code to specialized, and about the context
following the invocation of the specialized code. Furthermore, the
specialized code needs to be reintegrated into the application.
How can the binding times of values pointed to by global
variables or entry-point parameters be specified?
By default, pointed values have the same binding time as the
pointer. A different binding time can be specified using the
set_analysis_context() function in the .actx.c file.
How can alias relationships among global variables or
entry-point parameters be specified?
Aliases can be specified using the set_analysis_context()
function in the .actx.c file.
The code to be specialized contains a static assignment to a
global variable. When the variable is used in the application after
the specialized code is called, how can I force the assignment to be
residualized?
The variable live_locations allows one to specify what
locations are used in the application after the call to the
specialized code. More complex relationships can be specified using
the set_post_analysis_context() function in the .actx.c file.
When are external function calls residualized?
An external function call is residualized when any of the arguments
are dynamic. An external function call is also residualized when the
external_functions variable is set to a RESIDUALIZE list
including the name of the function, or when the
external_functions variable is set to an EVALUATE list
not including the name of the function. By default, all external
functions are residualized.
When are external function calls evaluated?
An external function call is never evaluated when any of the
arguments are dynamic. When all of the arguments are static, an
external function call is evaluated if the
external_functions variable is set to an EVALUATE
list including the name of the function, or when the
external_functions variable is set to a RESIDUALIZE
list not including the name of the function. Note that the decision
whether all the arguments are static depends on just the argument
values, not on values the arguments may point to.
How is the definition of an evaluated external function
obtained?
Evaluated external functions have to be linked in with the
specializer. Libraries and files defining external functions can be
specified using the ctcg_ldlibs variable.
How can the effect of an external function on binding times
be specified?
By default, an external call is assumed to have no effect on
binding times. Binding-time effects can be specified using an
abstract definition of the function in the .actx.c file.
How can the effect of an external function on aliases
be specified?
By default, an external call is assumed to have no effect on
aliases. Alias effects can be specified using an
abstract definition of the function in the .actx.c file.
How can a location be made static in the .actx.c file?
A location can be made static by just assigning it to a
constant, or to a global variable declared in the .actx.c file
and specified as static using the static_locations variable.
How can a location be made dynamic in the .actx.c file?
A location can be made dynamic just assigning it to a
global variable declared in the .actx.c file or by assigning it
to the result of a residualized external function call.
How can aliases be described in the .actx.c file?
Alias relationships between variables can be described using the
addresses of variables declared in the .actx.c file. A
collection of aliases for a single location can be specified using a
sequence of if statements.
How can memory allocation by external functions be
modeled?
Memory allocation can be modeled by defining an abstract
function that returns a pointer to some data structure defined in
the .actx.c file.
During specialization, variables declared in the specialized
program don't seem to communicate with variables declared in the rest
of the application.
In the current implementation of the specializer, global names are
renamed during specialization. This can cause problems if they are
are referenced externally during specialization, because references
in already-compiled code will not be renamed appropriately. A
solution is to include the .sctx.h file in all of the
files of the application, and recompile the entire application at
specialization time, rather than using existing .o
files.
Will the names of specialized functions conflict with the
names of existing functions in the original application?
All specialized functions except the specialized entry point are
declared as static, so they are not visible from
any other file.
What is the name of the specialized entry point?
A fresh name is chosen for the specialized entry point by
default. The name can be specified using the variable
specialized_entry_point_name.
My analysis takes a lot of time to compute? Do I have to
always re-run it from scratch?
As long as your source files (".c" and ".actx.c") and
configuration file (".config.sml") do not change, you can always
restart from some already generated intermediate file (suffixed ".as")
The an command
runs the whole sequence of analysis phases, starting from the C files.
But you may use the tempo top-level command
to run only a fraction of thoses analyses.
How are the values of the static parameters and globals
provided before specialization?
Static variables are initialized using the .sctx.c file
Why are there unbound variables when compiling the .sctx.c file?
Tempo changes the names of some variables. Thus, the .sctx.c file must #include the .sctx.h to perform
the renaming.
What does it mean when the specializer just sits there, doing
nothing?
Perhaps your program is in an infinite loop (see also Static Loops Containing
Dynamic Exits
in the Known
Bugs collection), or perhaps there is too much specialization
being performed. If a single static value varies a lot, you may end
up creating many very similar specialized functions. In this case it
may be useful to make some static values dynamic, to perform less
specialization.
What does it mean when there is a lot of garbage collection
during specialization?
Once you see messages about garbage collection, specialization has
successfully completed, and Tempo is performing postprocessing.
Probably your specialized program is just very large. In this case it
may be useful to make some static values dynamic, to perform less
specialization.
What does it mean if my static parameters are initialized to
zero or to some strange random values?
Initialization of the static parameters is specified by a user-written
function set_specialization_context() in a file
suffixed .sctx.c
. A common error is to set the local variables of this
function, not their pointer values (i.e. not the static
arguments of the entry point).
What does it mean if there is a bus error, segmentation
fault, or illegal instruction error during specialization?
If the error does not come rapidly when specialization starts, it may
mean that the specialized code has exceeded the allocated buffer size.
A larger buffer can be requested using the explicit_cts_bufsize
variable.
If the error comes rapidly when specialization starts, it is likely
that some data structure is not properly initialized (see Common Errors in Setting
Specialization Contexts
). Alternatively, there may be an error
in your program. You can use the debugger gdb by
compiling the specializer files with the -g option
(specified by adding -g to the value of
ctcg_cflags). Errors are likely to occur in the .ev.c
file. Each function in this file contains a comment
indicating the name of the function in the source program that it
comes from.
How can I see the result of the specialization before
post-processing?
The result of raw specialization is dumped into the file.rawcts.as
file. It is not turned into C text by default as it is
post-processed right away. To view it as C text, type this command at
the top level.
-
as2c "file.rawcts.as";
The corresponding file.rawcts.c
will be generated in the working directory. Alternatively,
you may also set variable output_mode.
|
See also:
|
Command:
as2c (generation of C text from abstract syntax format)
Variable:
output_mode (control of the intermediate files to generate)
|
Is there any way to specify that a single function should always
be inlined and no other function should ever be inlined, without
saying do_not_inline and listing the names of all the
functions?
The SML variable post_do_inline is bound to a list of
functions that must be inlined. The SML variable
post_do_not_inline is bound to a list of functions that must
not be inlined. But setting post_do_inline to a list of
function names does not does not mean that no other functions will be
inlined. Similarly setting post_do_not_inline to a list of
function names does not mean that all other functions will be inlined.
Instead the inlining of functions is controlled by the variables
post_inlining_max_nb_stmts and
post_inlining_max_nb_calls . These integer variables are the
thresholds at which to stop inlining functions not explicitly included
in the post_do_inline list. Thus to inline the function
"foo", but no other functions, set the flags as follows:
-
post_inlining := true;
post_do_inline := ["foo"];
post_inlining_max_nb_stmts := 0;
post_inlining_max_nb_calls := 0;
Note that no inlining happens, regardless of the value of
post_do_inline if post_inlining is set
to false.
If you want the calls within "foo" to be inlined as well,
use the following settings:
-
post_inlining := true;
post_do_inline := ["foo"];
post_start_inlining_func := ["foo"];
Variable start_inlining_func specifies the function at
which inlining begins. Function calls not directly or indirectly
within these functions are not inlined. inlining, and stops any
functions outside the branch of the function(s) specified from being
inlined.
Once the run-time specializer is created, how is it used in
the application?
The run-time specializer is invoked with the list of values for the
static arguments. The result is a pointer to a specialized function
that takes as inputs the values of the rest of the arguments.
The run-time specializer is generated in an
architecture-dependent directory; how do I know its name, how can I
change it?
All architecture-dependent files are generated, starting from in the
working directory, in a sub-directory given by variable arch_dep_dir. If
you want it to be written in the working directory instead, you may
assign arch_dep_dir to ".".
How can multiple specializations of a single function be
created?
By default, the run-time specializer allocate new buffer
space each time the specializer is called and for each function.
Other buffer manipulation strategies can be implemented by the user.
The reentrant flag can
be set to false to instruct the specializer to use a single buffer to store
the specialized code. Subsequent specializations overwrite previous
specializations.
What does a segmentation fault during run-time specialization
mean?
If the segmentation fault occurs during specialization, as opposed to
when running the specialized program, the problem might be that the
program is recursive. If the program is recursive, the reentrant_rts
flag must be set to true.
Why does emacs give an error when loading color files?
There is a problem with the enriched mode of emacs version
19.34. A patch is available, as described in the installation manual.
Why are some of the color annotations missing when viewing the color files under emacs?
There is a problem with the enriched mode of emacs version
19.34. A patch is available, as described in the installation manual.
Why are lines being wrapped when viewing color files under emacs?
The enriched mode of emacs will sometimes automatically perform filling
at a specific width. The solution is to turn off filling, as described in
the installation manual.
Why does my color file have lots of strange annotation when I view it under emacs?
The enriched mode of emacs will sometimes fail to display the file.
Reloading the file normally solves the problem.
Why don't the color files look like the source
program?
Several transformations are performed on the source program by
Suif and by Tempo. For example, Suif breaks up complex conditions,
rewrites all pointer dereferences to apply to a single variable, and
rewrites all loops as do-while loops. Early phases of Tempo eliminate
gotos and indirect function calls.
How can I get rid of all the comments in the color
files?
Alias comments can be eliminated by setting verbose_aliases
variable to false. Function-header comments can be eliminated by
setting verbose_headers variable to false.
What do the colors mean?
There is a legend at the top that describes the meaning of
each color.
What happened to the variable declarations?
If there are more global variable declarations than the threshold
specified by the variable max_decls_size, the
variable declarations are put in a .decl.h file.
How do I print a color file in emacs?
M-x ps-print-buffer-with-faces
-
Prints the current buffer on the current printer.
M-1 M-x ps-print-buffer-with-faces
-
Prompts for the name of a file where to save a postscript version
(with colors) of the current buffer.
M-x eval-expression
(ps-print-buffer-with-faces "file.ps")
-
Saves a postscript version (with colors) of the current buffer
into
file.ps.
MAIN
TUTOR
USER
REF
INSTALL
FAQ
LIMIT
BUGS
SUPPORT
SML
SUIF
DEMO
CONTRIB
Last modified: Wed Jun 24 17:38:45 MET DST 1998