Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpsd-software-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MPSD Computational Science
mpsd-software-manager
Commits
b44d2a29
Commit
b44d2a29
authored
1 year ago
by
Hans Fangohr
Browse files
Options
Downloads
Patches
Plain Diff
if MPSD_MICROARCH is not defined, use archspec to determine
parent
efef6a6a
Branches
Branches containing commit
No related tags found
1 merge request
!32
if MPSD_MICROARCH is not defined, use archspec to determine
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mpsd-software-environment.py
+55
-0
55 additions, 0 deletions
mpsd-software-environment.py
tests.py
+4
-0
4 additions, 0 deletions
tests.py
with
59 additions
and
0 deletions
mpsd-software-environment.py
+
55
−
0
View file @
b44d2a29
...
...
@@ -471,6 +471,61 @@ def prepare_environment(mpsd_release: str, script_dir: Path) -> List[str]:
return
available_toolchains
def
get_native_microarchitecture
():
"""
Return native microarchitecture.
On MPSD machines, there should be an environment variable
"
MPSD_MICROARCH
"
.
We try to read that. If it fails, we use the
'
archspec cpu
'
command.
If that fails, we ask the user to install it.
Returns
-------
MPSD_MICROARCH : str
Example
-------
>>>
get_native_microarchitecture
()
'
haswell
'
"""
# attempt to get MICRO_ARCH from environment variable (should work on
# MPSD_HPC and MPSD linux laptops). If not defined, return
# "UNKNOWN_MICROARCH"
microarch
=
os
.
environ
.
get
(
"
MPSD_MICROARCH
"
,
"
UNKNOWN_MICROARCH
"
)
# if we have not found the microarchitecture environment variable,
# try calling archspec
if
microarch
==
"
UNKNOWN_MICROARCH
"
:
logging
.
debug
(
"
Couldn
'
t find MPSD_MICROARCH environment variable. Will try archspec.
"
)
try
:
process
=
run
([
"
archspec
"
,
"
cpu
"
],
stdout
=
subprocess
.
PIPE
,
text
=
True
)
except
FileNotFoundError
as
e
:
logging
.
debug
(
f
"
Call of
'
archspec cpu
'
failed:
{
e
=
}
"
)
# Presumably 'archspec' is not installed.
msg
=
"
Please install archspec, for example via
'
pipx install archspec
'
.
\n
"
msg
+=
"
The command we need to execute is
'
archspec cpu
'
.
\n
"
msg
+=
"
Documentation of package: https://archspec.readthedocs.io/
"
logging
.
error
(
msg
)
sys
.
exit
(
1
)
else
:
# we have found archspec and executed it
if
process
.
returncode
==
0
:
# sanity check
microarch
=
process
.
stdout
logging
.
debug
(
f
"
Found microarchitecture from
'
archspec cpu
'
to be
'
{
microarch
}
'"
)
assert
len
(
microarch
)
>
0
# sanity check
else
:
raise
ValueError
(
f
"
Some error occurred when calling
'
archspec cpu
'
:
{
process
=
}
"
)
# at this point, we have determined the microarchitecture
log_metadata
(
"
microarchitecture
"
,
microarch
)
return
microarch
def
install_environment
(
mpsd_release
:
str
,
toolchains
:
List
[
str
],
...
...
This diff is collapsed.
Click to expand it.
tests.py
+
4
−
0
View file @
b44d2a29
...
...
@@ -361,3 +361,7 @@ def test_interface(tmp_path):
# check that the help message is printed when no arguments are provided
# check that the help message is printed when -h is provided
# check that the error messages are also logged to the log file
# other tests to add (ideally)
# - get_native_microarchitecture()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment