Newsgroups: comp.sys.transputer
From: Mark Booth <markb@oxim.demon.co.uk>
Subject: Re: Parallel input/output error message with kroc and spoc ?
Organization: Oxford Intelligent Machines Ltd
Date: Mon, 4 Aug 1997 13:33:32 +0100
Mime-Version: 1.0
Message-ID: <RLa1WPAcwc5z0Aua@oxim.demon.co.uk>

In article <asf6wDAJ1h4zEwFT@dalecass.demon.co.uk>, Dale Cass
<dale@dalecass.demon.co.uk> writes
>I haven't tried it because I am writing from home where I don't have an
>Occam compiler, but I think that you need to abbreviate channel c so
>that the compiler can be sure that you are not writing to elements in
>parallel.

Yup, it needs abbeviation, but the code isnt quite correct:

>  [10]CHAN OF INT c:  -- try some more channels
>  []CHAN OF INT b IS [c FROM 0 FOR ((SIZE c) - 1)]: -- abbreviate to use
>                                                    -- all but element 0
>  INT x, y:
>  INT i:
>  SEQ
>    i:=1
>    PAR
>      c[0] ? x
>      b[i] ? y   -- use the abbreviated channels
>      c[0] ! 10
>      b[i] ! 20
>:

Firstly the abbreviation is malformed, it abbreviates [c FROM 0 FOR 9]
rather than [c FROM 1 FOR 9]. Secondly now that i is indexing from 1 in
c rather than from 0, the channel references have to be adjusted:

  [10]CHAN OF INT c:  -- try some more channels
  []CHAN OF INT b IS [c FROM 1 FOR ((SIZE c) - 1)]: -- abbreviate to use
                                                    -- all but element 0
  INT x, y:
  INT i:
  SEQ
    i:=1
    PAR
      c[0]   ? x
      b[i-1] ? y   -- use the abbreviated channels
      c[0]   ! 10
      b[i-1] ! 20
:

I've tried this with d7405a (the latest Occam 2.1 toolset from SGS), and
it compiles withouty error, I expect that kroc/spoc should be the same.

Note that if you do this you have to be pretty careful about i, as it is
a variable, you are moving checking from compile time to run time. If
you are running on transputers which you cant post mortem debug (just
plucked out of the air for example st20450's *8') you might find it
really difficult to track down the rogue array dereferences.


Hope this helps,


Mark.........
-- 
Mark Booth

