Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SC19 Tutorial on OpenPOWER
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
Container registry
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nval
SC19 Tutorial on OpenPOWER
Commits
afc7d544
Commit
afc7d544
authored
Nov 17, 2019
by
Andreas Herten
Browse files
Options
Downloads
Patches
Plain Diff
Add Non-Notebook scripts for visalization
parent
d347d303
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
2-Performance_Counters/Handson/.master/graphing.py
+99
-45
99 additions, 45 deletions
2-Performance_Counters/Handson/.master/graphing.py
with
99 additions
and
45 deletions
2-Performance_Counters/Handson/.master/graphing.py
+
99
−
45
View file @
afc7d544
import
matplotlib
as
mpl
mpl
.
use
(
'
Agg
'
)
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
pandas
as
p
d
import
numpy
as
n
p
import
seaborn
as
sns
import
seaborn
as
sns
import
pandas
as
pd
import
common
sns
.
set
()
sns
.
set
()
plt
.
rcParams
[
'
figure.figsize
'
]
=
[
14
,
6
]
plt
.
rcParams
[
'
figure.figsize
'
]
=
[
14
,
6
]
import
common
def
linear_function
(
x
,
a
,
b
):
return
a
*
x
+
b
def
task1
(
input
=
"
poisson2d.ins_cyc.bin.csv
"
):
def
task1
(
input
=
"
poisson2d.ins_cyc.bin.csv
"
):
df
=
pd
.
read_csv
(
input
,
skiprows
=
range
(
2
,
50000
,
2
))
# Read in the CSV file from the bench run; parse with Pandas
df
=
pd
.
read_csv
(
"
poisson2d.ins_cyc.bin.csv
"
,
skiprows
=
range
(
2
,
50000
,
2
))
# Read in the CSV file from the bench run; parse with Pandas
common
.
normalize
(
df
,
"
PM_INST_CMPL (min)
"
,
"
Instructions / Loop Iteration
"
)
# Normalize to each iteration
df
[
"
Grid Points
"
]
=
df
[
"
nx
"
]
*
df
[
"
ny
"
]
# Add a new column of the number of grid points (the product of nx and ny)
common
.
normalize
(
df
,
"
PM_RUN_CYC (min)
"
,
"
Cycles / Loop Iteration
"
)
fit_parameters
,
fit_covariance
=
common
.
print_and_return_fit
(
[
"
PM_RUN_CYC (min)
"
,
"
PM_INST_CMPL (min)
"
],
df
.
set_index
(
"
Grid Points
"
),
linear_function
,
format_uncertainty
=
"
.4f
"
)
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
nrows
=
2
,
sharex
=
True
)
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
nrows
=
2
,
sharex
=
True
)
df
.
set_index
(
"
nx
"
)[
"
Cycles / Loop Iteration
"
].
plot
(
ax
=
ax1
,
legend
=
True
);
for
ax
,
pmu_counter
in
zip
([
ax1
,
ax2
],
[
"
PM_RUN_CYC (min)
"
,
"
PM_INST_CMPL (min)
"
]):
df
.
set_index
(
"
nx
"
)[
"
Instructions / Loop Iteration
"
].
plot
(
ax
=
ax2
,
legend
=
True
);
df
.
set_index
(
"
Grid Points
"
)[
pmu_counter
].
plot
(
ax
=
ax
,
legend
=
True
);
ax
.
plot
(
df
[
"
Grid Points
"
],
linear_function
(
df
[
"
Grid Points
"
],
*
fit_parameters
[
pmu_counter
]),
linestyle
=
"
--
"
,
label
=
"
Fit: {:.2f} * x + {:.2f}
"
.
format
(
*
fit_parameters
[
pmu_counter
])
)
ax
.
legend
();
fig
.
savefig
(
"
plot-task1.pdf
"
)
fig
.
savefig
(
"
plot-task1.pdf
"
)
def
task2a
(
input
=
"
poisson2d.ld_st.bin.csv
"
):
def
task2a
(
input
=
"
poisson2d.ld_st.bin.csv
"
):
df_ldst
=
pd
.
read_csv
(
input
,
skiprows
=
range
(
2
,
50000
,
2
))
df_ldst
=
pd
.
read_csv
(
"
poisson2d.ld_st.bin.csv
"
,
skiprows
=
range
(
2
,
50000
,
2
))
common
.
normalize
(
df_ldst
,
"
PM_LD_CMPL (min)
"
,
"
Loads / Loop Iteration
"
)
df_ldst
[
"
Grid Points
"
]
=
df_ldst
[
"
nx
"
]
*
df_ldst
[
"
ny
"
]
common
.
normalize
(
df_ldst
,
"
PM_ST_CMPL (min)
"
,
"
Stores / Loop Iteration
"
)
fit_parameters
,
fit_covariance
=
common
.
print_and_return_fit
(
[
"
PM_LD_CMPL (min)
"
,
"
PM_ST_CMPL (min)
"
],
df_ldst
.
set_index
(
"
Grid Points
"
),
linear_function
,
format_value
=
"
.4f
"
)
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
nrows
=
2
,
sharex
=
True
)
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
nrows
=
2
,
sharex
=
True
)
df_ldst
.
set_index
(
"
nx
"
)[
"
Loads / Loop Iteration
"
].
plot
(
ax
=
ax1
,
legend
=
True
);
for
ax
,
pmu_counter
in
zip
([
ax1
,
ax2
],
[
"
PM_LD_CMPL (min)
"
,
"
PM_ST_CMPL (min)
"
]):
df_ldst
.
set_index
(
"
nx
"
)[
"
Stores / Loop Iteration
"
].
plot
(
ax
=
ax2
,
legend
=
True
);
df_ldst
.
set_index
(
"
Grid Points
"
)[
pmu_counter
].
plot
(
ax
=
ax
,
legend
=
True
);
ax
.
plot
(
df_ldst
[
"
Grid Points
"
],
linear_function
(
df_ldst
[
"
Grid Points
"
],
*
fit_parameters
[
pmu_counter
]),
linestyle
=
"
--
"
,
label
=
"
Fit: {:.2f} * x + {:.2f}
"
.
format
(
*
fit_parameters
[
pmu_counter
])
)
ax
.
legend
();
fig
.
savefig
(
"
plot-task2a.pdf
"
)
fig
.
savefig
(
"
plot-task2a.pdf
"
)
def
task2b
(
input1
=
"
poisson2d.vld.bin.csv
"
,
input2
=
"
poisson2d.vst.bin.csv
"
,
input3
=
"
poisson2d.ld_st.bin.csv
"
,
bytes
=
False
):
def
task2b
(
input1
=
"
poisson2d.vld.bin.csv
"
,
input2
=
"
poisson2d.vst.bin.csv
"
,
input3
=
"
poisson2d.ld_st.bin.csv
"
,
bytes
=
False
,
just_return
=
False
):
df_vld
=
pd
.
read_csv
(
input1
,
skiprows
=
range
(
2
,
50000
,
2
))
df_vld
=
pd
.
read_csv
(
input1
,
skiprows
=
range
(
2
,
50000
,
2
))
df_vst
=
pd
.
read_csv
(
input2
,
skiprows
=
range
(
2
,
50000
,
2
))
df_vst
=
pd
.
read_csv
(
input2
,
skiprows
=
range
(
2
,
50000
,
2
))
df_vldvst
=
pd
.
concat
([
df_vld
.
set_index
(
"
nx
"
),
df_vst
.
set_index
(
"
nx
"
)[[
'
PM_VECTOR_ST_CMPL (total)
'
,
'
PM_VECTOR_ST_CMPL (min)
'
,
'
PM_VECTOR_ST_CMPL (max)
'
]]],
axis
=
1
).
reset_index
()
df_vldvst
=
pd
.
concat
([
df_vld
.
set_index
(
"
nx
"
),
df_vst
.
set_index
(
"
nx
"
)[[
'
PM_VECTOR_ST_CMPL (total)
'
,
'
PM_VECTOR_ST_CMPL (min)
'
,
'
PM_VECTOR_ST_CMPL (max)
'
]]],
axis
=
1
).
reset_index
()
common
.
normalize
(
df_vldvst
,
"
PM_VECTOR_LD_CMPL (min)
"
,
"
Vector Loads / Loop Iteration
"
)
df_vldvst
[
"
Grid Points
"
]
=
df_vldvst
[
"
nx
"
]
*
df_vldvst
[
"
ny
"
]
common
.
normalize
(
df_vldvst
,
"
PM_VECTOR_ST_CMPL (min)
"
,
"
Vector Stores / Loop Iteration
"
)
fit_parameters
,
fit_covariance
=
common
.
print_and_return_fit
(
[
"
PM_VECTOR_LD_CMPL (min)
"
,
"
PM_VECTOR_ST_CMPL (min)
"
],
df_vldvst
.
set_index
(
"
Grid Points
"
),
linear_function
,
format_value
=
"
.4f
"
,
)
if
bytes
is
False
:
if
bytes
is
False
:
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
nrows
=
2
,
sharex
=
True
)
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
nrows
=
2
,
sharex
=
True
)
df_vldvst
.
set_index
(
"
nx
"
)[
"
Vector Loads / Loop Iteration
"
].
plot
(
ax
=
ax1
,
legend
=
True
);
for
ax
,
pmu_counter
in
zip
([
ax1
,
ax2
],
[
"
PM_VECTOR_LD_CMPL (min)
"
,
"
PM_VECTOR_ST_CMPL (min)
"
]):
df_vldvst
.
set_index
(
"
nx
"
)[
"
Vector Stores / Loop Iteration
"
].
plot
(
ax
=
ax2
,
legend
=
True
);
df_vldvst
.
set_index
(
"
Grid Points
"
)[
pmu_counter
].
plot
(
ax
=
ax
,
legend
=
True
);
ax
.
plot
(
df_vldvst
[
"
Grid Points
"
],
linear_function
(
df_vldvst
[
"
Grid Points
"
],
*
fit_parameters
[
pmu_counter
]),
linestyle
=
"
--
"
,
label
=
"
Fit: {:.2f} * x + {:.2f}
"
.
format
(
*
fit_parameters
[
pmu_counter
])
)
ax
.
legend
();
fig
.
savefig
(
"
plot-task2b.pdf
"
)
fig
.
savefig
(
"
plot-task2b.pdf
"
)
else
:
else
:
df_ldst
=
pd
.
read_csv
(
input3
,
skiprows
=
range
(
2
,
50000
,
2
))
common
.
normalize
(
df_ldst
,
"
PM_LD_CMPL (min)
"
,
"
Loads / Loop Iteration
"
)
common
.
normalize
(
df_ldst
,
"
PM_ST_CMPL (min)
"
,
"
Stores / Loop Iteration
"
)
df_byte
=
pd
.
DataFrame
()
df_byte
=
pd
.
DataFrame
()
df_byte
[
"
Loads / Loop Iteration
"
]
=
(
df_vldvst
.
set_index
(
"
nx
"
)[
"
Vector Loads / Loop Iteration
"
]
+
df_ldst
.
set_index
(
"
nx
"
)[
"
Loads / Loop Iteration
"
])
*
8
df_ldst
=
pd
.
read_csv
(
input3
,
skiprows
=
range
(
2
,
50000
,
2
))
df_byte
[
"
Stores / Loop Iteration
"
]
=
(
df_vldvst
.
set_index
(
"
nx
"
)[
"
Vector Stores / Loop Iteration
"
]
+
df_ldst
.
set_index
(
"
nx
"
)[
"
Stores / Loop Iteration
"
])
*
8
df_ldst
[
"
Grid Points
"
]
=
df_ldst
[
"
nx
"
]
*
df_ldst
[
"
ny
"
]
df_byte
[
"
Loads
"
]
=
(
df_vldvst
.
set_index
(
"
Grid Points
"
)[
"
PM_VECTOR_LD_CMPL (min)
"
]
+
df_ldst
.
set_index
(
"
Grid Points
"
)[
"
PM_LD_CMPL (min)
"
])
*
8
df_byte
[
"
Stores
"
]
=
(
df_vldvst
.
set_index
(
"
Grid Points
"
)[
"
PM_VECTOR_ST_CMPL (min)
"
]
+
df_ldst
.
set_index
(
"
Grid Points
"
)[
"
PM_ST_CMPL (min)
"
])
*
8
if
not
just_return
:
_fit
,
_cov
=
common
.
print_and_return_fit
(
[
"
Loads
"
,
"
Stores
"
],
df_byte
,
linear_function
)
fit_parameters
=
{
**
fit_parameters
,
**
_fit
}
fit_covariance
=
{
**
fit_covariance
,
**
_cov
}
fig
,
ax
=
plt
.
subplots
()
fig
,
ax
=
plt
.
subplots
()
ax
=
df_byte
.
plot
(
ax
=
ax
)
for
pmu_counter
in
[
"
Loads
"
,
"
Stores
"
]:
ax
.
set_ylabel
(
"
Bytes / Loop Iteration
"
);
df_byte
[
pmu_counter
].
plot
(
ax
=
ax
,
legend
=
True
);
ax
.
plot
(
df_byte
.
index
,
linear_function
(
df_byte
.
index
,
*
fit_parameters
[
pmu_counter
]),
linestyle
=
"
--
"
,
label
=
"
Fit: {:.2f} * x + {:.2f}
"
.
format
(
*
fit_parameters
[
pmu_counter
])
)
ax
.
legend
();
ax
.
set_ylabel
(
"
Bytes
"
);
fig
.
savefig
(
"
plot-task2b-2.pdf
"
)
fig
.
savefig
(
"
plot-task2b-2.pdf
"
)
else
:
return
df_byte
def
task2c
(
input1
=
"
poisson2d.vld.bin.csv
"
,
input2
=
"
poisson2d.vst.bin.csv
"
,
input3
=
"
poisson2d.ld_st.bin.csv
"
,
input4
=
"
poisson2d.ins_cyc.bin.csv
"
):
def
task2c
(
input1
=
"
poisson2d.vld.bin.csv
"
,
input2
=
"
poisson2d.vst.bin.csv
"
,
input3
=
"
poisson2d.ld_st.bin.csv
"
,
input4
=
"
poisson2d.ins_cyc.bin.csv
"
):
df
=
pd
.
read_csv
(
input4
,
skiprows
=
range
(
2
,
50000
,
2
))
df
=
pd
.
read_csv
(
input4
,
skiprows
=
range
(
2
,
50000
,
2
))
...
@@ -77,29 +135,25 @@ def task4(input1="poisson2d.vld.bin.csv", input2="poisson2d.vst.bin.csv", input3
...
@@ -77,29 +135,25 @@ def task4(input1="poisson2d.vld.bin.csv", input2="poisson2d.vst.bin.csv", input3
df_sflop
=
pd
.
read_csv
(
input5
,
skiprows
=
range
(
2
,
50000
,
2
))
df_sflop
=
pd
.
read_csv
(
input5
,
skiprows
=
range
(
2
,
50000
,
2
))
df_vflop
=
pd
.
read_csv
(
input6
,
skiprows
=
range
(
2
,
50000
,
2
))
df_vflop
=
pd
.
read_csv
(
input6
,
skiprows
=
range
(
2
,
50000
,
2
))
df_flop
=
pd
.
concat
([
df_sflop
.
set_index
(
"
nx
"
),
df_vflop
.
set_index
(
"
nx
"
)[[
'
PM_VECTOR_FLOP_CMPL (total)
'
,
'
PM_VECTOR_FLOP_CMPL (min)
'
,
'
PM_VECTOR_FLOP_CMPL (max)
'
]]],
axis
=
1
).
reset_index
()
df_flop
=
pd
.
concat
([
df_sflop
.
set_index
(
"
nx
"
),
df_vflop
.
set_index
(
"
nx
"
)[[
'
PM_VECTOR_FLOP_CMPL (total)
'
,
'
PM_VECTOR_FLOP_CMPL (min)
'
,
'
PM_VECTOR_FLOP_CMPL (max)
'
]]],
axis
=
1
).
reset_index
()
common
.
normalize
(
df_flop
,
"
PM_SCALAR_FLOP_CMPL (min)
"
,
"
Scalar FlOps / Loop Iteration
"
)
common
.
normalize
(
df_flop
,
"
PM_VECTOR_FLOP_CMPL (min)
"
,
"
Vector Instructions / Loop Iteration
"
)
df_flop
[
"
Grid Points
"
]
=
df_flop
[
"
nx
"
]
*
df_flop
[
"
ny
"
]
df_flop
[
"
Vector FlOps / Loop Iteration
"
]
=
df_flop
[
"
Vector Instructions / Loop Iteration
"
]
*
2
df_flop
[
"
Vector FlOps (min)
"
]
=
df_flop
[
"
PM_VECTOR_FLOP_CMPL (min)
"
]
*
2
df_flop
[
"
Scalar FlOps (min)
"
]
=
df_flop
[
"
PM_SCALAR_FLOP_CMPL (min)
"
]
fit_parameters
,
fit_covariance
=
common
.
print_and_return_fit
(
[
"
Scalar FlOps (min)
"
,
"
Vector FlOps (min)
"
],
df_flop
.
set_index
(
"
Grid Points
"
),
linear_function
)
if
ai
is
False
:
if
ai
is
False
:
fig
,
ax
=
plt
.
subplots
()
fig
,
ax
=
plt
.
subplots
()
df_flop
.
set_index
(
"
nx
"
)[[
"
Scalar FlOps
/ Loop Iteration
"
,
"
Vector FlOps
/ Loop Iteration
"
]].
plot
(
ax
=
ax
);
df_flop
.
set_index
(
"
Grid Points
"
)[[
"
Scalar FlOps
(min)
"
,
"
Vector FlOps
(min)
"
]].
plot
(
ax
=
ax
);
fig
.
savefig
(
"
plot-task4.pdf
"
)
fig
.
savefig
(
"
plot-task4.pdf
"
)
else
:
else
:
df_vld
=
pd
.
read_csv
(
input1
,
skiprows
=
range
(
2
,
50000
,
2
))
df_byte
=
task2b
(
bytes
=
True
,
just_return
=
True
)
df_vst
=
pd
.
read_csv
(
input2
,
skiprows
=
range
(
2
,
50000
,
2
))
I_flop_scalar
=
df_flop
.
set_index
(
"
Grid Points
"
)[
"
Scalar FlOps (min)
"
]
df_vldvst
=
pd
.
concat
([
df_vld
.
set_index
(
"
nx
"
),
df_vst
.
set_index
(
"
nx
"
)[[
'
PM_VECTOR_ST_CMPL (total)
'
,
'
PM_VECTOR_ST_CMPL (min)
'
,
'
PM_VECTOR_ST_CMPL (max)
'
]]],
axis
=
1
).
reset_index
()
I_flop_vector
=
df_flop
.
set_index
(
"
Grid Points
"
)[
"
Vector FlOps (min)
"
]
common
.
normalize
(
df_vldvst
,
"
PM_VECTOR_LD_CMPL (min)
"
,
"
Vector Loads / Loop Iteration
"
)
I_mem_load
=
df_byte
[
"
Loads
"
]
common
.
normalize
(
df_vldvst
,
"
PM_VECTOR_ST_CMPL (min)
"
,
"
Vector Stores / Loop Iteration
"
)
I_mem_store
=
df_byte
[
"
Stores
"
]
df_ldst
=
pd
.
read_csv
(
input3
,
skiprows
=
range
(
2
,
50000
,
2
))
common
.
normalize
(
df_ldst
,
"
PM_LD_CMPL (min)
"
,
"
Loads / Loop Iteration
"
)
common
.
normalize
(
df_ldst
,
"
PM_ST_CMPL (min)
"
,
"
Stores / Loop Iteration
"
)
df_byte
=
pd
.
DataFrame
()
df_byte
[
"
Loads / Loop Iteration
"
]
=
(
df_vldvst
.
set_index
(
"
nx
"
)[
"
Vector Loads / Loop Iteration
"
]
+
df_ldst
.
set_index
(
"
nx
"
)[
"
Loads / Loop Iteration
"
])
*
8
df_byte
[
"
Stores / Loop Iteration
"
]
=
(
df_vldvst
.
set_index
(
"
nx
"
)[
"
Vector Stores / Loop Iteration
"
]
+
df_ldst
.
set_index
(
"
nx
"
)[
"
Stores / Loop Iteration
"
])
*
8
I_flop_scalar
=
df_flop
.
set_index
(
"
nx
"
)[
"
Scalar FlOps / Loop Iteration
"
]
I_flop_vector
=
df_flop
.
set_index
(
"
nx
"
)[
"
Vector FlOps / Loop Iteration
"
]
I_mem_load
=
df_byte
[
"
Loads / Loop Iteration
"
]
I_mem_store
=
df_byte
[
"
Stores / Loop Iteration
"
]
df_ai
=
pd
.
DataFrame
()
df_ai
=
pd
.
DataFrame
()
df_ai
[
"
Arithmetic Intensity
"
]
=
(
I_flop_scalar
+
I_flop_vector
)
/
(
I_mem_load
+
I_mem_store
)
df_ai
[
"
Arithmetic Intensity
"
]
=
(
I_flop_scalar
+
I_flop_vector
)
/
(
I_mem_load
+
I_mem_store
)
fig
,
ax
=
plt
.
subplots
()
fig
,
ax
=
plt
.
subplots
()
...
...
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