From 585b0f27fe0de16cd7c6f7c42bb948d047d826ea Mon Sep 17 00:00:00 2001 From: JoseSantosAMD Date: Mon, 25 Sep 2023 13:50:03 -0500 Subject: [PATCH] Check if csvs populated Signed-off-by: JoseSantosAMD --- tests/test_profile_general.py | 1336 ++++++++++++++++++++++++++++++++- 1 file changed, 1324 insertions(+), 12 deletions(-) diff --git a/tests/test_profile_general.py b/tests/test_profile_general.py index 38bf36390c..46ceafe485 100644 --- a/tests/test_profile_general.py +++ b/tests/test_profile_general.py @@ -3,10 +3,23 @@ from pathlib import Path from unittest.mock import patch import pytest from importlib.machinery import SourceFileLoader +import pandas as pd omniperf = SourceFileLoader("omniperf", "src/omniperf").load_module() workload_1 = os.path.realpath("workload") app = ["./sample/vcopy", "1048576", "256"] +ALL_CSVS = [ + "pmc_dispatch_info.csv", + "pmc_kernel_top.csv", + "roofline.csv", + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "sysinfo.csv", + "timestamps.csv", +] def test_path(): @@ -18,15 +31,27 @@ def test_path(): "profile", "-n", "app", + "-VVV", "--path", workload_1, "--", - ] + app + ] + + app, ): omniperf.main() - - #assert successful run + # assert successful run assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + def test_kernel(): with pytest.raises(SystemExit) as e: @@ -37,18 +62,31 @@ def test_kernel(): "profile", "-n", "app", + "-VVV", "--path", workload_1, "--kernel", - "kernel_name" + "kernel_name", "--", - ] + app + ] + + app, ): omniperf.main() - - #assert successful run + + # assert successful run assert e.value.code == 0 - + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + def test_kernel_summaries(): with pytest.raises(SystemExit) as e: with patch( @@ -58,13 +96,1287 @@ def test_kernel_summaries(): "profile", "-n", "app", + "-VVV", "--path", workload_1, "--kernel-summaries", "--", - ] + app + ] + + app, ): omniperf.main() - - #assert successful run - assert e.value.code == 0 \ No newline at end of file + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_kernel_summaries(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--kernel-summaries", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_SQ(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "SQ", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_SQC(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "SQC", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_TA(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "TA", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_TD(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "TD", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_TCP(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "TCP", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_TCC(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "TCC", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_SPI(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "SPI", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_CPC(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "CPC", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_CPF(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "CPF", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_SQ_CPC(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "SQ", + "CPC", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_SQ_TA(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "SQ", + "TA", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_SQ_SPI(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "SQ", + "SPI", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_SQ_SQC_TCP_CPC(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "SQ", + "SQC", + "TCP", + "CPC", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_ipblocks_SQ_SPI_TA_TCC_CPF(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--ipblocks", + "SQ", + "SPI", + "TA", + "TCC", + "CPF", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_dispatch_0(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--dispatch", + "0", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_dispatch_0_1(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--dispatch", + "0", + "1", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_dispatch_2(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--dispatch", + "2", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_kernel_verbose_0(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--kernelVerbose", + "0", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_kernel_verbose_1(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--kernelVerbose", + "1", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_kernel_verbose_2(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--kernelVerbose", + "2", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_kernel_verbose_3(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--kernelVerbose", + "3", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_kernel_verbose_4(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--kernelVerbose", + "4", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_kernel_verbose_5(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--kernelVerbose", + "5", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_join_type_grid(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--join-type", + "grid", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_join_type_kernel(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--join-type", + "kernel", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_device_0(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--device", + "0", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_no_roof(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--no-roof", + "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_sort_dispatches(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--sort", + "dispatches," "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_sort_kernels(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--sort", + "kernels," "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_mem_levels_HBM(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--mem-levels", + "HBM," "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_mem_levels_L2(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--mem-levels", + "L2," "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_mem_levels_vL1D(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--mem-levels", + "vL1D," "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_mem_levels_LDS(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--mem-levels", + "LDS," "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_mem_levels_HBM_LDS(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--mem-levels", + "HBM", + "LDS," "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_mem_levels_vL1D_LDS(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--mem-levels", + "vL1D", + "LDS," "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS + + +def test_mem_levels_L2_vL1D_LDS(): + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app", + "-VVV", + "--path", + workload_1, + "--mem-levels", + "L2", + "vL1D", + "LDS," "--", + ] + + app, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + files_in_workload = os.listdir(workload_1) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(file) + assert len(file_dict[file].index) + + assert file_dict.keys() == ALL_CSVS