예제 #1
0
def test_correctness_of_bus_invalidation_update_counting():
    op_list = [(0, 0b100000100001), (0, 0b1000000110000), (0, 0b1100000100111), (0, 0b10000000110011)]
    op_list1 = [(2, 10), (1, 0b100000100001)]
    simulator = Simulator(data=None, num_cores=2)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.run()
    assert simulator.bus.total_bus_invalidation_or_updates == 1
예제 #2
0
def test_cache_write_four_core_same_access():
    op_list = [(1, 0b100000100001), (1, 0b1000000110000), (1, 0b1100000100111), (1, 0b10000000110011)]
    simulator = Simulator(data=None, num_cores=4)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list)
    simulator.procs[2].op_stream = FakeOpStream(op_list)
    simulator.procs[3].op_stream = FakeOpStream(op_list)
    simulator.run()
def test_cache_fetch_from_memory_only():
    op_list = [(0, 0b100000100001), (0, 0b1000000110000), (0, 0b1100000100111), (0, 0b10000000110011)]
    op_list1 = [(0, 0b100001100001), (0, 0b1000001110000), (0, 0b1100001100111), (0, 0b10000001110011)]
    simulator = Simulator(data=None, protocol='dragon', num_cores=2)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.run()
    assert simulator.counter == len(op_list) * 101 + 1  # the extra 1 cycle is spent competing for bus ownership
def test_cache_read_four_core_same_access():
    op_list = [(0, 0b100000100001), (0, 0b1000000110000), (0, 0b1100000100111), (0, 0b10000000110011)]
    simulator = Simulator(data=None, protocol='dragon', num_cores=4)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list)
    simulator.procs[2].op_stream = FakeOpStream(op_list)
    simulator.procs[3].op_stream = FakeOpStream(op_list)
    simulator.run()
예제 #5
0
def test_correctness_of_total_bus_traffic_counting():
    op_list = [(0, 0b100000100001), (0, 0b1000000110000), (0, 0b1100000100111), (0, 0b10000000110011)]
    op_list1 = [(2, 10), (0, 0b100000100001)]
    simulator = Simulator(data=None, num_cores=2)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.run()
    cache0 = simulator.procs[0].cache
    assert simulator.bus.total_bus_traffic == cache0.block_size * 1
예제 #6
0
def test_interleaving_cache_write_from_different_caches():
    op_list = [(0, 0b100000100001), (1, 0b100000100001)]
    op_list1 = [(2, 10), (1, 0b100000100001)]
    simulator = Simulator(data=None, num_cores=2)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.run()
    assert simulator.procs[1].counter == 101 + simulator.procs[1].cache.block_size // 4 * 2 + 2
    assert simulator.procs[1].total_compute_cycles == 10
예제 #7
0
def test_cache_read_block_while_other_cache_fetching_same_block_from_mem():
    op_list = [(0, 0b100000100001), (0, 0b1000000110000), (0, 0b1100000100111), (0, 0b10000000110011)]
    op_list1 = [(2, 10), (0, 0b100000100001)]
    simulator = Simulator(data=None, num_cores=2)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.run()
    assert simulator.procs[1].counter == 100 + simulator.procs[1].cache.block_size // 4 * 2 + 1
    assert simulator.counter == 100 + simulator.procs[1].cache.block_size // 4 * 2 + (len(op_list) - 1) * 101
def test_cache_direct_hit_only():
    op_list = [(0, 0b100000100001), (0, 0b1000000110000), (0, 0b100000100111), (0, 0b1000000110011)]
    simulator = Simulator(protocol='dragon', data=None, num_cores=1)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[0].cache.data[1] = np.matrix([
        [1, SC, 0],
        [2, SC, 0]
    ])
    simulator.run()
    assert simulator.counter == len(op_list)
