Update year in README and charmc to 2018
[charm.git] / doc / charm++ / startuporder.tex
blob7d79adbce443a246e185ee06a71099d8b018e3bd
1 \section{\kw{initnode} and \kw{initproc} Routines}
2 \input{othercalls}
4 \section{Event Sequence During \charmpp{} Startup}
6 %describe the order in which entities are constructed on PE 0 and other PEs
7 %what assumptions can user program make about entity availability:
8 %ie groups are available in any chare array constructor, but not vice versa etc.
10 %A \charmpp{} program starts with the following sequence:
11 At startup, every \charmpp{} program performs the following actions, in sequence:
12 \begin{enumerate}
13 \item Module Registration: all modules given in the \kw{.ci} files are registered in the order
14 of their specification in the linking stage of program compilation.
15 For example, if you specified ``{\tt -module A -module B}'' while linking your \charmpp{} program,
16 then module {\tt A} is registered before module {\tt B} at runtime.
18 \item \kw{initnode}, \kw{initproc} Calls: all initnode and initproc functions are invoked before the
19 creation of \charmpp{} data structures, and before the invocation of any
20 mainchares' \kw{main()} methods.
22 \item \kw{readonly} Variables: \kw{readonly} variables are initialized on PE 0 in the \kw{mainchare},
23 following program order as given in the {\tt main()} method. After initialization, they
24 are broadcast to all other PEs making them available in the constructors
25 groups, chares, chare arrays, etc. (see below.)
27 \item \kw{Group} and \kw{NodeGroup} Creation: on PE 0, constructors of these
28 objects are invoked in program order. However, on all other PEs, their
29 creation is triggered by messages. Since message order is not guaranteed
30 in \charmpp{} program, constructors of groups and nodegroups should \textbf{not} depend
31 on other Group or NodeGroup objects on a PE. However, if your program structure requires
32 it, you can explicitly specify that the creation of certain Groups/NodeGroups depends
33 on the creation of others, as described in \S~\ref{sec:groups/creation}.
34 In addition, since those objects are initialized
35 after the initialization of readonly variables, readonly variables can be used
36 in the constructors of Groups and NodeGroups.
38 \item \charmpp{} Array Creation: the order in which array constructors are called on PEs is
39 similar to that described for groups and nodegroups, above.
40 %the same mechanism with that of Group and NodeGroup as described above.
41 Therefore, the creation of one array should \textbf{not} depend on other arrays.
42 As Array objects are initialized last, their constructors can use
43 readonly variables and local branches of Group or NodeGroup objects.
44 \end{enumerate}