def test_handle_hwpc_report_with_two_rapl_event_and_other_groups(state): """ handle a HWPC report with two RAPL events and events from other groups The HWPC report contain two RAPL events and events from a group 'sys' with two cores The handle method must return two PowerReport containing each RAPL event """ socket_id = '1' raw_power_1 = 10 rapl_event_id_1 = 'RAPL_1' raw_power_2 = 20 rapl_event_id_2 = 'RAPL_2' events = {rapl_event_id_1: raw_power_1, rapl_event_id_2: raw_power_2} hwpc_report = create_report_root([ create_group_report('rapl', [ create_socket_report( socket_id, [create_core_report('1', None, None, events=events)]) ]), create_group_report('sys', [ create_socket_report(socket_id, [ create_core_report('1', 'e0', 0), create_core_report('2', 'e0', 0) ]) ]) ]) validation_report_1 = PowerReport(hwpc_report.timestamp, hwpc_report.sensor, hwpc_report.target, math.ldexp(raw_power_1, -32), { 'socket': socket_id, 'event': rapl_event_id_1 }) validation_report_2 = PowerReport(hwpc_report.timestamp, hwpc_report.sensor, hwpc_report.target, math.ldexp(raw_power_2, -32), { 'socket': socket_id, 'event': rapl_event_id_2 }) result = RAPLFormulaHWPCReportHandler(get_fake_pusher())._process_report( hwpc_report, state) assert len(result) == 2 assert validation_report_1 in result assert validation_report_2 in result
def test_handle_hwpc_report_with_one_rapl_event(state): """ handle a HWPC report with a simple RAPL event The HWPC report contain only one RAPL event and no other groups The handle method must return a PowerReport containing only the RAPL event """ raw_power = 10 socket_id = '1' rapl_event_id = 'RAPL_1' hwpc_report = create_report_root([ create_group_report('rapl', [ create_socket_report( socket_id, [create_core_report('1', rapl_event_id, raw_power)]) ]) ]) validation_report = PowerReport(hwpc_report.timestamp, hwpc_report.sensor, hwpc_report.target, math.ldexp(raw_power, -32), { 'socket': socket_id, 'event': rapl_event_id }) result = RAPLHandler(state)._estimate(hwpc_report) assert [validation_report] == result
def test_handle_hwpc_report_with_one_rapl_event_and_other_groups(state): """ handle a HWPC report with a simple RAPL event and events from other groups The HWPC report contain one RAPL event and events from a group 'sys' with two cores The handle method must return a PowerReport containing only the RAPL event """ raw_power = 10 socket_id = '1' rapl_event_id = 'RAPL_1' hwpc_report = create_report_root([ create_group_report('rapl', [ create_socket_report( socket_id, [create_core_report('1', rapl_event_id, raw_power)]) ]), create_group_report('sys', [ create_socket_report(socket_id, [ create_core_report('1', 'e0', 0), create_core_report('2', 'e0', 0) ]) ]) ]) validation_report = PowerReport(hwpc_report.timestamp, hwpc_report.sensor, hwpc_report.target, math.ldexp(raw_power, -32), { 'socket': socket_id, 'event': rapl_event_id }) result = RAPLFormulaHWPCReportHandler(get_fake_pusher())._process_report( hwpc_report, state) assert [validation_report] == result
def test_handle_hwpc_report_with_two_rapl_event(state): """ handle a HWPC report with two RAPL events The HWPC report contain only two RAPL events and no other groups The handle method must return two PowerReport containing each RAPL event """ socket_id = '1' raw_power_1 = 10 rapl_event_id_1 = 'RAPL_1' raw_power_2 = 20 rapl_event_id_2 = 'RAPL_2' events = {rapl_event_id_1: raw_power_1, rapl_event_id_2: raw_power_2} hwpc_report = create_report_root([ create_group_report('rapl', [ create_socket_report( socket_id, [create_core_report('1', None, None, events=events)]) ]) ]) validation_report_1 = PowerReport(hwpc_report.timestamp, hwpc_report.sensor, hwpc_report.target, math.ldexp(raw_power_1, -32), { 'socket': socket_id, 'event': rapl_event_id_1 }) validation_report_2 = PowerReport(hwpc_report.timestamp, hwpc_report.sensor, hwpc_report.target, math.ldexp(raw_power_2, -32), { 'socket': socket_id, 'event': rapl_event_id_2 }) result = RAPLHandler(state)._estimate(hwpc_report) assert len(result) == 2 assert validation_report_1 in result assert validation_report_2 in result
def gen_hwpc_report(): """ Return a well formated HWPCReport """ cpua0 = create_core_report('1', 'e0', '0') cpub0 = create_core_report('2', 'e0', '1') cpuc0 = create_core_report('3', 'e0', '2') cpud0 = create_core_report('4', 'e0', '3') cpua1 = create_core_report('1', 'e1', '0') cpub1 = create_core_report('2', 'e1', '1') cpuc1 = create_core_report('3', 'e1', '2') cpud1 = create_core_report('4', 'e1', '3') socketa0 = create_socket_report('1', [cpua0, cpub0]) socketb0 = create_socket_report('2', [cpuc0, cpud0]) socketa1 = create_socket_report('1', [cpua1, cpub1]) socketb1 = create_socket_report('2', [cpuc1, cpud1]) groupa = create_group_report('group1', [socketa0, socketb0]) groupb = create_group_report('group2', [socketa1, socketb1]) return create_report_root([groupa, groupb])
def gen_hwpc_report(): """ Return a well formated HWPCReport """ cpua = create_core_report('1', 'e0', '0') cpub = create_core_report('2', 'e0', '1') cpuc = create_core_report('1', 'e0', '2') cpud = create_core_report('2', 'e0', '3') cpue = create_core_report('1', 'e1', '0') cpuf = create_core_report('2', 'e1', '1') cpug = create_core_report('1', 'e1', '2') cpuh = create_core_report('2', 'e1', '3') socketa = create_socket_report('1', [cpua, cpub]) socketb = create_socket_report('2', [cpuc, cpud]) socketc = create_socket_report('1', [cpue, cpuf]) socketd = create_socket_report('2', [cpug, cpuh]) groupa = create_group_report('1', [socketa, socketb]) groupb = create_group_report('2', [socketc, socketd]) return create_report_root([groupa, groupb])