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

  1. Newsgroups: comp.sys.transputer
  2. Path: sparky!uunet!news.univie.ac.at!chx400!news.unige.ch!hei.unige.ch!droux
  3. From: droux@hei.unige.ch
  4. Subject: Simulating procedure call
  5. Message-ID: <1993Jan7.182711.1@hei.unige.ch>
  6. Lines: 47
  7. Sender: usenet@news.unige.ch
  8. Organization: University of Geneva, Switzerland
  9. Date: Thu, 7 Jan 1993 16:27:11 GMT
  10.  
  11.  
  12. I am currently writing an occam program that uses a mathematical 
  13. library. The functions provided by this library typically gets 
  14. two-dimensional open arrays and vectors of real number, as well 
  15. as atomic types and channels. 
  16.  
  17. The calculations that are involved can get very large matrices 
  18. using megabytes of memory. As the size of these matrices is not 
  19. known at compile time, I have opted for a "dynamical" allocation 
  20. method where a memory pool is shared among various data. With 
  21. this method, a vector can be allocated as follows:
  22.  
  23.   allocate.memory(memory.pool, size, vector.ptr) -- alloc size words
  24.   [] REAL64 vector RETYPES [memory.pool FROM vector.ptr FOR size * 2] :
  25.   
  26. A problem is that the same method does not work with more than one 
  27. dimensions, as only one dimension can be omitted, for example:
  28.  
  29.   [][] REAL64 matrix RETYPES [memory....         -- allowed
  30.   [100][] REAL64 matrix RETYPES [memory...       -- not allowed
  31.   
  32. To bypass this problem, a solution is to define a "flat" matrix, 
  33. stored as a one dimensional vector. The index of the elements in 
  34. this vector are then calculated using the known dimensions of the 
  35. matrix. For example:
  36.   
  37.   [] REAL64 flat.matrix RETYPES [memory.pool FROM matrix.ptr FOR
  38.                                  size * size * 2] :
  39.                  
  40. This matrix should be then given as parameter to the calculation 
  41. routine. Unfortunately, due to the strong type checking of occam, 
  42. this is not possible simply by calling the function with flat.matrix 
  43. as argument. As I have seen in the Inmos manuals, a two dimensional 
  44. array is passed to a procedure as three values: a pointer to the 
  45. array, the first dimension and the second dimension of the array. 
  46.  
  47. My idea would be to simulate a call to the procedure by passing 
  48. these three information. A possibilty to do this should be the use 
  49. of the ASM construct to build the workspace containing the correct 
  50. parameters and calling the function. Unfortunately, I have no 
  51. experience writing Transputer assembler and I don't know how the 
  52. arguments are passed to a procedure. Does anybody can tell me if 
  53. this solution is realistic, and how I can simulate a such call ?
  54.  
  55. Nicolas Droux, droux@cs.isbiel.ch
  56. Engineering College of Biel, Switzerland
  57. Computer Science Dpt.
  58.