In CHARM++, chares, groups and nodegroups communicate by invoking each others methods. The methods may either take several parameters, described here; or take a special message object as described in the next section. Since parameters get marshalled into a message before being sent across the network, in this manual we use ``message'' to mean either a literal message object or a set of marshalled parameters.
For example, a chare could have this entry method declaration in the interface (.ci) file:
Since CHARM++ runs on distributed memory machines, we cannot pass an array via a pointer in the usual C++ way. Instead, we must specify the length of the array in the interface file, as:
This also means the data must be copied on the sending side, and to be kept must be copied again at the receive side. Especially for large arrays, this is less efficient than messages, as described in the next section.
Array parameters and other parameters can be combined in arbitrary ways, as:
The marshalling system uses the pup framework to copy data, meaning every user class that is marshalled needs either a pup routine, a ``PUPbytes'' declaration, or a working operator|. See the PUP description in Section 3.16 for more details on these routines.
Any user-defined types in the argument list must be declared before including the ``.decl.h'' file. As usual in C++, it is often dramatically more efficient to pass a large structure by reference (as shown) than by value.
For efficiency, arrays (like refChars above) are always copied as blocks of bytes and passed via pointers. This means classes that need their pup routines to be called, such as those with dynamically allocated data or virtual methods cannot be passed as arrays-use CkVec or STL vectors to pass lists of complicated user-defined classes. For historical reasons, pointer-accessible structures cannot appear alone in the parameter list (because they are confused with messages).
The order of marshalling operations on the send side is:
|a'' on each marshalled parameter with a sizing PUP::er.
|a'' on each marshalled parameter with a packing PUP::er.
The order of marshalling operations on the receive side is:
|a'' on each marshalled parameter using an unpacking PUP::er.
Finally, very large structures are most efficiently passed via messages, because messages are an efficient, low-level construct that minimizes copying and overhead; but very complicated structures are easiest to pass via marshalling, because marshalling uses the high-level pup framework.
November 23, 2009
Charm Homepage