aboutsummaryrefslogtreecommitdiffstats
path: root/parse
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-05-02 14:30:55 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2013-05-02 14:30:55 -0400
commit219e9595520c5069f4d7a41cd42db8ca50ac8005 (patch)
tree5d30be9ad5cd20a5f2e0e43e0227f678ad8d3c7d /parse
parent3f706cd240d039365cbb8f9975ad97480d8b6145 (diff)
parent6f2558b8c4f4e33630b40dfbe20024f7a372a8f0 (diff)
Merge branch 'master' into wip-color-mc
Conflicts: common.py gen/generator.py run/experiment.py run_exps.py
Diffstat (limited to 'parse')
-rw-r--r--parse/col_map.py4
-rw-r--r--parse/sched.py31
2 files changed, 29 insertions, 6 deletions
diff --git a/parse/col_map.py b/parse/col_map.py
index ceb8867..59484e8 100644
--- a/parse/col_map.py
+++ b/parse/col_map.py
@@ -22,7 +22,7 @@ class ColMapBuilder(object):
22 22
23class ColMap(object): 23class ColMap(object):
24 def __init__(self, col_list, values = None): 24 def __init__(self, col_list, values = None):
25 self.col_list = col_list 25 self.col_list = sorted(col_list)
26 self.rev_map = {} 26 self.rev_map = {}
27 self.values = values 27 self.values = values
28 28
@@ -50,7 +50,7 @@ class ColMap(object):
50 if col not in kv: 50 if col not in kv:
51 key += (None,) 51 key += (None,)
52 else: 52 else:
53 key += (kv[col],) 53 key += (str(kv[col]),)
54 54
55 return key 55 return key
56 56
diff --git a/parse/sched.py b/parse/sched.py
index 6e1fbe6..524f1ed 100644
--- a/parse/sched.py
+++ b/parse/sched.py
@@ -98,15 +98,38 @@ record_map = {}
98RECORD_SIZE = 24 98RECORD_SIZE = 24
99NSEC_PER_MSEC = 1000000 99NSEC_PER_MSEC = 1000000
100 100
101def bits_to_bytes(bits):
102 '''Includes padding'''
103 return bits / 8 + (1 if bits%8 else 0)
104
105def field_bytes(fields):
106 fbytes = 0
107 fbits = 0
108 for f in fields:
109 flist = list(f)
110
111 if len(flist) > 2:
112 # Specified a bitfield
113 fbits += flist[2]
114 else:
115 # Only specified a type, use types size
116 fbytes += sizeof(list(f)[1])
117
118 # Bitfields followed by a byte will cause any incomplete
119 # bytes to be turned into full bytes
120 fbytes += bits_to_bytes(fbits)
121 fbits = 0
122
123 fbytes += bits_to_bytes(fbits)
124 return fbytes + fbits
125
101def register_record(id, clazz): 126def register_record(id, clazz):
102 fields = clazz.FIELDS 127 fields = clazz.FIELDS
103 128 diff = RECORD_SIZE - field_bytes(SchedRecord.FIELDS) - field_bytes(fields)
104 fsize = lambda fields : sum([sizeof(list(f)[1]) for f in fields])
105 diff = RECORD_SIZE - fsize(SchedRecord.FIELDS) - fsize(fields)
106 129
107 # Create extra padding fields to make record the proper size 130 # Create extra padding fields to make record the proper size
108 # Creating one big field of c_uint64 and giving it a size of 8*diff 131 # Creating one big field of c_uint64 and giving it a size of 8*diff
109 # _shoud_ work, but doesn't. This is an uglier way of accomplishing 132 # _should_ work, but doesn't. This is an uglier way of accomplishing
110 # the same goal 133 # the same goal
111 for d in range(diff): 134 for d in range(diff):
112 fields += [("extra%d" % d, c_char)] 135 fields += [("extra%d" % d, c_char)]