Skip to content

Commit 58322c4

Browse files
author
Trevor L. McDonell
committed
Match output of other benchmark programs
1 parent 765239e commit 58322c4

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

Diff for: Benchmarks/BuildingSimulation/Haskell/app/Main.hs

+25-12
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66

77
module Main where
88

9-
import Numeric.AD.Double
10-
import Criterion.Main
119
import Control.Monad
10+
import Criterion
11+
import Criterion.Main
12+
import Criterion.Types
13+
import Numeric.AD.Double
14+
import Statistics.Types
15+
import Text.Printf
1216
import Prelude hiding (init)
1317

1418
import GHC.IsList
@@ -118,7 +122,7 @@ computeResistance
118122
-> Tube a
119123
-> Quanta a
120124
-> a
121-
computeResistance floor tube quanta =
125+
computeResistance floor tube _quanta =
122126
let geometry_coeff = 10.0
123127
-- f_coff = 0.3333333
124128

@@ -294,21 +298,30 @@ timesteps :: Int
294298
timesteps = 1000
295299

296300
printGradToCompare :: Bool
297-
printGradToCompare = True
301+
printGradToCompare = False
298302

299303
main :: IO ()
300304
main = do
301-
let params = init :: SimParams Double
302-
params' = unpack params
303-
fullPipe' = grad (fullPipe . pack)
305+
let simParams = init :: SimParams Double
306+
simParams' = unpack simParams
307+
fullPipe' = grad (fullPipe . pack)
308+
config = defaultConfig { verbosity = Quiet }
304309

305310
when printGradToCompare $
306-
print (pack (fullPipe' params'))
311+
print (pack (fullPipe' simParams'))
312+
313+
-- The default benchmarking setup will give more accurate information, but
314+
-- we'll prefer to just match the output of all benchmark programs instead
315+
-- defaultMain
316+
-- [ bench "primal" $ nf fullPipe simParams
317+
-- , bench "adjoint" $ nf fullPipe' simParams'
318+
-- ]
319+
320+
result_forward <- benchmarkWith' config $ nf fullPipe simParams
321+
result_gradient <- benchmarkWith' config $ nf fullPipe' simParams'
307322

308-
defaultMain
309-
[ bench "primal" $ nf fullPipe params
310-
, bench "adjoint" $ nf fullPipe' params'
311-
]
323+
printf "average forward only time: %f seconds\n" result_forward.reportAnalysis.anMean.estPoint
324+
printf "average forward and backwards (gradient) time: %f seconds\n" result_gradient.reportAnalysis.anMean.estPoint
312325

313326

314327
-- Helpers ---------------------------------------------------------------------

Diff for: Benchmarks/BuildingSimulation/Haskell/building-simulation.cabal

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ executable building-simulation
2424
-Wall
2525

2626
build-depends:
27-
base ^>= 4.17
28-
, ad ^>= 4.5
29-
, criterion ^>= 1.6
27+
base >= 4.17 && < 4.21
28+
, ad >= 4.5
29+
, criterion >= 1.6
30+
, statistics
3031

3132
-- vim: nospell

0 commit comments

Comments
 (0)