Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpvm-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
llvm
hpvm-release
Commits
37e1f530
Commit
37e1f530
authored
3 years ago
by
Yifan Zhao
Browse files
Options
Downloads
Patches
Plain Diff
Move away from dataclass (python 3.7+)
parent
49397dc3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hpvm/projects/hpvm-profiler/hpvm_profiler/__init__.py
+25
-14
25 additions, 14 deletions
hpvm/projects/hpvm-profiler/hpvm_profiler/__init__.py
with
25 additions
and
14 deletions
hpvm/projects/hpvm-profiler/hpvm_profiler/__init__.py
+
25
−
14
View file @
37e1f530
from
dataclasses
import
dataclass
from
pathlib
import
Path
from
subprocess
import
PIPE
,
CalledProcessError
from
typing
import
Iterable
,
List
,
Tuple
,
Union
...
...
@@ -39,7 +38,12 @@ def profile_config_file(
raise
ValueError
(
"
Config file with no configs is unsupported.
"
)
# Modifies configs in place.
profile_configs
(
binary_path
,
configs
[
1
:],
configs
[
0
],
progress_bar
,
profile_filename
,
qos_filename
binary_path
,
configs
[
1
:],
configs
[
0
],
progress_bar
,
profile_filename
,
qos_filename
,
)
write_hpvm_configs
(
header
,
configs
,
Path
(
output_config_path
))
...
...
@@ -57,10 +61,10 @@ def profile_configs(
from
tqdm
import
tqdm
baseline_time
,
baseline_acc
=
profil
e_config
(
binary_path
,
baseline_config
)
baseline_time
,
baseline_acc
=
measur
e_config
(
binary_path
,
baseline_config
)
iterable
=
tqdm
(
configs
,
desc
=
"
Configs profiled
"
)
if
progress_bar
else
configs
for
idx
in
iterable
:
time
,
acc
=
profil
e_config
(
binary_path
,
config
,
profile_filename
,
qos_filename
)
for
config
in
iterable
:
time
,
acc
=
measur
e_config
(
binary_path
,
config
,
profile_filename
,
qos_filename
)
speedup
=
baseline_time
/
time
config
.
update_profile_results
(
speedup
,
acc
,
baseline_acc
)
return
configs
...
...
@@ -127,15 +131,23 @@ def plot_hpvm_configs(
return
fig
@dataclass
class
Config
:
conf_name
:
str
speedup
:
float
energy
:
float
qos
:
float
qos_loss
:
float
# We don't care about the information in this part, and we don't parse this.
config_body
:
List
[
str
]
def
__init__
(
self
,
conf_name
:
str
,
speedup
:
float
,
energy
:
float
,
qos
:
float
,
qos_loss
:
float
,
config_body
:
List
[
str
],
):
self
.
conf_name
=
conf_name
self
.
speedup
=
speedup
self
.
energy
=
energy
self
.
qos
=
qos
self
.
qos_loss
=
qos_loss
# We don't care about the information in this part, and we don't parse this.
self
.
config_body
=
config_body
def
update_profile_results
(
self
,
speedup
:
float
,
qos
:
float
,
base_qos
:
float
):
recorded_base_qos
=
self
.
qos
+
self
.
qos_loss
...
...
@@ -189,7 +201,6 @@ def write_hpvm_configs(header: str, configs: Iterable[Config], to_file: PathLike
f
.
flush
()
def
_read_profile_file
(
profile_file_path
:
Path
):
with
profile_file_path
.
open
()
as
f
:
target_lines
=
[
line
.
strip
()
for
line
in
f
if
"
Total Time
"
in
line
]
...
...
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