Skip to content
Snippets Groups Projects
Commit 55c0b980 authored by Christoph Alt's avatar Christoph Alt
Browse files

added plotting functions

parent 15bb5892
Branches
No related tags found
1 merge request!3Devel/plotting
Pipeline #50724 failed
import plotly.graph_objs as go
from dataclasses import dataclass
@dataclass
class CPUInfo:
name: str
max_perf: float # MFLOP/s
max_band: float # MByte/s
SKYLAKE = CPUInfo("Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz",
max_perf=5582274.03,
max_band=159321.74)
DEFAULT_MARKER = dict(size=10, color='green')
def add_rooflines(fig, peak_perf, max_bw, max_x):
# Calculate maximum flops/byte value
ridge_point = peak_perf / max_bw
# Add horizontal bandwidth roofline
x_bw = [ridge_point, max_x]
y_bw = [peak_perf, peak_perf]
fig.add_trace(go.Scatter(x=x_bw, y=y_bw, mode='lines+text',
name="Compute Roofline",
text=[f'Peak Performance {peak_perf/1e9} GFlop/s',],
textposition="top right",
line=dict(color='blue', width=2)))
# Add diagonal compute roofline
x_compute = [0, ridge_point]
y_compute = [0, peak_perf]
fig.add_trace(go.Scatter(x=x_compute, y=y_compute, mode='lines+text',
name="Memory Roofline",
text=["", f"Memory bandwidth : {max_bw/1e9} GB/s",],
textposition="bottom left",
line=dict(color='green', width=2)))
return fig
def add_data_point(fig, x, y, *,
name="",
marker=DEFAULT_MARKER,
):
fig.add_trace(go.Scatter(
x=[x],
y=[y],
mode='markers',
marker=marker,
name=name
))
return fig
def set_axis(fig):
# Add roofline axes labels
fig.update_layout(
xaxis=dict(
type='log',
title='Operational Intensity (Flop/Byte)',
zeroline=True
),
yaxis=dict(
type='log',
title='Performance (Flop/s)',
zeroline=True
)
)
return fig
def create_plot(peak_perf, max_band):
fig = go.Figure()
fig = add_rooflines(fig, peak_perf, max_band, 100)
fig = set_axis(fig)
return fig
def add_data_points(fig, data_points, marker=DEFAULT_MARKER):
for oi, perf, name in data_points:
fig = add_data_point(fig, oi, perf, name=name, marker=marker)
return fig
......@@ -8,13 +8,16 @@ setup(name="cb-util",
author_email="Christoph.alt@fau.de",
packages=find_packages(include=["cbutil",
"cbutil.postprocessing",
"dashboards"]),
"dashboards",
"plotting"]),
install_requires=[
"python-dotenv",
"influxdb",
"gitpython",
"grafanalib",
"requests",
"plotly",
"kaleido",
],
setup_requires=['pytest-runner'],
tests_require=['pytest']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment