Skip to content

Commit

Permalink
Update 2023-11-22-常用作图脚本.md
Browse files Browse the repository at this point in the history
  • Loading branch information
WuK authored Jan 27, 2024
1 parent 9a349ab commit b7fabeb
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions _posts/2023-11-22-常用作图脚本.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,33 +139,34 @@ title: "常用作图脚本"

```python3
import sys
import pandas as pd
import altair as alt
import vl_convert as vlc
from cairosvg import svg2pdf


def main(*argv):
df = alt.Chart(pd.DataFrame({
'GPU': ['K40', 'P100', 'V100', 'A100', 'H100'],
'L1': [64, 64, 128, 192, 256],
'L2': [1536, 4096, 6144, 40960, 51200]
})).encode(
x=alt.X('L1').title('L1D+SMEM/KB per SM').scale(domain=(50, 250)),
y=alt.Y('L2').title('L2/KB').scale(domain=(0, 50000)),
text='GPU'
data = [{"GPU": "K40", "L1": 64, "L2": 1536},
{"GPU": "P100", "L1": 64, "L2": 4096},
{"GPU": "V100", "L1": 128, "L2": 6144},
{"GPU": "A100", "L1": 192, "L2": 40960},
{"GPU": "H100", "L1": 256, "L2": 51200}]

data = alt.Chart(alt.InlineData(data)).encode(
x=alt.X('L1:Q').title('L1D+SMEM/KB per SM').scale(domain=(50, 250)),
y=alt.Y('L2:Q').title('L2/KB').scale(domain=(0, 50000)),
text='GPU:N'
)

df = df.mark_line(
data = data.mark_line(
color="grey"
) + df.mark_text(
) + data.mark_text(
align='left',
baseline='middle',
dx=5,
dy=5
)

df = df.configure_axisY(
data = data.configure_axisY(
tickMinStep=10000
).configure_axisX(
tickMinStep=50
Expand All @@ -175,11 +176,11 @@ def main(*argv):
)

svg2pdf(write_to="gpu-evole.pdf",
bytestring=vlc.vegalite_to_svg(vl_spec=df.to_json()))
bytestring=vlc.vegalite_to_svg(vl_spec=data.to_json()))

return 0


if __name__ == '__main__':
sys.exit(main(*sys.argv))
```
```

0 comments on commit b7fabeb

Please sign in to comment.