next up previous contents
Next: 7 Algorithms Up: Reduction Operations Previous: 5 Data Types

6 Communication-routine Generation Procedure

The programmer writes a template for a general type of communication algorithm. The template generally embodies a number of cases of the algorithm. A template is transformed into source code by

1.
substitution of patterns
2.
conditional compilation.
E.g., pattern substition is used for substituting a type for variables and substituting a user-defined function name. Conditional compliation can be used to distinguish between vectors and scalars, or to alter the actual parameter list to the routine (code lengths of one line or more).

It is up to the programmer to determine how to write the template and table. However, we automate some of the processing of the template. The processing is three step

1.
Planguage parser indentifies communication case, selects a template, and builds data structures for it.

2.
A call is made from the compiler to the communication generating routine for the choosen template, passing the appropriate arguments.

3.
The communication generating routine (currently Perl script) performs the substitution, runs the preprocessor with defines, and compiles the algorithm into Fortran or C.

Input to parser:

Table of defines to be made for communication types. Rows indicate a communication type, and each column a variable. For example,

                            PF_INOUT   PF_SWITCH    PF_SUM   PF_FUNC   PF_MYOP
       call myOp{in,out}       Yes         Yes         No       No        Yes
       in= myOp{in}            No          No          No       No        Yes
The job of the parser is to
1.
determine the template
2.
determine the communication case for the template
3.
read the table and marshal arguments for the generation routine.

Input to generation script from parser:

 itemplate:  template to use
     icase:  communication case in template
         n:  number integers where bits corresponding to defines
 i1,...,in:  where bits correspond as follows
              i1.b0 :  define 1
              i1.b1 :  define 2
              i1.b2 :  define 3
               ...
              i1.b16:  define 16 
              i2.b0 :  define 17
              i3.b1 :  define 18
               etc.


next up previous contents
Next: 7 Algorithms Up: Reduction Operations Previous: 5 Data Types

Terry Clark
8/2/1998