next up previous
Next: 3.2 Operator type specifications Up: 3. MP Type Specifications Previous: 3. MP Type Specifications

  
3.1 Basic type specifications

Basic type specifications specify that the type of a transmitted data limb is one of the MP basic types.

The specification of basic types is done using CommonMetaType (Cmt) node packets whose value

More precisely, a basic type specification is defined by:2

<Basic TypeSpec>
::=
<IMP Integer Cmt> |
<IMP Real Cmt> |
<IMP StringBased Cmt> |
<Recursion Cmt> | Cmt:Proto::IMP_Raw
<IMP Integer Cmt>
::= Cmt:Proto::IMP_Sint32 | Cmt:Proto::IMP_Uint32 | Cmt:Proto::IMP_ApInt

<IMP Real Cmt>
::= Cmt:Proto::IMP_Real32 | Cmt:Proto::IMP_Real64 | Cmt:Proto::IMP_ApReal

<IMP StringBased Cmt>
::= Cmt:Proto::IMP_String | Cmt:Proto::IMP_Identifier | Cmt:Proto::IMP_Constant

<Recursion Cmt>
::= Cmt:Proto::RecUnion | Cmt:Proto::RecStruct

For a first simple example we encode an array of 1000 MP_Real32_t numbers. The resulting MP Tree is shown in a stylized fashion in figure 1. The actual encoding is binary and not easily human readable. A fragment of the code to produce the tree is shown in figure 2.


  
Figure 1: An array of 1000 IMP_Real32 numbers
\begin{figure}% latex2html id marker 493
\setlength{\tabcolsep}{1.0mm} \centerin...
...rmation\\
& & $\ldots$\space & & \\ \hline\end{tabular}\end{small}\end{figure}


  
Figure 2: Code fragment for putting an array of MP_Real32's
\begin{figure}% latex2html id marker 169
\begin{center}
\begin{tex2html_preform}...
...tion{Code fragment for putting an array of MP\_Real32's}\end{center}\end{figure}

Line (1) contains the common operator Array defined in the Proto dictionary. It has a single annotation and 1000 arguments. The annotation is a prototype annotation and is given on lines (2 - 3). It specifies that each element of the array is of the type IMP_Real32. Recall that the common meta type packet (Cmt) specifies the type of data that will appear in this position of the MP Tree that follows. The prototyped data tree follows, beginning on line (4). Note that there are no node packet headers to individually specify the type of each element of the prototyped data tree (this is the job of the prototype). Recall that the IMP_<type>s represent data only - there is no attached type information. An unprototyped version of figure 1 requires 8,008 bytes: 8 bytes for the Array node packet and 8,000 bytes for the array elements, 4,000 bytes of which is the actual data (1,000 32-bit floats) and the remaining 4,000 bytes are the overhead for the node packet headers. Using the prototype mechanism to specify the element type of the array reduces the total size of the array's encoding from 8,008 bytes (4,008 bytes total overhead) to 4,016 bytes (16 bytes of overhead). An important point to make about prototypes is that the size of the prototype is largely independent of the size of the data. In the example above, the overhead for the prototype stays at 16 bytes even if, for example, the size of the data doubles (4 to 8 bytes for an IMP_Real64) or the length of the array doubles.


next up previous
Next: 3.2 Operator type specifications Up: 3. MP Type Specifications Previous: 3. MP Type Specifications
| ZCA Home | Reports |