diff --git a/src/config.py b/src/config.py index 5cb8b279cf..88cde44384 100644 --- a/src/config.py +++ b/src/config.py @@ -32,4 +32,4 @@ HIDDEN_COLUMNS = ["coll_level"] HIDDEN_COLUMNS_CLI = ["Description", "coll_level"] HIDDEN_SECTIONS = [400, 1900, 2000] -TIME_UNITS = {"s": 10**9, "ms": 10**6, "us": 10**3, "ns": 1} +TIME_UNITS = {"s": 10 ** 9, "ms": 10 ** 6, "us": 10 ** 3, "ns": 1} diff --git a/src/rocprof_compute_soc/soc_base.py b/src/rocprof_compute_soc/soc_base.py index 334dd89f5f..1d8b95a43e 100644 --- a/src/rocprof_compute_soc/soc_base.py +++ b/src/rocprof_compute_soc/soc_base.py @@ -405,9 +405,10 @@ class OmniSoC_Base: subvariable_matches = set() for var in variable_matches: if var in build_in_vars: - hw_counter_matches_vars, variable_matches_vars = ( - self.parse_counters_text(build_in_vars[var]) - ) + ( + hw_counter_matches_vars, + variable_matches_vars, + ) = self.parse_counters_text(build_in_vars[var]) hw_counter_matches.update(hw_counter_matches_vars) subvariable_matches.update(variable_matches_vars) # process new found variables diff --git a/src/utils/roofline_calc.py b/src/utils/roofline_calc.py index c141c349ad..4fb715f1e5 100644 --- a/src/utils/roofline_calc.py +++ b/src/utils/roofline_calc.py @@ -259,11 +259,25 @@ def calc_ai(mspec, sort_type, ret_df): df = df.sort_values(by=["Kernel_Name"]) df = df.reset_index(drop=True) - total_flops = valu_flops = mfma_flops_f6f4 = mfma_flops_f8 = mfma_flops_bf16 = ( + total_flops = ( + valu_flops + ) = ( + mfma_flops_f6f4 + ) = ( + mfma_flops_f8 + ) = ( + mfma_flops_bf16 + ) = ( mfma_flops_f16 - ) = mfma_iops_i8 = mfma_flops_f32 = mfma_flops_f64 = lds_data = L1cache_data = ( - L2cache_data - ) = hbm_data = calls = totalDuration = avgDuration = 0.0 + ) = ( + mfma_iops_i8 + ) = ( + mfma_flops_f32 + ) = ( + mfma_flops_f64 + ) = ( + lds_data + ) = L1cache_data = L2cache_data = hbm_data = calls = totalDuration = avgDuration = 0.0 kernelName = "" @@ -484,13 +498,27 @@ def calc_ai(mspec, sort_type, ret_df): kernelName, idx, calls ) ) - total_flops = valu_flops = mfma_flops_f6f4 = mfma_flops_f8 = ( + total_flops = ( + valu_flops + ) = ( + mfma_flops_f6f4 + ) = ( + mfma_flops_f8 + ) = ( mfma_flops_bf16 - ) = mfma_flops_f16 = mfma_iops_i8 = mfma_flops_f32 = mfma_flops_f64 = ( + ) = ( + mfma_flops_f16 + ) = ( + mfma_iops_i8 + ) = ( + mfma_flops_f32 + ) = ( + mfma_flops_f64 + ) = ( lds_data - ) = L1cache_data = L2cache_data = hbm_data = calls = totalDuration = ( - avgDuration - ) = 0.0 + ) = ( + L1cache_data + ) = L2cache_data = hbm_data = calls = totalDuration = avgDuration = 0.0 if sort_type == "dispatches": myList.append( @@ -514,13 +542,27 @@ def calc_ai(mspec, sort_type, ret_df): avgDuration, ) ) - total_flops = valu_flops = mfma_flops_f6f4 = mfma_flops_f8 = ( + total_flops = ( + valu_flops + ) = ( + mfma_flops_f6f4 + ) = ( + mfma_flops_f8 + ) = ( mfma_flops_bf16 - ) = mfma_flops_f16 = mfma_iops_i8 = mfma_flops_f32 = mfma_flops_f64 = ( + ) = ( + mfma_flops_f16 + ) = ( + mfma_iops_i8 + ) = ( + mfma_flops_f32 + ) = ( + mfma_flops_f64 + ) = ( lds_data - ) = L1cache_data = L2cache_data = hbm_data = calls = totalDuration = ( - avgDuration - ) = 0.0 + ) = ( + L1cache_data + ) = L2cache_data = hbm_data = calls = totalDuration = avgDuration = 0.0 myList.sort(key=lambda x: x.totalDuration, reverse=True) diff --git a/tests/test_analyze_commands.py b/tests/test_analyze_commands.py index 2105b87366..13106f93ca 100644 --- a/tests/test_analyze_commands.py +++ b/tests/test_analyze_commands.py @@ -42,7 +42,7 @@ indirs = [ "tests/workloads/vcopy/MI350", ] -time_units = {"s": 10**9, "ms": 10**6, "us": 10**3, "ns": 1} +time_units = {"s": 10 ** 9, "ms": 10 ** 6, "us": 10 ** 3, "ns": 1} @pytest.mark.misc @@ -500,7 +500,15 @@ def test_col_2(binary_handler_analyze_rocprof_compute): for dir in indirs: workload_dir = test_utils.setup_workload_dir(dir) code = binary_handler_analyze_rocprof_compute( - ["analyze", "--path", workload_dir, "--cols", "2", "--include-cols", "Description"] + [ + "analyze", + "--path", + workload_dir, + "--cols", + "2", + "--include-cols", + "Description", + ] ) assert code == 0 @@ -1300,9 +1308,9 @@ def test_mathematical_correctness_all_units(sample_time_data, original_ns_values from utils.tty import convert_time_columns test_cases = [ - ("s", 10**9), # 1 second = 10^9 nanoseconds - ("ms", 10**6), # 1 millisecond = 10^6 nanoseconds - ("us", 10**3), # 1 microsecond = 10^3 nanoseconds + ("s", 10 ** 9), # 1 second = 10^9 nanoseconds + ("ms", 10 ** 6), # 1 millisecond = 10^6 nanoseconds + ("us", 10 ** 3), # 1 microsecond = 10^3 nanoseconds ("ns", 1), # 1 nanosecond = 1 nanosecond ] diff --git a/tests/test_autogen_config.py b/tests/test_autogen_config.py index 7b09ede7e9..1c623544e8 100644 --- a/tests/test_autogen_config.py +++ b/tests/test_autogen_config.py @@ -19,21 +19,27 @@ def test_modification_time(): Path("src/rocprof_compute_soc/analysis_configs").glob("gfx*/*.yaml") ) - assert ( - unified_config_path.stat().st_mtime < hash_path.stat().st_mtime + unified_config_time = unified_config_path.stat().st_mtime + + def is_autogenerated(filepath): + # Autogenerated filepath should be newer than the unified config + # Autogenerated filepath can be older than unified config by at most a second due to file system delays + return unified_config_time - filepath.stat().st_mtime < 1 + + assert is_autogenerated( + hash_path ), f"{unified_config_path} is not older than {hash_path}" - assert ( - unified_config_path.stat().st_mtime < docs_config_path.stat().st_mtime + assert is_autogenerated( + docs_config_path ), f"{unified_config_path} is not older than {docs_config_path}" for analysis_config_path in analysis_config_paths: - assert ( - unified_config_path.stat().st_mtime < analysis_config_path.stat().st_mtime + assert is_autogenerated( + analysis_config_path ), f"{unified_config_path} is not older than {analysis_config_path}" # Ensure hash map consistency - with open(hash_path, "r") as f: hash_map = yaml.safe_load(f) for file, hash in hash_map.items(): diff --git a/tests/test_db_connector.py b/tests/test_db_connector.py index 6d7908df16..7a6aa2171f 100644 --- a/tests/test_db_connector.py +++ b/tests/test_db_connector.py @@ -53,7 +53,6 @@ The tests use mocks instead of a real MongoDB server for speed and reliability. class TestDatabaseConnector: - @pytest.fixture def mock_args_import(self): """Mock arguments for import operation""" @@ -210,9 +209,9 @@ class TestDatabaseConnector: with patch.object(connector, "prep_import") as mock_prep: mock_prep.return_value = None - connector.connection_info["db"] = ( - "rocprofiler-compute_test_team_test_workload_MI100" - ) + connector.connection_info[ + "db" + ] = "rocprofiler-compute_test_team_test_workload_MI100" connector.db_import() diff --git a/tests/test_profile_general.py b/tests/test_profile_general.py index 8f03888ca6..741d52d8b7 100644 --- a/tests/test_profile_general.py +++ b/tests/test_profile_general.py @@ -742,29 +742,6 @@ def test_roof_rocpd(binary_handler_profile_rocprof_compute): test_utils.clean_output_dir(config["cleanup"], workload_dir) -@pytest.mark.misc -def test_roofline_kernel_names_validation_error(binary_handler_profile_rocprof_compute): - """ - Test validate_parameters() error: --roof-only is required for --kernel-names - This should trigger console_error("--roof-only is required for --kernel-names") - """ - if soc in ("MI100"): - # roofline is not supported on MI100 - pytest.skip("Skipping roofline test for MI100") - return - - options = ["--device", "0", "--kernel-names"] # missing --roof-only - workload_dir = test_utils.get_output_dir() - - returncode = binary_handler_profile_rocprof_compute( - config, workload_dir, options, check_success=False, roof=True - ) - - assert returncode != 0 - - test_utils.clean_output_dir(config["cleanup"], workload_dir) - - @pytest.mark.misc def test_roofline_workload_dir_not_set_error(): """