Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ diff -u mhz.c ../mhz.new/mhz.c
- --- mhz.c 2018-02-04 12:30:45.000000000 +0200
- +++ ../mhz.new/mhz.c 2018-02-04 21:56:41.147617493 +0200
- @@ -29,14 +29,14 @@
- * to parallelize. The "asm" statements are here to prevent the compiler from
- * reordering this code.
- */
- -#define dont_move(var) do { asm volatile("" : "=r"(var) : "0" (var)); } while (0)
- +#define produce(var) do { asm volatile("" : "=r"(var) : ); } while (0)
- +#define consume(var) do { asm volatile("" : : "r"(var)); } while (0)
- -#define run1cycle_ae() do { a ^= e; dont_move(a); } while (0)
- -#define run1cycle_ba() do { b ^= a; dont_move(b); } while (0)
- -#define run1cycle_cb() do { c ^= b; dont_move(c); } while (0)
- -#define run1cycle_dc() do { d ^= c; dont_move(d); } while (0)
- -#define run1cycle_ed() do { e ^= d; dont_move(e); } while (0)
- -#define run1cycle_eb() do { e ^= b; dont_move(e); } while (0)
- +#define run1cycle_ae() do { a ^= e; } while (0)
- +#define run1cycle_ba() do { b ^= a; } while (0)
- +#define run1cycle_cb() do { c ^= b; } while (0)
- +#define run1cycle_dc() do { d ^= c; } while (0)
- +#define run1cycle_ed() do { e ^= d; } while (0)
- #define run5cycles() \
- do { \
- @@ -74,7 +74,13 @@
- */
- static __attribute__((noinline)) void loop50(unsigned int n)
- {
- - unsigned int a = 0, b = 0, c = 0, d = 0, e = 0;
- + unsigned int a, b, c, d, e;
- +
- + produce(a);
- + produce(b);
- + produce(c);
- + produce(d);
- + produce(e);
- do {
- run10cycles();
- @@ -83,6 +89,12 @@
- run10cycles();
- run10cycles();
- } while (__builtin_expect(--n, 1));
- +
- + consume(a);
- + consume(b);
- + consume(c);
- + consume(d);
- + consume(e);
- }
- /* performs 250 operations in a loop, all dependant on each other, so that the
- @@ -92,7 +104,13 @@
- */
- static __attribute__((noinline)) void loop250(unsigned int n)
- {
- - unsigned int a = 0, b = 0, c = 0, d = 0, e = 0;
- + unsigned int a, b, c, d, e;
- +
- + produce(a);
- + produce(b);
- + produce(c);
- + produce(d);
- + produce(e);
- do {
- run10cycles();
- @@ -103,6 +121,12 @@
- run100cycles();
- run100cycles();
- } while (__builtin_expect(--n, 1));
- +
- + consume(a);
- + consume(b);
- + consume(c);
- + consume(d);
- + consume(e);
- }
- void run_once(long count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement