home *** CD-ROM | disk | FTP | other *** search
/ What PC? 1997 December / WPCDEC97.ISO / HTML / RES / RESOURCE / ESSENTIA / CACHCHK2.ZIP / CACHECHK.DOC next >
Encoding:
Text File  |  1995-11-01  |  6.3 KB  |  148 lines

  1.         CACHECHK 
  2.         v2 11/2/95
  3.     Copyright (c) 1995 by Ray Van Tassle.
  4.  
  5.     This is NOT freeware.  This is postcard-ware.  Send me a nice
  6.     picture post card as the registration fee.
  7.     Ray Van Tassle
  8.     1020 Fox Run Lane
  9.     Alqonuin, Il. 60102 USA
  10.     (708)658-4941
  11.  
  12.  
  13. CACHECHK performs memory access timing tests, to see if you have a 
  14. cache, how many caches, and to check the access speed.
  15.  
  16. There are two kinds of caches,  the on-chip cache (level one, or L1) 
  17. which is in the CPU processor chip, and off-chip cache (level two, or 
  18. L2) which is on the motherboard.
  19.  
  20. Some 386 motherboards have 64KB of off-chip cache.
  21. Some CYRIX 386/486 chips have a very small L1 cache.
  22. 486's have an on-chip cache, and most new motherboards also have a L2 
  23. cache.
  24. The AMD 486 has 8KB of L1 cache.
  25. The Intel 486 has 16KB of L1 cache.
  26. Intel Pentium has 16KB of L1 cache, 8KB for data and 8KB for code.
  27.  
  28. The typical 486 MB has 256KB of L2 cache, although many will let you 
  29. install 512KB or even 1MB.
  30.   
  31. Q: HOW MUCH CACHE DO I NEED?
  32. For a 486, get a 256K cache.
  33. All the writeups that I have seen say:
  34.     64KB cache gets a LOT of improvement.
  35.     128KB gets a bit more.
  36.     256KB gets a teeny bit more.
  37.     512KB gets only a teensy weensy bit more.
  38. (Note: these are for DOS and WINDOWS3.  A real OS, like LINUX, OS/2, 
  39. and perhaps WIN-95 and WIN-NT may be different.)
  40. In general, this seems to be the way all caches work---the first bit 
  41. gets a lot of bang, and each additional bit gives smaller and smaller 
  42. improvements.
  43. It is claimed that, as long as you have a decent L2 cache, that an AMD
  44. (with an 8k L1) is virtually identical in performance to an Intel 486 
  45. (with a 16K L1).
  46.  
  47. 256K uses 8-(32K x 8) SRAM chips (8 * 32K = 256KB), in two banks,
  48. and the MB can interleave accesses to the two banks.
  49. 512K uses 4-(128K x 8) SRAM chips (4 * 128K = 512KB, but this is only 
  50. one bank, so the access time is slower, because the MB can't do bank 
  51. interleaving.
  52. So, 512K costs a LOT more than 256K and gives only a marginal improvement 
  53. in performance, so stick with 256K.
  54.  
  55. Q: Why does my main memory show faster with the cache enabled, even
  56. out beyond the cache size?
  57. A: The L1 cache (on a 486) is filled in granularity of 16 bytes (this
  58. is the "cache line size").  When you read a byte, all 16 bytes of that
  59. line are read into the cache, in 4 quadbyte (32 bit) units.  The quadbyte
  60. which is addressed is read from memory first, put into the cache, and
  61. transferred to the CPU.  Then the other 3 quadbytes are read into the cache.
  62. So, if you are accessing the memory in sequential order (like CACHECHK does),
  63. the next bytes have been (or are being) automatically sucked into the cache,
  64. a "read-ahead", if you will.
  65. If the cache is disabled, this read-ahead does not take place.
  66.  
  67.  
  68. CACHECHK will run the access tests using all the memory in your 
  69. machine, so that you can check to make sure that all the memory is 
  70. cached.
  71.  
  72.  
  73. Usage: CACHECHK -tn -hfvwqz? [Optional comments]
  74. Cache memory detector & timer.  Runs only on 80386 (or better) CPU.
  75.     -h? = Print this help text.
  76.     -f  = Perform tests with cache disabled.
  77.     -n  = Don't calibrate timer.
  78.     -q  = Quick. Faster but not as accurate.
  79.     -qq = Each 'q' is 2 times quicker. But less accurate.
  80.     -tn = Top of memory to test. n = nth MB
  81.     -v  = Verbose
  82.     -w  = Do memory write (otherwise memory read).
  83.     -z  = Slower.  Like q, but the other direction.
  84.           Probably won't be needed on anything less than a 586DX4/200.
  85.  
  86. The "optional comments" just get logged, so you can identify test information
  87. along with the results.  Mostly useful if you redirect the output to
  88. a file. For example:
  89.     cachechk -q Test with bios set to 1 wait state >before.dat
  90.  
  91. The basic timing loop is 1/2 second per size.  Each 'q' cuts the time 
  92. in half.  Each 'z' doubles the time.  If the timing figures aren't 
  93. steady, you probably have too many q's.
  94.  
  95. You can run the tests with the cache disabled, with the 'f' option (on 
  96. a 486 or Pentium).  Naturally, it is re-enabled again when it's done.
  97. This generally turns off BOTH the L1 and L2 cache.  Your bios setup 
  98. may (or may not) let you individually enable/disable the caches.
  99.  
  100. Times cache & memory access, and figures out cache size(s).
  101. Results are in:
  102.    microseconds per KB, MB per seconds, and nanoseconds per byte.
  103.  
  104. Memory is access in quadbytes, in flat 32-bit protected mode. For base 
  105. memory (first MB, MB#0) only 640KB is accessed. Memory accesses are in 
  106. various block sizes, from 1KB to 2MB. Each megabyte is tested starting 
  107. at the beginning of that megabyte.  CACHECHK will work under a memory 
  108. manager (HIMEM, EMM386, QEMM, Windows, etc.), but the results may be 
  109. inaccurate, the machine might crash, and it won't be able to test all 
  110. of the memory. It will run under WINDOWS, but results are wildly 
  111. inaccurate. For best results, boot clean--on DOS 6 & above, hit F5 
  112. while it boots.
  113.  
  114. It will NOT touch extended memory that is already allocated or in use.
  115. If you have a memory manager installed, it usually occupies the first
  116. portion of the 2nd megabyte, so CACHECHK will not be able to check that.
  117.  
  118.  
  119. SOME TIMINGS I HAVE TAKEN
  120.  
  121. CPU    L1    L1speed    L2    L2Speed    Mem    Speeds
  122. type    siz    ns/byte    size    ns/byt    ns/byt    µsec/KB
  123. ------    ----    -------    ----    ------    ------    ----------
  124. 386/25    0    n/a     64k    59.2    90    62......94
  125. 486/33    8k    30.7    128k    43.6    70    31..45..73    (Intel)
  126. 486/66    8k    16.1    0    n/a    50    15......52    (Intel)
  127. 486/100    8k    11.1    0    n/a    46    10......48    (AMD)
  128. 486/100    16k    10.0    256k    18.8    26    10..19..27    (Intel)
  129. P-75    8k    10.2    256k    16.4    24    10..17..24
  130.  
  131.  
  132. Timer
  133. -----
  134. CACHECHK re-programs the timer chip to get a high-precision timer (about
  135. 1,200,000 ticks per second).  In some motherboards (notibly reported
  136. to be "UMC with fake cache chips"), there is a flaw with this timer.
  137. I worked around this in version 2, but there may be some boards where my
  138. work-around still doesn't work.
  139.  
  140. Normally, CACHECHK calibrates this timer against the Real-Time-Clock, which 
  141. is in all systems 286 and above.  If your RTC isn't standard, this may hang
  142. or give bogus values.
  143. I count the number of timer ticks in 1/16th second. When four in a row 
  144. give the same value (within .01%), I take the average of those four counts,
  145. and use this as the calibration value.
  146. If there is some problem with this calibration, use the "-n" switch, and
  147. it will use the pre-defined value of 1,193,728 (0.84 microseconds per tick).
  148.