diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-09 18:34:45 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-09 18:34:45 -0500 |
commit | 9acc84176fc4aae0622ebfc7edb3200018ce6969 (patch) | |
tree | ba95888d056aa5d56bbb7060907ea7e7d422a31f | |
parent | 72cdd86d0bfb3de36bdcdaecd3d457671d8ce349 (diff) |
add memtrash, a background workload task
This is the old background workload task used for the synthetic experiments.
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | bin/memthrash.c | 26 |
2 files changed, 30 insertions, 1 deletions
@@ -15,7 +15,7 @@ vpath %.c bin/ | |||
15 | # ############################################################################## | 15 | # ############################################################################## |
16 | # Targets | 16 | # Targets |
17 | 17 | ||
18 | all = cache_cost | 18 | all = cache_cost memthrash |
19 | 19 | ||
20 | .PHONY: all clean | 20 | .PHONY: all clean |
21 | all: ${all} | 21 | all: ${all} |
@@ -25,5 +25,8 @@ clean: | |||
25 | obj-cache_cost = cache_cost.o | 25 | obj-cache_cost = cache_cost.o |
26 | cache_cost: ${obj-cache_cost} | 26 | cache_cost: ${obj-cache_cost} |
27 | 27 | ||
28 | obj-memthrash = memthrash.o | ||
29 | memthrash: ${obj-memthrash} | ||
30 | |||
28 | # dependency discovery | 31 | # dependency discovery |
29 | include ${LIBLITMUS}/inc/depend.makefile | 32 | include ${LIBLITMUS}/inc/depend.makefile |
diff --git a/bin/memthrash.c b/bin/memthrash.c new file mode 100644 index 0000000..9b2275b --- /dev/null +++ b/bin/memthrash.c | |||
@@ -0,0 +1,26 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | |||
4 | #include <time.h> | ||
5 | |||
6 | #define NUM_VARS 5000000 | ||
7 | |||
8 | long data[NUM_VARS]; | ||
9 | |||
10 | int main(int argc, char** argv) | ||
11 | { | ||
12 | int i; | ||
13 | long sum; | ||
14 | srand(time(NULL)); | ||
15 | while (1) { | ||
16 | for (i = 0; i < NUM_VARS; i++) | ||
17 | data[i] = rand(); | ||
18 | sum = 0; | ||
19 | for (i = 0; i < NUM_VARS; i++) | ||
20 | sum += (i % 2 ? 1 : -1) * data[i]; | ||
21 | for (i = NUM_VARS - 1; i >= 0; i--) | ||
22 | sum += (i % 2 ? -1 : 1) / data[i]; | ||
23 | if (argc > 1) | ||
24 | printf("sum: %ld\n", sum); | ||
25 | } | ||
26 | } | ||