From d28b96448a7f2e78f4688628e5e871c06859f0aa Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Wed, 17 Jul 2024 12:35:26 +0800 Subject: [PATCH] Add more xvshuf figures --- docs/diagram/gen.py | 88 ++- docs/diagram/xvshuf_b.svg | 1267 +++++++++++++++++++++++++++++++++++++ docs/diagram/xvshuf_d.svg | 102 +-- docs/diagram/xvshuf_h.svg | 387 +++++++++++ docs/diagram/xvshuf_w.svg | 139 ++++ 5 files changed, 1886 insertions(+), 97 deletions(-) create mode 100644 docs/diagram/xvshuf_b.svg create mode 100644 docs/diagram/xvshuf_h.svg create mode 100644 docs/diagram/xvshuf_w.svg diff --git a/docs/diagram/gen.py b/docs/diagram/gen.py index 0ea8bce0..8d8c8f13 100644 --- a/docs/diagram/gen.py +++ b/docs/diagram/gen.py @@ -7,9 +7,9 @@ index_x = 20 arg_x = 100 desc_y_off = 15 -element_x = 20 -element_x_unit = 1 -col_space = 320 +element_x = 10 +element_x_unit = 2 +col_space = 570 box_height = 26 @@ -96,50 +96,46 @@ def add_line(f, from_row, from_col, from_index, to_row, to_col, to_index): print(f'', file=f) -def xvshuf_d(): +def xvshuf(): global elen, vlen - elen = 64 - vlen = 256 - with open("xvshuf_d.svg", "w") as f: - init(f, 3, 2) - add_row(f) - add_box(f, "b", "data", indices=[3, 2, 3, 2]) - add_box( - f, - "c", - "data", - indices=[1, 0, 1, 0], - ) - add_row(f) - add_box(f, "a", "indices") - add_row(f) - add_box(f, "ret", "returns") - - # b to a - add_line(f, 1, 0, 0, 2, 0, 0) - add_line(f, 1, 0, 0, 2, 0, 1) - add_line(f, 1, 0, 1, 2, 0, 0) - add_line(f, 1, 0, 1, 2, 0, 1) - add_line(f, 1, 0, 2, 2, 0, 2) - add_line(f, 1, 0, 2, 2, 0, 3) - add_line(f, 1, 0, 3, 2, 0, 2) - add_line(f, 1, 0, 3, 2, 0, 3) - - # c to a - add_line(f, 1, 1, 0, 2, 0, 0) - add_line(f, 1, 1, 0, 2, 0, 1) - add_line(f, 1, 1, 1, 2, 0, 0) - add_line(f, 1, 1, 1, 2, 0, 1) - add_line(f, 1, 1, 2, 2, 0, 2) - add_line(f, 1, 1, 2, 2, 0, 3) - add_line(f, 1, 1, 3, 2, 0, 2) - add_line(f, 1, 1, 3, 2, 0, 3) - - # a to ret - for i in range(vlen // elen): - add_line(f, 2, 0, i, 3, 0, i) - end(f) + for el, name in [(64, "d"), (32, "w"), (16, "h"), (8, "b")]: + elen = el + vlen = 256 + with open(f"xvshuf_{name}.svg", "w") as f: + init(f, 3, 2) + add_row(f) + add_box( + f, + "b" if elen > 8 else "a", + "data", + indices=list(range(vlen // elen - 1, vlen // elen // 2 - 1, -1)) * 2, + ) + add_box( + f, + "c" if elen > 8 else "b", + "data", + indices=list(range(vlen // elen // 2 - 1, -1, -1)) * 2, + ) + add_row(f) + add_box(f, "a" if elen > 8 else "c", "indices") + add_row(f) + add_box(f, "ret", "returns") + + # b to a & c to a + for i in range(vlen // elen // 2): + for j in range(vlen // elen // 2): + add_line(f, 1, 0, j, 2, 0, i) + add_line(f, 1, 1, j, 2, 0, i) + for i in range(vlen // elen // 2, vlen // elen): + for j in range(vlen // elen // 2, vlen // elen): + add_line(f, 1, 0, j, 2, 0, i) + add_line(f, 1, 1, j, 2, 0, i) + + # a to ret + for i in range(vlen // elen): + add_line(f, 2, 0, i, 3, 0, i) + end(f) if __name__ == "__main__": - xvshuf_d() + xvshuf() diff --git a/docs/diagram/xvshuf_b.svg b/docs/diagram/xvshuf_b.svg new file mode 100644 index 00000000..d810738a --- /dev/null +++ b/docs/diagram/xvshuf_b.svg @@ -0,0 +1,1267 @@ + +(1) +a +data + +31 + +30 + +29 + +28 + +27 + +26 + +25 + +24 + +23 + +22 + +21 + +20 + +19 + +18 + +17 + +16 + +31 + +30 + +29 + +28 + +27 + +26 + +25 + +24 + +23 + +22 + +21 + +20 + +19 + +18 + +17 + +16 +upper +lower +b +data + +15 + +14 + +13 + +12 + +11 + +10 + +9 + +8 + +7 + +6 + +5 + +4 + +3 + +2 + +1 + +0 + +15 + +14 + +13 + +12 + +11 + +10 + +9 + +8 + +7 + +6 + +5 + +4 + +3 + +2 + +1 + +0 +upper +lower +(2) +c +indices + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(3) +ret +returns + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/diagram/xvshuf_d.svg b/docs/diagram/xvshuf_d.svg index 90a7aec0..736a1be8 100644 --- a/docs/diagram/xvshuf_d.svg +++ b/docs/diagram/xvshuf_d.svg @@ -1,63 +1,63 @@ (1) b data - -3 - -2 - -3 - -2 -upper -lower -c -data - -1 - -0 - -1 - -0 -upper -lower + +3 + +2 + +3 + +2 +upper +lower +c +data + +1 + +0 + +1 + +0 +upper +lower (2) a indices - - - - + + + + (3) ret returns - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/diagram/xvshuf_h.svg b/docs/diagram/xvshuf_h.svg new file mode 100644 index 00000000..95a62cb8 --- /dev/null +++ b/docs/diagram/xvshuf_h.svg @@ -0,0 +1,387 @@ + +(1) +b +data + +15 + +14 + +13 + +12 + +11 + +10 + +9 + +8 + +15 + +14 + +13 + +12 + +11 + +10 + +9 + +8 +upper +lower +c +data + +7 + +6 + +5 + +4 + +3 + +2 + +1 + +0 + +7 + +6 + +5 + +4 + +3 + +2 + +1 + +0 +upper +lower +(2) +a +indices + + + + + + + + + + + + + + + + +(3) +ret +returns + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/diagram/xvshuf_w.svg b/docs/diagram/xvshuf_w.svg new file mode 100644 index 00000000..b10ef324 --- /dev/null +++ b/docs/diagram/xvshuf_w.svg @@ -0,0 +1,139 @@ + +(1) +b +data + +7 + +6 + +5 + +4 + +7 + +6 + +5 + +4 +upper +lower +c +data + +3 + +2 + +1 + +0 + +3 + +2 + +1 + +0 +upper +lower +(2) +a +indices + + + + + + + + +(3) +ret +returns + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +