diff --git a/tests/test_profile_general.py b/tests/test_profile_general.py index b763c72d90..691f356ee1 100644 --- a/tests/test_profile_general.py +++ b/tests/test_profile_general.py @@ -9,14 +9,13 @@ import re import shutil import inspect import sys +import test_utils omniperf = SourceFileLoader("omniperf", "src/omniperf").load_module() -workload_1 = os.path.realpath("workload") kernel_name_1 = "vecCopy(double*, double*, double*, int, int) [clone .kd]" app_1 = ["./tests/vcopy", "-n", "1048576", "-b", "256", "-i", "3"] num_kernels = 3 - dispatch_id = 0 DEFAULT_ABS_DIFF = 2.2 @@ -92,7 +91,7 @@ ROOF_ONLY_FILES = [ # logging function for threshold outliers set to false COUNTER_LOGGING = False -METRIC_LOGGING = True +METRIC_LOGGING = False # Absolute Difference < 2 CONSISTENT_ABS_METRIC_INDICES = [ @@ -147,6 +146,8 @@ CONSISTENT_REL_METRIC_INDICES = [ # "16.3.15", "17.1.0", ] +# check for parallel resource allocation +test_utils.check_resource_allocation() def metric_compare(test_name, errors_pd, baseline_df, run_df, threshold=5): @@ -240,27 +241,44 @@ def gpu_soc(): soc = gpu_soc() -# change to directory where baseline is at -Baseline_dir = os.path.realpath("Baseline_vcopy_" + soc) -if os.path.exists(Baseline_dir): - shutil.rmtree(Baseline_dir) -with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - Baseline_dir, - "--", - ] - + app_1, - ): - omniperf.main() +if METRIC_LOGGING: + # change to directory where baseline is at + Baseline_dir = os.path.realpath("Baseline_vcopy_" + soc) + if os.path.exists(Baseline_dir): + shutil.rmtree(Baseline_dir) + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + Baseline_dir, + "--", + ] + + app_1, + ): + omniperf.main() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + Baseline_dir, + "--", + ] + + app_1, + ): + omniperf.main() def log_counter(file_dict, test_name): for file in file_dict.keys(): @@ -305,7 +323,7 @@ def log_metric(test_name, thresholds, args=[]): Baseline_dir, ] + args - + ["--path", workload_1, "--report-diff", str(DEFAULT_REL_DIFF)], + + ["--path", workload_dir, "--report-diff", str(DEFAULT_REL_DIFF)], stdout=subprocess.PIPE, ) captured_output = t.communicate(timeout=1300)[0].decode("utf-8") @@ -371,10 +389,9 @@ def log_metric(test_name, thresholds, args=[]): if not error_df.empty: error_df.to_csv(Baseline_dir + "/metric_error_log.csv") - +@pytest.mark.misc def test_path(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) + workload_dir = test_utils.get_output_dir() with pytest.raises(SystemExit) as e: with patch( "sys.argv", @@ -385,7 +402,7 @@ def test_path(): "app_1", "-VVV", "--path", - workload_1, + workload_dir, "--", ] + app_1, @@ -394,13 +411,13 @@ def test_path(): # assert successful run assert e.value.code == 0 - files_in_workload = os.listdir(workload_1) + files_in_workload = os.listdir(workload_dir) # Check if csvs have data file_dict = {} for file in files_in_workload: if file.endswith(".csv"): - file_dict[file] = pd.read_csv(workload_1 + "/" + file, index_col=0) + file_dict[file] = pd.read_csv(workload_dir + "/" + file, index_col=0) # TODO: verify contents: we know function evaluated if not "sysinfo" in file: assert len(file_dict[file].index) >= num_kernels @@ -421,1797 +438,9 @@ def test_path(): ) -def test_kernel(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--kernel", - kernel_name_1, - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_kernel_summaries(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--kernel-summaries", - "vcopy", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_SQ(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "SQ", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_10.csv", - "pmc_perf_11.csv", - "pmc_perf_12.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "roofline.csv", - "sysinfo.csv", - "timestamps.csv", - ] - - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_SQC(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "SQC", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - expected_csvs = [ - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs.insert(5, "roofline.csv") - - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_TA(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "TA", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - - expected_csvs = [ - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs.insert(9, "roofline.csv") - - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_TD(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "TD", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - - expected_csvs = [ - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs = [ - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "roofline.csv", - "sysinfo.csv", - "timestamps.csv", - ] - - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_TCP(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "TCP", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - expected_csvs = [ - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs.insert(11, "roofline.csv") - - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_TCC(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "TCC", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - expected_csvs = [ - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_10.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs.insert(12, "roofline.csv") - - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_SPI(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "SPI", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - expected_csvs = [ - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs.insert(10, "roofline.csv") - - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_CPC(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "CPC", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - expected_csvs = [ - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs.insert(7, "roofline.csv") - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_CPF(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "CPF", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - expected_csvs = [ - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs.insert(5, "roofline.csv") - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_SQ_CPC(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "SQ", - "CPC", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_10.csv", - "pmc_perf_11.csv", - "pmc_perf_12.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "roofline.csv", - "sysinfo.csv", - "timestamps.csv", - ] - - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_SQ_TA(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "SQ", - "TA", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_10.csv", - "pmc_perf_11.csv", - "pmc_perf_12.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "roofline.csv", - "sysinfo.csv", - "timestamps.csv", - ] - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_SQ_SPI(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "SQ", - "SPI", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_10.csv", - "pmc_perf_11.csv", - "pmc_perf_12.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "roofline.csv", - "sysinfo.csv", - "timestamps.csv", - ] - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_SQ_SQC_TCP_CPC(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "SQ", - "SQC", - "TCP", - "CPC", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_10.csv", - "pmc_perf_11.csv", - "pmc_perf_12.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "roofline.csv", - "sysinfo.csv", - "timestamps.csv", - ] - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_ipblocks_SQ_SPI_TA_TCC_CPF(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--ipblocks", - "SQ", - "SPI", - "TA", - "TCC", - "CPF", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - - - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_10.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "sysinfo.csv", - "timestamps.csv", - ] - if soc == "mi200": - expected_csvs = [ - "SQ_IFETCH_LEVEL.csv", - "SQ_INST_LEVEL_LDS.csv", - "SQ_INST_LEVEL_SMEM.csv", - "SQ_INST_LEVEL_VMEM.csv", - "SQ_LEVEL_WAVES.csv", - "pmc_perf.csv", - "pmc_perf_0.csv", - "pmc_perf_1.csv", - "pmc_perf_10.csv", - "pmc_perf_11.csv", - "pmc_perf_12.csv", - "pmc_perf_2.csv", - "pmc_perf_3.csv", - "pmc_perf_4.csv", - "pmc_perf_5.csv", - "pmc_perf_6.csv", - "pmc_perf_7.csv", - "pmc_perf_8.csv", - "pmc_perf_9.csv", - "roofline.csv", - "sysinfo.csv", - "timestamps.csv", - ] - assert sorted(list(file_dict.keys())) == expected_csvs - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_dispatch_0(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--dispatch", - "0", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file and not "roofline" in file: - assert len(file_dict[file].index) == 1 - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - [ - "--dispatch", - "0", - ], - ) - - -def test_dispatch_0_1(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--dispatch", - "0:2", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file and not "roofline" in file: - assert len(file_dict[file].index) == 2 - - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ["--dispatch", "0", "1"], - ) - - -def test_dispatch_2(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--dispatch", - dispatch_id, - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file and not "roofline" in file: - assert len(file_dict[file].index) == 1 - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - [ - "--dispatch", - str(dispatch_id), - ], - ) - - -def test_kernel_verbose_0(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--kernel-verbose", - "0", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_kernel_verbose_1(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--kernel-verbose", - "1", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_kernel_verbose_2(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--kernel-verbose", - "2", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_kernel_verbose_3(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--kernel-verbose", - "3", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_kernel_verbose_4(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--kernel-verbose", - "4", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_kernel_verbose_5(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--kernel-verbose", - "5", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_join_type_grid(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--join-type", - "grid", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_join_type_kernel(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--join-type", - "kernel", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_device_0(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--device", - "0", - "--", - ] - + app_1, - ): - 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(workload_1 + "/" + file) - if not "sysinfo" in file: - if "roofline" in file: - assert len(file_dict[file].index) - else: - assert len(file_dict[file].index) >= num_kernels - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - +@pytest.mark.misc def test_no_roof(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) + workload_dir = test_utils.get_output_dir() with pytest.raises(SystemExit) as e: with patch( "sys.argv", @@ -2222,7 +451,7 @@ def test_no_roof(): "app_1", "-VVV", "--path", - workload_1, + workload_dir, "--no-roof", "--", ] @@ -2233,17 +462,17 @@ def test_no_roof(): # assert successful run assert e.value.code == 0 - files_in_workload = os.listdir(workload_1) + files_in_workload = os.listdir(workload_dir) # Check if csvs have data file_dict = {} for file in files_in_workload: if file.endswith(".csv"): - file_dict[file] = pd.read_csv(workload_1 + "/" + file) + file_dict[file] = pd.read_csv(workload_dir + "/" + file) if not "sysinfo" in file: assert len(file_dict[file].index) >= num_kernels if soc == "mi200": - + print(sorted(list(file_dict.keys()))) assert sorted(list(file_dict.keys())) == [ "SQ_IFETCH_LEVEL.csv", "SQ_INST_LEVEL_LDS.csv", @@ -2284,537 +513,9 @@ def test_no_roof(): ) -def test_sort_dispatches(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--roof-only", - "--sort", - "dispatches", - "--", - ] - + app_1, - ): - omniperf.main() - - if soc == "mi100": - # assert that it did not run - assert e.value.code >= 1 - # Do not continue testing - return - - # 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - elif file.endswith(".pdf"): - file_dict[file] = "pdf" - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_sort_kernels(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--roof-only", - "--sort", - "kernels", - "--", - ] - + app_1, - ): - omniperf.main() - if soc == "mi100": - # assert that it did not run - assert e.value.code >= 1 - # Do not continue testing - return - - # assert successful run - assert e.value.code == 0 - - files_in_workload = os.listdir(workload_1) - - file_dict = {} - # Check if csvs have data - for file in files_in_workload: - if file.endswith(".csv"): - file_dict[file] = pd.read_csv(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - elif file.endswith(".pdf"): - file_dict[file] = "pdf" - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_mem_levels_HBM(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--roof-only", - "--mem-level", - "HBM", - "--", - ] - + app_1, - ): - omniperf.main() - - if soc == "mi100": - # assert that it did not run - assert e.value.code >= 1 - # Do not continue testing - return - - # 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - elif file.endswith(".pdf"): - file_dict[file] = "pdf" - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_mem_levels_L2(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--roof-only", - "--mem-level", - "L2", - "--", - ] - + app_1, - ): - omniperf.main() - - if soc == "mi100": - # assert that it did not run - assert e.value.code >= 1 - # Do not continue testing - return - - # 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - elif file.endswith(".pdf"): - file_dict[file] = "pdf" - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_mem_levels_vL1D(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--roof-only", - "--mem-level", - "vL1D", - "--", - ] - + app_1, - ): - omniperf.main() - if soc == "mi100": - # assert that it did not run - assert e.value.code >= 1 - # Do not continue testing - return - - # 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - elif file.endswith(".pdf"): - file_dict[file] = "pdf" - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_mem_levels_LDS(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--roof-only", - "--mem-level", - "LDS", - "--", - ] - + app_1, - ): - omniperf.main() - if soc == "mi100": - # assert that it did not run - assert e.value.code >= 1 - # Do not continue testing - return - - # 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - elif file.endswith(".pdf"): - file_dict[file] = "pdf" - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_mem_levels_HBM_LDS(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--roof-only", - "--mem-level", - "HBM", - "LDS", - "--", - ] - + app_1, - ): - omniperf.main() - if soc == "mi100": - # assert that it did not run - assert e.value.code >= 1 - # Do not continue testing - return - - # 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - elif file.endswith(".pdf"): - file_dict[file] = "pdf" - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_mem_levels_vL1D_LDS(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--roof-only", - "--mem-level", - "vL1D", - "LDS", - "--", - ] - + app_1, - ): - omniperf.main() - if soc == "mi100": - # assert that it did not run - assert e.value.code >= 1 - # Do not continue testing - return - - # 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - elif file.endswith(".pdf"): - file_dict[file] = "pdf" - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - -def test_mem_levels_L2_vL1D_LDS(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) - with pytest.raises(SystemExit) as e: - with patch( - "sys.argv", - [ - "omniperf", - "profile", - "-n", - "app_1", - "-VVV", - "--path", - workload_1, - "--roof-only", - "--mem-level", - "L2", - "vL1D", - "LDS", - "--", - ] - + app_1, - ): - omniperf.main() - if soc == "mi100": - # assert that it did not run - assert e.value.code >= 1 - # Do not continue testing - return - # 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(workload_1 + "/" + file) - if not "sysinfo" in file: - assert len(file_dict[file].index) >= num_kernels - elif file.endswith(".pdf"): - file_dict[file] = "pdf" - if soc == "mi200": - - assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES - else: - assert sorted(list(file_dict.keys())) == ALL_CSVS - - if COUNTER_LOGGING: - log_counter(file_dict, inspect.stack()[0][3]) - - if METRIC_LOGGING: - log_metric( - inspect.stack()[0][3], - {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, - ) - - +@pytest.mark.misc def test_kernel_names(): - if os.path.exists(workload_1): - shutil.rmtree(workload_1) + workload_dir = test_utils.get_output_dir() with pytest.raises(SystemExit) as e: with patch( "sys.argv", @@ -2825,7 +526,7 @@ def test_kernel_names(): "app_1", "-VVV", "--path", - workload_1, + workload_dir, "--roof-only", "--kernel-names", "--", @@ -2842,19 +543,19 @@ def test_kernel_names(): # assert successful run assert e.value.code == 0 - files_in_workload = os.listdir(workload_1) + files_in_workload = os.listdir(workload_dir) # Check if csvs have data file_dict = {} for file in files_in_workload: if file.endswith(".csv"): - file_dict[file] = pd.read_csv(workload_1 + "/" + file) + file_dict[file] = pd.read_csv(workload_dir + "/" + file) if not "sysinfo" in file: assert len(file_dict[file].index) >= num_kernels elif file.endswith(".pdf"): file_dict[file] = "pdf" if soc == "mi200": - + print(sorted(list(file_dict.keys()))) assert sorted(list(file_dict.keys())) == [ "empirRoof_gpu-ALL_fp32.pdf", "empirRoof_gpu-ALL_int8_fp16.pdf", @@ -2878,3 +579,2460 @@ def test_kernel_names(): inspect.stack()[0][3], {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, ) + +@pytest.mark.kernel_execution +def test_kernel(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--kernel", + kernel_name_1, + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.kernel_execution +def test_kernel_summaries(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--kernel-summaries", + "vcopy", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_SQ(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "SQ", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_10.csv", + "pmc_perf_11.csv", + "pmc_perf_12.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "roofline.csv", + "sysinfo.csv", + "timestamps.csv", + ] + + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_SQC(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "SQC", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + expected_csvs = [ + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs.insert(5, "roofline.csv") + + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_TA(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "TA", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + + expected_csvs = [ + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs.insert(9, "roofline.csv") + + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_TD(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "TD", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + + expected_csvs = [ + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs = [ + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "roofline.csv", + "sysinfo.csv", + "timestamps.csv", + ] + + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_TCP(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "TCP", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + expected_csvs = [ + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs.insert(11, "roofline.csv") + + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_TCC(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "TCC", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + expected_csvs = [ + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_10.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs.insert(12, "roofline.csv") + + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_SPI(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "SPI", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + expected_csvs = [ + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs.insert(10, "roofline.csv") + + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_CPC(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "CPC", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + expected_csvs = [ + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs.insert(7, "roofline.csv") + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_CPF(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "CPF", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + expected_csvs = [ + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs.insert(5, "roofline.csv") + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_SQ_CPC(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "SQ", + "CPC", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_10.csv", + "pmc_perf_11.csv", + "pmc_perf_12.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "roofline.csv", + "sysinfo.csv", + "timestamps.csv", + ] + + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_SQ_TA(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "SQ", + "TA", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_10.csv", + "pmc_perf_11.csv", + "pmc_perf_12.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "roofline.csv", + "sysinfo.csv", + "timestamps.csv", + ] + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_SQ_SPI(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "SQ", + "SPI", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_10.csv", + "pmc_perf_11.csv", + "pmc_perf_12.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "roofline.csv", + "sysinfo.csv", + "timestamps.csv", + ] + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_SQ_SQC_TCP_CPC(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "SQ", + "SQC", + "TCP", + "CPC", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_10.csv", + "pmc_perf_11.csv", + "pmc_perf_12.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "roofline.csv", + "sysinfo.csv", + "timestamps.csv", + ] + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.ipblocks +def test_ipblocks_SQ_SPI_TA_TCC_CPF(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--ipblocks", + "SQ", + "SPI", + "TA", + "TCC", + "CPF", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + + + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_10.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "sysinfo.csv", + "timestamps.csv", + ] + if soc == "mi200": + expected_csvs = [ + "SQ_IFETCH_LEVEL.csv", + "SQ_INST_LEVEL_LDS.csv", + "SQ_INST_LEVEL_SMEM.csv", + "SQ_INST_LEVEL_VMEM.csv", + "SQ_LEVEL_WAVES.csv", + "pmc_perf.csv", + "pmc_perf_0.csv", + "pmc_perf_1.csv", + "pmc_perf_10.csv", + "pmc_perf_11.csv", + "pmc_perf_12.csv", + "pmc_perf_2.csv", + "pmc_perf_3.csv", + "pmc_perf_4.csv", + "pmc_perf_5.csv", + "pmc_perf_6.csv", + "pmc_perf_7.csv", + "pmc_perf_8.csv", + "pmc_perf_9.csv", + "roofline.csv", + "sysinfo.csv", + "timestamps.csv", + ] + assert sorted(list(file_dict.keys())) == expected_csvs + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.dispatch +def test_dispatch_0(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--dispatch", + "0", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file and not "roofline" in file: + assert len(file_dict[file].index) == 1 + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + [ + "--dispatch", + "0", + ], + ) + + +@pytest.mark.dispatch +def test_dispatch_0_1(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--dispatch", + "0:2", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file and not "roofline" in file: + assert len(file_dict[file].index) == 2 + + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ["--dispatch", "0", "1"], + ) + + +@pytest.mark.dispatch +def test_dispatch_2(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--dispatch", + dispatch_id, + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file and not "roofline" in file: + assert len(file_dict[file].index) == 1 + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + [ + "--dispatch", + str(dispatch_id), + ], + ) + + +@pytest.mark.verbosity +def test_kernel_verbose_0(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--kernel-verbose", + "0", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.verbosity +def test_kernel_verbose_1(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--kernel-verbose", + "1", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.verbosity +def test_kernel_verbose_2(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--kernel-verbose", + "2", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.verbosity +def test_kernel_verbose_3(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--kernel-verbose", + "3", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.verbosity +def test_kernel_verbose_4(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--kernel-verbose", + "4", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.verbosity +def test_kernel_verbose_5(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--kernel-verbose", + "5", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.join +def test_join_type_grid(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--join-type", + "grid", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.join +def test_join_type_kernel(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--join-type", + "kernel", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +def test_device_0(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--device", + "0", + "--", + ] + + app_1, + ): + omniperf.main() + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + if "roofline" in file: + assert len(file_dict[file].index) + else: + assert len(file_dict[file].index) >= num_kernels + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ALL_CSVS_MI200 + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +# def test_no_roof(): +# if os.path.exists(workload_1): +# shutil.rmtree(workload_1) +# with pytest.raises(SystemExit) as e: +# with patch( +# "sys.argv", +# [ +# "omniperf", +# "profile", +# "-n", +# "app_1", +# "-VVV", +# "--path", +# workload_1, +# "--no-roof", +# "--", +# ] +# + app_1, +# ): +# 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(workload_1 + "/" + file) +# if not "sysinfo" in file: +# assert len(file_dict[file].index) >= num_kernels +# if soc == "mi200": + +# assert sorted(list(file_dict.keys())) == [ +# "SQ_IFETCH_LEVEL.csv", +# "SQ_INST_LEVEL_LDS.csv", +# "SQ_INST_LEVEL_SMEM.csv", +# "SQ_INST_LEVEL_VMEM.csv", +# "SQ_LEVEL_WAVES.csv", +# "pmc_perf.csv", +# "pmc_perf_0.csv", +# "pmc_perf_1.csv", +# "pmc_perf_10.csv", +# "pmc_perf_11.csv", +# "pmc_perf_12.csv", +# "pmc_perf_13.csv", +# "pmc_perf_14.csv", +# "pmc_perf_15.csv", +# "pmc_perf_16.csv", +# "pmc_perf_2.csv", +# "pmc_perf_3.csv", +# "pmc_perf_4.csv", +# "pmc_perf_5.csv", +# "pmc_perf_6.csv", +# "pmc_perf_7.csv", +# "pmc_perf_8.csv", +# "pmc_perf_9.csv", +# "sysinfo.csv", +# "timestamps.csv", +# ] +# else: +# assert sorted(list(file_dict.keys())) == ALL_CSVS + +# if COUNTER_LOGGING: +# log_counter(file_dict, inspect.stack()[0][3]) + +# if METRIC_LOGGING: +# log_metric( +# inspect.stack()[0][3], +# {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, +# ) + + +@pytest.mark.sort +def test_sort_dispatches(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--roof-only", + "--sort", + "dispatches", + "--", + ] + + app_1, + ): + omniperf.main() + + if soc == "mi100": + # assert that it did not run + assert e.value.code >= 1 + # Do not continue testing + return + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + elif file.endswith(".pdf"): + file_dict[file] = "pdf" + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.sort +def test_sort_kernels(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--roof-only", + "--sort", + "kernels", + "--", + ] + + app_1, + ): + omniperf.main() + if soc == "mi100": + # assert that it did not run + assert e.value.code >= 1 + # Do not continue testing + return + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + file_dict = {} + # Check if csvs have data + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + elif file.endswith(".pdf"): + file_dict[file] = "pdf" + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.mem +def test_mem_levels_HBM(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--roof-only", + "--mem-level", + "HBM", + "--", + ] + + app_1, + ): + omniperf.main() + + if soc == "mi100": + # assert that it did not run + assert e.value.code >= 1 + # Do not continue testing + return + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + elif file.endswith(".pdf"): + file_dict[file] = "pdf" + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.mem +def test_mem_levels_L2(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--roof-only", + "--mem-level", + "L2", + "--", + ] + + app_1, + ): + omniperf.main() + + if soc == "mi100": + # assert that it did not run + assert e.value.code >= 1 + # Do not continue testing + return + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + elif file.endswith(".pdf"): + file_dict[file] = "pdf" + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.mem +def test_mem_levels_vL1D(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--roof-only", + "--mem-level", + "vL1D", + "--", + ] + + app_1, + ): + omniperf.main() + if soc == "mi100": + # assert that it did not run + assert e.value.code >= 1 + # Do not continue testing + return + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + elif file.endswith(".pdf"): + file_dict[file] = "pdf" + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.mem +def test_mem_levels_LDS(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--roof-only", + "--mem-level", + "LDS", + "--", + ] + + app_1, + ): + omniperf.main() + if soc == "mi100": + # assert that it did not run + assert e.value.code >= 1 + # Do not continue testing + return + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + elif file.endswith(".pdf"): + file_dict[file] = "pdf" + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.mem +def test_mem_levels_HBM_LDS(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--roof-only", + "--mem-level", + "HBM", + "LDS", + "--", + ] + + app_1, + ): + omniperf.main() + if soc == "mi100": + # assert that it did not run + assert e.value.code >= 1 + # Do not continue testing + return + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + elif file.endswith(".pdf"): + file_dict[file] = "pdf" + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.mem +def test_mem_levels_vL1D_LDS(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--roof-only", + "--mem-level", + "vL1D", + "LDS", + "--", + ] + + app_1, + ): + omniperf.main() + if soc == "mi100": + # assert that it did not run + assert e.value.code >= 1 + # Do not continue testing + return + + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + elif file.endswith(".pdf"): + file_dict[file] = "pdf" + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +@pytest.mark.mem +def test_mem_levels_L2_vL1D_LDS(): + workload_dir = test_utils.get_output_dir() + with pytest.raises(SystemExit) as e: + with patch( + "sys.argv", + [ + "omniperf", + "profile", + "-n", + "app_1", + "-VVV", + "--path", + workload_dir, + "--roof-only", + "--mem-level", + "L2", + "vL1D", + "LDS", + "--", + ] + + app_1, + ): + omniperf.main() + if soc == "mi100": + # assert that it did not run + assert e.value.code >= 1 + # Do not continue testing + return + # assert successful run + assert e.value.code == 0 + + files_in_workload = os.listdir(workload_dir) + + # Check if csvs have data + file_dict = {} + for file in files_in_workload: + if file.endswith(".csv"): + file_dict[file] = pd.read_csv(workload_dir + "/" + file) + if not "sysinfo" in file: + assert len(file_dict[file].index) >= num_kernels + elif file.endswith(".pdf"): + file_dict[file] = "pdf" + if soc == "mi200": + + assert sorted(list(file_dict.keys())) == ROOF_ONLY_FILES + else: + assert sorted(list(file_dict.keys())) == ALL_CSVS + + if COUNTER_LOGGING: + log_counter(file_dict, inspect.stack()[0][3]) + + if METRIC_LOGGING: + log_metric( + inspect.stack()[0][3], + {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, + ) + + +# def test_kernel_names(): +# if os.path.exists(workload_1): +# shutil.rmtree(workload_1) +# with pytest.raises(SystemExit) as e: +# with patch( +# "sys.argv", +# [ +# "omniperf", +# "profile", +# "-n", +# "app_1", +# "-VVV", +# "--path", +# workload_1, +# "--roof-only", +# "--kernel-names", +# "--", +# ] +# + app_1, +# ): +# omniperf.main() + +# if soc == "mi100": +# # assert that it did not run +# assert e.value.code >= 1 +# # Do not continue testing +# return +# # 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(workload_1 + "/" + file) +# if not "sysinfo" in file: +# assert len(file_dict[file].index) >= num_kernels +# elif file.endswith(".pdf"): +# file_dict[file] = "pdf" +# if soc == "mi200": + +# assert sorted(list(file_dict.keys())) == [ +# "empirRoof_gpu-ALL_fp32.pdf", +# "empirRoof_gpu-ALL_int8_fp16.pdf", +# "kernelName_legend.pdf", +# "pmc_perf.csv", +# "pmc_perf_0.csv", +# "pmc_perf_1.csv", +# "pmc_perf_2.csv", +# "roofline.csv", +# "sysinfo.csv", +# "timestamps.csv", +# ] +# else: +# assert sorted(list(file_dict.keys())) == ALL_CSVS + +# if COUNTER_LOGGING: +# log_counter(file_dict, inspect.stack()[0][3]) + +# if METRIC_LOGGING: +# log_metric( +# inspect.stack()[0][3], +# {"default": {"absolute": DEFAULT_ABS_DIFF, "relative": DEFAULT_REL_DIFF}}, +# )