Process Placement



next up previous contents index
Next: Submachines Up: Mapping Previous: Virtual Computers

Process Placement

 

The LOCATION  annotation specifies the processor on which the annotated process is to execute. It is similar in form and function to an array reference. It has the general form LOCATION(I, ...,I), where and the I have the same form as the indices in an array reference. The indices must not reference a processor array element that is outside the bounds specified by the PROCESSORS  declaration provided in the process or subroutine in which the annotation occurs.

The following code fragment shows how the program ring1.fm (§3.2.3) might be extended to specify process placement. The PROCESSORS  declaration indicates that this program is to execute in a virtual computer with 4 processors, while the LOCATION  annotation placed on the process call specifies that each ringnode process is to execute on a separate virtual processor.

==

      program ring1_with_mapping
      parameter (nodes=4)
      processors(nodes)
      ...
      processdo i = 1, nodes
         processcall ringnode(i, pi(i), po(i)) location(i)
      endprocessdo
      end
=1.03

The program tree.fm shows the a more complex use of mapping constructs. The process tree creates a set of ( a power of 2) processes connected in a binary tree. The mapping construct ensures that processes at the same depth in the tree execute on different processors, if , where is the number of processors.

==

      process tree(locn, n, toparent)
      intent (in) locn, n, toparent
      inport  (integer) li, ri
      outport (integer) lo, ro, toparent
      processors(16)
      if(n .gt. 1) then
         channel(in=li, out=lo)
         channel(in=ri, out=ro)
         processes
            processcall tree(locn,n/2,lo) 
            processcall tree(locn+n/2,n/2,ro) location(locn+n/2)
            processcall reduce(li,ri,toparent)
         endprocesses
      else
         call leaf(toparent)
      endif
      end
=1.03   

 



Steve Tuecke
Tue Aug 30 12:20:34 CDT 1994