aboutsummaryrefslogtreecommitdiffstats
path: root/gen
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-04-25 16:43:49 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2013-04-25 16:43:49 -0400
commit15f231a79320cbc97cd88d8a4751515a47ce223e (patch)
treeb86b202cadc816a5da7b96372b9de4362da88116 /gen
parent2ceaa6c607ef85bde4f14017634d9d1621efca29 (diff)
Bug fixes from testing.
Diffstat (limited to 'gen')
-rw-r--r--gen/color.py10
-rw-r--r--gen/mc_generators.py28
2 files changed, 27 insertions, 11 deletions
diff --git a/gen/color.py b/gen/color.py
index 8184b8b..46ec8dc 100644
--- a/gen/color.py
+++ b/gen/color.py
@@ -29,19 +29,22 @@ class BlockColorScheme(ColorScheme):
29 if self.way_first: 29 if self.way_first:
30 # Way first means maximize ways 30 # Way first means maximize ways
31 pages_per_color = min(self.ways, pages_needed) 31 pages_per_color = min(self.ways, pages_needed)
32 colors_per_task = int(ceil(pages_needed/pages_per_color)) 32 colors_per_task = int(ceil(float(pages_needed)/pages_per_color))
33 else: 33 else:
34 # Color first means maximize colors 34 # Color first means maximize colors
35 colors_per_task = min(self.colors, pages_needed) 35 colors_per_task = min(self.colors, pages_needed)
36 pages_per_color = int(ceil(pages_needed/colors_per_task)) 36 pages_per_color = int(ceil(float(pages_needed)/colors_per_task))
37 37
38 curr_color = 0 38 curr_color = 0
39 for cpu, tasks in cpus.iteritems(): 39 for cpu, tasks in cpus.iteritems():
40 # All tasks on a CPU have the same coloring scheme 40 # All tasks on a CPU have the same coloring scheme
41 cpu_colors = defaultdict(int) 41 cpu_colors = defaultdict(int)
42 for _ in xrange(colors_per_task): 42 for _ in xrange(colors_per_task):
43 curr_color = (curr_color + 1) % self.colors
44 cpu_colors[curr_color] = pages_per_color 43 cpu_colors[curr_color] = pages_per_color
44 curr_color = (curr_color + 1) % self.colors
45
46 if sum(cpu_colors.values()) < pages_needed:
47 raise Exception("Failed to block color cpu, %s" % cpu_colors)
45 48
46 for t in tasks: 49 for t in tasks:
47 t.colors = cpu_colors 50 t.colors = cpu_colors
@@ -80,7 +83,6 @@ class EvilColorScheme(ColorScheme):
80 for t in tasks: 83 for t in tasks:
81 t.colors = colors 84 t.colors = colors
82 85
83
84INFO_FIELDS = ['cache', 'line', 'page', 'ways', 'sets', 'colors'] 86INFO_FIELDS = ['cache', 'line', 'page', 'ways', 'sets', 'colors']
85INFO_PROC = '/proc/sys/litmus/color/cache_info' 87INFO_PROC = '/proc/sys/litmus/color/cache_info'
86 88
diff --git a/gen/mc_generators.py b/gen/mc_generators.py
index 8f5bd84..d8c172d 100644
--- a/gen/mc_generators.py
+++ b/gen/mc_generators.py
@@ -243,8 +243,9 @@ TP_TYPE = """#if $type != 'unmanaged'
243/proc/sys/litmus/color/preempt_cache{0} 243/proc/sys/litmus/color/preempt_cache{0}
244#end if""" 244#end if"""
245 245
246# Always add some pages 246# Now done by experiment.py
247TP_ADD = """/proc/sys/litmus/color/add_pages{1}""" 247# # Always add some pages
248# TP_ADD = """/proc/sys/litmus/color/add_pages{1}"""
248 249
249# Use special spin for color tasks 250# Use special spin for color tasks
250TP_COLOR_BASE = """colorspin -y $t.id -x $t.colorcsv -q $t.wss -l $t.loops """ 251TP_COLOR_BASE = """colorspin -y $t.id -x $t.colorcsv -q $t.wss -l $t.loops """
@@ -253,8 +254,8 @@ TP_COLOR_B = TP_BASE.format("b", TP_COLOR_BASE + "-p $t.cpu ")
253TP_COLOR_C = TP_BASE.format("c", TP_COLOR_BASE) 254TP_COLOR_C = TP_BASE.format("c", TP_COLOR_BASE)
254 255
255# Not even sure job splitting is still possible 256# Not even sure job splitting is still possible
256TP_CHUNK = """#if $chunk_size > 0 257TP_CHUNK = """#if $chunk_size_ns > 0
257/proc/sys/litmus/color/chunk_size{$chunk_size} 258/proc/sys/litmus/color/chunk_size{$chunk_size_ns}
258#end if""" 259#end if"""
259 260
260COLOR_TYPES = ['scheduling', 'locking', 'unmanaged'] 261COLOR_TYPES = ['scheduling', 'locking', 'unmanaged']
@@ -264,7 +265,7 @@ class ColorMcGenerator(McGenerator):
264 265
265 def __init__(self, params = {}): 266 def __init__(self, params = {}):
266 super(ColorMcGenerator, self).__init__("MC", 267 super(ColorMcGenerator, self).__init__("MC",
267 templates=[TP_ADD, TP_TYPE, TP_CHUNK, TP_COLOR_B, TP_COLOR_C], 268 templates=[TP_TYPE, TP_CHUNK, TP_COLOR_B, TP_COLOR_C],
268 options=self.__make_options(), 269 options=self.__make_options(),
269 params=self.__extend_params(params)) 270 params=self.__extend_params(params))
270 271
@@ -336,7 +337,7 @@ class ColorMcGenerator(McGenerator):
336 'System colors (cache size / ways).'), 337 'System colors (cache size / ways).'),
337 GenOption('page_size', int, self.cache.page, 338 GenOption('page_size', int, self.cache.page,
338 'System page size.'), 339 'System page size.'),
339 GenOption('wss', [float, int], .5, 340 GenOption('wss', [float, int], .25,
340 'Task working set sizes. Can be expressed as a fraction ' + 341 'Task working set sizes. Can be expressed as a fraction ' +
341 'of the cache.')] 342 'of the cache.')]
342 343
@@ -359,7 +360,8 @@ class ColorMcGenerator(McGenerator):
359 if pages > cache_pages: 360 if pages > cache_pages:
360 raise Exception('WSS (%d) larger than the cache!' % (wss)) 361 raise Exception('WSS (%d) larger than the cache!' % (wss))
361 362
362 return pages 363 # Divide in half for HRT, SRT divide
364 return pages / 2
363 365
364 366
365 def __make_csv(self, task): 367 def __make_csv(self, task):
@@ -410,11 +412,23 @@ class ColorMcGenerator(McGenerator):
410 hrt_colorer = EvilColorScheme(c, w) 412 hrt_colorer = EvilColorScheme(c, w)
411 srt_colorer = hrt_colorer 413 srt_colorer = hrt_colorer
412 else: 414 else:
415 # Divide cache between hrt and srt
416 c /= 2
413 srt_colorer = RandomColorScheme(c, w) 417 srt_colorer = RandomColorScheme(c, w)
414 hrt_colorer = BlockColorScheme(c, w, way_first=True) 418 hrt_colorer = BlockColorScheme(c, w, way_first=True)
415 419
416 hrt_colorer.color(task_system['lvlb'], pages_needed) 420 hrt_colorer.color(task_system['lvlb'], pages_needed)
417 srt_colorer.color(task_system['lvlc'], pages_needed) 421 srt_colorer.color(task_system['lvlc'], pages_needed)
418 422
423 # This check has saved me a lot of trouble already, leave it in
424 for t in task_system['lvlb'] + task_system['lvlc']:
425 if sum(t.colors.values()) * params['page_size'] < real_wss:
426 raise Exception("Didn't color enough pages for %s" % params)
427
428 if params['type'] != 'unmanaged':
429 # Bump srt into the second half of the cache
430 for t in task_system['lvlc']:
431 t.colors = {colors+c:w for colors, w in t.colors.iteritems()}
432
419 for t in all_tasks: 433 for t in all_tasks:
420 self.__make_csv(t) 434 self.__make_csv(t)