def oheads(self, sched=False): self.o.lock = const(3) self.o.unlock = const(5) self.o.read_lock = const(7) self.o.read_unlock = const(11) self.o.syscall_in = const(17) self.o.syscall_out = const(19) if sched: self.o.ipi_latency = const(23) self.o.schedule = const(27) self.o.ctx_switch = const(31) self.o.cache_affinity_loss.set_cpmd_cost(m.CacheDelay.L1, const(41))
def test_sem_integral(self): self.no_reads() self.o.unlock = const(1.75) self.assertIs( locking.charge_semaphore_overheads(self.o, True, False, self.ts), self.ts) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + 2)
def zero_overheads(self): # cache-related preemption/migration delay self.cache_affinity_loss = CacheDelay() # cost of loading working set into cache at start of execution self.initial_cache_load = CacheDelay() for (name, field) in self.FIELD_MAPPING: self.__dict__[field] = const(0)
def test_dedicated(self): self.o.ipi_latency = const(100) self.assertEqual(jlfp.charge_scheduling_overheads(self.o, 4, True, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10100) self.assertEqual(self.ts[1].cost, 5100) self.unchanged_period() self.unchanged_deadline() self.o.release = const(133) self.assertEqual(jlfp.charge_scheduling_overheads(self.o, 4, True, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10333) self.assertEqual(self.ts[1].cost, 5333) self.unchanged_period() self.unchanged_deadline()
def test_ctx_switch(self): self.o.ctx_switch = const(100) self.assertEqual(pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 12500) self.assertEqual(self.ts[1].cost, 6500) self.unchanged_period() self.unchanged_deadline()
def test_cache_affinity_loss(self): self.o.cache_affinity_loss = const(0.5) self.assertEqual(pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10500) self.assertEqual(self.ts[1].cost, 5000) self.unchanged_period() self.unchanged_deadline()
def test_tick(self): self.o.tick = const(50) self.assertEqual(pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 11500) self.assertEqual(self.ts[1].cost, 6000) self.unchanged_period() self.unchanged_deadline()
def load_approximations(self, fname, non_decreasing=True, custom_fields=None, per_cpu_task_counts=False, num_cpus=None): if custom_fields is None: custom_fields = [] data = load_column_csv(fname, convert=float) if not 'TASK-COUNT' in data.by_name: raise IOError, "TASK-COUNT column is missing" # initialize custom fields, if any for (name, field) in custom_fields: self.__dict__[field] = const(0) for (name, field) in Overheads.FIELD_MAPPING + custom_fields: if name in data.by_name: points = zip(data.by_name['TASK-COUNT'], data.by_name[name]) if per_cpu_task_counts: points = [(num_cpus * x, y) for (x, y) in points] if non_decreasing: self.__dict__[field] = monotonic_pwlin(points) else: self.__dict__[field] = piece_wise_linear(points)
def test_initial_load(self): self.o.initial_cache_load = const(4) self.assertEqual(jlfp.charge_initial_load(self.o, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10004) self.assertEqual(self.ts[1].cost, 5004) self.unchanged_period() self.unchanged_deadline()
def test_cache_affinity_loss(self): self.o.cache_affinity_loss = const(1) self.assertEqual(jlfp.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10001) self.assertEqual(self.ts[1].cost, 5001) self.unchanged_period() self.unchanged_deadline()
def test_ipi_latency(self): # IPI latency is irrelevant for Pfair self.o.ipi_latency = const(1000) self.assertEqual(pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10000) self.assertEqual(self.ts[1].cost, 5000) self.unchanged_period() self.unchanged_deadline()
def test_release(self): self.o.release = const(1) self.assertEqual(jlfp.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10005) self.assertEqual(self.ts[1].cost, 5005) self.unchanged_period() self.unchanged_deadline()
def test_release_latency(self): self.o.release_latency = const(1) self.assertEqual(jlfp.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.unchanged_cost() self.assertEqual(self.ts[0].period, 99999) self.assertEqual(self.ts[1].period, 49999) self.assertEqual(self.ts[0].deadline, 99999) self.assertEqual(self.ts[1].deadline, 49999)
def test_tick(self): self.o.tick = const(50) self.assertEqual( pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 11500) self.assertEqual(self.ts[1].cost, 6000) self.unchanged_period() self.unchanged_deadline()
def test_ctx_switch(self): self.o.ctx_switch = const(100) self.assertEqual( pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 12500) self.assertEqual(self.ts[1].cost, 6500) self.unchanged_period() self.unchanged_deadline()
def test_release(self): self.o.release = const(50) self.assertEqual(pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 11500) self.assertEqual(self.ts[1].cost, 6000) self.assertEqual(self.ts[0].period, 99000) self.assertEqual(self.ts[1].period, 49000) self.assertEqual(self.ts[0].deadline, 99000) self.assertEqual(self.ts[1].deadline, 49000)
def test_cache_affinity_loss(self): self.o.cache_affinity_loss = const(0.5) self.assertEqual( pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10500) self.assertEqual(self.ts[1].cost, 5000) self.unchanged_period() self.unchanged_deadline()
def test_ipi_latency(self): # IPI latency is irrelevant for Pfair self.o.ipi_latency = const(1000) self.assertEqual( pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10000) self.assertEqual(self.ts[1].cost, 5000) self.unchanged_period() self.unchanged_deadline()
def test_cache_affinity_loss(self): self.o.cache_affinity_loss = const(1) self.assertEqual( jlfp.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10001) self.assertEqual(self.ts[1].cost, 5001) self.unchanged_period() self.unchanged_deadline()
def test_release(self): self.o.release = const(1) self.assertEqual( jlfp.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10005) self.assertEqual(self.ts[1].cost, 5005) self.unchanged_period() self.unchanged_deadline()
def test_release(self): self.o.release = const(50) self.assertEqual( pfair.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 11500) self.assertEqual(self.ts[1].cost, 6000) self.assertEqual(self.ts[0].period, 99000) self.assertEqual(self.ts[1].period, 49000) self.assertEqual(self.ts[0].deadline, 99000) self.assertEqual(self.ts[1].deadline, 49000)
def test_ctx_switch(self): self.o.ctx_switch = const(1) ts = fp.charge_scheduling_overheads(self.o, 4, False, self.ts) self.assertEqual(fp.quantize_params(ts), ts) self.assertIsNot(ts, False) self.assertIsNot(ts, self.ts) self.assertEqual(self.ts[0].cost, 10002) self.assertEqual(self.ts[1].cost, 5002) self.unchanged_period() self.unchanged_deadline() self.no_jitter()
def test_release_latency(self): self.o.release_latency = const(1) ts = fp.charge_scheduling_overheads(self.o, 4, False, self.ts) self.assertEqual(fp.quantize_params(ts), ts) self.assertIsNot(ts, False) self.assertIsNot(ts, self.ts) self.unchanged_cost() self.unchanged_period() self.unchanged_deadline() self.assertEqual(self.ts[0].jitter, 1) self.assertEqual(self.ts[1].jitter, 1)
def test_dedicated(self): self.o.ipi_latency = const(100) self.assertEqual( jlfp.charge_scheduling_overheads(self.o, 4, True, self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10100) self.assertEqual(self.ts[1].cost, 5100) self.unchanged_period() self.unchanged_deadline() self.o.release = const(133) self.assertEqual( jlfp.charge_scheduling_overheads(self.o, 4, True, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.assertEqual(self.ts[0].cost, 10333) self.assertEqual(self.ts[1].cost, 5333) self.unchanged_period() self.unchanged_deadline()
def test_release_latency(self): self.o.release_latency = const(1) self.assertEqual( jlfp.charge_scheduling_overheads(self.o, 4, False, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.unchanged_cost() self.assertEqual(self.ts[0].period, 99999) self.assertEqual(self.ts[1].period, 49999) self.assertEqual(self.ts[0].deadline, 99999) self.assertEqual(self.ts[1].deadline, 49999)
def test_tick_example(self): e1 = 2000 e2 = 3000 Q = 5000 tck = 2000 self.ts[0].cost = e1 self.ts[1].cost = e2 self.o.tick = const(tck) self.o.quantum_length = Q self.assertEqual(jlfp.charge_scheduling_overheads(self.o, 1, False, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.assertEqual(self.ts[0].cost, int(ceil(30000 / 3))) self.assertEqual(self.ts[1].cost, 5000 + int(ceil(20000 / 3)))
def test_tick(self): self.o.tick = const(123) self.o.quantum_length = 777 ts = fp.charge_scheduling_overheads(self.o, 4, False, self.ts) self.assertEqual(fp.quantize_params(ts), ts) self.assertIsNot(ts, False) self.assertIsNot(ts, self.ts) self.unchanged_cost() self.unchanged_period() self.unchanged_deadline() self.no_jitter() self.assertEqual(ts[0].cost, 123) self.assertEqual(ts[0].period, 777)
def test_tick_example(self): e1 = 2000 e2 = 3000 Q = 5000 tck = 2000 self.ts[0].cost = e1 self.ts[1].cost = e2 self.o.tick = const(tck) self.o.quantum_length = Q self.assertEqual( jlfp.charge_scheduling_overheads(self.o, 1, False, self.ts), self.ts) self.assertEqual(jlfp.quantize_params(self.ts), self.ts) self.assertEqual(self.ts[0].cost, int(ceil(30000 / 3))) self.assertEqual(self.ts[1].cost, 5000 + int(ceil(20000 / 3)))
def test_dpcp_integral(self): self.no_reads() self.init_susp() self.o.lock = const(1.75) self.assertIs(locking.charge_dpcp_overheads(self.o, self.ts), self.ts) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + 2)
def ts_test(ts): global b global b_lp global b_np #global b_np_qpa global avg_np global max_np global avg_lp global max_lp global avg_p global max_p global printed_example o_np_avg = m.Overheads() o_np_avg.zero_overheads() o_np_avg.ctx_switch = const(27) o_np_max = m.Overheads() o_np_max.zero_overheads() o_np_max.ctx_switch = const(44) o_p_avg = m.Overheads() o_p_avg.zero_overheads() o_p_avg.ctx_switch = const(263) o_p_max = m.Overheads() o_p_max.zero_overheads() o_p_max.ctx_switch = const(434) for t in ts: t.wss = 0 ts_np = make_np(ts.copy()) ts_lp = make_lp(ts.copy()) ts_np_avg = charge_sched_overheads_np(o_np_avg, ts_np.copy()) ts_np_max = charge_sched_overheads_np(o_np_max, ts_np.copy()) ts_lp_avg = fp.charge_scheduling_overheads(o_np_avg, 1, False, ts_lp.copy()) ts_lp_max = fp.charge_scheduling_overheads(o_np_max, 1, False, ts_lp.copy()) ts_p_avg = fp.charge_scheduling_overheads(o_p_avg, 1, False, ts.copy()) ts_p_max = fp.charge_scheduling_overheads(o_p_max, 1, False, ts.copy()) if edf.is_schedulable(1, ts): b += 1 #if edf.is_schedulable(1, ts, preemptive=False): # b_np += 1 if edf.is_schedulable(1, ts_lp): b_lp += 1 if edf.is_schedulable(1, ts_np): b_np += 1 if edf.is_schedulable(1, ts_np_avg): avg_np += 1 if edf.is_schedulable(1, ts_np_max): max_np += 1 if edf.is_schedulable(1, ts_lp_avg): avg_lp += 1 if edf.is_schedulable(1, ts_lp_max): max_lp += 1 if edf.is_schedulable(1, ts_p_avg): avg_p += 1 if edf.is_schedulable(1, ts_p_max): max_p += 1
def test_sem_integral(self): self.no_reads() self.o.unlock = const(1.75) self.assertIs(locking.charge_semaphore_overheads(self.o, True, False, self.ts), self.ts) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + 2)
def test_dpcp_infeasible(self): self.no_reads() self.init_susp() self.o.syscall_in = const(10000000) self.assertIs(locking.charge_dpcp_overheads(self.o, self.ts), False)
def test_spinlock_integral(self): self.o.lock = const(1.75) self.assertIs(locking.charge_spinlock_overheads(self.o, self.ts), self.ts) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + 2)
def test_sem_infeasible(self): self.no_reads() self.o.syscall_in = const(10000000) self.assertIs(locking.charge_semaphore_overheads(self.o, True, False, self.ts), False)
def test_spinlock_infeasible(self): self.o.syscall_in = const(10000000) self.assertIs(locking.charge_spinlock_overheads(self.o, self.ts), False)
def test_sem_infeasible(self): self.no_reads() self.o.syscall_in = const(10000000) self.assertIs( locking.charge_semaphore_overheads(self.o, True, False, self.ts), False)
def setUp(self): self.f = m.lin(1, 3) self.c = m.const(123) self.pwlin = m.monotonic_pwlin([(0, 1), (1, 0), (1, 4), (2, 5)])
def __init__(self, l1=0, l2=0, l3=0, mem=0): self.mem_hierarchy = [const(mem), const(l1), const(l2), const(l3)] for (i, name) in CacheDelay.MAPPING: self.__dict__[name] = self.mem_hierarchy[i]
x += step else: # should really be if step < 0 with an extra check for step == 0 while x > stop: my_list.append(x) x += step return my_list def custom_range(): my_list = range(2,10)+range(10,60,10)+range(60,201,20) print my_list return my_list #main o_np_avg = m.Overheads() o_np_avg.zero_overheads() o_np_avg.ctx_switch = const(27) o_np_max = m.Overheads() o_np_max.zero_overheads() o_np_max.ctx_switch = const(44) for wgs in custom_range(): global u u_no = 0.0 u_avg = 0.0 u_max = 0.0 u_no_99 = 0.0 u_avg_99 = 0.0 u_max_99 = 0.0 for u in float_range(0.2, 1.01, 0.01):