summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2010-11-09 16:36:35 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2010-11-09 16:36:35 -0500
commita22adccaad686956bc8bca764082ba21ffe91f8d (patch)
treeeaac3f1f5fd404631926956f6c053923c4a0ba20
parent4ca9c950dae7d81f96cf84b31f8242ec2718d9ed (diff)
allow cross-compilation for ARM targets
This uses the pre-defined make rules from liblitmus.
-rw-r--r--Makefile29
-rw-r--r--bin/cache_cost.c16
2 files changed, 42 insertions, 3 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..eb09b1b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,29 @@
1# ##############################################################################
2# User variables
3
4# user variables can be specified in the environment or in a .config file
5-include .config
6
7LIBLITMUS ?= ../liblitmus2010
8
9# Include default configuration from liblitmus
10include ${LIBLITMUS}/inc/config.makefile
11
12# all sources
13vpath %.c bin/
14
15# ##############################################################################
16# Targets
17
18all = cache_cost
19
20.PHONY: all clean
21all: ${all}
22clean:
23 rm -f ${all} *.o *.d
24
25obj-cache_cost = cache_cost.o
26cache_cost: ${obj-cache_cost}
27
28# dependency discovery
29include ${LIBLITMUS}/inc/depend.makefile
diff --git a/bin/cache_cost.c b/bin/cache_cost.c
index c41fa01..2b804a8 100644
--- a/bin/cache_cost.c
+++ b/bin/cache_cost.c
@@ -11,7 +11,7 @@
11#include <sys/utsname.h> 11#include <sys/utsname.h>
12 12
13#include "litmus.h" 13#include "litmus.h"
14#include "asm.h" 14#include "asm/cycles.h"
15 15
16static void die(char *error) 16static void die(char *error)
17{ 17{
@@ -126,6 +126,8 @@ static int touch_mem(int *mem, int wss, int write_cycle)
126 return sum; 126 return sum;
127} 127}
128 128
129
130
129static void do_random_experiment(FILE* outfile, 131static void do_random_experiment(FILE* outfile,
130 int num_cpus, int wss, 132 int num_cpus, int wss,
131 int sleep_min, int sleep_max, 133 int sleep_min, int sleep_max,
@@ -145,15 +147,18 @@ static void do_random_experiment(FILE* outfile,
145 /* prefault and dirty cache */ 147 /* prefault and dirty cache */
146 touch_arena(); 148 touch_arena();
147 149
148 150#if defined(__i386__) || defined(__x86_64__)
149 iopl(3); 151 iopl(3);
152#endif
150 while (!sample_count || sample_count >= counter) { 153 while (!sample_count || sample_count >= counter) {
151 delay = sleep_min + random() % (sleep_max - sleep_min + 1); 154 delay = sleep_min + random() % (sleep_max - sleep_min + 1);
152 next_cpu = random() % num_cpus; 155 next_cpu = random() % num_cpus;
153 156
154 mem = allocate(wss); 157 mem = allocate(wss);
155 158
159#if defined(__i386__) || defined(__x86_64__)
156 cli(); 160 cli();
161#endif
157 start = get_cycles(); 162 start = get_cycles();
158 mem[0] = touch_mem(mem, wss, write_cycle); 163 mem[0] = touch_mem(mem, wss, write_cycle);
159 stop = get_cycles(); 164 stop = get_cycles();
@@ -173,16 +178,21 @@ static void do_random_experiment(FILE* outfile,
173 mem[0] = touch_mem(mem, wss, write_cycle); 178 mem[0] = touch_mem(mem, wss, write_cycle);
174 stop = get_cycles(); 179 stop = get_cycles();
175 hot3 = stop - start; 180 hot3 = stop - start;
181#if defined(__i386__) || defined(__x86_64__)
176 sti(); 182 sti();
177 183#endif
178 migrate_to(next_cpu); 184 migrate_to(next_cpu);
179 sleep_us(delay); 185 sleep_us(delay);
180 186
187#if defined(__i386__) || defined(__x86_64__)
181 cli(); 188 cli();
189#endif
182 start = get_cycles(); 190 start = get_cycles();
183 mem[0] = touch_mem(mem, wss, write_cycle); 191 mem[0] = touch_mem(mem, wss, write_cycle);
184 stop = get_cycles(); 192 stop = get_cycles();
193#if defined(__i386__) || defined(__x86_64__)
185 sti(); 194 sti();
195#endif
186 after_resume = stop - start; 196 after_resume = stop - start;
187 197
188 /* run, write ratio, wss, delay, from, to, cold, hot1, hot2, 198 /* run, write ratio, wss, delay, from, to, cold, hot1, hot2,