예제 #9
0
def test_cache_store_direct_hit():
    op_list = [(1, 0b100000100001), (1, 0b1000000110000), (1, 0b100000100111), (1, 0b1000000110011)]
    simulator = Simulator(data=None, num_cores=1)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[0].cache.data[1] = np.matrix([
        [1, EXCLUSIVE, 0],
        [2, MODIFIED, 0]
    ])
    simulator.run()
    assert simulator.counter == len(op_list)
    assert np.all(simulator.procs[0].cache.data[1][:, 1] == MODIFIED)
예제 #10
0
def test_counting_total_private_accesses():
    op_list = [(0, 0b100000100001), (0, 0b1000000110000), (0, 0b1100000100111), (0, 0b10000000110011)]
    op_list1 = [(2, 10), (1, 0b100000100001), (0, 0b1000000110000)]
    simulator = Simulator(data=None, num_cores=2)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.run()
    cache0 = simulator.procs[0].cache
    cache1 = simulator.procs[1].cache
    assert cache0.total_private_accesses == 4
    assert cache1.total_private_accesses == 1
    assert cache1.total_access_count == 2
예제 #11
0
def test_bus_read_x_to_full_cacheset_does_not_evict_block_if_block_present(home_array, remote_array, home_array_after):
    op_list_raw = [(1, 11, 1, 1)]
    op_list1 = []
    simulator = Simulator(data=None, num_cores=2)
    op_list = [(x[0], simulator.procs[0].cache.get_address_from_pieces(*x[1:])) for x in op_list_raw]

    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.procs[0].cache.data[1] = np.matrix(home_array)
    simulator.procs[1].cache.data[1] = np.matrix(remote_array)
    simulator.run()
    assert np.array_equal(simulator.procs[0].cache.data[1], home_array_after)
예제 #12
0
def test_cache_store_hit_from_bus_or_mem(cache_set_array, number_of_mem_access, dest_block_states):
    op_list_raw = [(1, 11, 1, 1), (1, 22, 1, 1)]
    op_list1 = []
    simulator = Simulator(data=None, num_cores=2)
    op_list = [(x[0], simulator.procs[0].cache.get_address_from_pieces(*x[1:])) for x in op_list_raw]

    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.procs[1].cache.data[1] = np.matrix(cache_set_array)
    simulator.run()
    assert np.array_equal(simulator.procs[1].cache.data[1][:, 1], dest_block_states)
    assert simulator.counter == (len(op_list) - number_of_mem_access) * (
                simulator.procs[0].cache.block_size // 4 * 2 + 1) + number_of_mem_access * 101
예제 #13
0
def test_another(home_array, remote_array, home_array_after):
    op_list_raw = [(1, 11, 1, 1)]
    op_list1 = []
    simulator = Simulator(data=None, num_cores=2)
    op_list = [(x[0], simulator.procs[0].cache.get_address_from_pieces(*x[1:])) for x in op_list_raw]

    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.procs[0].cache.data[1] = np.matrix(home_array)
    simulator.procs[1].cache.data[1] = np.matrix(remote_array)
    simulator.run()
    assert np.array_equal(simulator.procs[0].cache.data[1], home_array_after)
    assert simulator.procs[0].counter == 1
def test_cache_write_block_while_other_cache_fetching_same_block_from_mem():
    op_list = [(0, 0b100000100001), (0, 0b1000000110000), (0, 0b1100000100111), (0, 0b10000000110011)]
    op_list1 = [(2, 10), (1, 0b100000100001)]
    simulator = Simulator(data=None, protocol='dragon', num_cores=2)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.run()
    assert simulator.procs[1].counter == 100 + simulator.procs[1].cache.block_size // 4 * 2 + 2
    assert simulator.counter == 101 + simulator.procs[1].cache.block_size // 4 * 2 + (len(op_list) - 1) * 101
    assert simulator.procs[0].total_load_instructions == 4
    assert simulator.procs[0].total_store_instructions == 0
    assert simulator.procs[1].total_load_instructions == 0
    assert simulator.procs[1].total_store_instructions == 1
예제 #15
0
def test_cache_direct_hit_only():
    op_list = [(0, 0b100000100001), (0, 0b1000000110000), (0, 0b100000100111), (0, 0b1000000110011)]
    simulator = Simulator(data=None, num_cores=1)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[0].cache.data[1] = np.matrix([
        [1, 1, 0],
        [2, 1, 0]
    ])
    simulator.run()
    assert simulator.procs[0].cache.total_access_count == len(op_list)
    assert simulator.procs[0].cache.cache_miss_count == 0
    assert simulator.counter == len(op_list)
    assert np.array_equal(simulator.procs[0].cache.data[1], [
        [2, 1, 0],
        [1, 1, 0]
    ])
예제 #16
0
def test_incoming_read_x_wait_for_local_read():
    op_list = [(1, 0b100000100001)]
    op_list1 = [(0, 0b100000100001)]
    simulator = Simulator(data=None, num_cores=2)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.procs[1].op_stream = FakeOpStream(op_list1)
    simulator.procs[0].cache.data[1] = np.matrix([
        [0, 0, 0],
        [0, 0, 0]
    ])
    simulator.procs[1].cache.data[1] = np.matrix([
        [1, EXCLUSIVE, 0],
        [0, 0, 0]
    ])
    simulator.run()
    assert simulator.counter == 18
    assert simulator.procs[0].counter == 18
    assert simulator.procs[1].counter == 1
예제 #17
0
파일: load.py 프로젝트: lesunb/HMRSsim
scenario_helper.add_camera('robot')
scenario_helper.add_camera('robot2')
scenario_helper.add_camera('robot3')
scenario_helper.add_approximation_ability()
scenario_helper.add_detection_ability()

scenario_helper.add_ability_to_navigate()
pois_tag = 'intersection1, intersection2, patientRoom2, patientRoom3, patientRoom4, intersection2, robotHome'
scenario_helper.add_script_ability()
pois = pois_tag.replace(' ', '').split(',')
for poi in pois:
    scenario_helper.add_go_command('robot', poi)

pois_tag = 'intersection1, intersection2, patientRoom1'
pois = pois_tag.replace(' ', '').split(',')
for poi in pois:
    scenario_helper.add_go_command('robot2', poi)

pois_tag = 'patientRoom3'
pois = pois_tag.replace(' ', '').split(',')
for poi in pois:
    scenario_helper.add_go_command('robot3', poi)

scenario_helper.add_camera_detection_event('robot', 'person3')
scenario_helper.add_camera_detection_event('robot2', 'person2')
scenario_helper.add_camera_detection_event('robot3', 'person1')

simulation.run()

#assert assertion_helper.approximated('robot', 'person3')
def test_cpu_only_job():
    simulator = Simulator()
    simulator.run()
    assert simulator.counter == 0x27 * 3
    assert simulator.procs[1].total_compute_cycles == 0x27 * 3
예제 #19
0
    Seer.init([firebase_seer_consumer], 0.05, False),
    (ClawProcessor.process,),
    (ObjectManager.process,),
    (energySystem.process,),
    (NavigationSystemProcess,),
    (ScriptProcessor,),
]
# Add processors to the simulation, according to processor type
for p in normal_processors:
    simulator.add_system(p)
for p in des_processors:
    simulator.add_des_system(p)


# Create the error handlers dict
error_handlers = {
    NavigationSystem.PathErrorTag: NavigationSystem.handle_PathError
}
# Adding error handlers to the robot
robot = simulator.objects[0][0]
script = simulator.world.component_for_entity(robot, Script)
script.error_handlers = error_handlers

if __name__ == "__main__":
    # NOTE!  schedule_interval will automatically pass a "delta time" argument
    #        to world.process, so you must make sure that your Processor classes
    #        account for this. See the example Processors above.
    simulator.run()
    print("Robot's script logs")
    print("\n".join(script.logs))
예제 #20
0
def test_cache_store_fetch_from_memory_only():
    op_list = [(1, 0b100000100001), (1, 0b1000000110000), (1, 0b1100000100111), (1, 0b10000000110011)]
    simulator = Simulator(data=None, num_cores=1)
    simulator.procs[0].op_stream = FakeOpStream(op_list)
    simulator.run()
    assert simulator.counter == len(op_list) * 101 + 200