home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / transput / 1370 < prev    next >
Encoding:
Text File  |  1993-01-08  |  3.2 KB  |  101 lines

  1. Newsgroups: comp.sys.transputer
  2. Path: sparky!uunet!inmos!titan.inmos.co.uk!news
  3. From: conor@lion.inmos.co.uk (Conor O'Neill)
  4. Subject: Re: On-chip Ram: Helios, D7205
  5. Message-ID: <1993Jan8.175706.15966@titan.inmos.co.uk>
  6. Sender: news@titan.inmos.co.uk
  7. Organization: INMOS Limited, Bristol, UK
  8. References: <1993Jan07.200247.37029@dcc.uchile.cl>
  9. Date: Fri, 8 Jan 1993 17:57:06 GMT
  10. Lines: 89
  11.  
  12. In article <1993Jan07.200247.37029@dcc.uchile.cl> maurro@inf.utfsm.cl (Mauricio Gomez Calderon) writes:
  13. >   But what about the best times? 6 sec in Helios and 10 sec in D7205 for the
  14. >   almost 'same' application... Furthermore, the occam process is the only
  15. >   process in the transputer...
  16. >
  17. >   Why this difference?         Thanks in Advance...
  18.  
  19. I can perhaps offer one suggestion; you are not comparing similar programs.
  20.  
  21. I know it sounds trivial, but in C you are using:
  22.  
  23. >   void cycle(int iterations) {
  24. >
  25. >        int i;
  26. >       for(i=0; i<iterations; i++) {
  27. >           /* nothing! */
  28. >           }
  29. >
  30. >   }
  31.  
  32. whereas in occam you have:
  33.       
  34. >   VAL INT iterations IS 10000000:
  35. >   SEQ
  36. >     clock ? time1
  37. >     i := 0
  38. >     WHILE ( i < iterations )
  39. >       SEQ
  40. >         -- nothing!
  41. >        i := i + 1
  42. >     clock ? time2
  43.        
  44. The C version holds `iterations' as a variable, whereas the occam program
  45. has a constant. Large constants are (relatively) expensive on a transputer;
  46. it is faster to load a local variable than to generate the
  47. constant '10000000'.
  48.        
  49. Try changing the occam to something equivalent to the C:
  50.  
  51.   PROC cycle(VAL INT iterations)
  52.     INT i :
  53.     SEQ
  54.       i := 0
  55.       WHILE i < iterations
  56.         i := i + 1
  57.   :
  58.   
  59. You will find that this is the entire reason for the change.
  60.  
  61. The D4205A compiler produces this for the version with the constant
  62. value for `iterations':
  63.  
  64.        0: 20 20 20                pfix    0
  65.        3: 60 BF                   ajw     -1
  66.        5: 40                      ldc     0
  67.        6: D0                      stl     0
  68.        7: 29 28 29 26 28 40       ldc     10000000
  69.       13: 70                      ldl     0
  70.       14: F9                      gt
  71.       15: A5                      cj      5
  72.       16: 70                      ldl     0
  73.       17: 81                      adc     1
  74.       18: D0                      stl     0
  75.       19: 60 02                   j       -14
  76.       21: B1                      ajw     1
  77.       22: 22 F0                   ret
  78.  
  79. and this for the version where it is a formal parameter:
  80.  
  81.        0: 60 BF                   ajw     -1
  82.        2: 40                      ldc     0
  83.        3: D0                      stl     0
  84.        4: 72                      ldl     2
  85.        5: 70                      ldl     0
  86.        6: F9                      gt
  87.        7: A5                      cj      5
  88.        8: 70                      ldl     0
  89.        9: 81                      adc     1
  90.       10: D0                      stl     0
  91.       11: 60 07                   j       -9
  92.       13: B1                      ajw     1
  93.       14: 22 F0                   ret
  94.  
  95. The same problem would occur in C if you used the constant in the for loop.
  96.  
  97. ---
  98. Conor O'Neill, Software Group, INMOS Ltd., UK.
  99. UK: conor@inmos.co.uk        US: conor@inmos.com
  100. "It's state-of-the-art" "But it doesn't work!" "That is the state-of-the-art".
  101.