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
e40760d5
Commit
e40760d5
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Fixed popen bug when running promise timing model
parent
d579f04c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/projects/soc_simulator/src/driver.py
+33
-43
33 additions, 43 deletions
llvm/projects/soc_simulator/src/driver.py
with
33 additions
and
43 deletions
llvm/projects/soc_simulator/src/driver.py
+
33
−
43
View file @
e40760d5
...
...
@@ -35,21 +35,21 @@ def parse_tensor_layer_file(layer_filename):
tensor_layer
[
"
Name
"
]
=
layer_name
if
is_conv
(
layer_name
):
tensor_layer
[
"
N
"
]
=
layer_data
[
1
]
tensor_layer
[
"
Cin
"
]
=
layer_data
[
2
]
tensor_layer
[
"
H
"
]
=
layer_data
[
3
]
tensor_layer
[
"
W
"
]
=
layer_data
[
4
]
tensor_layer
[
"
Cout
"
]
=
layer_data
[
5
]
tensor_layer
[
"
Kh
"
]
=
layer_data
[
6
]
tensor_layer
[
"
Kw
"
]
=
layer_data
[
7
]
tensor_layer
[
"
Sh
"
]
=
layer_data
[
8
]
tensor_layer
[
"
Sw
"
]
=
layer_data
[
9
]
tensor_layer
[
"
N
"
]
=
int
(
layer_data
[
1
]
)
tensor_layer
[
"
Cin
"
]
=
int
(
layer_data
[
2
]
)
tensor_layer
[
"
H
"
]
=
int
(
layer_data
[
3
]
)
tensor_layer
[
"
W
"
]
=
int
(
layer_data
[
4
]
)
tensor_layer
[
"
Cout
"
]
=
int
(
layer_data
[
5
]
)
tensor_layer
[
"
Kh
"
]
=
int
(
layer_data
[
6
]
)
tensor_layer
[
"
Kw
"
]
=
int
(
layer_data
[
7
]
)
tensor_layer
[
"
Sh
"
]
=
int
(
layer_data
[
8
]
)
tensor_layer
[
"
Sw
"
]
=
int
(
layer_data
[
9
]
)
elif
is_fc
(
layer_name
):
tensor_layer
[
"
RA
"
]
=
layer_data
[
1
]
tensor_layer
[
"
CA
"
]
=
layer_data
[
2
]
tensor_layer
[
"
RB
"
]
=
layer_data
[
3
]
tensor_layer
[
"
CB
"
]
=
layer_data
[
4
]
tensor_layer
[
"
RA
"
]
=
int
(
layer_data
[
1
]
)
tensor_layer
[
"
CA
"
]
=
int
(
layer_data
[
2
]
)
tensor_layer
[
"
RB
"
]
=
int
(
layer_data
[
3
]
)
tensor_layer
[
"
CB
"
]
=
int
(
layer_data
[
4
]
)
elif
not
is_nml
(
layer_name
):
# TODO should we store data for NMLs?
print
(
"
ERROR: Invalid layer name %s
"
%
layer_name
)
...
...
@@ -113,7 +113,7 @@ class ApproxTypes:
def
is_promise
(
config_layer
):
# TODO overhead in call to split?
return
config_layer
.
split
(
'
'
)[
0
]
<
fp16_swing
return
int
(
config_layer
.
split
(
'
'
)[
0
]
)
<
fp16_swing
# NOTE smart_dma is always true
def
quantize
(
curr_layer
,
prev_layer
,
h2f_f2h_operation_ind
,
layer_data
):
...
...
@@ -167,17 +167,20 @@ def run_promise_simulation(swing, layer_data):
exit
(
1
)
# Run promise simulator
# TODO need to print time and energy so we can pipe it
# get output --> total time and energy
ptm_process
=
subprocess
.
Popen
([
"
./ptm
"
,
str
(
rows_a
),
str
(
cols_a
),
str
(
rows_b
),
\
str
(
cols_b
),
str
(
patch_factor
),
str
(
swing
)])
output
,
_
=
ptm_process
.
communicate
()
total_time_energy
=
output
.
strip
().
split
(
'
'
)
# TODO need to print time and energy in the ptm runner so we can pipe it
output
=
subprocess
.
Popen
([
"
./ptm
"
,
str
(
rows_a
),
str
(
cols_a
),
str
(
rows_b
),
\
str
(
cols_b
),
str
(
patch_factor
),
str
(
swing
)],
\
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
).
communicate
()[
0
]
total_time_energy
=
output
.
strip
().
split
(
'
,
'
)
assert
(
len
(
total_time_energy
)
==
2
)
return
total_time_energy
[
0
],
total_time_energy
[
1
]
assert
(
len
(
total_time_energy
)
==
2
)
return
total_time_energy
[
0
],
total_time_energy
[
1
]
# Default dict of default dicts
# [Time/Energy][number corresponding to order the layer config was read in] = time/energy
aggregate_results
=
defaultdict
(
lambda
:
defaultdict
(
float
))
def
run_simulations
(
config_filename
,
results_filename
):
config_file
=
open
(
config_filename
,
"
r
"
)
results_file
=
open
(
results_filename
,
"
w
"
)
...
...
@@ -186,41 +189,27 @@ def run_simulations(config_filename, results_filename):
# layers are separated by commas
# tensor ops are separated by spaces
for
config
in
config_file
:
for
config
_ind
,
config
in
enumerate
(
config_file
)
:
config_layers
=
config
.
strip
().
split
(
'
,
'
)
prev_layer
=
ApproxTypes
.
FP32
curr_layer
=
None
for
layer_ind
,
config_layer
in
enumerate
(
config_layers
):
# level
layer_data
=
tensor_layers
[
layer_ind
]
# layer
if
is_promise
(
config_layer
):
print
(
"
IS PROMISE
"
)
print
(
"
Running layer %s on PROMISE
"
%
layer_data
[
"
Name
"
])
curr_layer
=
ApproxTypes
.
PROMISE
quant_time
,
quant_energy
=
quantize
(
curr_layer
,
prev_layer
,
0
,
layer_data
)
# Compute
time
,
energy
=
run_promise_simulation
(
config_layer
,
layer_data
)
aggregate_results
[
"
Time
"
][
config_ind
]
=
time
aggregate_results
[
"
Energy
"
][
config_ind
]
=
energy
else
:
print
(
"
Not promise
"
)
pass
# for each config file line --> parse the comma separated voltage swing levels
# recall: each line = a configuration that works
# for each level
# if promise --> promise runs an entire layer
# quantize, no patching and unpatching
# run on promise
# output the total time and energy
# else
# for each sublevel (separated by spaces)
# quantize
# run
# keep track of total time and energy --> update as needed
# output the total time and energy
# quantization: we always have smart dma
# need to search stuff up
# $layer = a map of elements
# stores the layer name, then
if
__name__
==
"
__main__
"
:
'''
...
...
@@ -230,3 +219,4 @@ if __name__ == "__main__":
'''
parse_tensor_layer_file
(
"
/home/nvidia/Gitlab/hpvm/llvm/projects/hpvm-tensor-rt/build_mobilenet/mobilenet_layers.txt
"
)
parse_tensor_table
(
"
/home/nvidia/Gitlab/hpvm/llvm/projects/hpvm-tensor-rt/build_pldi/mobilenet_results/mobilenet_tensors.txt
"
)
run_simulations
(
"
/home/nvidia/Gitlab/hpvm/llvm/projects/soc_simulator/pipeline_GEMO/pipeline_GEMO_promise_confs1.txt
"
,
"
blah
"
)
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