Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tsoc
superbenchmark
Commits
655519cb
Commit
655519cb
authored
Apr 18, 2026
by
one
Browse files
Runner: validate MPI bind-to option and cover configurable bind-to in tests
parent
eea26d0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
+69
-0
superbench/runner/runner.py
superbench/runner/runner.py
+10
-0
tests/runner/test_runner.py
tests/runner/test_runner.py
+59
-0
No files found.
superbench/runner/runner.py
View file @
655519cb
...
@@ -65,6 +65,14 @@ def __set_logger(self, filename):
...
@@ -65,6 +65,14 @@ def __set_logger(self, filename):
"""
"""
SuperBenchLogger
.
add_handler
(
logger
.
logger
,
filename
=
str
(
self
.
_output_path
/
filename
))
SuperBenchLogger
.
add_handler
(
logger
.
logger
,
filename
=
str
(
self
.
_output_path
/
filename
))
def
__validate_mpi_bind_to
(
self
,
bind_to
):
"""Validate mpi bind_to option."""
valid_mpi_bind_to
=
{
'slot'
,
'hwthread'
,
'core'
,
'l1cache'
,
'l2cache'
,
'l3cache'
,
'package'
,
'numa'
,
'none'
}
if
bind_to
not
in
valid_mpi_bind_to
:
raise
ValueError
(
'Invalid bind_to value {}. Must be one of: {}'
.
format
(
bind_to
,
sorted
(
valid_mpi_bind_to
))
)
def
__validate_sb_config
(
self
):
# noqa: C901
def
__validate_sb_config
(
self
):
# noqa: C901
"""Validate SuperBench config object.
"""Validate SuperBench config object.
...
@@ -98,6 +106,8 @@ def __validate_sb_config(self): # noqa: C901
...
@@ -98,6 +106,8 @@ def __validate_sb_config(self): # noqa: C901
}
}
if
'bind_to'
not
in
mode
:
if
'bind_to'
not
in
mode
:
self
.
_sb_benchmarks
[
name
].
modes
[
idx
].
bind_to
=
'numa'
self
.
_sb_benchmarks
[
name
].
modes
[
idx
].
bind_to
=
'numa'
else
:
self
.
__validate_mpi_bind_to
(
mode
.
bind_to
)
for
key
in
[
'PATH'
,
'LD_LIBRARY_PATH'
,
'SB_MICRO_PATH'
,
'SB_WORKSPACE'
]:
for
key
in
[
'PATH'
,
'LD_LIBRARY_PATH'
,
'SB_MICRO_PATH'
,
'SB_WORKSPACE'
]:
self
.
_sb_benchmarks
[
name
].
modes
[
idx
].
env
.
setdefault
(
key
,
None
)
self
.
_sb_benchmarks
[
name
].
modes
[
idx
].
env
.
setdefault
(
key
,
None
)
if
'pattern'
in
mode
:
if
'pattern'
in
mode
:
...
...
tests/runner/test_runner.py
View file @
655519cb
...
@@ -56,6 +56,8 @@ def test_validate_sb_config(self):
...
@@ -56,6 +56,8 @@ def test_validate_sb_config(self):
self
.
assertIn
(
'proc_num'
,
mode
)
self
.
assertIn
(
'proc_num'
,
mode
)
if
mode
.
name
==
'mpi'
:
if
mode
.
name
==
'mpi'
:
self
.
assertIn
(
'mca'
,
mode
)
self
.
assertIn
(
'mca'
,
mode
)
self
.
assertIn
(
'bind_to'
,
mode
)
self
.
assertEqual
(
'numa'
,
mode
.
bind_to
)
def
test_get_failure_count
(
self
):
def
test_get_failure_count
(
self
):
"""Test get_failure_count."""
"""Test get_failure_count."""
...
@@ -153,6 +155,7 @@ def test_get_mode_command(self):
...
@@ -153,6 +155,7 @@ def test_get_mode_command(self):
'name'
:
'mpi'
,
'name'
:
'mpi'
,
'proc_num'
:
8
,
'proc_num'
:
8
,
'proc_rank'
:
1
,
'proc_rank'
:
1
,
'bind_to'
:
'numa'
,
'mca'
:
{},
'mca'
:
{},
'env'
:
{
'env'
:
{
'PATH'
:
None
,
'PATH'
:
None
,
...
@@ -172,6 +175,7 @@ def test_get_mode_command(self):
...
@@ -172,6 +175,7 @@ def test_get_mode_command(self):
'name'
:
'mpi'
,
'name'
:
'mpi'
,
'proc_num'
:
8
,
'proc_num'
:
8
,
'proc_rank'
:
2
,
'proc_rank'
:
2
,
'bind_to'
:
'numa'
,
'mca'
:
{
'mca'
:
{
'coll_hcoll_enable'
:
0
,
'coll_hcoll_enable'
:
0
,
},
},
...
@@ -196,6 +200,7 @@ def test_get_mode_command(self):
...
@@ -196,6 +200,7 @@ def test_get_mode_command(self):
'node_num'
:
1
,
'node_num'
:
1
,
'proc_num'
:
8
,
'proc_num'
:
8
,
'proc_rank'
:
2
,
'proc_rank'
:
2
,
'bind_to'
:
'numa'
,
'mca'
:
{
'mca'
:
{
'coll_hcoll_enable'
:
0
,
'coll_hcoll_enable'
:
0
,
},
},
...
@@ -240,6 +245,7 @@ def test_get_mode_command(self):
...
@@ -240,6 +245,7 @@ def test_get_mode_command(self):
'name'
:
'mpi'
,
'name'
:
'mpi'
,
'proc_num'
:
8
,
'proc_num'
:
8
,
'proc_rank'
:
1
,
'proc_rank'
:
1
,
'bind_to'
:
'numa'
,
'mca'
:
{},
'mca'
:
{},
'pattern'
:
{
'pattern'
:
{
'type'
:
'all-nodes'
,
'type'
:
'all-nodes'
,
...
@@ -255,6 +261,44 @@ def test_get_mode_command(self):
...
@@ -255,6 +261,44 @@ def test_get_mode_command(self):
f
'sb exec --output-dir
{
self
.
sb_output_dir
}
-c sb.config.yaml -C superbench.enable=foo'
f
'sb exec --output-dir
{
self
.
sb_output_dir
}
-c sb.config.yaml -C superbench.enable=foo'
),
),
},
},
{
'benchmark_name'
:
'foo'
,
'mode'
:
{
'name'
:
'mpi'
,
'proc_num'
:
8
,
'proc_rank'
:
0
,
'bind_to'
:
'core'
,
'mca'
:
{},
'env'
:
{
'PATH'
:
None
,
},
},
'expected_command'
:
(
'mpirun -tag-output -allow-run-as-root -hostfile hostfile -map-by ppr:8:node -bind-to core '
' -x PATH '
f
'sb exec --output-dir
{
self
.
sb_output_dir
}
-c sb.config.yaml -C superbench.enable=foo'
),
},
{
'benchmark_name'
:
'foo'
,
'mode'
:
{
'name'
:
'mpi'
,
'proc_num'
:
8
,
'proc_rank'
:
0
,
'bind_to'
:
'none'
,
'mca'
:
{},
'env'
:
{
'PATH'
:
None
,
},
},
'expected_command'
:
(
'mpirun -tag-output -allow-run-as-root -hostfile hostfile -map-by ppr:8:node -bind-to none '
' -x PATH '
f
'sb exec --output-dir
{
self
.
sb_output_dir
}
-c sb.config.yaml -C superbench.enable=foo'
),
},
]
]
for
test_case
in
test_cases
:
for
test_case
in
test_cases
:
...
@@ -285,6 +329,21 @@ def test_get_mode_command(self):
...
@@ -285,6 +329,21 @@ def test_get_mode_command(self):
),
expected_command
),
expected_command
)
)
def
test_validate_sb_config_invalid_mpi_bind_to
(
self
):
"""Test validate_sb_config rejects unsupported mpi bind_to values."""
test_config_file
=
Path
(
__file__
).
parent
/
'../../tests/data/test.yaml'
with
test_config_file
.
open
()
as
fp
:
invalid_config
=
OmegaConf
.
create
(
yaml
.
load
(
fp
,
Loader
=
yaml
.
SafeLoader
))
invalid_config
.
superbench
.
benchmarks
[
'nccl-bw:all-nodes'
].
modes
[
0
].
bind_to
=
'socket'
with
self
.
assertRaisesRegex
(
ValueError
,
'Invalid bind_to value'
):
SuperBenchRunner
(
invalid_config
,
OmegaConf
.
create
({}),
OmegaConf
.
create
({}),
self
.
sb_output_dir
,
)
def
test_run_empty_benchmarks
(
self
):
def
test_run_empty_benchmarks
(
self
):
"""Test run empty benchmarks, nothing should happen."""
"""Test run empty benchmarks, nothing should happen."""
self
.
runner
.
_sb_enabled_benchmarks
=
[]
self
.
runner
.
_sb_enabled_benchmarks
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment