home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / programm / 3386 < prev    next >
Encoding:
Internet Message Format  |  1993-01-01  |  2.8 KB

  1. Path: sparky!uunet!spool.mu.edu!yale.edu!ira.uka.de!sbusol.rz.uni-sb.de!coli.uni-sb.de!coli-gate.coli.uni-sb.de!spackman
  2. From: spackman@disco-sol.dfki.uni-sb.de (Stephen Spackman)
  3. Newsgroups: comp.programming
  4. Subject: Re: Fast array rotation
  5. Date: 1 Jan 1993 19:02:33 GMT
  6. Organization: DFKI Saarbruecken GmbH, D-W 6600 Saarbruecken
  7. Lines: 37
  8. Message-ID: <SPACKMAN.93Jan1200705@disco-sol.dfki.uni-sb.de>
  9. References: <u895027.724990251@tasman> <1992Dec22.154338.15357@news.eng.convex.com>
  10. Reply-To: stephen@acm.org
  11. NNTP-Posting-Host: disco-sol.dfki.uni-sb.de
  12. In-reply-to: Dave Dodson's message of Tue, 22 Dec 1992 15:43:38 GMT
  13.  
  14. In article <1992Dec22.154338.15357@news.eng.convex.com> Dave Dodson <dodson@convex.COM> writes:
  15. |In article <u895027.724990251@tasman> u895027@tasman.cc.utas.edu.au (Mark Mackey) writes:
  16. |>
  17. |>    I am currently writing a terrain display routine which utilises
  18. |>a fast surface display algorithm based on scan-line processing. As
  19. |>part of the algorith I need to rotate the raw data array. I have an
  20. |>algorithm to do this using two 1d transforms, but in between these
  21. |>transforms the data array needs to be transposed.
  22. |>    Does anyone out there have any code for fast array transposition
  23. |>on disk, minimising disk access time? Alternatively, if anyone out there
  24. |>has ideas on how to rotate a large array (512*512 reals) efficiently
  25. |>I would be most grateful.
  26. |
  27. |I assume you have the array stored on disk in row- or column-major order.
  28. |There is a way to transpose the array by reading and writing the matrix
  29. |twice.  For simplicity, assume you have row-major order, 4 byte reals,
  30. |and a scratch array of length 64K bytes.  Read 65536/4/512 = 16 rows into
  31. |the scratch array.  Write 16 x 16 square blocks onto a scratch file.  There
  32. |will be 512/16 = 32 of them for every 16 rows.  Repeat for all rows of the
  33. |matrix.  Now randomly read blocks 1, 33, 65, ... .  Transpose each 16 x 16
  34. |block in memory, and write out the first 16 rows of the transposed matrix.
  35. |Repeat with blocks 2, 34, 66, ... , 3, 35, 67, ... .
  36.  
  37. Or, under certain circumstances, you might consider doing nothing at
  38. all. After all, it's only the indexing calculation that distinguishes
  39. layouts; could you parameterise on it and be done? (That might entail
  40. either multiple versions of the various operations or runtime code
  41. generation, to get really good performance; in the latter case, be sure
  42. you know how to explain things to any caches that might be kicking
  43. around :-). In a sense this is no more than a generalisation of dodson's
  44. suggestion, of course....
  45.  
  46. But hey, if by a "real" you mean a float, you've only got a meg or two
  47. of data there. Where do disks come into it? :-).
  48. ------------------------------------------------------------------------
  49. stephen p spackman                                       stephen@acm.org
  50. ------------------------------------------------------------------------
  51.