aboutsummaryrefslogtreecommitdiffstats
path: root/parse/sched.py
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/sched.py
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/sched.py')
-rw-r--r--parse/sched.py31
1 files changed, 27 insertions, 4 deletions
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)]