[PATCH] D146198: [RISCV] Make ResourceCycles relevant to LMUL

Wang Pengcheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 16 18:57:55 PDT 2023


pcwang-thead added a comment.

In D146198#4199432 <https://reviews.llvm.org/D146198#4199432>, @michaelmaitland wrote:

> One concern I have is that a microarchitecture may wish to have more flexibility over the number of resource cycles for each LMUL than the `multiplier` subroutine allows for. I am imagining a scenario where the number of resource cycles for different LMUL is more complex than multiplication by the LMUL factor. Something like this would allow for maximum flexibility:
>
>   for mx in MxList {
>     defvar RC = ...; // Something that may be more complex than BaseCycles * multiplier
>     defvar L = ...; // Maybe latency is still relevant, even if it is less important than ResourceCycles
>     let ResourceCycles = [RC], Latency = L in {
>       ...
>     }
>   }

Yes, I wanted it to be flexible as what you described.
But for `Latency`  and `ResourceCycles`, both of them are TableGen compile-time constants (of course we can override them via some target hooks, but it is off the table), so there is no way to specify them as custom handling code.
I tried to model them as something like below:

1. We pass subtoutines to `LMULWriteResImpl` in `RISCVSchedule.td`

  multiclass LMULWriteResImpl<string name, list<ProcResourceKind> resources,,
                              LatencySubroutine latencySubroutine,
                              list<ResourceCycleSubroutine> resourceCycleSubroutines>{
    for mx in MxList {
      defvar RC = apply resourceCycleSubroutines to mx; // It acts like calling these subroutines.
      defvar L =apply latencySubroutine to mx; // Same as above.
      let ResourceCycles = [RC], Latency = L in {
        ...
      }
    }
  }

2. We define these subroutines in custom scheduling model `RISCVSchedXXX.td`

  class CustomSubroutine1<string mx> {
    list<int> ResourceCycles = ...; // Custom handling of different LMULs.
  }
  class CustomSubroutine2<string mx>{
  ......
  }
  ……

But for TableGen, we can't pass functions since it is a template description language, so we can't achieve something like this (if I understand TableGen correctly). So I think we may define some pre-defined subroutines like `fixed`, `multipler` and so on in `RISCVSchedule.td`, and then users can use them in their scheduling models. If there are some microarchitectures that can't be modeled, just add a new subroutine to upstream if approved.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146198/new/

https://reviews.llvm.org/D146198



More information about the llvm-commits mailing list