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
3524975c
Unverified
Commit
3524975c
authored
Jan 29, 2022
by
Yifan Xiong
Committed by
GitHub
Jan 29, 2022
Browse files
Config - Support customized env for all modes (#295)
Support customized env for all modes in configuration.
parent
f3d05006
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
11 deletions
+23
-11
docs/superbench-config.mdx
docs/superbench-config.mdx
+7
-3
superbench/runner/runner.py
superbench/runner/runner.py
+13
-7
tests/runner/test_runner.py
tests/runner/test_runner.py
+3
-1
No files found.
docs/superbench-config.mdx
View file @
3524975c
...
...
@@ -384,7 +384,7 @@ Some attributes may only be suitable for specific mode.
| `proc_num` | ✓ | ✓ | ✓ |
| `node_num` | ✘ | ✓ | ✘ |
| `prefix` | ✓ | ✘ | ✘ |
| `env` |
✘
|
✘
| ✓ |
| `env` |
✓
|
✓
| ✓ |
| `mca` | ✘ | ✘ | ✓ |
| `parallel` | ✓ | ✘ | ✘ |
...
...
@@ -421,8 +421,12 @@ So `prefix: CUDA_VISIBLE_DEVICES={proc_rank}` will be expressed as `CUDA_VISIBLE
### `env`
Environment variables to use in the mode,
in a flatten key-value dictionary.
Environment variables to use in the mode, in a flatten key-value dictionary.
The value needs to be string, any integer or boolean values need to be enclosed in quotes.
Formatted string is also supported in value, available variables include:
+ `proc_rank`
+ `proc_num`
### `mca`
...
...
superbench/runner/runner.py
View file @
3524975c
...
...
@@ -68,6 +68,8 @@ def __validate_sb_config(self): # noqa: C901
if
not
self
.
_sb_benchmarks
[
name
].
modes
:
self
.
_sb_benchmarks
[
name
].
modes
=
[]
for
idx
,
mode
in
enumerate
(
self
.
_sb_benchmarks
[
name
].
modes
):
if
not
mode
.
env
:
self
.
_sb_benchmarks
[
name
].
modes
[
idx
].
env
=
{}
if
mode
.
name
==
'local'
:
if
not
mode
.
proc_num
:
self
.
_sb_benchmarks
[
name
].
modes
[
idx
].
proc_num
=
1
...
...
@@ -84,8 +86,6 @@ def __validate_sb_config(self): # noqa: C901
'btl_tcp_if_exclude'
:
'lo,docker0'
,
'coll_hcoll_enable'
:
0
,
}
if
not
mode
.
env
:
self
.
_sb_benchmarks
[
name
].
modes
[
idx
].
env
=
{}
for
key
in
[
'PATH'
,
'LD_LIBRARY_PATH'
,
'SB_MICRO_PATH'
]:
self
.
_sb_benchmarks
[
name
].
modes
[
idx
].
env
.
setdefault
(
key
,
None
)
...
...
@@ -150,7 +150,10 @@ def __get_mode_command(self, benchmark_name, mode, timeout=None):
).
format
(
proc_num
=
mode
.
proc_num
,
mca_list
=
' '
.
join
(
f
'-mca
{
k
}
{
v
}
'
for
k
,
v
in
mode
.
mca
.
items
()),
env_list
=
' '
.
join
(
f
'-x
{
k
}
=
{
v
}
'
if
v
else
f
'-x
{
k
}
'
for
k
,
v
in
mode
.
env
.
items
()),
env_list
=
' '
.
join
(
f
'-x
{
k
}
=
{
str
(
v
).
format
(
proc_rank
=
mode
.
proc_rank
,
proc_num
=
mode
.
proc_num
)
}
'
if
isinstance
(
v
,
str
)
else
f
'-x
{
k
}
'
for
k
,
v
in
mode
.
env
.
items
()
),
command
=
exec_command
,
)
else
:
...
...
@@ -384,11 +387,14 @@ def _run_proc(self, benchmark_name, mode, vars):
logger
.
info
(
'Runner is going to run %s in %s mode, proc rank %d.'
,
benchmark_name
,
mode
.
name
,
mode
.
proc_rank
)
timeout
=
self
.
_sb_benchmarks
[
benchmark_name
].
timeout
env_list
=
'--env-file sb.env'
for
k
,
v
in
mode
.
env
.
items
():
if
isinstance
(
v
,
str
):
env_list
+=
f
' -e
{
k
}
=
{
str
(
v
).
format
(
proc_rank
=
mode
.
proc_rank
,
proc_num
=
mode
.
proc_num
)
}
'
ansible_runner_config
=
self
.
_ansible_client
.
get_shell_config
(
(
'docker exec sb-workspace bash -c '
"'set -o allexport && source sb.env && set +o allexport && {command}'"
).
format
(
command
=
self
.
__get_mode_command
(
benchmark_name
,
mode
,
timeout
))
"docker exec {env_list} sb-workspace bash -c '{command}'"
.
format
(
env_list
=
env_list
,
command
=
self
.
__get_mode_command
(
benchmark_name
,
mode
,
timeout
)
)
)
if
mode
.
name
==
'mpi'
:
ansible_runner_config
=
self
.
_ansible_client
.
update_mpi_config
(
ansible_runner_config
)
...
...
tests/runner/test_runner.py
View file @
3524975c
...
...
@@ -153,11 +153,13 @@ def test_get_mode_command(self):
'env'
:
{
'SB_MICRO_PATH'
:
'/sb'
,
'FOO'
:
'BAR'
,
'RANK'
:
'{proc_rank}'
,
'NUM'
:
'{proc_num}'
,
},
},
'expected_command'
:
(
'mpirun -tag-output -allow-run-as-root -hostfile hostfile -map-by ppr:8:node -bind-to numa '
'-mca coll_hcoll_enable 0 -x SB_MICRO_PATH=/sb -x FOO=BAR '
'-mca coll_hcoll_enable 0 -x SB_MICRO_PATH=/sb -x FOO=BAR
-x RANK=2 -x NUM=8
'
f
'sb exec --output-dir
{
self
.
sb_output_dir
}
-c sb.config.yaml -C superbench.enable=foo'
),
},
...
...
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