Skip to content

Commit

Permalink
Use a Krun object for Krun primitive calls
Browse files Browse the repository at this point in the history
This makes for much cleaner integration with SOM++.
  • Loading branch information
jacob-hughes committed Oct 26, 2020
1 parent 6d88c3b commit 3a792f5
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions iterations_runners/iterations_runner.som
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
iterations_runner = (
| benchmarkClass numIterations param debug instrument numCores |

krunInit = primitive
krunDone = primitive
krunGetNumCores = primitive
krunMeasure: idx = primitive
krunGetWallclock: idx = primitive
krunGetCoreCyclesDouble: index core: core = primitive
| benchmarkClass numIterations param debug instrument numCores krun |

run: args = (
krun := Krun new.
self processArguments: args.
self runBenchmark.
)
Expand Down Expand Up @@ -50,8 +44,8 @@ iterations_runner = (
runBenchmark = (
| bench wallclockTimes coreCycleCounts i |

self krunInit.
numCores := self krunGetNumCores.
krun krunInit.
numCores := krun krunGetNumCores.
bench := benchmarkClass new.
wallclockTimes := Array new: numIterations.
coreCycleCounts := Array new: numCores.
Expand All @@ -64,21 +58,21 @@ iterations_runner = (
('[iterations_runner.som] iteration ' + i + '/' + numIterations) println.
].

self krunMeasure: 0.
krun krunMeasure: 0.
bench run_iter: param.
self krunMeasure: 1.
krun krunMeasure: 1.

start := self krunGetWallclock: 0.
end := self krunGetWallclock: 1.
start := krun krunGetWallclock: 0.
end := krun krunGetWallclock: 1.

wallclockTimes at: (i + 1) put: (end - start).

core := 1.
[ core < (numCores + 1) ] whileTrue: [
| cycle_start cycle_end |

cycle_end := (self krunGetCoreCyclesDouble: 1 core: (core - 1)).
cycle_start := (self krunGetCoreCyclesDouble: 0 core: (core -1)).
cycle_end := (krun krunGetCoreCyclesDouble: 1 core: (core - 1)).
cycle_start := (krun krunGetCoreCyclesDouble: 0 core: (core -1)).

(coreCycleCounts at: core) at: (i + 1) put: (cycle_end - cycle_start).
core := core + 1.
Expand All @@ -87,7 +81,7 @@ iterations_runner = (
i := i + 1.
].

self krunDone.
krun krunDone.
"Emit measurements"
'{' print.
'"wallclock_times": [' print.
Expand Down

0 comments on commit 3a792f5

Please sign in to comment.