Skip to content

Instantly share code, notes, and snippets.

@NeapolitanIcecream
Created July 12, 2023 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeapolitanIcecream/517baadc9256418dd8d696cccf0b56cd to your computer and use it in GitHub Desktop.
Save NeapolitanIcecream/517baadc9256418dd8d696cccf0b56cd to your computer and use it in GitHub Desktop.
  • challenge:指令调度
    • 17 个寄存器 r0 ~ r15 和 lc(仅用于保存 hwloop 的 loop count)
    • 一开始 r0 = 0
    • 有无限的内存
    • 无流水线,每个指令需要且仅需要一个周期
    • 4-slot VLIW,一个周期可以发射四条指令,此时称这四条指令被打包成了一个 bundle
      • 算术指令只能放入前两个 slot
      • 访存指令只能放入后两个 slot
    • 保证输入调度器的程序只有 prologue(loop 前的一些指令),loop 和 epilogue(loop 后的一些指令),输入的程序是没有经过打包的
    • 指令
      • 算术指令
        • r0 = r1 + r2: ADD 0 1 2
        • r0 = r1 + c: ADDI 0 1 c
        • r0 = r1 - r2: SUB 0 1 2
        • r0 = r1 - c: SUBI 0 1 c
        • r0 = r1 * r2: MUL 0 1 2
        • r0 = r1 / r2: DIV 0 1 2
      • 访存指令
        • r0 = M[r1 + c]: LOAD 0 1 c
        • M[r0 + c] = r1: STORE 0 c 1
        • M[r0] = M[r1]: MOVEM 0 1
      • 伪指令(不占 cycle,不能打包,仅标记循环体和循环范围)
        • for lc = c0 to c2: LOOP c0 c2
        • endfor: ENDLOOP
    • 指标
      • 语义不变:若 ri 有定义,调度前后的程序运行后,ri 需要相同
      • 最后的 bundle 数不多于输入的指令数的 4 倍((1 * 4 unroll * 2 软流水 + 2 余量) / 2.5 每 bundle 指令数经验值)
      • cycle 数尽量低(循环外 bundle 数 + 循环内 bundle 数 * 循环次数)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment