circt icon indicating copy to clipboard operation
circt copied to clipboard

Some statistics are zero, disabling threading seems to fix

Open dtzSiFive opened this issue 2 years ago • 0 comments

Noticed this while adding statistics, here's a small test case names-cse.fir:

circuit Names:
  module Names:
    input i: UInt<1>
    input j: UInt<1>
    output o: UInt
    wire w: UInt
    wire w2: UInt
    w <- and(i, j)
    w2 <- and(i, j)
    o <- add(w, w2)

This can be observed with --mlir-pass-statistics, for example:

$ ./bin/firtool --mlir-pass-statistics ./names-cse.fir |& grep '(S)'
    (S) 0 num-added-annos     - Number of additional annotations
    (S) 0 num-annos           - Total number of annotations processed
    (S) 0 num-unhandled-annos - Number of unhandled annotations
    (S) 0 num-raw-annos       - Number of raw annotations on circuit
      (S) 0 num-names-converted - Number of interesting names made droppable
      (S) 0 num-dce'd - Number of operations DCE'd
      (S) 0 num-cse'd - Number of operations CSE'd
    (S) 0 num-erased-op - Number of operations erased
    (S) 0 num-folded-op - Number of operations folded
      (S) 0 num-names-converted - Number of interesting names made droppable
    (S) 0 num-removed-ports - Number of ports erased
    (S) 0 num-dce'd - Number of operations DCE'd
    (S) 0 num-cse'd - Number of operations CSE'd
    (S) 0 num-dce'd - Number of operations DCE'd
    (S) 2 num-cse'd - Number of operations CSE'd

Note this reports no names were dropped/converted, all statistics are zero except the last CSE statistic (?).

Compared to disabling threads:

$ ./bin/firtool --mlir-pass-statistics --mlir-disable-threading ./names-cse.fir |& grep '(S)'
    (S) 0 num-added-annos     - Number of additional annotations
    (S) 0 num-annos           - Total number of annotations processed
    (S) 0 num-unhandled-annos - Number of unhandled annotations
    (S) 0 num-raw-annos       - Number of raw annotations on circuit
      (S) 2 num-names-converted - Number of interesting names made droppable
      (S) 0 num-dce'd - Number of operations DCE'd
      (S) 2 num-cse'd - Number of operations CSE'd
    (S) 0 num-erased-op - Number of operations erased
    (S) 0 num-folded-op - Number of operations folded
      (S) 2 num-names-converted - Number of interesting names made droppable
    (S) 0 num-removed-ports - Number of ports erased
    (S) 0 num-dce'd - Number of operations DCE'd
    (S) 0 num-cse'd - Number of operations CSE'd
    (S) 0 num-dce'd - Number of operations DCE'd
    (S) 2 num-cse'd - Number of operations CSE'd

Where you can see 2 names are converted, and an earlier CSE run is non-zero also.

Passes impacted are firrtl.modue passes, but I'm not sure if that's all that's needed.

dtzSiFive avatar Jul 12 '22 17:07 dtzSiFive