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
ceb100d0
"git@gitlab.engr.illinois.edu:cs525-sp18-g07/spark.git" did not exist on "db9b90fdbd0b105c205959c997d7de2dba42e6e8"
Commit
ceb100d0
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Finished file output method
parent
a339f4b6
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
llvm/projects/soc_simulator/src/driver.py
+54
-12
54 additions, 12 deletions
llvm/projects/soc_simulator/src/driver.py
with
54 additions
and
12 deletions
llvm/projects/soc_simulator/src/driver.py
+
54
−
12
View file @
ceb100d0
...
@@ -188,24 +188,31 @@ def run_gpu_simulation(curr_layer, layer_name, tensor_ind):
...
@@ -188,24 +188,31 @@ def run_gpu_simulation(curr_layer, layer_name, tensor_ind):
return
(
conversion_time
,
conversion_energy
)
return
(
conversion_time
,
conversion_energy
)
# Default dict of default dicts
# Default dict of default dicts
results_time_key
=
"
Time
"
results_energy_key
=
"
Energy
"
# [Time/Energy][number corresponding to order the layer config was read in] = time/energy
# [Time/Energy][number corresponding to order the layer config was read in] = time/energy
aggregate_results
=
defaultdict
(
lambda
:
defaultdict
(
float
))
aggregate_results
=
defaultdict
(
lambda
:
defaultdict
(
float
))
config_count
=
0
def
run_simulations
(
config_filename
):
global
config_count
if
not
os
.
path
.
isfile
(
config_filename
):
print
(
"
ERROR: %s was not found
"
%
config_filename
)
exit
(
1
)
def
run_simulations
(
config_filename
,
results_filename
):
config_file
=
open
(
config_filename
,
"
r
"
)
config_file
=
open
(
config_filename
,
"
r
"
)
results_file
=
open
(
results_filename
,
"
w
"
)
# each line = indepedent configuration
# each line = indepedent configuration
# layers are separated by commas
# layers are separated by commas
# tensor ops are separated by spaces
# tensor ops are separated by spaces
for
config
in
config_file
:
for
config_ind
,
config
in
enumerate
(
config_file
):
config_layers
=
config
.
strip
().
split
(
'
,
'
)
config_layers
=
config
.
strip
().
split
(
'
,
'
)
prev_layer
=
ApproxTypes
.
FP32
prev_layer
=
ApproxTypes
.
FP32
curr_layer
=
None
curr_layer
=
None
aggregate_results
[
"
Time
"
][
config_
ind
]
=
0
aggregate_results
[
results_time_key
][
config_
count
]
=
0
aggregate_results
[
"
E
nergy
"
][
config_
ind
]
=
0
aggregate_results
[
results_e
nergy
_key
][
config_
count
]
=
0
for
layer_ind
,
config_layer
in
enumerate
(
config_layers
):
# level
for
layer_ind
,
config_layer
in
enumerate
(
config_layers
):
# level
layer_data
=
tensor_layers
[
layer_ind
]
# layer
layer_data
=
tensor_layers
[
layer_ind
]
# layer
...
@@ -219,8 +226,8 @@ def run_simulations(config_filename, results_filename):
...
@@ -219,8 +226,8 @@ def run_simulations(config_filename, results_filename):
# Compute
# Compute
time
,
energy
=
run_promise_simulation
(
config_layer
,
layer_data
)
time
,
energy
=
run_promise_simulation
(
config_layer
,
layer_data
)
aggregate_results
[
"
Time
"
][
config_
ind
]
+=
time
aggregate_results
[
results_time_key
][
config_
count
]
+=
time
aggregate_results
[
"
E
nergy
"
][
config_
ind
]
+=
energy
aggregate_results
[
results_e
nergy
_key
][
config_
count
]
+=
energy
else
:
else
:
print
(
"
Running layer %s on GPU
"
%
layer_name
)
print
(
"
Running layer %s on GPU
"
%
layer_name
)
...
@@ -240,10 +247,44 @@ def run_simulations(config_filename, results_filename):
...
@@ -240,10 +247,44 @@ def run_simulations(config_filename, results_filename):
total_time
+=
conv_time
total_time
+=
conv_time
total_time
+=
conv_energy
total_time
+=
conv_energy
aggregate_results
[
"
Time
"
][
config_
ind
]
+=
total_time
aggregate_results
[
results_time_key
][
config_
count
]
+=
total_time
aggregate_results
[
"
E
nergy
"
][
config_
ind
]
+=
total_energy
aggregate_results
[
results_e
nergy
_key
][
config_
count
]
+=
total_energy
print
(
"
DONE WITH LAYER
"
)
print
(
"
DONE WITH LAYER
"
)
prev_layer
=
curr_layer
prev_layer
=
curr_layer
config_count
+=
1
config_count
+=
1
# because we're storing the count and not the index
config_file
.
close
()
def
display_results
(
results_filename
):
results_file
=
open
(
results_filename
,
"
w
"
)
attributes_to_print
=
[
results_time_key
,
results_energy_key
]
for
attribute
in
attributes_to_print
:
attribute_data
=
[]
# Store as list and then write to file once bc syscalls are slow
attribute_data
.
append
(
attribute
)
attribute_data
.
append
(
"
Configuration,Total,Improvement
"
)
# header
baseline_val
=
aggregate_results
[
attribute
][
0
]
best_config
=
None
best_result
=
None
for
config_ind
in
range
(
config_count
):
config_data
=
[
"
c%d
"
%
config_ind
]
time_or_energy_val
=
aggregate_results
[
attribute
][
config_ind
]
config_data
.
append
(
str
(
time_or_energy_val
))
config_data
.
append
(
str
(
baseline_val
/
(
time_or_energy_val
+
0.0001
)))
attribute_data
.
append
(
'
,
'
.
join
(
config_data
))
if
not
best_result
or
time_or_energy_val
<
best_result
:
best_result
=
time_or_energy_val
best_config
=
config_ind
attribute_data
.
append
(
"
c%d,%d
"
%
(
best_config
,
aggregate_results
[
attribute
][
best_config
]))
attribute_data
.
append
(
""
)
# To add an additional new line
results_file
.
write
(
'
\n
'
.
join
(
attribute_data
))
results_file
.
close
()
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
'''
'''
...
@@ -253,4 +294,5 @@ if __name__ == "__main__":
...
@@ -253,4 +294,5 @@ if __name__ == "__main__":
'''
'''
parse_tensor_layer_file
(
"
/home/nvidia/Gitlab/hpvm/llvm/projects/hpvm-tensor-rt/build_mobilenet/mobilenet_layers.txt
"
)
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
"
)
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/hpvm-tensor-rt/build_mobilenet/mobilenet_conf2.txt
"
,
"
blah
"
)
run_simulations
(
"
/home/nvidia/Gitlab/hpvm/llvm/projects/hpvm-tensor-rt/build_mobilenet/mobilenet_conf2.txt
"
)
display_results
(
"
blah.txt
"
)
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