Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions build_tools/github_actions/github_actions_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down
32 changes: 29 additions & 3 deletions build_tools/github_actions/test_executable_scripts/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -89,6 +86,35 @@
##############################################


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

possible_patterns = []
arch_str = gpu_arch

for i in range(len(arch_str) - 1, 1, -1):
pattern = arch_str[:i] + "X"
possible_patterns.append(pattern)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: reversed iteration order makes this code tricky to read. Could be worth a comment or something like sorting/reversing then iterating


for pattern in possible_patterns:
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.
Expand Down
Loading