Guest User

Untitled

a guest
Feb 4th, 2018
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ diff -u mhz.c ../mhz.new/mhz.c
  2. --- mhz.c   2018-02-04 12:30:45.000000000 +0200
  3. +++ ../mhz.new/mhz.c    2018-02-04 21:56:41.147617493 +0200
  4. @@ -29,14 +29,14 @@
  5.   * to parallelize. The "asm" statements are here to prevent the compiler from
  6.   * reordering this code.
  7.   */
  8. -#define dont_move(var) do { asm volatile("" : "=r"(var) : "0" (var)); } while (0)
  9. +#define produce(var) do { asm volatile("" : "=r"(var) : ); } while (0)
  10. +#define consume(var) do { asm volatile("" : : "r"(var)); } while (0)
  11.  
  12. -#define run1cycle_ae()   do { a ^= e; dont_move(a); } while (0)
  13. -#define run1cycle_ba()   do { b ^= a; dont_move(b); } while (0)
  14. -#define run1cycle_cb()   do { c ^= b; dont_move(c); } while (0)
  15. -#define run1cycle_dc()   do { d ^= c; dont_move(d); } while (0)
  16. -#define run1cycle_ed()   do { e ^= d; dont_move(e); } while (0)
  17. -#define run1cycle_eb()   do { e ^= b; dont_move(e); } while (0)
  18. +#define run1cycle_ae()   do { a ^= e; } while (0)
  19. +#define run1cycle_ba()   do { b ^= a; } while (0)
  20. +#define run1cycle_cb()   do { c ^= b; } while (0)
  21. +#define run1cycle_dc()   do { d ^= c; } while (0)
  22. +#define run1cycle_ed()   do { e ^= d; } while (0)
  23.  
  24.  #define run5cycles()                                    \
  25.     do {                                            \
  26. @@ -74,7 +74,13 @@
  27.   */
  28.  static __attribute__((noinline)) void loop50(unsigned int n)
  29.  {
  30. -   unsigned int a = 0, b = 0, c = 0, d = 0, e = 0;
  31. +   unsigned int a, b, c, d, e;
  32. +
  33. +   produce(a);
  34. +   produce(b);
  35. +   produce(c);
  36. +   produce(d);
  37. +   produce(e);
  38.  
  39.     do {
  40.         run10cycles();
  41. @@ -83,6 +89,12 @@
  42.         run10cycles();
  43.         run10cycles();
  44.     } while (__builtin_expect(--n, 1));
  45. +
  46. +   consume(a);
  47. +   consume(b);
  48. +   consume(c);
  49. +   consume(d);
  50. +   consume(e);
  51.  }
  52.  
  53.  /* performs 250 operations in a loop, all dependant on each other, so that the
  54. @@ -92,7 +104,13 @@
  55.   */
  56.  static __attribute__((noinline)) void loop250(unsigned int n)
  57.  {
  58. -   unsigned int a = 0, b = 0, c = 0, d = 0, e = 0;
  59. +   unsigned int a, b, c, d, e;
  60. +
  61. +   produce(a);
  62. +   produce(b);
  63. +   produce(c);
  64. +   produce(d);
  65. +   produce(e);
  66.  
  67.     do {
  68.         run10cycles();
  69. @@ -103,6 +121,12 @@
  70.         run100cycles();
  71.         run100cycles();
  72.     } while (__builtin_expect(--n, 1));
  73. +
  74. +   consume(a);
  75. +   consume(b);
  76. +   consume(c);
  77. +   consume(d);
  78. +   consume(e);
  79.  }
  80.  
  81.  void run_once(long count)
RAW Paste Data