Newsgroups: comp.sys.transputer
From: rolf@kih.no (Rolf Moholth)
Subject: occam2 : many-to-many communication
Keywords: occam2, process communications
Organization: kih
Date: Wed, 4 May 1994 14:04:45
Message-ID: <rolf.1.000E14AE@kih.no>

I'm a lecturer at Kongsberg College of engineering, and we've just started 
teaching our students about parallel programming.  We've also bought in some 
4xT800 transputer boards and the INMOS occam2 toolset.

I'm a very inexperienced novice in the occam2 language, so I often run into 
problems when I try to do something useful on the transputer. Here's my latest 
problem :

I'm trying to illustrate the concept of a "distributed" version of the 
"Replicated Workers" mechanism in occam2 - based on the algorithms described 
in Bruce Lester's ; "The Art of Parallel Programming" Ch.11. The problem to be 
solved by the system is that of finding the shortest path from a node X in a 
graph to all others.  To do this,  every node in the graph is assigned to one 
process each ... (a full explanation take too much space)...

The bottom line is : For a graph consisting of N nodes, I need N occam2 
processes. Every process needs to send AND receive work items from the N-1 
other processes. This means that I need a total N x N channels declared in my 
main process. Question : HOW DO I DISTRIBUTE THE RIGHT SET OF INPUT & OUTPUT 
CHANNELS TO THE VARIOUS WORKERS?

The principle of what I need is shown below :

(1) The Worker process looks like this :

PROC Worker( VAL INT MyNodeId, [no.of.nodes]CHAN OF WORKITEM Out, 
                             [no.of.nodes]CHAN OF WORKITEM In,
                             INT ShortesDistanceToMe )
  --  Parameters in :
  --
  --      Out         Channels to all other worker processes 
  --       In            Channels FROM all other worker processes
  --  
SEQ     ..

(2) The main process where the workers are activated

  --
  --  Description of array of channels :
  --
  --      Channel[A][B]     Is defined as the channel going FROM
  --                                         process A TO process B
  --      In general :
  --
  --                Row A        All outgoing channels from A
  --                Col    A        All incoming channels to A
  [no.of.processes][no.of.processes]CHAN OF WORKITEM Channel:
  --  Results array 
  [no.of.nodes]INT Result:
                    .....
  SEQ
    PAR WorkerId = 0 FOR no.of.workers
      Worker( WorkerId, <row A of array Channel>, 
                        <col A of array Channel>,  Result[WorkerId] )  
             ...

My problem is how do the partitioning I need of the channel array - the 
principle of what I need is shown in the Worker activation shown above.

How do I do this?

(I was supposed to show my students the occam2 implementation of this 
algorithm today, but instead I had to explain why it wasn't so easy after all!)


Rolf Moholth
Kongsberg College of Engineering
Computer Science Department
P.O.Box 235
N-3601 Kongsberg
NORWAY

