Privatization of Permanent Variables
In the target program execution, each target process has a separate copy of the
permanent variables of the program i.e. global variables and
static variables within functions.
In the simulation however, if they execute the target
program unmodified, all threads in the
same host process end up sharing their permanent variables (although
since they have separate stacks, they do not share automatic variables).
In order to prevent this sharing, the target program is parsed and
a dimension added to the definition and reference of
each permanent variable. The size of this dimension
is equal to the maximum number of threads in a host process. At
execution time, each thread
uses its id to access its copy of the permanent variable. We call the
process of adding a dimension privatization, for obvious reasons.
Privatization changes the memory access pattern of the target program,
and introduces further inaccuracy in runtime measurement
(see Chapter 4.4). In practice,
this inaccuracy is not significant for a number
of applications.
Miscellaneous
Besides privatization, the only other changes that need to be
made to the target program for use by a thread are:
(a) Renaming main to an ordinary
function name, for reasons that will become evident in
Section 5.4.1.2, and
(b) Renaming all MPI calls to the corresponding
MPISIM calls. This is because MPISIM uses MPI for message delivery,
and the thread uses MPISIM. Since both MPISIM and MPI
are required to be linked into the simulation,
the corresponding functions must have different names.