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
4 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
pathlib
import
Path
from
subprocess
import
PIPE
,
CalledProcessError
from
subprocess
import
PIPE
,
CalledProcessError
from
typing
import
Iterable
,
List
,
Tuple
,
Union
from
typing
import
Iterable
,
List
,
Tuple
,
Union
...
@@ -39,7 +38,12 @@ def profile_config_file(
...
@@ -39,7 +38,12 @@ def profile_config_file(
raise
ValueError
(
"
Config file with no configs is unsupported.
"
)
raise
ValueError
(
"
Config file with no configs is unsupported.
"
)
# Modifies configs in place.
# Modifies configs in place.
profile_configs
(
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
))
write_hpvm_configs
(
header
,
configs
,
Path
(
output_config_path
))
...
@@ -57,10 +61,10 @@ def profile_configs(
...
@@ -57,10 +61,10 @@ def profile_configs(
from
tqdm
import
tqdm
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
iterable
=
tqdm
(
configs
,
desc
=
"
Configs profiled
"
)
if
progress_bar
else
configs
for
idx
in
iterable
:
for
config
in
iterable
:
time
,
acc
=
profil
e_config
(
binary_path
,
config
,
profile_filename
,
qos_filename
)
time
,
acc
=
measur
e_config
(
binary_path
,
config
,
profile_filename
,
qos_filename
)
speedup
=
baseline_time
/
time
speedup
=
baseline_time
/
time
config
.
update_profile_results
(
speedup
,
acc
,
baseline_acc
)
config
.
update_profile_results
(
speedup
,
acc
,
baseline_acc
)
return
configs
return
configs
...
@@ -127,15 +131,23 @@ def plot_hpvm_configs(
...
@@ -127,15 +131,23 @@ def plot_hpvm_configs(
return
fig
return
fig
@dataclass
class
Config
:
class
Config
:
conf_name
:
str
def
__init__
(
speedup
:
float
self
,
energy
:
float
conf_name
:
str
,
qos
:
float
speedup
:
float
,
qos_loss
:
float
energy
:
float
,
# We don't care about the information in this part, and we don't parse this.
qos
:
float
,
config_body
:
List
[
str
]
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
):
def
update_profile_results
(
self
,
speedup
:
float
,
qos
:
float
,
base_qos
:
float
):
recorded_base_qos
=
self
.
qos
+
self
.
qos_loss
recorded_base_qos
=
self
.
qos
+
self
.
qos_loss
...
@@ -189,7 +201,6 @@ def write_hpvm_configs(header: str, configs: Iterable[Config], to_file: PathLike
...
@@ -189,7 +201,6 @@ def write_hpvm_configs(header: str, configs: Iterable[Config], to_file: PathLike
f
.
flush
()
f
.
flush
()
def
_read_profile_file
(
profile_file_path
:
Path
):
def
_read_profile_file
(
profile_file_path
:
Path
):
with
profile_file_path
.
open
()
as
f
:
with
profile_file_path
.
open
()
as
f
:
target_lines
=
[
line
.
strip
()
for
line
in
f
if
"
Total Time
"
in
line
]
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