next up previous contents
Next: Extensibility Up: Computational Model Previous: The Load Function

COP/HLL Integration Example

Let us consider the simple broadcast example first mentioned in 2.2, (broadcast 'b 0). Figure 2.3 shows a tiny but complete application; Lisp is used for the examples to simplify the presentation. The first part of the figure contains the one-line COP program for the application. The second part shows the application code for the master broadcasting node (node zero), and the third part shows the code for the slave (`worker') nodes in the mesh. Node zero is passed a list of `work' of some sort, it broadcasts it to the workers, and they perform appropriate work based on, e.g., their coordinates in the mesh. The worker-function is the function that does the work, and it is not included in the example; it could be any interesting function (such as, say, computing a portion of a Mandelbrot set).


  
Figure 2.3: Simple application code
\begin{figure}
\hspace*{.5in}{\sl COP code:}
{\small \begin{verbatim}
(broadcast...
 ...in)
 (b-load)
 (while t
 (worker-function (b-read))))\end{verbatim}}\end{figure}

In Figure 2.3, the HLL compiler is assumed to have generated a COP program with an arbitrary label (`b'), then used that label to generate the appropriate calls to the I/O and load functions (b-load, b-write, and b-read).

If a scheduled router is the target, the COP compiler will take the COP code and return functions similar to those in Figure 2.4. The load function downloads appropriate data (e.g., VFSM configuration and a schedule) to the router using the hypothetical cop-reprogram-router function, then starts the newly-loaded phase running; *new-phase* represents the schedule index of the phase whose information has just been downloaded. The b-write and b-read functions check that they are running on a legal node, then write to the processor/router interface (interface address seven is used in the example). *node* is the subset index of each node in the set.


  
Figure 2.4: COP output for simple application
\begin{figure}
\begin{center}
{\small
\begin{verbatim}
(define (b-load)
 (cop-re...
 ...d val)
 (if (!= *node* 0)
 (cop-read 7)))\end{verbatim}}\end{center}\end{figure}

The HLL compiler takes the output code returned in Figure 2.4 and integrates it with the application code that it has generated for carrying out the computation. Figure 2.5 shows the final, integrated code for the master node (node zero). The code has been specialized for node zero, so references to *node* have disappeared. The HLL compiler will convert this into object code (including the router code); the object code will then be downloaded to node zero at run time, while the matching code for each slave node (not shown) is similarly downloaded.


  
Figure 2.5: Final HLL code for node zero
\begin{figure}
\hspace*{.5in}{\sl Final application code for the master node:}
{...
 ...ase *new-phase*)
 (foreach i input
 (cop-write 7 i)))\end{verbatim}}\end{figure}


next up previous contents
Next: Extensibility Up: Computational Model Previous: The Load Function
Back to Chris Metcalf's home page