Repository navigation
[rocjitsu][ci] Add cpu thread budget in CI #12652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
RattataKing
wants to merge
5
commits into
develop
from
users/RattataKing/rocjitsu-asan-ubsan-timeout
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d4fcd2e
Restore corpus simulator CPU budget limits
RattataKing 0e6730f
Align name
RattataKing 24f9ecc
Fix name
RattataKing 7c35b26
Preserve automatic corpus thread budget sizing
RattataKing c6ce2e0
Reorder step and extend timeout
RattataKing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
emulation/rocjitsu/tests/corpus/test-run-corpus-tests.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| #!/usr/bin/env python3 | ||
| # Copyright (c) 2026 Advanced Micro Devices, Inc. | ||
| # SPDX-License-Identifier: MIT | ||
| # Test corpus budget forwarding without launching simulator workloads. | ||
| # Usage: python tests/corpus/test-run-corpus-tests.py | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
| import shlex | ||
| import subprocess | ||
| import tempfile | ||
| import unittest | ||
|
|
||
| SOURCE = Path(__file__).resolve().parents[2] | ||
| SCRIPT = SOURCE / 'tests/corpus/run-corpus-tests.sh' | ||
|
|
||
|
|
||
| class ThreadBudgetTests(unittest.TestCase): | ||
| def setUp(self): | ||
| self.temporary = tempfile.TemporaryDirectory() | ||
| self.addCleanup(self.temporary.cleanup) | ||
| self.root = Path(self.temporary.name) | ||
| binary = self.root / 'bin' | ||
| binary.mkdir() | ||
| stubs = { | ||
| 'rocjitsu': '#!/bin/bash\nprintf "%s\\0" "$@" >> "$PREFLIGHT_LOG"\n', | ||
| 'pytest': ( | ||
| '#!/bin/bash\n' | ||
| 'printf "%s\\0" "$@" >> "$ARGV_LOG"\n' | ||
| 'printf "\\0" >> "$ARGV_LOG"\n' | ||
| 'if [[ "$*" == *--junitxml* && "${FORCE_RETRY:-0}" == 1 ]]; then exit 1; fi\n' | ||
| ), | ||
| } | ||
| for name, content in stubs.items(): | ||
| path = binary / name | ||
| path.write_text(content) | ||
| path.chmod(0o755) | ||
| symbolizer = self.root / 'lib/llvm/bin/llvm-symbolizer' | ||
| symbolizer.parent.mkdir(parents=True) | ||
| symbolizer.write_text('#!/bin/bash\nexit 0\n') | ||
| symbolizer.chmod(0o755) | ||
| (self.root / 'lib/libamdhip64.so').touch() | ||
| self.env = dict( | ||
| os.environ, | ||
| PATH=f'{binary}:{os.environ["PATH"]}', | ||
| ROCM_PATH=str(self.root), | ||
| ROCJITSU_SOURCE_DIR=str(SOURCE), | ||
| ARGV_LOG=str(self.root / 'argv'), | ||
| PREFLIGHT_LOG=str(self.root / 'preflight'), | ||
| ) | ||
|
|
||
| def run_script(self, *args): | ||
| return subprocess.run( | ||
| ['bash', str(SCRIPT), *args], | ||
| cwd=self.root, | ||
| env=self.env, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
|
|
||
| def assert_budget(self, argv, budget): | ||
| self.assertNotIn('--rocjitsu-thread-budget', argv) | ||
| if budget is None: | ||
| self.assertNotIn('--cpu-thread-budget', argv) | ||
| else: | ||
| self.assertEqual(argv.count('--cpu-thread-budget'), 1) | ||
| self.assertEqual(argv[argv.index('--cpu-thread-budget') + 1], budget) | ||
|
|
||
| def test_budget_across_initial_runs_reruns_and_preflight(self): | ||
| for budget in (None, '0', '3'): | ||
| for sanitizer in ('none', 'clang-asan', 'gcc-asan'): | ||
| with self.subTest(budget=budget, sanitizer=sanitizer): | ||
| (self.root / 'argv').write_bytes(b'') | ||
| (self.root / 'preflight').write_bytes(b'') | ||
| self.env['FORCE_RETRY'] = '1' | ||
| args = ['--rerun-failed', '--sanitizer', sanitizer] | ||
| if budget is not None: | ||
| args += ['--rocjitsu-thread-budget', budget] | ||
| result = self.run_script(*args) | ||
| # A successful retry must not hide the original failure. | ||
| self.assertEqual(result.returncode, 1, result.stderr) | ||
| calls = (self.root / 'argv').read_bytes().split(b'\0\0') | ||
| wrappers = [] | ||
| for call in calls: | ||
| argv = [item.decode() for item in call.split(b'\0')] | ||
| if '--run-wrapper' in argv: | ||
| wrapper = shlex.split(argv[argv.index('--run-wrapper') + 1]) | ||
| self.assert_budget(wrapper, budget) | ||
| wrappers.append(wrapper) | ||
| self.assertEqual(len(wrappers), 10) | ||
| preflight = (self.root / 'preflight').read_bytes() | ||
| if sanitizer == 'clang-asan': | ||
| self.assertTrue(preflight) | ||
| self.assert_budget(preflight.decode().split('\0'), budget) | ||
| else: | ||
| self.assertFalse(preflight) | ||
|
|
||
| def test_invalid_budget(self): | ||
| for value in ('', '-1', 'abc'): | ||
| with self.subTest(value=value): | ||
| result = self.run_script('--rocjitsu-thread-budget', value) | ||
| self.assertNotEqual(result.returncode, 0) | ||
| self.assertIn('requires a non-negative integer', result.stderr) | ||
| result = self.run_script('--rocjitsu-thread-budget') | ||
| self.assertNotEqual(result.returncode, 0) | ||
| self.assertIn('--rocjitsu-thread-budget requires a value', result.stderr) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking at this again, I'm not convinced we need tests that test our tests... I'd drop this.