Skip to content

Commit

Permalink
Perform packing/unpacking of arguments and results in HDL
Browse files Browse the repository at this point in the history
Running three experiments with the old and the new code shows that
avoiding packing/unpacking in Haskell yields a ~50% performance
increase.

Figures are taken by observing `clash-vexriscv-sim:unittests`'s debug
times.

| Old 1 | Old 2 | Old 3 | Old min | New 1 | New 2 | New 3 | New min | New faster |
|-------|-------|-------|---------|-------|-------|-------|---------|------------|
| 0.25  | 0.31  | 0.3   | 0.25    | 0.28  | 0.24  | 0.26  | 0.24    | 4.2%       |
| 0.65  | 0.69  | 0.74  | 0.65    | 0.51  | 0.48  | 0.5   | 0.48    | 35.4%      |
| 0.44  | 0.48  | 0.53  | 0.44    | 0.36  | 0.31  | 0.34  | 0.31    | 41.9%      |
| 1.84  | 1.72  | 1.7   | 1.7     | 1.12  | 1.08  | 1.12  | 1.08    | 57.4%      |
| 1.57  | 1.58  | 1.58  | 1.57    | 1.03  | 1.06  | 1.01  | 1.01    | 55.4%      |
| 0.43  | 0.4   | 0.4   | 0.4     | 0.33  | 0.33  | 0.32  | 0.32    | 25.0%      |
| 4.62  | 4.18  | 4.5   | 4.18    | 2.69  | 2.73  | 2.73  | 2.69    | 55.4%      |
| 0.17  | 0.18  | 0.24  | 0.17    | 0.18  | 0.24  | 0.23  | 0.18    | -5.6%      |
| 2.26  | 2.57  | 2.43  | 2.26    | 1.35  | 1.45  | 1.42  | 1.35    | 67.4%      |
  • Loading branch information
martijnbastiaan committed Mar 5, 2024
1 parent f797bbf commit 29f5ae2
Show file tree
Hide file tree
Showing 4 changed files with 291 additions and 343 deletions.
4 changes: 2 additions & 2 deletions clash-vexriscv-sim/src/Utils/Cpu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ cpu bootIMem bootDMem = (output, writes, iS2M, dS2M)
{ timerInterrupt = low,
externalInterrupt = low,
softwareInterrupt = low,
iBusWbS2M = makeDefined iBus,
dBusWbS2M = makeDefined dBus
iBusWbS2M = iBus,
dBusWbS2M = dBus
}
)
<$> iS2M
Expand Down
12 changes: 12 additions & 0 deletions clash-vexriscv/clash-vexriscv.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,36 @@ library
default-language: Haskell2010
exposed-modules:
VexRiscv
VexRiscv.BlackBox
VexRiscv.ClockTicks
VexRiscv.FFI
VexRiscv.TH
VexRiscv.VecToTuple

-- See https://github.com/clash-lang/clash-compiler/pull/2511
if impl(ghc >= 9.4)
CPP-Options: -DCLASH_OPAQUE=OPAQUE
else
CPP-Options: -DCLASH_OPAQUE=NOINLINE

build-depends:
base,
bytestring >= 0.10 && < 0.13,
clash-lib,
clash-prelude,
clash-protocols,
containers,
directory >= 1.3 && < 1.4,
filepath,
Glob,
infinite-list,
mtl,
pretty-show,
process >= 1.6 && < 1.8,
string-interpolate,
tagged,
template-haskell,
text,
extra-libraries: VexRiscvFFI, stdc++
include-dirs: src/

Expand Down
Loading

0 comments on commit 29f5ae2

Please sign in to comment.