项目作者: Michaelangel007

项目描述 :
Cache Line Memory Access Speed Row vs Col
高级语言: C++
项目地址: git://github.com/Michaelangel007/cache_line_speed.git
创建时间: 2016-12-21T15:02:55Z
项目社区:https://github.com/Michaelangel007/cache_line_speed

开源协议:GNU General Public License v3.0

下载


Cache Line Speed: Row vs Col memory access

Let’s allocate an 32-bit array of 1,073,741,824 elements for a total size of 4GB.

We’ll fill this array from 0,1,2,…n-1 and then sum it.

  1. Sum 1+2+3+...+n = n*(n+1)/2
  2. Sum of 0+1+2+...+n-1 = (n-1)*n/2

Sum array of 1,073,741,824 elements = 576,460,751,766,552,576.

i += Bytes Op/s Time
1 4 1 G/s 00:00:00s
2 8 1 G/s 00:00:00s
4 16 733 M/s 00:00:01s
8 32 388 M/s 00:00:02s
16 64 213 M/s 00:00:04s
32 128 141 M/s 00:00:07s
64 256 116 M/s 00:00:08s
128 512 115 M/s 00:00:08s
256 1,024 115 M/s 00:00:08s
512 2,048 100 M/s 00:00:10s
1024 4,096 66 M/s 00:00:15s

Notes:

  • += Stride element delta access
  • Bytes Stride delta in bytes

Tests

Running tests which does bin/col #

  1. Stride: [1] @ 4 bytes
  2. Len: 1,073,741,824
  3. int: 4
  4. Mem: 4,294,967,296
  5. Sum= 576,460,751,766,552,576 pass
  6. 1 G cells/s 1 seconds = 00:00:00
  7. Stride: [2] @ 8 bytes
  8. Len: 1,073,741,824
  9. int: 4
  10. Mem: 4,294,967,296
  11. Sum= 576,460,751,766,552,576 pass
  12. 1 G cells/s 1 seconds = 00:00:00
  13. Stride: [4] @ 16 bytes
  14. Len: 1,073,741,824
  15. int: 4
  16. Mem: 4,294,967,296
  17. Sum= 576,460,751,766,552,576 pass
  18. 733 M cells/s 1 seconds = 00:00:01
  19. Stride: [8] @ 32 bytes
  20. Len: 1,073,741,824
  21. int: 4
  22. Mem: 4,294,967,296
  23. Sum= 576,460,751,766,552,576 pass
  24. 388 M cells/s 3 seconds = 00:00:02
  25. Stride: [16] @ 64 bytes
  26. Len: 1,073,741,824
  27. int: 4
  28. Mem: 4,294,967,296
  29. Sum= 576,460,751,766,552,576 pass
  30. 213 M cells/s 5 seconds = 00:00:04
  31. Stride: [32] @ 128 bytes
  32. Len: 1,073,741,824
  33. int: 4
  34. Mem: 4,294,967,296
  35. Sum= 576,460,751,766,552,576 pass
  36. 141 M cells/s 7 seconds = 00:00:07
  37. Stride: [64] @ 256 bytes
  38. Len: 1,073,741,824
  39. int: 4
  40. Mem: 4,294,967,296
  41. Sum= 576,460,751,766,552,576 pass
  42. 116 M cells/s 9 seconds = 00:00:08
  43. Stride: [128] @ 512 bytes
  44. Len: 1,073,741,824
  45. int: 4
  46. Mem: 4,294,967,296
  47. Sum= 576,460,751,766,552,576 pass
  48. 115 M cells/s 9 seconds = 00:00:08
  49. Stride: [256] @ 1024 bytes
  50. Len: 1,073,741,824
  51. int: 4
  52. Mem: 4,294,967,296
  53. Sum= 576,460,751,766,552,576 pass
  54. 115 M cells/s 9 seconds = 00:00:08
  55. Stride: [512] @ 2048 bytes
  56. Len: 1,073,741,824
  57. int: 4
  58. Mem: 4,294,967,296
  59. Sum= 576,460,751,766,552,576 pass
  60. 100 M cells/s 10 seconds = 00:00:10
  61. Stride: [1024] @ 4096 bytes
  62. Len: 1,073,741,824
  63. int: 4
  64. Mem: 4,294,967,296
  65. Sum= 576,460,751,766,552,576 pass
  66. 66 M cells/s 16 seconds = 00:00:15