diff --git a/build_tools/github_actions/github_actions_utils.py b/build_tools/github_actions/github_actions_utils.py index 10ef294a23f..ace46d21e3a 100644 --- a/build_tools/github_actions/github_actions_utils.py +++ b/build_tools/github_actions/github_actions_utils.py @@ -596,40 +596,6 @@ def get_first_gpu_architecture(env=None, therock_bin_dir: str | None = None) -> raise RuntimeError("No GPU architecture found in rocminfo output") -def find_matching_gpu_arch(gpu_arch: str, available_gpu_archs: set[str]) -> str | None: - """ - Find the most specific GPU architecture in the set that matches the given GPU. - - Tries in order from most specific to least specific: - # Example: - # find_matching_gpu_arch('gfx1151', {'gfx1151', 'gfx115X', 'gfx11X'}) gives 'gfx1151' - # find_matching_gpu_arch('gfx1151', {'gfx1150', 'gfx94X', 'gfx11X'}) gives 'gfx11X' - - Wildcard matches (gfx115X, gfx11X, etc.) - - Returns the matching architecture string or None if no match found. - """ - # First, try exact match - if gpu_arch in available_gpu_archs: - return gpu_arch - - # Generate possible wildcard patterns from most specific to least specific - # For gfx1151: try gfx115X, gfx11X - possible_patterns = [] - arch_str = gpu_arch - - # Generate patterns by replacing characters with X from right to left - for i in range(len(arch_str) - 1, 1, -1): - pattern = arch_str[:i] + "X" - possible_patterns.append(pattern) - - # Try each pattern - for pattern in possible_patterns: - if pattern in available_gpu_archs: - return pattern - - return None - - def is_asan(): """Using artifact_group, determines if this is an asan build""" ARTIFACT_GROUP = os.getenv("ARTIFACT_GROUP", "") diff --git a/build_tools/github_actions/test_executable_scripts/README.md b/build_tools/github_actions/test_executable_scripts/README.md index 391dabadff3..7228b510f29 100644 --- a/build_tools/github_actions/test_executable_scripts/README.md +++ b/build_tools/github_actions/test_executable_scripts/README.md @@ -47,7 +47,7 @@ ______________________________________________________________________ 1. **Resolve GPU arch** Parse `AMDGPU_FAMILIES` for the first `gfx...` token (e.g. `gfx1151`). If missing or generic, the script will exclude all GPU-specific tests (`-LE ex_gpu`). 1. **Match GPU to suite** - Using `find_matching_gpu_arch()` (from `github_actions_utils`): + Using `find_matching_gpu_arch()` (defined in `test_runner.py`): - Prefer **exact** match in the discovered set (e.g. `gfx1151`). - Else try **wildcard** patterns from most to least specific (e.g. for `gfx1151`: `gfx115X`, then `gfx11X`). diff --git a/build_tools/github_actions/test_executable_scripts/test_runner.py b/build_tools/github_actions/test_executable_scripts/test_runner.py index 6271cbb9de0..b80b51c0e23 100644 --- a/build_tools/github_actions/test_executable_scripts/test_runner.py +++ b/build_tools/github_actions/test_executable_scripts/test_runner.py @@ -23,9 +23,6 @@ import shlex from pathlib import Path -sys.path.insert(0, os.fspath(Path(__file__).resolve().parent.parent)) -from github_actions_utils import find_matching_gpu_arch - THEROCK_BIN_DIR = os.getenv("THEROCK_BIN_DIR") SCRIPT_DIR = Path(__file__).resolve().parent THEROCK_DIR = SCRIPT_DIR.parent.parent.parent @@ -89,6 +86,31 @@ ############################################## +def find_matching_gpu_arch(gpu_arch: str, available_gpu_archs: set[str]) -> str | None: + """ + Find the most specific GPU architecture in the set that matches the given GPU. + + Tries in order from most specific to least specific: + # Example: + # find_matching_gpu_arch('gfx1151', {'gfx1151', 'gfx115X', 'gfx11X'}) gives 'gfx1151' + # find_matching_gpu_arch('gfx1151', {'gfx1150', 'gfx94X', 'gfx11X'}) gives 'gfx11X' + - Wildcard matches (gfx115X, gfx11X, etc.) + + Returns the matching architecture string or None if no match found. + """ + if gpu_arch in available_gpu_archs: + return gpu_arch + + # Start matching from the end (gfx115X) and go back till the 5th character (gfx11X) + # Return the top matching pattern + for i in range(len(gpu_arch) - 1, 4, -1): + pattern = gpu_arch[:i] + "X" + if pattern in available_gpu_archs: + return pattern + + return None + + def get_available_gpu_suite_tests(): """ Get all available GPU architecture labels from ctest --print-labels.