In CHARM++, chares, groups and
nodegroups communicate using remote method invocation. These ``remote entry'' methods may either take marshalled parameters, described in the next section; or special objects called messages. Messages are lower level, more efficient, more flexible, and more difficult to use than parameter marshalling.
An entry method is always a part of a chare-
there are no global entry methods in CHARM++.
Entry methods are declared in the the interface file as:
entry void Entry1(parameters);
Parameters is either a list of marshalled parameters,
(e.g., ``int i, double x''), or a message description (e.g.,
``MyMessage *msg''). See section 3.3 and
section 3.4 for details on these types of
parameters.
Entry methods typically do not return data- in C++, they have
return type ``void''. An entry method with the same name
as its enclosing class is a constructor. Constructors in C++
have no return type. Finally, sync methods, described below,
may return a message.
CHARM++ provides a handful of special attributes that entry methods may have. In order to give a particular entry method an attribute, you must specify the keyword for the desired
attribute in the attribute list of that entry method's .ci file
declaration. The syntax for this is as follows:
CHARM++ currently offers the following attributes that one may assign to
an entry method:
threaded, sync, exclusive, nokeep, notrace, immediate, expedited, inline, local, python.
threaded
entry methods are simply entry
methods which are run in their own nonpremptible threads. To make an
entry method threaded, one simply adds the keyword
threaded to the attribute list of that entry method.
sync
entry methods are special in that calls to
sync entry methods are blocking - they do not return control to the caller
until the method is finished executing completely. Sync methods may have
return values; however, they may only return messages. To make an entry method a sync entry method, add the keyword sync to the
attribute list of that entry method.
exclusive
entry methods, which exist only on node groups, are
entry methods that do not execute while other exclusive
entry methods of its node group are executing in the same
node. If one exclusive method of a node group is executing on node 0, and
another one is scheduled to run on that same node, the second exclusive method
will wait for the first to finish before it executes. To make an entry method exclusive, add the keyword exclusive to that
entry method's attribute list.
nokeep
entry methods tells Charm++ that messages passed to
these user entry methods will not be kept by the calls. Charm++ runtime
may be able to adopt optimization for reusing the message memory.
notrace
entry methods simply tells Charm++ that calls to
these entry methods should be not traced in trace projections or summary mode.
immediate
entry methods are entry functions in which
short messages can be executed in an ``immediate'' fashion when they are
received either by an interrupt (Network version) or by a communication thread
(in SMP version). Such messages can be useful for implementing
multicasts/reductions as well as data lookup, in which case processing of
critical messages won't be delayed (in the scheduler queue) by entry functions
that could take long time to finish. Immediate messages are only available for
nodegroup entry methods. Immediate messages are implicitly ``exclusive'' on each
node, that is one execution of immediate message will not be interrupted by
another. Function CmiProbeImmediateMsg() can be called in users code to
probe and process immediate messages periodically.
expedited
entry methods are entry functions
that skip Charm++'s priority-based message queue. It is useful for messages that
require prompt processing however in the situation when immediate message does
not apply. Compared with immediate message, it provides a more general solution
that works for all Charm++ objects, i.e. Chare, Group, NodeGroup and Chare
Array. However, skipscheduler message still needs to be scheduled in low level
Converse message queue and be processed in the order of arrival. It may still
suffer from long running entry methods.
inline
entry methods are entry functions in which the
message is delivered immediately to the recipient if it happens to reside on the
same processor. Therefore, these entry methods need to be reentrant, as they
could be called multiple times recursively. If the recipient reside on another
processor, a regular message is sent, and inline has no effect.
local
entry methods are equivalent to function calls: the
entry method is always called immediately. This feature is available only for
Groups and Chare Arrays. The user has to guarantee that the recipient chare
element reside on the same processor, a failure will result in the application
to abort. In contrast will all other entry methods where input parameters are
marshalled into a message, local entry methods pass them direcly to the
callee. This implies that the callee can modify the caller data if this is
passed by pointer or reference. Furthermore, the input parameters do not require
to be PUPable. Being these entry methods always called immediately, they are
allowed to have a non-void return type. Nevertheless, the returned type must be
a pointer.
python
entry methods are methods which are enabled to be
called from python scripts running as explained in section 3.22. In
order to work, the object owning the method must also be declared with the
keywork python.