home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / acorn / tech / 1466 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  3.7 KB

  1. Path: sparky!uunet!crdgw1!rpi!usc!howland.reston.ans.net!spool.mu.edu!yale.edu!newsserver.jvnc.net!gmd.de!Germany.EU.net!mcsun!dxcern!dscomsa!vxdesy.desy.de!burke
  2. From: burke@vxdesy.desy.de (Stephen Burke)
  3. Newsgroups: comp.sys.acorn.tech
  4. Subject: ARM code optimisation
  5. Message-ID: <1993Jan27.194033.1@vxdesy.desy.de>
  6. Date: 27 Jan 93 19:40:33 GMT
  7. Sender: usenet@dscomsa.desy.de (usenet)
  8. Organization: (DESY, Hamburg, Germany)
  9. Lines: 53
  10.  
  11.  
  12. I've been reading the ARM data manual and trying to work out what optimisations
  13. can be made. I've come up with the following; if anyone knows better they'll no
  14. doubt say so :-)
  15.  
  16. 1) The MEMC can access memory in either an s-cyle (sequential) or an n-cycle
  17. (non-sequential). The first takes one clock cycle (to RAM at least), and the
  18. second takes two clock cycles. You can only have an s-cycle if it's an access
  19. to an address immediately following the one previously accessed (this isn't
  20. strictly correct, but it's the way it works out). DMA requests (video update
  21. etc.) are held up during s-cycles, so the MEMC forces any access on a quadword
  22. boundary (i.e. byte address divisible by 16, last hex digit zero) to be an
  23. n-cycle regardless. The basic optimisation is therefore to arrange to have
  24. accesses which couldn't be sequential anyway occur on a quadword boundary.
  25.  
  26. 2) For an ARM 2, as far as I can see this basically means that the target
  27. of a branch, the instruction following a store (but not a load), and the
  28. first address accessed by an STM or LDM should always be on a quadword
  29. boundary. You also get maximum speed/word if code segments are a multiple of
  30. 4 words long, and all LDM/STM instructions transfer a multiple of four
  31. registers. All instructions start with an opcode prefetch, so I think you
  32. get no gain from having loads or stores consecutively.
  33.  
  34. 3) An ARM3 with cache off behaves like an ARM2. This is also true for stores,
  35. as all writes go "through" the cache (they're also written into the cache if
  36. appropriate). If a read or an opcode fetch finds it's target in the cache then
  37. it's read in one (25 MHz or whatever) cycle, regardless of whether it's an n or
  38. s access, or what the address is. If it isn't in the cache, it reads one cache
  39. line, which is four words starting on a quadword boundary. The cpu is halted
  40. until the word it wants has been read. Thus you gain twice by starting code
  41. segments on quadword boundaries; you don't waste time reading words you don't
  42. want, and the cpu starts again as soon as the first word is read. You also get
  43. better cache usage efficiency if code and data chunks are a multiple of four
  44. words long.
  45.  
  46.   The final effect is fairly small. The cache is organised as four blocks of 64
  47. 4-word lines. Thus if you read 16 sequential words they're guaranteed to go
  48. into different locations in the cache. When you read the next word it goes
  49. randomly into one of the 64 lines in that block, so you have a 1/64 chance that
  50. it removes the first 4 words you read. This is a low probability, and after a
  51. few iterations you can usually assume that the whole loop is in the cache
  52. (unless it's nearly as big as the cache). However, it does presumably mean that
  53. there's a small advantage to having chunks be a multiple of 16 words.
  54.  
  55.   As far as I can see, this covers all the possible optimisation issues above
  56. the basic times for the instructions. Does anyone have anything more?
  57.  
  58. e----><----p | Stephen Burke           | Internet: burke@vxdesy.desy.de
  59.  H   H   1   | Gruppe FH1T (Liverpool) | DECnet:   vxdesy::burke (13313::burke)
  60.  H   H  11   | DESY, Notkestrasse 85   | BITNET:   BURKE@DESYVAX or SB2@UKACRL
  61.  HHHHH   1   | 2000 Hamburg 52         | JANET:    sb2@uk.ac.rl.ib
  62.  H   H   1   | Germany                 | Phone:    + 49 40 8998 2282
  63.  H   H 11111 | HERA, the world's largest electron microscope!
  64.